When loading a crashlog using scripted process, inlined frames get lost. This happens because `ScriptedThread::LoadArtificialStackFrames` creates all frames as concrete frames via `SetFrameAtIndex`, completely bypassing the inline frame synthesis that `StackFrameList::FetchFramesUpTo` normally performs using `GetParentOfInlinedScope`. Since two crashlog frames share the same PC when one is inlined into the other, `CalculateSymbolContext` resolves both to the innermost inlined scope, which causes the containing function to be dropped from the backtrace. This patch fixes the issue in two parts: - On the Python side, `resolve_stackframes` now skips frames whose PC matches the next frame's PC. These are inlined frames that LLDB will synthesize from debug info when it processes the concrete frames we provide. Indices are renumbered accordingly, and `len(frames) == 0` is used for first-frame detection. - On the C++ side, `LoadArtificialStackFrames` now replicates the inline synthesis loop from `FetchFramesUpTo`: after creating each concrete frame, it calls `GetParentOfInlinedScope` in a loop and creates a `StackFrame` for each inlined parent scope. rdar://154981041 Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>
21 lines
986 B
Plaintext
21 lines
986 B
Plaintext
# REQUIRES: python, native && system-darwin
|
|
|
|
# RUN: %clang_host -g -arch arm64 %S/Inputs/inline_test.c -o %t.out
|
|
# RUN: cp %S/Inputs/a.out.inline.ips %t.ips
|
|
# RUN: %python %S/patch-crashlog.py --binary %t.out --crashlog %t.ips --offsets '{"main":20, "bar":16}' --json
|
|
# RUN: %lldb %t.out \
|
|
# RUN: -o 'command script import lldb.macosx.crashlog' \
|
|
# RUN: -o 'crashlog -a -i %t.ips' \
|
|
# RUN: -o 'thread backtrace' 2>&1 | FileCheck %s
|
|
|
|
# CHECK: "crashlog" {{.*}} commands have been installed, use the "--help" options on these commands
|
|
|
|
# Verify that the inlined frame (foo) marked with "inline": true in the JSON
|
|
# crash report is skipped by the scripted process and reconstructed by LLDB
|
|
# from debug info as a proper [inlined] frame.
|
|
# CHECK: (lldb) thread backtrace
|
|
# CHECK-NEXT: * thread #1
|
|
# CHECK-NEXT: * frame #0: {{.*}}out`foo{{.*}} [synthetic] [inlined]
|
|
# CHECK-NEXT: frame #1: {{.*}}out`bar
|
|
# CHECK: frame #{{[0-9]+}}: {{.*}}out`main{{.*}} [synthetic]
|