https://git.reactos.org/?p=reactos.git;a=commitdiff;h=74014e74c00f1610ce62cb...
commit 74014e74c00f1610ce62cb950743ef12fa17c845 Author: Timo Kreuzer timo.kreuzer@reactos.org AuthorDate: Sat Jul 23 17:07:37 2022 +0200 Commit: Timo Kreuzer timo.kreuzer@reactos.org CommitDate: Thu Aug 4 16:15:24 2022 +0200
[NTOS:KDBG] Improve x64 stack trace printing --- ntoskrnl/kdbg/kdb_cli.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-)
diff --git a/ntoskrnl/kdbg/kdb_cli.c b/ntoskrnl/kdbg/kdb_cli.c index d22b38658e8..e044572691d 100644 --- a/ntoskrnl/kdbg/kdb_cli.c +++ b/ntoskrnl/kdbg/kdb_cli.c @@ -1211,44 +1211,30 @@ KdbpCmdBackTrace( PCHAR Argv[]) { CONTEXT Context = *KdbCurrentTrapFrame; - ULONG64 CurrentRsp, CurrentRip; - - KdbpPrint("Rip:\n"); - if (!KdbSymPrintAddress((PVOID)KeGetContextPc(&Context), &Context)) - KdbpPrint("<%p>\n", KeGetContextPc(&Context)); - else - KdbpPrint("\n");
/* Walk through the frames */ KdbpPrint("Frames:\n"); - for (;;) + do { - CurrentRip = Context.Rip; - CurrentRsp = Context.Rsp; - - BOOLEAN GotNextFrame = GetNextFrame(&Context); + BOOLEAN GotNextFrame;
- KdbpPrint("[%p] ", (PVOID)CurrentRsp); - Context.Rsp = Context.Rsp; + KdbpPrint("[%p] ", (PVOID)Context.Rsp);
- /* Print the location afrer the call instruction */ - if (!KdbSymPrintAddress((PVOID)CurrentRip, &Context)) + /* Print the location after the call instruction */ + if (!KdbSymPrintAddress((PVOID)Context.Rip, &Context)) KdbpPrint("<%p>", (PVOID)Context.Rip); - - KdbpPrint(" (stack: 0x%Ix)\n", Context.Rsp - CurrentRsp); + KdbpPrint("\n");
if (KdbOutputAborted) break;
- if (Context.Rsp == 0) - break; - + GotNextFrame = GetNextFrame(&Context); if (!GotNextFrame) { - KdbpPrint("Couldn't access memory at 0x%p!\n", (PVOID)Context.Rsp); + KdbpPrint("Couldn't get next frame\n"); break; } - } + } while ((Context.Rip != 0) && (Context.Rsp != 0));
return TRUE; }