summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/alpha/alpha/db_trace.c14
-rw-r--r--sys/amd64/amd64/db_trace.c14
-rw-r--r--sys/arm/arm/db_trace.c3
-rw-r--r--sys/ddb/db_command.c45
-rw-r--r--sys/ddb/ddb.h1
-rw-r--r--sys/i386/i386/db_trace.c14
-rw-r--r--sys/ia64/ia64/db_trace.c14
-rw-r--r--sys/powerpc/powerpc/db_trace.c14
-rw-r--r--sys/sparc64/sparc64/db_trace.c14
9 files changed, 45 insertions, 88 deletions
diff --git a/sys/alpha/alpha/db_trace.c b/sys/alpha/alpha/db_trace.c
index 79ed437..615bd2e 100644
--- a/sys/alpha/alpha/db_trace.c
+++ b/sys/alpha/alpha/db_trace.c
@@ -324,20 +324,6 @@ db_backtrace(struct thread *td, db_addr_t frame, db_addr_t pc, int count)
}
void
-db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
- char *modif)
-{
- struct thread *td;
-
- td = (have_addr) ? kdb_thr_lookup(addr) : kdb_thread;
- if (td == NULL) {
- db_printf("Thread %d not found\n", (int)addr);
- return;
- }
- db_trace_thread(td, count);
-}
-
-void
db_trace_self(void)
{
register_t pc, sp;
diff --git a/sys/amd64/amd64/db_trace.c b/sys/amd64/amd64/db_trace.c
index 03842cb..5928dbe 100644
--- a/sys/amd64/amd64/db_trace.c
+++ b/sys/amd64/amd64/db_trace.c
@@ -463,20 +463,6 @@ db_backtrace(struct thread *td, struct trapframe *tf,
}
void
-db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
- char *modif)
-{
- struct thread *td;
-
- td = (have_addr) ? kdb_thr_lookup(addr) : kdb_thread;
- if (td == NULL) {
- db_printf("Thread %ld not found\n", addr);
- return;
- }
- db_trace_thread(td, count);
-}
-
-void
db_trace_self(void)
{
struct amd64_frame *frame;
diff --git a/sys/arm/arm/db_trace.c b/sys/arm/arm/db_trace.c
index 8ada1ef..b05e760 100644
--- a/sys/arm/arm/db_trace.c
+++ b/sys/arm/arm/db_trace.c
@@ -86,7 +86,7 @@ void db_md_list_watchpoints(void);
#define FR_RSP (-2)
#define FR_RFP (-3)
-void
+static void
db_stack_trace_cmd(addr, have_addr, count, modif)
db_expr_t addr;
int have_addr;
@@ -242,6 +242,7 @@ db_md_set_watchpoint(db_expr_t addr, db_expr_t size)
{
return (0);
}
+
int
db_trace_thread(struct thread *thr, int count)
{
diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c
index 30740ab..03fd662 100644
--- a/sys/ddb/db_command.c
+++ b/sys/ddb/db_command.c
@@ -70,6 +70,7 @@ static db_cmdfcn_t db_fncall;
static db_cmdfcn_t db_gdb;
static db_cmdfcn_t db_kill;
static db_cmdfcn_t db_reset;
+static db_cmdfcn_t db_stack_trace;
static db_cmdfcn_t db_watchdog;
/* XXX this is actually forward-static. */
@@ -410,8 +411,8 @@ static struct command db_command_table[] = {
{ "until", db_trace_until_call_cmd,0, 0 },
{ "next", db_trace_until_matching_cmd,0, 0 },
{ "match", db_trace_until_matching_cmd,0, 0 },
- { "trace", db_stack_trace_cmd, 0, 0 },
- { "where", db_stack_trace_cmd, 0, 0 },
+ { "trace", db_stack_trace, 0, 0 },
+ { "where", db_stack_trace, 0, 0 },
{ "call", db_fncall, CS_OWN, 0 },
{ "show", 0, 0, db_show_cmds },
{ "ps", db_ps, 0, 0 },
@@ -623,3 +624,43 @@ db_gdb(db_expr_t dummy1, boolean_t dummy2, db_expr_t dummy3, char *dummy4)
else
db_printf("Step to enter the remote GDB backend.\n");
}
+
+static void
+db_stack_trace(db_expr_t tid, boolean_t hastid, db_expr_t count, char *modif)
+{
+ struct thread *td;
+ db_expr_t radix;
+ int t;
+
+ /*
+ * We parse our own arguments. We don't like the default radix.
+ */
+ radix = db_radix;
+ db_radix = 10;
+ hastid = db_expression(&tid);
+ t = db_read_token();
+ if (t == tCOMMA) {
+ if (!db_expression(&count)) {
+ db_printf("Count missing\n");
+ db_flush_lex();
+ return;
+ }
+ } else {
+ db_unread_token(t);
+ count = -1;
+ }
+ db_skip_to_eol();
+ db_radix = radix;
+
+ if (hastid) {
+ td = kdb_thr_lookup((lwpid_t)tid);
+ if (td == NULL)
+ td = kdb_thr_from_pid((pid_t)tid);
+ if (td == NULL) {
+ db_printf("Thread %d not found\n", (int)tid);
+ return;
+ }
+ } else
+ td = kdb_thread;
+ db_trace_thread(td, count);
+}
diff --git a/sys/ddb/ddb.h b/sys/ddb/ddb.h
index c1ffff9..97d332e 100644
--- a/sys/ddb/ddb.h
+++ b/sys/ddb/ddb.h
@@ -128,7 +128,6 @@ db_cmdfcn_t db_set_thread;
db_cmdfcn_t db_show_regs;
db_cmdfcn_t db_show_threads;
db_cmdfcn_t db_single_step_cmd;
-db_cmdfcn_t db_stack_trace_cmd;
db_cmdfcn_t db_trace_until_call_cmd;
db_cmdfcn_t db_trace_until_matching_cmd;
db_cmdfcn_t db_watchpoint_cmd;
diff --git a/sys/i386/i386/db_trace.c b/sys/i386/i386/db_trace.c
index aaf11e0..d7ae3e3 100644
--- a/sys/i386/i386/db_trace.c
+++ b/sys/i386/i386/db_trace.c
@@ -449,20 +449,6 @@ db_backtrace(struct thread *td, struct trapframe *tf, struct i386_frame *frame,
}
void
-db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
- char *modif)
-{
- struct thread *td;
-
- td = (have_addr) ? kdb_thr_lookup(addr) : kdb_thread;
- if (td == NULL) {
- db_printf("Thread %d not found\n", addr);
- return;
- }
- db_trace_thread(td, count);
-}
-
-void
db_trace_self(void)
{
struct i386_frame *frame;
diff --git a/sys/ia64/ia64/db_trace.c b/sys/ia64/ia64/db_trace.c
index 11a2e55..7f9c53c 100644
--- a/sys/ia64/ia64/db_trace.c
+++ b/sys/ia64/ia64/db_trace.c
@@ -125,20 +125,6 @@ db_backtrace(struct thread *td, struct pcb *pcb, int count)
}
void
-db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
- char *modif)
-{
- struct thread *td;
-
- td = (have_addr) ? kdb_thr_lookup(addr) : kdb_thread;
- if (td == NULL) {
- db_printf("Thread %d not found\n", (int)addr);
- return;
- }
- db_trace_thread(td, count);
-}
-
-void
db_trace_self(void)
{
struct pcb pcb;
diff --git a/sys/powerpc/powerpc/db_trace.c b/sys/powerpc/powerpc/db_trace.c
index a4291d9..9fe1cc3 100644
--- a/sys/powerpc/powerpc/db_trace.c
+++ b/sys/powerpc/powerpc/db_trace.c
@@ -267,20 +267,6 @@ db_backtrace(struct thread *td, db_addr_t fp, int count)
}
void
-db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
- char *modif)
-{
- struct thread *td;
-
- td = (have_addr) ? kdb_thr_lookup(addr) : kdb_thread;
- if (td == NULL) {
- db_printf("Thread %d not found\n", (int)addr);
- return;
- }
- db_trace_thread(td, count);
-}
-
-void
db_trace_self(void)
{
db_addr_t addr;
diff --git a/sys/sparc64/sparc64/db_trace.c b/sys/sparc64/sparc64/db_trace.c
index ae53841..b5fdec9 100644
--- a/sys/sparc64/sparc64/db_trace.c
+++ b/sys/sparc64/sparc64/db_trace.c
@@ -272,20 +272,6 @@ db_backtrace(struct thread *td, struct frame *fp, int count)
}
void
-db_stack_trace_cmd(db_expr_t addr, boolean_t have_addr, db_expr_t count,
- char *modif)
-{
- struct thread *td;
-
- td = (have_addr) ? kdb_thr_lookup(addr) : kdb_thread;
- if (td == NULL) {
- db_printf("Thread %d not found\n", (int)addr);
- return;
- }
- db_trace_thread(td, count);
-}
-
-void
db_trace_self(void)
{
db_expr_t addr;
OpenPOWER on IntegriCloud