Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aarch64: add thread_main to improve stacktraces
This patch improves debugging experience by making gdb show correct stack traces that look similar to what one can see in x86_64 port. It also solves sporadic errors when iterating over list of threads using 'osv info threads' when gdb would break like so: `Python Exception <class 'gdb.error'> Attempt to assign to an unmodifiable value.: Error occurred in Python: Attempt to assign to an unmodifiable value.' So in essence this patch adds new function implemented in assembly - 'thread_main' - which calls 'thread_main_c'. The address of this new function is also what we set 'pc' field of the thread _state instead of 'thread_main_c'. The main benefit of adding this extra redirection is that we can add proper CFI (Call Frame Information) directive - '.cfi_undefined x30` - to force gdb not to look up the stack for call frames beyond the 'thread_main' one. This is similar to what we do in x86_64 port. So in the end, besides fixing sporadic gdb errors when iterating over threads, we also get much better and correct looking stacktraces that end with (or start with from the bottom): Before the patch: ----------------- #0 reschedule_from_interrupt () at arch/aarch64/sched.S:54 #1 0x00000000402e36d4 in sched::cpu::schedule () at core/sched.cc:229 #2 0x00000000402e79a0 in sched::thread::wait (this=<optimized out>) at core/sched.cc:1273 #3 sched::thread::do_wait_until<sched::noninterruptible, sched::thread::dummy_lock, sched::cpu::load_balance()::<lambda()> > (mtx=<synthetic pointer>..., pred=...) at include/osv/sched.hh:1101 #4 sched::thread::wait_until<sched::cpu::load_balance()::<lambda()> > (pred=...) at include/osv/sched.hh:1112 #5 sched::cpu::load_balance ( this=0x40700960 <construction vtable for std::ostream-in-std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >+24>) at core/sched.cc:730 #6 0x00000000402e72b4 in sched::thread::main (this=0xffffa000408a39a0) at core/sched.cc:1267 #7 sched::thread_main_c (t=0xffffa000408a39a0) at arch/aarch64/arch-switch.hh:161 #8 0x00000000402c04e0 in reschedule_from_interrupt () at arch/aarch64/sched.S:50 #9 0x0000000000000000 in ?? () After the patch: ---------------- #0 reschedule_from_interrupt () at arch/aarch64/sched.S:54 #1 0x00000000402e36d4 in sched::cpu::schedule () at core/sched.cc:229 #2 0x00000000402e79a0 in sched::thread::wait (this=<optimized out>) at core/sched.cc:1273 #3 sched::thread::do_wait_until<sched::noninterruptible, sched::thread::dummy_lock, sched::cpu::load_balance()::<lambda()> > (mtx=<synthetic pointer>..., pred=...) at include/osv/sched.hh:1101 #4 sched::thread::wait_until<sched::cpu::load_balance()::<lambda()> > (pred=...) at include/osv/sched.hh:1112 #5 sched::cpu::load_balance ( this=0x407009b8 <construction vtable for std::ostream-in-std::__cxx11::basic_ostringstream<char, std::char_traits<char>, std::allocator<char> >+24>) at core/sched.cc:730 #6 0x00000000402e72b4 in sched::thread::main (this=0xffffa000408a39a0) at core/sched.cc:1267 #7 sched::thread_main_c (t=0xffffa000408a39a0) at arch/aarch64/arch-switch.hh:162 #8 0x000000004020b788 in thread_main () at arch/aarch64/entry.S:112 Refs #1128 Signed-off-by: Waldemar Kozaczuk <[email protected]> Message-Id: <[email protected]>
- Loading branch information