aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2004-09-20 19:05:32 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2004-09-20 19:05:32 +0000
commit76764432e4a9595092bcaccd8153b269cdaaa831 (patch)
treeb2136a0a4b646b54ea0fa359879a4c4a13989501 /sys
parentb89daf89a80faa1fcd9b67b0433b7b119eba8279 (diff)
downloadsrc-76764432e4a9595092bcaccd8153b269cdaaa831.tar.gz
src-76764432e4a9595092bcaccd8153b269cdaaa831.zip
- Add support for "paging" in stack trace output. That is, when you do
a stack trace from ddb, the output will pause with a '--More--' prompt every 18 lines. If you hit Enter, it will print another line and prompt again. If you hit space it will output another page and then prompt. If you hit 'q' or 'x' it will abort the rest of the stack trace. - Fix the sparc64 userland stack trace to honor the total count of lines to print. This is useful if your trace happens to walk back onto 0xdeadc0de and gets stuck in an endless loop. MFC after: 1 month Tested on: i386, alpha, sparc64
Notes
Notes: svn path=/head/; revision=135529
Diffstat (limited to 'sys')
-rw-r--r--sys/alpha/alpha/db_trace.c6
-rw-r--r--sys/amd64/amd64/db_trace.c6
-rw-r--r--sys/arm/arm/db_trace.c6
-rw-r--r--sys/i386/i386/db_trace.c6
-rw-r--r--sys/ia64/ia64/db_trace.c6
-rw-r--r--sys/powerpc/powerpc/db_trace.c5
-rw-r--r--sys/sparc64/sparc64/db_trace.c15
7 files changed, 33 insertions, 17 deletions
diff --git a/sys/alpha/alpha/db_trace.c b/sys/alpha/alpha/db_trace.c
index 615bd2edff28..8671ca82586b 100644
--- a/sys/alpha/alpha/db_trace.c
+++ b/sys/alpha/alpha/db_trace.c
@@ -213,14 +213,16 @@ db_backtrace(struct thread *td, db_addr_t frame, db_addr_t pc, int count)
db_expr_t diff;
db_addr_t symval;
u_long last_ipl, tfps;
- int i;
+ int i, quit;
if (count == -1)
count = 1024;
last_ipl = ~0L;
tf = NULL;
- while (count--) {
+ quit = 0;
+ db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE);
+ while (count-- && !quit) {
sym = db_search_symbol(pc, DB_STGY_ANY, &diff);
if (sym == DB_SYM_NULL)
return (ENOENT);
diff --git a/sys/amd64/amd64/db_trace.c b/sys/amd64/amd64/db_trace.c
index 5928dbe48d68..a4d464a7277f 100644
--- a/sys/amd64/amd64/db_trace.c
+++ b/sys/amd64/amd64/db_trace.c
@@ -373,14 +373,16 @@ db_backtrace(struct thread *td, struct trapframe *tf,
long *argp;
db_expr_t offset;
c_db_sym_t sym;
- int narg;
+ int narg, quit;
boolean_t first;
if (count == -1)
count = 1024;
first = TRUE;
- while (count--) {
+ quit = 0;
+ db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE);
+ while (count-- && !quit) {
sym = db_search_symbol(pc, DB_STGY_ANY, &offset);
db_symbol_values(sym, &name, NULL);
diff --git a/sys/arm/arm/db_trace.c b/sys/arm/arm/db_trace.c
index b05e760d448c..28ca26de5ac8 100644
--- a/sys/arm/arm/db_trace.c
+++ b/sys/arm/arm/db_trace.c
@@ -102,7 +102,7 @@ db_stack_trace_cmd(addr, have_addr, count, modif)
db_expr_t offset;
boolean_t kernel_only = TRUE;
boolean_t trace_thread = FALSE;
- int scp_offset;
+ int scp_offset, quit;
if (kdb_frame == NULL && !have_addr)
return;
@@ -142,7 +142,9 @@ db_stack_trace_cmd(addr, have_addr, count, modif)
lastframe = NULL;
scp_offset = -(get_pc_str_offset() >> 2);
- while (count-- && frame != NULL) {
+ quit = 0;
+ db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE);
+ while (count-- && frame != NULL && !quit) {
db_addr_t scp;
u_int32_t savecode;
int r;
diff --git a/sys/i386/i386/db_trace.c b/sys/i386/i386/db_trace.c
index ca3435eaf348..4b6cb61e3522 100644
--- a/sys/i386/i386/db_trace.c
+++ b/sys/i386/i386/db_trace.c
@@ -379,14 +379,16 @@ db_backtrace(struct thread *td, struct trapframe *tf, struct i386_frame *frame,
int *argp;
db_expr_t offset;
c_db_sym_t sym;
- int narg;
+ int narg, quit;
boolean_t first;
if (count == -1)
count = 1024;
first = TRUE;
- while (count--) {
+ quit = 0;
+ db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE);
+ while (count-- && !quit) {
sym = db_search_symbol(pc, DB_STGY_ANY, &offset);
db_symbol_values(sym, &name, NULL);
diff --git a/sys/ia64/ia64/db_trace.c b/sys/ia64/ia64/db_trace.c
index 7f9c53cd9614..6065eb656279 100644
--- a/sys/ia64/ia64/db_trace.c
+++ b/sys/ia64/ia64/db_trace.c
@@ -57,10 +57,12 @@ db_backtrace(struct thread *td, struct pcb *pcb, int count)
db_expr_t offset;
uint64_t bsp, cfm, ip, pfs, reg, sp;
c_db_sym_t sym;
- int args, error, i;
+ int args, error, i, quit;
+ quit = 0;
+ db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE);
error = unw_create_from_pcb(&rs, pcb);
- while (!error && count--) {
+ while (!error && count-- && !quit) {
error = unw_get_cfm(&rs, &cfm);
if (!error)
error = unw_get_bsp(&rs, &bsp);
diff --git a/sys/powerpc/powerpc/db_trace.c b/sys/powerpc/powerpc/db_trace.c
index 9fe1cc38322a..23d4e50eb5c6 100644
--- a/sys/powerpc/powerpc/db_trace.c
+++ b/sys/powerpc/powerpc/db_trace.c
@@ -129,6 +129,7 @@ db_backtrace(struct thread *td, db_addr_t fp, int count)
const char *symname;
boolean_t kernel_only = TRUE;
boolean_t full = FALSE;
+ int quit;
#if 0
{
@@ -148,7 +149,9 @@ db_backtrace(struct thread *td, db_addr_t fp, int count)
stackframe = fp;
- for (;;) {
+ quit = 0;
+ db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE);
+ while (!quit) {
if (stackframe < PAGE_SIZE)
break;
diff --git a/sys/sparc64/sparc64/db_trace.c b/sys/sparc64/sparc64/db_trace.c
index b5fdec9f42b0..acb4b5ad565f 100644
--- a/sys/sparc64/sparc64/db_trace.c
+++ b/sys/sparc64/sparc64/db_trace.c
@@ -96,7 +96,7 @@ db_frame(struct db_variable *vp, db_expr_t *valuep, int op)
* User stack trace (debugging aid).
*/
static void
-db_utrace(struct thread *td, struct trapframe *tf)
+db_utrace(struct thread *td, struct trapframe *tf, int count, int *quitp)
{
struct pcb *pcb;
db_addr_t sp, rsp, o7, pc;
@@ -108,7 +108,7 @@ db_utrace(struct thread *td, struct trapframe *tf)
FALSE);
pc = db_get_value((db_addr_t)&tf->tf_tpc, sizeof(tf->tf_tpc), FALSE);
db_printf("user trace: trap %%o7=%#lx\n", o7);
- while (sp != 0) {
+ while (count-- && sp != 0 && !*quitp) {
db_printf("pc %#lx, sp %#lx\n", pc, sp);
/* First, check whether the frame is in the pcb. */
found = 0;
@@ -134,7 +134,7 @@ db_utrace(struct thread *td, struct trapframe *tf)
}
static int
-db_print_trap(struct thread *td, struct trapframe *tf)
+db_print_trap(struct thread *td, struct trapframe *tf, int count, int *quitp)
{
struct proc *p;
const char *symname;
@@ -212,7 +212,7 @@ db_print_trap(struct thread *td, struct trapframe *tf)
db_printf("userland() at ");
db_printsym(tpc, DB_STGY_PROC);
db_printf("\n");
- db_utrace(td, tf);
+ db_utrace(td, tf, count, quitp);
}
return (user);
}
@@ -229,6 +229,7 @@ db_backtrace(struct thread *td, struct frame *fp, int count)
db_addr_t pc;
int trap;
int user;
+ int quit;
if (count == -1)
count = 1024;
@@ -236,7 +237,9 @@ db_backtrace(struct thread *td, struct frame *fp, int count)
trap = 0;
user = 0;
npc = 0;
- while (count-- && !user) {
+ quit = 0;
+ db_setup_paging(db_simple_pager, &quit, DB_LINES_PER_PAGE);
+ while (count-- && !user && !quit) {
pc = (db_addr_t)db_get_value((db_addr_t)&fp->fr_pc,
sizeof(fp->fr_pc), FALSE);
if (trap) {
@@ -260,7 +263,7 @@ db_backtrace(struct thread *td, struct frame *fp, int count)
tf = (struct trapframe *)(fp + 1);
npc = db_get_value((db_addr_t)&tf->tf_tpc,
sizeof(tf->tf_tpc), FALSE);
- user = db_print_trap(td, tf);
+ user = db_print_trap(td, tf, count, &quit);
trap = 1;
} else {
db_printf("%s() at ", name);