Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 May 2004 22:25:21 -0700 (PDT)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 52498 for review
Message-ID:  <200405080525.i485PLZw067278@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <sys/proc.h>
 
 #include <ddb/ddb.h>
+#include <ddb/db_command.h>
+#include <ddb/db_sym.h>
 
 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);
 	}
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200405080525.i485PLZw067278>