Project

General

Profile

Actions

Bug #1614

closed

x86_64 garbled backtrace

Added by alexh almost 15 years ago. Updated about 14 years ago.

Status:
Closed
Priority:
High
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

We really need to fix the garbled output of the db> trace on x86_64, it makes it
difficult to debug a number of issues.
Does anyone have any insight on why this happens?

Cheers,
Alex Hornung

Actions #1

Updated by qhwt+dfly almost 15 years ago

On Tue, Nov 24, 2009 at 09:01:54AM +0000, Alex Hornung (via DragonFly issue tracker) wrote:

We really need to fix the garbled output of the db> trace on x86_64, it makes it
difficult to debug a number of issues.
Does anyone have any insight on why this happens?

I've just committed an essential fix to this problem. At least you have
functions list now. However, calling print_backtrace() from kernel code
still triggers a GPF; I think this is probably because of missing INKERNEL
-conditionals used here and there in i386 version. I'm thinking of
applying something like this: (the last few lines in db_stack_trace_cmd()
are not brought in from i386 version, because doing so corrupts the
functions list in a different way than it used to do).

Cheers.

diff --git a/sys/platform/pc64/x86_64/db_trace.c b/sys/platform/pc64/x86_64/db_trace.c
index ec09e5f..8ddca3d 100644
--- a/sys/platform/pc64/x86_64/db_trace.c
+++ b/sys/platform/pc64/x86_64/db_trace.c
@ -269,46 +269,37 @ db_nextframe(struct x86_64_frame **fp, db_addr_t *ip)
*/
tf = (struct trapframe *)((long)*fp + 16);

+ if (INKERNEL) {
#if 0
- rsp = (ISPL SEL_UPL) ? tf->tf_rsp : (long)&tf->tf_rsp;
+ rsp = (ISPL(tf->tf_cs) SEL_UPL) ? tf->tf_rsp : (long)&tf->tf_rsp;
#endif
- rsp = (long)&tf->tf_rsp;

switch (frame_type) {
- case TRAP:
- {
- rip = tf->tf_rip;
- rbp = tf->tf_rbp;
- db_printf(
- "--- trap %016lx, rip = %016lx, rsp = %016lx, rbp = %016lx ---\n",
- tf->tf_trapno, rip, rsp, rbp);
- }
- break;
- case SYSCALL:
- {
- rip = tf->tf_rip;
- rbp = tf->tf_rbp;
- db_printf(
- "--- syscall %016lx, rip = %016lx, rsp = %016lx, rbp = %016lx ---\n",
- tf->tf_rax, rip, rsp, rbp);
- }
- break;
- case INTERRUPT:
- tf = (struct trapframe *)((long)*fp + 16);
- {
- rip = tf->tf_rip;
- rbp = tf->tf_rbp;
- db_printf(
- "--- interrupt, rip = %016lx, rsp = %016lx, rbp = %016lx ---\n",
- rip, rsp, rbp);
- }
- break;
- default:
+ rsp = (long)&tf->tf_rsp;
rip = tf->tf_rip;
rbp = tf->tf_rbp;
- break;
- }

+ switch (frame_type) {
+ case TRAP:
+ db_printf("--- trap %016lx, "
+ "rip = %016lx, rsp = %016lx, rbp = %016lx "
+ "---\n",
+ tf->tf_trapno, rip, rsp, rbp);
+ break;
+ case SYSCALL:
+ db_printf("--- syscall %016lx, "
+ "rip = %016lx, rsp = %016lx, rbp = %016lx "
+ "---\n",
+ tf->tf_rax, rip, rsp, rbp);
+ break;
+ case INTERRUPT:
+ db_printf("--- interrupt, "
+ "rip = %016lx, rsp = %016lx, rbp = %016lx "
+ "---\n",
+ rip, rsp, rbp);
+ break;
+ default:
+ break;
+ }
+ }
ip = (db_addr_t) rip;
*fp = (struct x86_64_frame *) rbp;
}
@ -331,6 +322,10 @ db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
if (frame == NULL)
frame = (struct x86_64_frame *)(SP_REGS(&ddb_regs) - 8);
callpc = PC_REGS(&ddb_regs);
+ } else if (!INKERNEL) {
+ /
XXX /
+ db_printf("no kernel stack address\n");
+ return;
} else {
/
* Look for something that might be a frame pointer, just as

Actions #2

Updated by alexh over 14 years ago

Any news on this?

Cheers,
Alex Hornung

Actions #3

Updated by alexh over 14 years ago

Fixed in 71f9f0206c2940ce40ff70a0f1fd641c99d5ee74

Actions #4

Updated by qhwt.dfly about 14 years ago

Hi.
I'm still seeing the garbled backtrace on the console when I dropped
to DDB or when the kernel panicked. I doubt 71f9f020 fixed this issue
as the patch is for kgdb, not DDB (I haven't been running x86_64 for
a while, so I'm not sure if it's been there or recently re-introduced).

Actions

Also available in: Atom PDF