Please, consider LLDB behaviour in the case where we have inlined functions, explained below.
(lldb) bt * thread #1, name = 'inline', stop reason = signal SIGSEGV * frame #0: 0x00000000004005e4 inline`print_info(node=0x00007ffcd1425cd8) at inline.c:16:32 frame #1: 0x0000000000400645 inline`main [inlined] func1 at inline.c:28:3 frame #2: 0x000000000040060f inline`main [inlined] func2 at inline.c:35 frame #3: 0x000000000040060f inline`main at inline.c:39 frame #4: 0x00007fab30fdb7b3 libc.so.6`__libc_start_main + 243 frame #5: 0x000000000040050e inline`_start + 46
Parents of the inlined frames (#2 and #3) have PC which points to the beginning of the inlined sequence (0x40060f)
regardless of where the current PC is in the same inlined sequence (backtrace above).
Because of the inlining, PC register value is the same for frames #1, #2 and #3.
However, if we use LLDB GetPC() interface, we would get the frame PC value as is in the backtrace,
which could be misleading.
GDB just shows PC value for the first inlined frame (output below).
(gdb) bt #0 0x00000000004005e4 in print_info (node=0x7fff7f41bc18) at double.c:16 #1 0x0000000000400645 in func1 () at double.c:28 #2 func2 () at double.c:35 #3 main () at double.c:39
Is the explained LLDB behaviour (different from GDB) expected?
If not, please, consider the solution proposed by this patch.
When doing stack unwinding of inlined functions, we start from the inlined frame and iterate through parents,
recursively, until we find the non inlined frame. During that process, we create StackFrame instances
for each frame and we are using GetParentOfInlinedScope hook to get needed info.
This patch proposes using PC from the deepest inlined frame, for all consecutive inlined parents (recursively)
and the first non inlined (where the inlined code is located).
After this patch the backtrace from the example above has the following form
* thread #1, name = 'double', stop reason = signal SIGSEGV * frame #0: 0x00000000004005e4 double`print_info(node=0x00007fff7f41bc18) at double.c:16:32 frame #1: 0x0000000000400645 double`main [inlined] func1 at double.c:28:3 frame #2: 0x0000000000400645 double`main [inlined] func2 at double.c:35:3 frame #3: 0x0000000000400645 double`main at double.c:39:1 frame #4: 0x00007f03adf0a7b3 libc.so.6`__libc_start_main + 243 frame #5: 0x000000000040050e double`_start + 46
Any feedback is welcome, thanks!