From 0510e34cbfe1b920b968c33e83101bed49c47aeb Mon Sep 17 00:00:00 2001 From: "ted.mielczarek@gmail.com" Date: Mon, 19 Aug 2013 18:31:51 +0000 Subject: Allow setting a limit on the number of frames to be recovered by stack scanning. Patch by Julian Seward 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 --- src/processor/stackwalker.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src/processor/stackwalker.cc') 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 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; -- cgit v1.2.1