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 {
PRUint32 skipFrames;
HANDLE thread;
bool walkCallingThread;
HANDLE process;
HANDLE eventStart;
HANDLE eventEnd;
@ -564,7 +565,8 @@ WalkStackMain64(struct WalkStackData* data)
HANDLE myThread = data->thread;
DWORD64 addr;
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;
// Get a context for the specified thread.
@ -812,11 +814,13 @@ NS_StackWalk(NS_WalkStackCallback aCallback, PRUint32 aSkipFrames,
if (!EnsureImageHlpInitialized())
return false;
HANDLE targetThread;
HANDLE targetThread = ::GetCurrentThread();
data.walkCallingThread = true;
if (aThread) {
targetThread = reinterpret_cast<HANDLE> (aThread);
} else {
targetThread = ::GetCurrentThread();
HANDLE threadToWalk = reinterpret_cast<HANDLE> (aThread);
// walkCallingThread indicates whether we are walking the caller's stack
data.walkCallingThread = (threadToWalk == targetThread);
targetThread = threadToWalk;
}
// Have to duplicate handle to get a real handle.