From 16a880e1356959f2c5747ecb09dd1da60ef7b665 Mon Sep 17 00:00:00 2001 From: "chrisha@chromium.org" Date: Fri, 23 Aug 2013 19:41:36 +0000 Subject: Create StackFrame::FRAME_TRUST_PREWALKED trust type. This creates a new frame trust type for prewalked stack frames, as suggested in the review of https://breakpad.appspot.com/620002/. R=ted.mielczarek@gmail.com, mark@chromium.org Review URL: https://breakpad.appspot.com/621002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1208 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/google_breakpad/processor/stack_frame.h | 15 +++++++++------ src/processor/stackwalker_address_list.cc | 2 +- src/processor/stackwalker_address_list_unittest.cc | 8 +++++++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/google_breakpad/processor/stack_frame.h b/src/google_breakpad/processor/stack_frame.h index 23e69bb4..b55eb9c7 100644 --- a/src/google_breakpad/processor/stack_frame.h +++ b/src/google_breakpad/processor/stack_frame.h @@ -45,12 +45,13 @@ struct StackFrame { // stack scanning, it can wind up with dubious frames. // In rough order of "trust metric". enum FrameTrust { - FRAME_TRUST_NONE, // Unknown - FRAME_TRUST_SCAN, // Scanned the stack, found this - FRAME_TRUST_CFI_SCAN, // Scanned the stack using call frame info, found this - FRAME_TRUST_FP, // Derived from frame pointer - FRAME_TRUST_CFI, // Derived from call frame info - FRAME_TRUST_CONTEXT // Given as instruction pointer in a context + FRAME_TRUST_NONE, // Unknown + FRAME_TRUST_SCAN, // Scanned the stack, found this + FRAME_TRUST_CFI_SCAN, // Found while scanning stack using call frame info + FRAME_TRUST_FP, // Derived from frame pointer + FRAME_TRUST_CFI, // Derived from call frame info + FRAME_TRUST_PREWALKED, // Explicitly provided by some external stack walker. + FRAME_TRUST_CONTEXT // Given as instruction pointer in a context }; StackFrame() @@ -70,6 +71,8 @@ struct StackFrame { switch (trust) { case StackFrame::FRAME_TRUST_CONTEXT: return "given as instruction pointer in context"; + case StackFrame::FRAME_TRUST_PREWALKED: + return "recovered by external stack walker"; case StackFrame::FRAME_TRUST_CFI: return "call frame info"; case StackFrame::FRAME_TRUST_CFI_SCAN: diff --git a/src/processor/stackwalker_address_list.cc b/src/processor/stackwalker_address_list.cc index fdc9b9ae..55656032 100644 --- a/src/processor/stackwalker_address_list.cc +++ b/src/processor/stackwalker_address_list.cc @@ -85,7 +85,7 @@ StackFrame* StackwalkerAddressList::GetCallerFrame(const CallStack* stack, // explicitly provided. StackFrame* frame = new StackFrame(); frame->instruction = frames_[frame_index]; - frame->trust = StackFrame::FRAME_TRUST_CONTEXT; + frame->trust = StackFrame::FRAME_TRUST_PREWALKED; return frame; } diff --git a/src/processor/stackwalker_address_list_unittest.cc b/src/processor/stackwalker_address_list_unittest.cc index 8af63fb1..2eb36cd7 100644 --- a/src/processor/stackwalker_address_list_unittest.cc +++ b/src/processor/stackwalker_address_list_unittest.cc @@ -106,8 +106,14 @@ class StackwalkerAddressListTest : public testing::Test { void CheckCallStack(const CallStack& call_stack) { const std::vector* frames = call_stack.frames(); ASSERT_EQ(arraysize(kDummyFrames), frames->size()); - for (size_t i = 0; i < arraysize(kDummyFrames); ++i) + for (size_t i = 0; i < arraysize(kDummyFrames); ++i) { ASSERT_EQ(kDummyFrames[i], frames->at(i)->instruction); + if (i == 0) { + ASSERT_EQ(StackFrame::FRAME_TRUST_CONTEXT, frames->at(i)->trust); + } else { + ASSERT_EQ(StackFrame::FRAME_TRUST_PREWALKED, frames->at(i)->trust); + } + } ASSERT_EQ(static_cast(&module2), frames->at(0)->module); ASSERT_EQ(static_cast(&module2), frames->at(1)->module); ASSERT_EQ(static_cast(&module2), frames->at(2)->module); -- cgit v1.2.1