mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2025-12-25 16:54:43 +01:00
Allow setting a limit on the number of frames to be recovered by stack scanning.
Patch by Julian Seward <jseward@acm.org> R=ted at https://bugzilla.mozilla.org/show_bug.cgi?id=894264 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1206 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
parent
aaeb7e4f13
commit
0510e34cbf
17 changed files with 262 additions and 29 deletions
|
|
@ -57,9 +57,12 @@
|
|||
namespace google_breakpad {
|
||||
|
||||
const int Stackwalker::kRASearchWords = 30;
|
||||
|
||||
uint32_t Stackwalker::max_frames_ = 1024;
|
||||
bool Stackwalker::max_frames_set_ = false;
|
||||
|
||||
uint32_t Stackwalker::max_frames_scanned_ = 1024;
|
||||
|
||||
Stackwalker::Stackwalker(const SystemInfo* system_info,
|
||||
MemoryRegion* memory,
|
||||
const CodeModules* modules,
|
||||
|
|
@ -115,6 +118,10 @@ bool Stackwalker::Walk(
|
|||
// Begin with the context frame, and keep getting callers until there are
|
||||
// no more.
|
||||
|
||||
// Keep track of the number of scanned or otherwise dubious frames seen
|
||||
// so far, as the caller may have set a limit.
|
||||
uint32_t scanned_frames = 0;
|
||||
|
||||
// Take ownership of the pointer returned by GetContextFrame.
|
||||
scoped_ptr<StackFrame> frame(GetContextFrame());
|
||||
|
||||
|
|
@ -147,6 +154,17 @@ bool Stackwalker::Walk(
|
|||
break;
|
||||
}
|
||||
|
||||
// Keep track of the number of dubious frames so far.
|
||||
switch (frame.get()->trust) {
|
||||
case StackFrame::FRAME_TRUST_NONE:
|
||||
case StackFrame::FRAME_TRUST_SCAN:
|
||||
case StackFrame::FRAME_TRUST_CFI_SCAN:
|
||||
scanned_frames++;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Add the frame to the call stack. Relinquish the ownership claim
|
||||
// over the frame, because the stack now owns it.
|
||||
stack->frames_.push_back(frame.release());
|
||||
|
|
@ -159,7 +177,8 @@ bool Stackwalker::Walk(
|
|||
}
|
||||
|
||||
// Get the next frame and take ownership.
|
||||
frame.reset(GetCallerFrame(stack));
|
||||
bool stack_scan_allowed = scanned_frames < max_frames_scanned_;
|
||||
frame.reset(GetCallerFrame(stack, stack_scan_allowed));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue