Bug 716590 - WalkStackMain64 shouldn't skip frames unless it's walking the thread that called NS_StackWalk. r=dbaron

This commit is contained in:
Vladan Djeric 2012-01-23 17:21:23 -05:00
Родитель 231e4020da
Коммит d2acc78182
1 изменённых файлов: 9 добавлений и 5 удалений

Просмотреть файл

@ -338,6 +338,7 @@ BOOL SymGetModuleInfoEspecial(HANDLE aProcess, DWORD aAddr, PIMAGEHLP_MODULE aMo
struct WalkStackData { struct WalkStackData {
PRUint32 skipFrames; PRUint32 skipFrames;
HANDLE thread; HANDLE thread;
bool walkCallingThread;
HANDLE process; HANDLE process;
HANDLE eventStart; HANDLE eventStart;
HANDLE eventEnd; HANDLE eventEnd;
@ -564,7 +565,8 @@ WalkStackMain64(struct WalkStackData* data)
HANDLE myThread = data->thread; HANDLE myThread = data->thread;
DWORD64 addr; DWORD64 addr;
STACKFRAME64 frame64; STACKFRAME64 frame64;
int skip = 3 + data->skipFrames; // skip our own stack walking frames // skip our own stack walking frames
int skip = (data->walkCallingThread ? 3 : 0) + data->skipFrames;
BOOL ok; BOOL ok;
// Get a context for the specified thread. // Get a context for the specified thread.
@ -812,11 +814,13 @@ NS_StackWalk(NS_WalkStackCallback aCallback, PRUint32 aSkipFrames,
if (!EnsureImageHlpInitialized()) if (!EnsureImageHlpInitialized())
return false; return false;
HANDLE targetThread; HANDLE targetThread = ::GetCurrentThread();
data.walkCallingThread = true;
if (aThread) { if (aThread) {
targetThread = reinterpret_cast<HANDLE> (aThread); HANDLE threadToWalk = reinterpret_cast<HANDLE> (aThread);
} else { // walkCallingThread indicates whether we are walking the caller's stack
targetThread = ::GetCurrentThread(); data.walkCallingThread = (threadToWalk == targetThread);
targetThread = threadToWalk;
} }
// Have to duplicate handle to get a real handle. // Have to duplicate handle to get a real handle.