Date: Sun, 13 Jun 2004 05:31:11 GMT From: Marcel Moolenaar <marcel@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 54788 for review Message-ID: <200406130531.i5D5VBN6027900@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=54788 Change 54788 by marcel@marcel_nfs on 2004/06/13 05:30:58 o In kdb_trap(), save the current context in kdb_pcb. o In kdb_thr_first() and kdb_thr_next(), remove checking td_last_frame and instead check PS_INMEM. o In kdb_thr_select(), switch kdb_thrctx to the PCB of the thread we're selecting, unless it's curthread. For curthread the context is in kdb_pcb. Affected files ... .. //depot/projects/gdb/sys/kern/subr_kdb.c#14 edit .. //depot/projects/gdb/sys/sys/kdb.h#11 edit Differences ... ==== //depot/projects/gdb/sys/kern/subr_kdb.c#14 (text+ko) ==== @@ -38,10 +38,13 @@ #include <sys/sysctl.h> #include <machine/kdb.h> +#include <machine/pcb.h> int kdb_active = 0; void *kdb_jmpbufp = NULL; struct kdb_dbbe *kdb_dbbe = NULL; +struct pcb kdb_pcb; +struct pcb *kdb_thrctx = NULL; struct thread *kdb_thread = NULL; struct trapframe *kdb_frame = NULL; @@ -282,11 +285,11 @@ p = LIST_FIRST(&allproc); while (p != NULL) { - thr = FIRST_THREAD_IN_PROC(p); - while (thr != NULL && thr->td_last_frame == NULL) - thr = TAILQ_NEXT(thr, td_plist); - if (thr != NULL) - return (thr); + if (p->p_sflag & PS_INMEM) { + thr = FIRST_THREAD_IN_PROC(p); + if (thr != NULL) + return (thr); + } p = LIST_NEXT(p, p_list); } return (NULL); @@ -311,12 +314,10 @@ p = thr->td_proc; thr = TAILQ_NEXT(thr, td_plist); do { - while (thr != NULL && thr->td_last_frame == NULL) - thr = TAILQ_NEXT(thr, td_plist); if (thr != NULL) return (thr); p = LIST_NEXT(p, p_list); - if (p != NULL) + if (p != NULL && (p->p_sflag & PS_INMEM)) thr = FIRST_THREAD_IN_PROC(p); } while (p != NULL); return (NULL); @@ -325,10 +326,10 @@ int kdb_thr_select(struct thread *thr) { - if (thr == NULL || thr->td_last_frame == NULL) + if (thr == NULL) return (EINVAL); kdb_thread = thr; - kdb_frame = kdb_thread->td_last_frame; + kdb_thrctx = (thr == curthread) ? &kdb_pcb : thr->td_pcb; return (0); } @@ -348,11 +349,13 @@ if (kdb_active) return (0); + savectx(&kdb_pcb); + critical_enter(); kdb_active++; - kdb_thread = curthread; kdb_frame = tf; + kdb_thr_select(curthread); #ifdef SMP stop_cpus(PCPU_GET(other_cpus)); ==== //depot/projects/gdb/sys/sys/kdb.h#11 (text+ko) ==== @@ -52,13 +52,15 @@ }; \ DATA_SET(kdb_dbbe_set, name##_dbbe) +struct pcb; struct thread; struct trapframe; extern int kdb_active; /* Non-zero while in debugger. */ extern struct kdb_dbbe *kdb_dbbe; /* Default debugger backend or NULL. */ +extern struct trapframe *kdb_frame; /* Frame to kdb_trap(). */ +extern struct pcb *kdb_thrctx; /* Current context. */ extern struct thread *kdb_thread; /* Current thread. */ -extern struct trapframe *kdb_frame; /* Current frame. */ int kdb_alt_break(int, int *); void kdb_backtrace(void);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200406130531.i5D5VBN6027900>