Index: lldb/source/Target/StackFrameList.cpp =================================================================== --- lldb/source/Target/StackFrameList.cpp +++ lldb/source/Target/StackFrameList.cpp @@ -533,6 +533,15 @@ SymbolContext next_frame_sc; Address next_frame_address; + // Use PC from the top inlined frame for all consecutive inlined parent frames + // and the first non inlined (example below). + // next_frame_address points to the first instruction in the inlined sequence + // regardless where the current PC points to. + // + // frame #1: 0x0000000000400645 inline`main [inlined] func1 at inline.c:28:3 + // frame #2: 0x0000000000400645 inline`main [inlined] func2 at inline.c:35 + // frame #3: 0x0000000000400645 inline`main at inline.c:39 + Address deepest_inline_pc_addr = unwind_frame_sp.get()->GetFrameCodeAddress(); while (unwind_sc.GetParentOfInlinedScope( curr_frame_address, next_frame_sc, next_frame_address)) { @@ -540,7 +549,7 @@ behaves_like_zeroth_frame = false; StackFrameSP frame_sp(new StackFrame( m_thread.shared_from_this(), m_frames.size(), idx, - unwind_frame_sp->GetRegisterContextSP(), cfa, next_frame_address, + unwind_frame_sp->GetRegisterContextSP(), cfa, deepest_inline_pc_addr, behaves_like_zeroth_frame, &next_frame_sc)); m_frames.push_back(frame_sp); Index: lldb/test/Shell/Unwind/Inputs/inlined-scope-pc.c =================================================================== --- /dev/null +++ lldb/test/Shell/Unwind/Inputs/inlined-scope-pc.c @@ -0,0 +1,39 @@ +typedef struct inside_str { + int y; + int x; +} nested_str; + +typedef struct node { + char *x; + int *val; + nested_str * val2; +} info; + +__attribute__((noinline)) +void crash (info *node) { + node->val2->x = 4; +} + +__attribute__((always_inline)) +static void func1() { + info node; + char c; + nested_str n = {10,20}; + node.val = 0; + node.val2 = &n; + crash (&node); + node.val2 = 0; + crash (&node); + node.x = &c; + crash (&node); +} + +__attribute__((always_inline)) +static void func2() { + func1(); +} + +int main() { +func2(); +return 0; +} Index: lldb/test/Shell/Unwind/inlined-scope-pc.test =================================================================== --- /dev/null +++ lldb/test/Shell/Unwind/inlined-scope-pc.test @@ -0,0 +1,12 @@ + +# RUN: %clang_host -g -O0 %p/Inputs/inlined-scope-pc.c -o %t +# RUN: %lldb %t -s %s -o exit | FileCheck %s + +run +# CHECK: stop reason = signal SIGSEGV + +bt +# CHECK: frame #0: {{.*}}`crash +# CHECK: frame #1: 0x[[INLINE_PC:[0-9a-f]+]] {{.*}}`main [inlined] func1 at +# CHECK: frame #2: 0x[[INLINE_PC]] {{.*}}`main [inlined] func2 at +# CHECK: frame #3: 0x[[INLINE_PC]] {{.*}}`main at