aboutsummaryrefslogtreecommitdiff
path: root/src/processor/stackwalker.cc
diff options
context:
space:
mode:
authorted.mielczarek@gmail.com <ted.mielczarek@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2013-08-19 18:31:51 +0000
committerted.mielczarek@gmail.com <ted.mielczarek@gmail.com@4c0a9323-5329-0410-9bdc-e9ce6186880e>2013-08-19 18:31:51 +0000
commit0510e34cbfe1b920b968c33e83101bed49c47aeb (patch)
tree3cc4bfb4e3c4bcd5a90599c7534116fef0c89426 /src/processor/stackwalker.cc
parentEnable the SIGABRT handler on desktop OS X (diff)
downloadbreakpad-0510e34cbfe1b920b968c33e83101bed49c47aeb.tar.xz
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
Diffstat (limited to 'src/processor/stackwalker.cc')
-rw-r--r--src/processor/stackwalker.cc21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/processor/stackwalker.cc b/src/processor/stackwalker.cc
index 00358b26..c8438ccf 100644
--- a/src/processor/stackwalker.cc
+++ b/src/processor/stackwalker.cc
@@ -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;