mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-09 13:25:00 +00:00
Bug 767479 - Handle the case of more than 1024 frames when walking the stack of another thread on Windows, and also use the infallible allocator when walking the stack of your own thread; r=dbaron
This commit is contained in:
parent
7caf761704
commit
617bcfa1a1
@ -173,6 +173,7 @@ StackWalkInitCriticalAddress()
|
||||
#include <windows.h>
|
||||
#include <process.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include "plstr.h"
|
||||
#include "mozilla/FunctionTimer.h"
|
||||
|
||||
@ -488,6 +489,13 @@ NS_StackWalk(NS_WalkStackCallback aCallback, PRUint32 aSkipFrames,
|
||||
// If we're walking the stack of another thread, we don't need to
|
||||
// use a separate walker thread.
|
||||
WalkStackMain64(&data);
|
||||
|
||||
if (data.pc_count > data.pc_size) {
|
||||
data.pcs = (void**) _alloca(data.pc_count * sizeof(void*));
|
||||
data.pc_size = data.pc_count;
|
||||
data.pc_count = 0;
|
||||
WalkStackMain64(&data);
|
||||
}
|
||||
} else {
|
||||
data.eventStart = ::CreateEvent(NULL, FALSE /* auto-reset*/,
|
||||
FALSE /* initially non-signaled */, NULL);
|
||||
@ -501,7 +509,7 @@ NS_StackWalk(NS_WalkStackCallback aCallback, PRUint32 aSkipFrames,
|
||||
if (walkerReturn != WAIT_OBJECT_0)
|
||||
PrintError("SignalObjectAndWait (1)");
|
||||
if (data.pc_count > data.pc_size) {
|
||||
data.pcs = (void**) malloc(data.pc_count * sizeof(void*));
|
||||
data.pcs = (void**) _alloca(data.pc_count * sizeof(void*));
|
||||
data.pc_size = data.pc_count;
|
||||
data.pc_count = 0;
|
||||
::PostThreadMessage(gStackWalkThread, WM_USER, 0, (LPARAM)&data);
|
||||
@ -520,9 +528,6 @@ NS_StackWalk(NS_WalkStackCallback aCallback, PRUint32 aSkipFrames,
|
||||
for (PRUint32 i = 0; i < data.pc_count; ++i)
|
||||
(*aCallback)(data.pcs[i], aClosure);
|
||||
|
||||
if (data.pc_size > ArrayLength(local_pcs))
|
||||
free(data.pcs);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user