From owner-p4-projects@FreeBSD.ORG Sat May 8 22:06:08 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3C24516A4D0; Sat, 8 May 2004 22:06:08 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F0ABE16A4CE for ; Sat, 8 May 2004 22:06:07 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9767743D39 for ; Sat, 8 May 2004 22:06:07 -0700 (PDT) (envelope-from marcel@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.10/8.12.10) with ESMTP id i49567Ge013288 for ; Sat, 8 May 2004 22:06:07 -0700 (PDT) (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i49567Up013285 for perforce@freebsd.org; Sat, 8 May 2004 22:06:07 -0700 (PDT) (envelope-from marcel@freebsd.org) Date: Sat, 8 May 2004 22:06:07 -0700 (PDT) Message-Id: <200405090506.i49567Up013285@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to marcel@freebsd.org using -f From: Marcel Moolenaar To: Perforce Change Reviews Subject: PERFORCE change 52522 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 May 2004 05:06:08 -0000 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 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;