Commit 5a0b81b4 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[arm64/sim] Add a simple backtrace debug command

Add a simple backtrace/bt command to the simulator debugger, which does
the frame-pointer stack walk and dumps pc/fp/sp for each frame.

This is strictly less powerful than the full JS stack dump, but can be
used to debug issues with corrupted frames that prevent the JS stack
dumper from working correctly.

Change-Id: I26cc962ab8d22c0a219d6a35548544602aa89418
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2666688
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72480}
parent 1f72df06
......@@ -3530,6 +3530,33 @@ bool Simulator::ExecDebugCommand(ArrayUniquePtr<char> line_ptr) {
PrintF("Use `break <address>` to set or disable a breakpoint\n");
}
// backtrace / bt
// ---------------------------------------------------------------
} else if (strcmp(cmd, "backtrace") == 0 || strcmp(cmd, "bt") == 0) {
Address pc = reinterpret_cast<Address>(pc_);
Address lr = reinterpret_cast<Address>(this->lr());
Address sp = static_cast<Address>(this->sp());
Address fp = static_cast<Address>(this->fp());
int i = 0;
while (true) {
PrintF("#%d: " V8PRIxPTR_FMT " (sp=" V8PRIxPTR_FMT ", fp=" V8PRIxPTR_FMT
")\n",
i, pc, sp, fp);
pc = lr;
sp = fp;
if (pc == reinterpret_cast<Address>(kEndOfSimAddress)) {
break;
}
lr = *(reinterpret_cast<Address*>(fp) + 1);
fp = *reinterpret_cast<Address*>(fp);
i++;
if (i > 100) {
PrintF("Too many frames\n");
break;
}
}
// gdb
// -------------------------------------------------------------------
} else if (strcmp(cmd, "gdb") == 0) {
......@@ -3584,6 +3611,8 @@ bool Simulator::ExecDebugCommand(ArrayUniquePtr<char> line_ptr) {
"break / b\n"
" break : list all breakpoints\n"
" break <address> : set / enable / disable a breakpoint.\n"
"backtrace / bt\n"
" Walk the frame pointers, dumping the pc/sp/fp for each frame.\n"
"gdb\n"
" Enter gdb.\n"
"sysregs\n"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment