This is an archive of the discontinued LLVM Phabricator instance.

[lldb][AArch64] Account for extra libc frames in PAC unwind test
ClosedPublic

Authored by DavidSpickett on Jun 30 2023, 4:53 AM.

Details

Summary

Running this on Amazon Ubuntu the final backtrace is:

(lldb) thread backtrace
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
  * frame #0: 0x0000aaaaaaaa07d0 a.out`func_c at main.c:10:3
    frame #1: 0x0000aaaaaaaa07c4 a.out`func_b at main.c:14:3
    frame #2: 0x0000aaaaaaaa07b4 a.out`func_a at main.c:18:3
    frame #3: 0x0000aaaaaaaa07a4 a.out`main(argc=<unavailable>, argv=<unavailable>) at main.c:22:3
    frame #4: 0x0000fffff7b373fc libc.so.6`___lldb_unnamed_symbol2962 + 108
    frame #5: 0x0000fffff7b374cc libc.so.6`__libc_start_main + 152
    frame #6: 0x0000aaaaaaaa06b0 a.out`_start + 48

This causes the test to fail because of the extra ___lldb_unnamed_symbol2962 frame
(an inlined function?).

To fix this, strictly check all the frames in main.c then for the rest
just check we find __libc_start_main and _start in that order regardless
of other frames in between.

Diff Detail

Event Timeline

DavidSpickett created this revision.Jun 30 2023, 4:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 30 2023, 4:53 AM
DavidSpickett requested review of this revision.Jun 30 2023, 4:53 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 30 2023, 4:53 AM

Interesting, libc.so must have stripped the names of non-externally-visible functions, and libc_start_main calls one of them which calls main in turn. This change to the test case looks correct to me.

omjavaid accepted this revision.Jul 4 2023, 2:55 AM
This revision is now accepted and ready to land.Jul 4 2023, 2:55 AM