Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsStackFrameUnix.h File Reference
#include "stdio.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void DumpStackToFile (FILE *out)
 Walk the stack, translating PC's found into strings and recording the chain in aBuffer.

Function Documentation

void DumpStackToFile ( FILE aStream)

Walk the stack, translating PC's found into strings and recording the chain in aBuffer.

For this to work properly, the DLLs must be rebased so that the address in the file agrees with the address in memory. Otherwise StackWalk will return FALSE when it hits a frame in a DLL whose in memory address doesn't match its in-file address.

Definition at line 439 of file nsStackFrameWin.cpp.

{
    HANDLE myProcess = ::GetCurrentProcess();
    HANDLE myThread, walkerThread;
    DWORD walkerReturn;
    struct DumpStackToFileData data;

    if (!EnsureSymInitialized())
        return;

    // Have to duplicate handle to get a real handle.
    ::DuplicateHandle(
      ::GetCurrentProcess(),
      ::GetCurrentThread(),
      ::GetCurrentProcess(),
      &myThread,
      THREAD_ALL_ACCESS, FALSE, 0
    );

    data.stream = aStream;
    data.thread = myThread;
    data.process = myProcess;
    walkerThread = ::CreateThread( NULL, 0, DumpStackToFileThread, (LPVOID) &data, 0, NULL ) ;
    if (walkerThread) {
        walkerReturn = ::WaitForSingleObject(walkerThread, 2000); // no timeout is never a good idea
        CloseHandle(myThread) ;
        if (walkerReturn != WAIT_OBJECT_0) {
            PrintError("ThreadWait", aStream);
        }
    }
    else {
        PrintError("ThreadCreate", aStream);
    }
    return;
}

Here is the call graph for this function: