Page MenuHomeFreeBSD

D7646.id19695.diff
No OneTemporary

D7646.id19695.diff

Index: sys/ddb/db_command.c
===================================================================
--- sys/ddb/db_command.c
+++ sys/ddb/db_command.c
@@ -72,6 +72,7 @@
static db_cmdfcn_t db_kill;
static db_cmdfcn_t db_reset;
static db_cmdfcn_t db_stack_trace;
+static db_cmdfcn_t db_stack_trace_active;
static db_cmdfcn_t db_stack_trace_all;
static db_cmdfcn_t db_watchdog;
@@ -79,6 +80,12 @@
* 'show' commands
*/
+static struct command db_show_active_cmds[] = {
+ { "trace", db_stack_trace_active, 0, NULL },
+};
+struct command_table db_show_active_table =
+ LIST_HEAD_INITIALIZER(db_show_active_table);
+
static struct command db_show_all_cmds[] = {
{ "trace", db_stack_trace_all, 0, NULL },
};
@@ -86,6 +93,7 @@
LIST_HEAD_INITIALIZER(db_show_all_table);
static struct command db_show_cmds[] = {
+ { "active", 0, 0, &db_show_active_table },
{ "all", 0, 0, &db_show_all_table },
{ "registers", db_show_regs, 0, NULL },
{ "breaks", db_listbreak_cmd, 0, NULL },
@@ -120,6 +128,8 @@
{ "match", db_trace_until_matching_cmd,0, NULL },
{ "trace", db_stack_trace, CS_OWN, NULL },
{ "t", db_stack_trace, CS_OWN, NULL },
+ /* XXX alias for active trace */
+ { "acttrace", db_stack_trace_active, 0, NULL },
/* XXX alias for all trace */
{ "alltrace", db_stack_trace_all, 0, NULL },
{ "where", db_stack_trace, CS_OWN, NULL },
@@ -195,6 +205,9 @@
db_command_register(&db_cmd_table, &db_cmds[i]);
for (i = 0; i < N(db_show_cmds); i++)
db_command_register(&db_show_table, &db_show_cmds[i]);
+ for (i = 0; i < N(db_show_active_cmds); i++)
+ db_command_register(&db_show_active_table,
+ &db_show_active_cmds[i]);
for (i = 0; i < N(db_show_all_cmds); i++)
db_command_register(&db_show_all_table, &db_show_all_cmds[i]);
#undef N
@@ -799,8 +812,7 @@
}
static void
-db_stack_trace_all(db_expr_t dummy, bool dummy2, db_expr_t dummy3,
- char *dummy4)
+_db_stack_trace_all(bool active_only)
{
struct proc *p;
struct thread *td;
@@ -811,8 +823,18 @@
prev_jb = kdb_jmpbuf(jb);
if (setjmp(jb) == 0) {
FOREACH_THREAD_IN_PROC(p, td) {
- db_printf("\nTracing command %s pid %d tid %ld td %p\n",
- p->p_comm, p->p_pid, (long)td->td_tid, td);
+ if (active_only) {
+ if (td->td_state != TDS_RUNNING)
+ continue;
+ db_printf("\nTracing command %s pid %d"
+ " tid %ld td %p (CPU %d)\n",
+ p->p_comm, p->p_pid,
+ (long)td->td_tid, td,
+ td->td_oncpu);
+ } else
+ db_printf("\nTracing command %s pid %d"
+ " tid %ld td %p\n", p->p_comm,
+ p->p_pid, (long)td->td_tid, td);
db_trace_thread(td, -1);
if (db_pager_quit) {
kdb_jmpbuf(prev_jb);
@@ -824,6 +846,22 @@
}
}
+static void
+db_stack_trace_active(db_expr_t dummy, bool dummy2, db_expr_t dummy3,
+ char *dummy4)
+{
+
+ _db_stack_trace_all(true);
+}
+
+static void
+db_stack_trace_all(db_expr_t dummy, bool dummy2, db_expr_t dummy3,
+ char *dummy4)
+{
+
+ _db_stack_trace_all(false);
+}
+
/*
* Take the parsed expression value from the command line that was parsed
* as a hexadecimal value and convert it as if the expression was parsed

File Metadata

Mime Type
text/plain
Expires
Thu, Oct 23, 11:52 PM (20 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
24108352
Default Alt Text
D7646.id19695.diff (3 KB)

Event Timeline