Date: Sat, 8 May 2004 22:06:07 -0700 (PDT) From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 52522 for review Message-ID: <200405090506.i49567Up013285@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=52522 Change 52522 by marcel@marcel_nfs on 2004/05/08 22:05:40 Have the thread command parse its own arguments so that thread IDs can be parsed with radix 10. While here, add db_print_thread() to print the current thread. Affected files ... .. //depot/projects/gdb/sys/ddb/db_command.c#4 edit .. //depot/projects/gdb/sys/ddb/db_main.c#6 edit .. //depot/projects/gdb/sys/ddb/db_thread.c#3 edit .. //depot/projects/gdb/sys/ddb/ddb.h#6 edit Differences ... ==== //depot/projects/gdb/sys/ddb/db_command.c#4 (text+ko) ==== @@ -417,7 +417,7 @@ { "reset", db_reset, 0, 0 }, { "kill", db_kill, CS_OWN, 0 }, { "watchdog", db_watchdog, 0, 0 }, - { "thread", db_set_thread, 0, 0 }, + { "thread", db_set_thread, CS_OWN, 0 }, { (char *)0, } }; ==== //depot/projects/gdb/sys/ddb/db_main.c#6 (text+ko) ==== @@ -213,17 +213,18 @@ db_printf("After %d instructions (%d loads, %d stores),\n", db_inst_count, db_load_count, db_store_count); } - db_printf("[thread 0x%x]\n", kdb_thread->td_tid); - if (bkpt) - db_printf("Breakpoint at\t"); - else if (watchpt) - db_printf("Watchpoint at\t"); - else - db_printf("Stopped at\t"); - db_dot = PC_REGS(DDB_REGS); prev_jb = kdb_jmpbuf(jb); - if (setjmp(jb) == 0) + if (setjmp(jb) == 0) { + db_dot = PC_REGS(DDB_REGS); + db_print_thread(); + if (bkpt) + db_printf("Breakpoint at\t"); + else if (watchpt) + db_printf("Watchpoint at\t"); + else + db_printf("Stopped at\t"); db_print_loc_and_inst(db_dot); + } db_command_loop(); (void)kdb_jmpbuf(prev_jb); } ==== //depot/projects/gdb/sys/ddb/db_thread.c#3 (text+ko) ==== @@ -37,31 +37,48 @@ #include <ddb/db_sym.h> void +db_print_thread(void) +{ + db_printf("[thread %d]\n", kdb_thread->td_tid); +} + +void db_set_thread(db_expr_t tid, boolean_t hastid, db_expr_t cnt, char *mod) { struct thread *thr; + db_expr_t radix; int err; + /* + * We parse our own arguments. We don't like the default radix. + */ + radix = db_radix; + db_radix = 10; + hastid = db_expression(&tid); + db_radix = radix; + db_skip_to_eol(); + if (hastid) { thr = kdb_thr_lookup(tid); if (thr != NULL) { *kdb_frame = ddb_regs; - err= kdb_thr_select(thr); + err = kdb_thr_select(thr); if (err == 0) { - db_printf("switching to thread 0x%x\n", - thr->td_tid); ddb_regs = *kdb_frame; db_dot = PC_REGS(DDB_REGS); - db_print_loc_and_inst(db_dot); - } else - db_printf("unable to switch to thread 0x%x\n", - thr->td_tid); - } else - db_printf("0x%x: invalid thread\n", (int)tid); - } else { - db_printf("current thread is 0x%x\n", kdb_thread->td_tid); - db_print_loc_and_inst(PC_REGS(DDB_REGS)); + } else { + db_printf("unable to switch to thread %d\n", + (int)thr->td_tid); + return; + } + } else { + db_printf("%d: invalid thread\n", (int)tid); + return; + } } + + db_print_thread(); + db_print_loc_and_inst(PC_REGS(DDB_REGS)); } void @@ -75,7 +92,7 @@ pager_quit = 0; thr = kdb_thr_first(); while (!pager_quit && thr != NULL) { - db_printf(" 0x%x (%p) ", thr->td_tid, thr); + db_printf(" %6d (%p) ", (int)thr->td_tid, thr); db_printsym(PC_REGS(thr->td_last_frame), DB_STGY_PROC); db_printf("\n"); thr = kdb_thr_next(thr); ==== //depot/projects/gdb/sys/ddb/ddb.h#6 (text+ko) ==== @@ -93,6 +93,7 @@ boolean_t db_map_current(struct vm_map *); boolean_t db_map_equal(struct vm_map *, struct vm_map *); void db_print_loc_and_inst(db_addr_t loc); +void db_print_thread(void); void db_printf(const char *fmt, ...) __printflike(1, 2); void db_read_bytes(vm_offset_t addr, size_t size, char *data); /* machine-dependent */ @@ -106,9 +107,6 @@ #define db_strcpy strcpy int db_value_of_name(const char *name, db_expr_t *valuep); void db_write_bytes(vm_offset_t addr, size_t size, char *data); - /* machine-dependent */ -void db_stack_thread(db_expr_t addr, boolean_t have_addr, - db_expr_t count, char *modif); db_cmdfcn_t db_breakpoint_cmd; db_cmdfcn_t db_continue_cmd;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200405090506.i49567Up013285>