Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Rename the machine-specific stack trace printing functions
details: https://anonhg.NetBSD.org/src/rev/87355e1b03e1
branches: trunk
changeset: 486587:87355e1b03e1
user: jhawk <jhawk%NetBSD.org@localhost>
date: Fri May 26 03:34:24 2000 +0000
description:
Rename the machine-specific stack trace printing functions
from db_stack_trace_cmd() to db_stack_trace_print(),
and add an additional argument, a function pointer for an
output routine (i.e. printf() or db_printf()).
Add db_stack_trace_cmd() in db_command.[ch], calling
db_stack_trace_print() with db_printf() as the printer.
Move count==-1 special handling from db_stack_trace_print() [nee
db_stack_trace_cmd()] to db_stack_trace_cmd() [nascent here].
Again, I'm unable to test compilation on all affected platforms,
so advance apologies for potential brokenness.
diffstat:
sys/arch/alpha/alpha/db_trace.c | 63 +++++++++++++++-------------
sys/arch/arm26/arm26/db_trace.c | 38 ++++++++---------
sys/arch/arm32/arm32/db_trace.c | 30 ++++++-------
sys/arch/i386/i386/db_trace.c | 52 +++++++++++-----------
sys/arch/m68k/m68k/db_trace.c | 57 +++++++++++++------------
sys/arch/mips/mips/db_trace.c | 15 +++---
sys/arch/pc532/pc532/db_trace.c | 53 ++++++++++++-----------
sys/arch/powerpc/powerpc/db_trace.c | 12 ++---
sys/arch/sh3/sh3/db_trace.c | 52 +++++++++++-----------
sys/arch/sparc/sparc/db_trace.c | 28 +++++------
sys/arch/sparc64/sparc64/db_trace.c | 22 ++++-----
sys/arch/vax/vax/db_machdep.c | 81 +++++++++++++++++++-----------------
sys/ddb/db_command.c | 15 ++++++-
sys/ddb/db_command.h | 3 +-
sys/ddb/db_interface.h | 6 +-
15 files changed, 272 insertions(+), 255 deletions(-)
diffs (truncated from 1652 to 300 lines):
diff -r 08bdc7798db2 -r 87355e1b03e1 sys/arch/alpha/alpha/db_trace.c
--- a/sys/arch/alpha/alpha/db_trace.c Fri May 26 03:10:31 2000 +0000
+++ b/sys/arch/alpha/alpha/db_trace.c Fri May 26 03:34:24 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_trace.c,v 1.5 2000/05/25 19:57:30 jhawk Exp $ */
+/* $NetBSD: db_trace.c,v 1.6 2000/05/26 03:34:24 jhawk Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@
#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
-__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.5 2000/05/25 19:57:30 jhawk Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_trace.c,v 1.6 2000/05/26 03:34:24 jhawk Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -98,16 +98,19 @@
{ NULL }
};
-static void decode_prologue __P((db_addr_t, db_addr_t, struct prologue_info *));
-static void decode_syscall(int, struct proc *);
+static void decode_prologue __P((db_addr_t, db_addr_t, struct prologue_info *,
+ void (*)(const char *, ...)));
+static void decode_syscall __P((int, struct proc *,
+ void (*)(const char *, ...)));
static int sym_is_trapsymbol __P((void *));
void
-db_stack_trace_cmd(addr, have_addr, count, modif)
+db_stack_trace_print(addr, have_addr, count, modif, pr)
db_expr_t addr;
boolean_t have_addr;
db_expr_t count;
char *modif;
+ void (*pr) __P((const char *, ...));
{
db_addr_t callpc, frame, symval;
struct prologue_info pi;
@@ -129,8 +132,6 @@
while ((c = *cp++) != 0)
trace_thread |= c == 't';
- if (count == -1)
- count = 65535;
if (!have_addr) {
p = curproc;
@@ -139,22 +140,22 @@
have_trapframe = 1;
} else {
if (trace_thread) {
- db_printf ("trace: pid %d ", (int)addr);
+ (*pr)("trace: pid %d ", (int)addr);
p = pfind(addr);
if (p == NULL) {
- db_printf("not found\n");
+ (*pr)("not found\n");
return;
}
if ((p->p_flag & P_INMEM) == 0) {
- db_printf("swapped out\n");
+ (*pr)("swapped out\n");
return;
}
pcbp = &p->p_addr->u_pcb;
addr = (db_expr_t)pcbp->pcb_hw.apcb_ksp;
callpc = pcbp->pcb_context[7];
- db_printf("at 0x%lx\n", addr);
+ (*pr)("at 0x%lx\n", addr);
} else {
- db_printf("alpha trace requires known PC =eject=\n");
+ (*pr)("alpha trace requires known PC =eject=\n");
return;
}
frame = addr;
@@ -175,7 +176,7 @@
symval_f = (void *)symval;
if (callpc < symval) {
- db_printf("symbol botch: callpc 0x%lx < "
+ (*pr)("symbol botch: callpc 0x%lx < "
"func 0x%lx (%s)\n", callpc, symval, symname);
return;
}
@@ -207,9 +208,9 @@
* could get the arguments if we use a remote source-level
* debugger (for serious debugging).
*/
- db_printf("%s() at ", symname);
- db_printsym(callpc, DB_STGY_PROC, db_printf);
- db_printf("\n");
+ (*pr)("%s() at ", symname);
+ db_printsym(callpc, DB_STGY_PROC, pr);
+ (*pr)("\n");
/*
* If we are in a trap vector, frame points to a
@@ -220,20 +221,20 @@
for (i = 0; special_symbols[i].ss_val != NULL; ++i)
if (symval_f == special_symbols[i].ss_val)
- db_printf("--- %s",
+ (*pr)("--- %s",
special_symbols[i].ss_note);
tfps = tf->tf_regs[FRAME_PS];
if (symval_f == &XentSys)
- decode_syscall(tf->tf_regs[FRAME_V0], p);
+ decode_syscall(tf->tf_regs[FRAME_V0], p, pr);
if ((tfps & ALPHA_PSL_IPL_MASK) != last_ipl) {
last_ipl = tfps & ALPHA_PSL_IPL_MASK;
if (symval_f != &XentSys)
- db_printf(" (from ipl %ld)", last_ipl);
+ (*pr)(" (from ipl %ld)", last_ipl);
}
- db_printf(" ---\n");
+ (*pr)(" ---\n");
if (tfps & ALPHA_PSL_USERMODE) {
- db_printf("--- user mode ---\n");
+ (*pr)("--- user mode ---\n");
break; /* Terminate search. */
}
have_trapframe = 1;
@@ -246,7 +247,7 @@
*
* XXX How does this interact w/ alloca()?!
*/
- decode_prologue(callpc, symval, &pi);
+ decode_prologue(callpc, symval, &pi, pr);
if ((pi.pi_regmask & (1 << 26)) == 0) {
/*
* No saved RA found. We might have RA from
@@ -257,7 +258,7 @@
if (ra_from_tf)
callpc = tf->tf_regs[FRAME_RA];
else {
- db_printf("--- root of call graph ---\n");
+ (*pr)("--- root of call graph ---\n");
break;
}
} else
@@ -279,9 +280,10 @@
* which registers are stored where, and how large the stack frame is.
*/
static void
-decode_prologue(callpc, func, pi)
+decode_prologue(callpc, func, pi, pr)
db_addr_t callpc, func;
struct prologue_info *pi;
+ void (*pr) __P((const char *, ...));
{
long signed_immediate;
alpha_instruction ins;
@@ -293,7 +295,7 @@
#define CHECK_FRAMESIZE \
do { \
if (pi->pi_frame_size != 0) { \
- db_printf("frame size botch: adjust register offsets?\n"); \
+ (*pr)("frame size botch: adjust register offsets?\n"); \
} \
} while (0)
@@ -311,7 +313,7 @@
signed_immediate = (long)ins.mem_format.displacement;
#if 1
if (signed_immediate > 0)
- db_printf("prologue botch: displacement %ld\n",
+ (*pr)("prologue botch: displacement %ld\n",
signed_immediate);
#endif
CHECK_FRAMESIZE;
@@ -351,16 +353,17 @@
}
static void
-decode_syscall(number, p)
+decode_syscall(number, p, pr)
int number;
struct proc *p;
+ void (*pr) __P((const char *, ...));
{
db_sym_t sym;
db_expr_t diff;
char *symname, *ename;
int (*f) __P((struct proc *, void *, register_t *));
- db_printf(" (%d", number); /* ) */
+ (*pr)(" (%d", number); /* ) */
if (!p)
goto out;
if (0 <= number && number < p->p_emul->e_nsysent) {
@@ -370,9 +373,9 @@
if (sym == DB_SYM_NULL || diff != 0)
goto out;
db_symbol_values(sym, &symname, NULL);
- db_printf(", %s.%s", ename, symname);
+ (*pr)(", %s.%s", ename, symname);
}
out:
- db_printf(")");
+ (*pr)(")");
return;
}
diff -r 08bdc7798db2 -r 87355e1b03e1 sys/arch/arm26/arm26/db_trace.c
--- a/sys/arch/arm26/arm26/db_trace.c Fri May 26 03:10:31 2000 +0000
+++ b/sys/arch/arm26/arm26/db_trace.c Fri May 26 03:34:24 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_trace.c,v 1.3 2000/05/25 19:57:32 jhawk Exp $ */
+/* $NetBSD: db_trace.c,v 1.4 2000/05/26 03:34:30 jhawk Exp $ */
/*
* Copyright (c) 1996 Scott K. Stevens
@@ -75,11 +75,12 @@
#define FR_RFP (-3)
void
-db_stack_trace_cmd(addr, have_addr, count, modif)
+db_stack_trace_print(addr, have_addr, count, modif, pr)
db_expr_t addr;
int have_addr;
db_expr_t count;
char *modif;
+ void (*pr) __P((const char *, ...));
{
u_int32_t *frame, *lastframe;
char c, *cp = modif;
@@ -93,28 +94,25 @@
trace_thread = TRUE;
}
- if (count == -1)
- count = 65535;
-
if (!have_addr)
frame = (u_int32_t *)(DDB_TF->tf_r11);
else {
if (trace_thread) {
struct proc *p;
struct user *u;
- db_printf ("trace: pid %d ", (int)addr);
+ (*pr) ("trace: pid %d ", (int)addr);
p = pfind(addr);
if (p == NULL) {
- db_printf("not found\n");
+ (*pr)("not found\n");
return;
}
if (!(p->p_flag & P_INMEM)) {
- db_printf("swapped out\n");
+ (*pr)("swapped out\n");
return;
}
u = p->p_addr;
frame = (u_int32_t *)(u->u_pcb.pcb_sf->sf_r11);
- db_printf("at %p\n", frame);
+ (*pr)("at %p\n", frame);
} else
frame = (u_int32_t *)(addr);
}
@@ -138,13 +136,13 @@
if (name == NULL)
name = "?";
- db_printf("%s", name);
- db_printf("(scp=0x%x(", frame[FR_SCP]);
- db_printsym(scp, DB_STGY_PROC, db_printf);
- db_printf("), rlv=0x%x(", frame[FR_RLV]);
- db_printsym(frame[FR_RLV] & R15_PC, DB_STGY_PROC, db_printf);
- db_printf("),\n\trsp=0x%x", frame[FR_RSP]);
- db_printf(", rfp=0x%x", frame[FR_RFP]);
+ (*pr)("%s", name);
+ (*pr)("(scp=0x%x(", frame[FR_SCP]);
+ db_printsym(scp, DB_STGY_PROC, pr);
+ (*pr)("), rlv=0x%x(", frame[FR_RLV]);
+ db_printsym(frame[FR_RLV] & R15_PC, DB_STGY_PROC, pr);
+ (*pr)("),\n\trsp=0x%x", frame[FR_RSP]);
+ (*pr)(", rfp=0x%x", frame[FR_RFP]);
savecode = ((u_int32_t *)scp)[-3];
if ((savecode & 0x0e100000) == 0x08000000) {
@@ -152,12 +150,12 @@
rp = frame - 4;
for (r = 10; r >= 0; r--)
if (savecode & (1 << r))
- db_printf(",%sr%d=0x%x",
+ (*pr)(",%sr%d=0x%x",
(frame - rp) % 4 == 2 ?
"\n\t" : " ", r, *rp--);
}
- db_printf(")\n");
+ (*pr)(")\n");
/*
* Switch to next frame up
@@ -171,7 +169,7 @@
if (INKERNEL((int)frame)) {
Home |
Main Index |
Thread Index |
Old Index