From owner-p4-projects@FreeBSD.ORG Fri May 7 22:25:22 2004 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 3A0B916A4D0; Fri, 7 May 2004 22:25:22 -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 12B4A16A4CF for ; Fri, 7 May 2004 22:25:22 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 789AA43D49 for ; Fri, 7 May 2004 22:25:21 -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 i485PLGe067286 for ; Fri, 7 May 2004 22:25:21 -0700 (PDT) (envelope-from marcel@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.10/8.12.10/Submit) id i485PLZw067278 for perforce@freebsd.org; Fri, 7 May 2004 22:25:21 -0700 (PDT) (envelope-from marcel@freebsd.org) Date: Fri, 7 May 2004 22:25:21 -0700 (PDT) Message-Id: <200405080525.i485PLZw067278@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 52498 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: Sat, 08 May 2004 05:25:22 -0000 http://perforce.freebsd.org/chv.cgi?CH=52498 Change 52498 by marcel@marcel_nfs on 2004/05/07 22:24:58 First rough implementation for thread support. The global ddb_regs is copied to the current KDB frame prior to switching the thread. When a new thread is selected, its trapframe is copied into ddb_regs. Consequently, the type of ddb_regs has to be struct trapframe. Except for powerpc, this already is the case. While here, remove db_trap.c. It's unused. Affected files ... .. //depot/projects/gdb/sys/ddb/db_main.c#5 edit .. //depot/projects/gdb/sys/ddb/db_thread.c#2 edit .. //depot/projects/gdb/sys/ddb/db_trap.c#2 delete Differences ... ==== //depot/projects/gdb/sys/ddb/db_main.c#5 (text+ko) ==== @@ -213,6 +213,7 @@ 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) ==== //depot/projects/gdb/sys/ddb/db_thread.c#2 (text+ko) ==== @@ -33,31 +33,51 @@ #include #include +#include +#include void -db_set_thread(db_expr_t addr, boolean_t hasaddr, db_expr_t cnt, char *mod) +db_set_thread(db_expr_t tid, boolean_t hastid, db_expr_t cnt, char *mod) { + struct thread *thr; + int err; - db_printf("Current thread is %d\n", kdb_thread->td_tid); + if (hastid) { + thr = kdb_thr_lookup(tid); + if (thr != NULL) { + *kdb_frame = ddb_regs; + 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)); + } } void db_show_threads(db_expr_t addr, boolean_t hasaddr, db_expr_t cnt, char *mod) { - struct proc *p; - struct thread *t; + struct thread *thr; int pager_quit; db_setup_paging(db_simple_pager, &pager_quit, DB_LINES_PER_PAGE); - p = LIST_FIRST(&allproc); pager_quit = 0; - while (!pager_quit && p != NULL) { - t = TAILQ_FIRST(&p->p_threads); - while (!pager_quit && t != NULL) { - db_printf(" %d (%p)\n", t->td_tid, t); - t = TAILQ_NEXT(t, td_plist); - } - p = LIST_NEXT(p, p_list); + thr = kdb_thr_first(); + while (!pager_quit && thr != NULL) { + db_printf(" 0x%x (%p) ", thr->td_tid, thr); + db_printsym(PC_REGS(thr->td_last_frame), DB_STGY_PROC); + db_printf("\n"); + thr = kdb_thr_next(thr); } }