Changeset View
Changeset View
Standalone View
Standalone View
sys/ddb/db_command.c
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | |||||
static db_cmdfcn_t db_dump; | static db_cmdfcn_t db_dump; | ||||
static db_cmdfcn_t db_fncall; | static db_cmdfcn_t db_fncall; | ||||
static db_cmdfcn_t db_gdb; | static db_cmdfcn_t db_gdb; | ||||
static db_cmdfcn_t db_halt; | static db_cmdfcn_t db_halt; | ||||
static db_cmdfcn_t db_kill; | static db_cmdfcn_t db_kill; | ||||
static db_cmdfcn_t db_reset; | static db_cmdfcn_t db_reset; | ||||
static db_cmdfcn_t db_stack_trace; | 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_stack_trace_all; | ||||
static db_cmdfcn_t db_watchdog; | static db_cmdfcn_t db_watchdog; | ||||
/* | /* | ||||
* 'show' commands | * '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[] = { | static struct command db_show_all_cmds[] = { | ||||
{ "trace", db_stack_trace_all, 0, NULL }, | { "trace", db_stack_trace_all, 0, NULL }, | ||||
}; | }; | ||||
struct command_table db_show_all_table = | struct command_table db_show_all_table = | ||||
LIST_HEAD_INITIALIZER(db_show_all_table); | LIST_HEAD_INITIALIZER(db_show_all_table); | ||||
static struct command db_show_cmds[] = { | static struct command db_show_cmds[] = { | ||||
{ "active", 0, 0, &db_show_active_table }, | |||||
{ "all", 0, 0, &db_show_all_table }, | { "all", 0, 0, &db_show_all_table }, | ||||
{ "registers", db_show_regs, 0, NULL }, | { "registers", db_show_regs, 0, NULL }, | ||||
{ "breaks", db_listbreak_cmd, 0, NULL }, | { "breaks", db_listbreak_cmd, 0, NULL }, | ||||
{ "threads", db_show_threads, 0, NULL }, | { "threads", db_show_threads, 0, NULL }, | ||||
}; | }; | ||||
struct command_table db_show_table = LIST_HEAD_INITIALIZER(db_show_table); | struct command_table db_show_table = LIST_HEAD_INITIALIZER(db_show_table); | ||||
static struct command db_cmds[] = { | static struct command db_cmds[] = { | ||||
Show All 18 Lines | static struct command db_cmds[] = { | ||||
{ "s", db_single_step_cmd, 0, NULL }, | { "s", db_single_step_cmd, 0, NULL }, | ||||
{ "continue", db_continue_cmd, 0, NULL }, | { "continue", db_continue_cmd, 0, NULL }, | ||||
{ "c", db_continue_cmd, 0, NULL }, | { "c", db_continue_cmd, 0, NULL }, | ||||
{ "until", db_trace_until_call_cmd,0, NULL }, | { "until", db_trace_until_call_cmd,0, NULL }, | ||||
{ "next", db_trace_until_matching_cmd,0, NULL }, | { "next", db_trace_until_matching_cmd,0, NULL }, | ||||
{ "match", db_trace_until_matching_cmd,0, NULL }, | { "match", db_trace_until_matching_cmd,0, NULL }, | ||||
{ "trace", db_stack_trace, CS_OWN, NULL }, | { "trace", db_stack_trace, CS_OWN, NULL }, | ||||
{ "t", 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 */ | /* XXX alias for all trace */ | ||||
{ "alltrace", db_stack_trace_all, 0, NULL }, | { "alltrace", db_stack_trace_all, 0, NULL }, | ||||
{ "where", db_stack_trace, CS_OWN, NULL }, | { "where", db_stack_trace, CS_OWN, NULL }, | ||||
{ "bt", db_stack_trace, CS_OWN, NULL }, | { "bt", db_stack_trace, CS_OWN, NULL }, | ||||
{ "call", db_fncall, CS_OWN, NULL }, | { "call", db_fncall, CS_OWN, NULL }, | ||||
{ "show", 0, 0, &db_show_table }, | { "show", 0, 0, &db_show_table }, | ||||
{ "ps", db_ps, 0, NULL }, | { "ps", db_ps, 0, NULL }, | ||||
{ "gdb", db_gdb, 0, NULL }, | { "gdb", db_gdb, 0, NULL }, | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
#define N(a) (sizeof(a) / sizeof(a[0])) | #define N(a) (sizeof(a) / sizeof(a[0])) | ||||
int i; | int i; | ||||
for (i = 0; i < N(db_cmds); i++) | for (i = 0; i < N(db_cmds); i++) | ||||
db_command_register(&db_cmd_table, &db_cmds[i]); | db_command_register(&db_cmd_table, &db_cmds[i]); | ||||
for (i = 0; i < N(db_show_cmds); i++) | for (i = 0; i < N(db_show_cmds); i++) | ||||
db_command_register(&db_show_table, &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++) | for (i = 0; i < N(db_show_all_cmds); i++) | ||||
db_command_register(&db_show_all_table, &db_show_all_cmds[i]); | db_command_register(&db_show_all_table, &db_show_all_cmds[i]); | ||||
#undef N | #undef N | ||||
} | } | ||||
/* | /* | ||||
* Register a command. | * Register a command. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 585 Lines • ▼ Show 20 Lines | db_stack_trace(db_expr_t tid, bool hastid, db_expr_t count, char *modif) | ||||
} else | } else | ||||
td = kdb_thread; | td = kdb_thread; | ||||
if (td->td_proc != NULL) | if (td->td_proc != NULL) | ||||
pid = td->td_proc->p_pid; | pid = td->td_proc->p_pid; | ||||
else | else | ||||
pid = -1; | pid = -1; | ||||
db_printf("Tracing pid %d tid %ld td %p\n", pid, (long)td->td_tid, td); | db_printf("Tracing pid %d tid %ld td %p\n", pid, (long)td->td_tid, td); | ||||
db_trace_thread(td, count); | db_trace_thread(td, count); | ||||
} | |||||
static void | |||||
db_stack_trace_active(db_expr_t dummy, bool dummy2, db_expr_t dummy3, | |||||
char *dummy4) | |||||
{ | |||||
struct proc *p; | |||||
struct thread *td; | |||||
jmp_buf jb; | |||||
void *prev_jb; | |||||
FOREACH_PROC_IN_SYSTEM(p) { | |||||
prev_jb = kdb_jmpbuf(jb); | |||||
if (setjmp(jb) == 0) { | |||||
FOREACH_THREAD_IN_PROC(p, td) { | |||||
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); | |||||
db_trace_thread(td, -1); | |||||
if (db_pager_quit) { | |||||
kdb_jmpbuf(prev_jb); | |||||
return; | |||||
} | |||||
} | |||||
} | |||||
kdb_jmpbuf(prev_jb); | |||||
} | |||||
} | } | ||||
static void | static void | ||||
db_stack_trace_all(db_expr_t dummy, bool dummy2, db_expr_t dummy3, | db_stack_trace_all(db_expr_t dummy, bool dummy2, db_expr_t dummy3, | ||||
char *dummy4) | char *dummy4) | ||||
{ | { | ||||
struct proc *p; | struct proc *p; | ||||
struct thread *td; | struct thread *td; | ||||
Show All 11 Lines | if (setjmp(jb) == 0) { | ||||
kdb_jmpbuf(prev_jb); | kdb_jmpbuf(prev_jb); | ||||
return; | return; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
kdb_jmpbuf(prev_jb); | kdb_jmpbuf(prev_jb); | ||||
} | } | ||||
} | } | ||||
mjg: I think it would be beneficial (apart from introduction the acctrace command) to extend the… | |||||
Not Done Inline ActionsThe active_only (acttrace) output does include td_oncpu. It's the other clause of the if :-). Or do you mean, I should add oncpu output to "all trace" as well? cem: The `active_only` (acttrace) output does include `td_oncpu`. It's the other clause of the `if`… | |||||
Not Done Inline ActionsThe latter. mjg: The latter. | |||||
Not Done Inline ActionsTo be more specific, either only print CPU if the thread is running OR print CPU unconditionally along with the state, so that one can tell if it is on cpu (as opposed to having a note what last cpu it was on). mjg: To be more specific, either only print CPU if the thread is running OR print CPU… | |||||
/* | /* | ||||
* Take the parsed expression value from the command line that was parsed | * 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 | * as a hexadecimal value and convert it as if the expression was parsed | ||||
* as a decimal value. Returns -1 if the expression was not a valid | * as a decimal value. Returns -1 if the expression was not a valid | ||||
* decimal value. | * decimal value. | ||||
*/ | */ | ||||
db_expr_t | db_expr_t | ||||
db_hex2dec(db_expr_t expr) | db_hex2dec(db_expr_t expr) | ||||
Show All 16 Lines |
I think it would be beneficial (apart from introduction the acctrace command) to extend the default output with cpu number, if given thread is running.
Other than that looks good to me, thanks.