Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc64/sparc64 convert stackdump() to look up symb...
details: https://anonhg.NetBSD.org/src/rev/5221879af024
branches: trunk
changeset: 765665:5221879af024
user: mrg <mrg%NetBSD.org@localhost>
date: Wed Jun 01 23:41:04 2011 +0000
description:
convert stackdump() to look up symbols rather than dumping raw %pc values.
diffstat:
sys/arch/sparc64/sparc64/machdep.c | 55 ++++++++++++++++++++++++++++++++-----
1 files changed, 47 insertions(+), 8 deletions(-)
diffs (112 lines):
diff -r 9cb5a58d8510 -r 5221879af024 sys/arch/sparc64/sparc64/machdep.c
--- a/sys/arch/sparc64/sparc64/machdep.c Wed Jun 01 22:59:44 2011 +0000
+++ b/sys/arch/sparc64/sparc64/machdep.c Wed Jun 01 23:41:04 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: machdep.c,v 1.256 2011/03/04 22:25:29 joerg Exp $ */
+/* $NetBSD: machdep.c,v 1.257 2011/06/01 23:41:04 mrg Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.256 2011/03/04 22:25:29 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.257 2011/06/01 23:41:04 mrg Exp $");
#include "opt_ddb.h"
#include "opt_multiprocessor.h"
@@ -103,6 +103,7 @@
#include <sys/ucontext.h>
#include <sys/cpu.h>
#include <sys/module.h>
+#include <sys/ksyms.h>
#include <sys/exec_aout.h>
@@ -131,6 +132,7 @@
#include <sparc64/sparc64/cache.h>
/* #include "fb.h" */
+#include "ksyms.h"
int bus_space_debug = 0; /* This may be used by macros elsewhere. */
#ifdef DEBUG
@@ -879,6 +881,31 @@
(unsigned long long)tf->tf_out[6],
(unsigned long long)tf->tf_out[7]);
}
+
+static void
+get_symbol_and_offset(const char **mod, const char **sym, vaddr_t *offset, vaddr_t pc)
+{
+ static char symbuf[256];
+ unsigned long symaddr;
+
+#if NKSYMS || defined(DDB) || defined(MODULAR)
+ if (ksyms_getname(mod, sym, pc,
+ KSYMS_CLOSEST|KSYMS_PROC|KSYMS_ANY) == 0) {
+ if (ksyms_getval(*mod, *sym, &symaddr,
+ KSYMS_CLOSEST|KSYMS_PROC|KSYMS_ANY) != 0)
+ goto failed;
+
+ *offset = (vaddr_t)(pc - symaddr);
+ return;
+ }
+#endif
+ failed:
+ snprintf(symbuf, sizeof symbuf, "%llx", (unsigned long long)pc);
+ *mod = "netbsd";
+ *sym = symbuf;
+ *offset = 0;
+}
+
/*
* get the fp and dump the stack as best we can. don't leave the
* current stack page
@@ -888,6 +915,8 @@
{
struct frame32 *fp = (struct frame32 *)getfp(), *sfp;
struct frame64 *fp64;
+ const char *mod, *sym;
+ vaddr_t offset;
sfp = fp;
printf("Frame pointer is at %p\n", fp);
@@ -896,8 +925,10 @@
if( ((long)fp) & 1 ) {
fp64 = (struct frame64*)(((char*)fp)+BIAS);
/* 64-bit frame */
- printf("%llx(%llx, %llx, %llx, %llx, %llx, %llx, %llx) fp = %llx\n",
- (unsigned long long)fp64->fr_pc,
+ get_symbol_and_offset(&mod, &sym, &offset, fp64->fr_pc);
+ printf(" %s:%s+%#llx(%llx, %llx, %llx, %llx, %llx, %llx, %llx) fp = %llx\n",
+ mod, sym,
+ (unsigned long long)offset,
(unsigned long long)fp64->fr_arg[0],
(unsigned long long)fp64->fr_arg[1],
(unsigned long long)fp64->fr_arg[2],
@@ -909,11 +940,19 @@
fp = (struct frame32 *)(u_long)fp64->fr_fp;
} else {
/* 32-bit frame */
- printf(" pc = %x args = (%x, %x, %x, %x, %x, %x, %x) fp = %x\n",
- fp->fr_pc, fp->fr_arg[0], fp->fr_arg[1], fp->fr_arg[2],
- fp->fr_arg[3], fp->fr_arg[4], fp->fr_arg[5], fp->fr_arg[6],
+ get_symbol_and_offset(&mod, &sym, &offset, fp->fr_pc);
+ printf(" %s:%s+%#lx(%x, %x, %x, %x, %x, %x, %x) fp = %x\n",
+ mod, sym,
+ (unsigned long)offset,
+ fp->fr_arg[0],
+ fp->fr_arg[1],
+ fp->fr_arg[2],
+ fp->fr_arg[3],
+ fp->fr_arg[4],
+ fp->fr_arg[5],
+ fp->fr_arg[6],
fp->fr_fp);
- fp = (struct frame32*)(u_long)(u_short)fp->fr_fp;
+ fp = (struct frame32*)(u_long)fp->fr_fp;
}
}
}
Home |
Main Index |
Thread Index |
Old Index