PERFORCE change 54708 for review
Marcel Moolenaar
marcel at FreeBSD.org
Sat Jun 12 07:39:57 GMT 2004
http://perforce.freebsd.org/chv.cgi?CH=54708
Change 54708 by marcel at marcel_nfs on 2004/06/12 07:39:36
Implement the kernel thread support functions. We now
have thread info in the debugger.
Affected files ...
.. //depot/projects/gdb/usr.bin/kgdb/kthr.c#3 edit
Differences ...
==== //depot/projects/gdb/usr.bin/kgdb/kthr.c#3 (text+ko) ====
@@ -31,40 +31,87 @@
#include <sys/proc.h>
#include <sys/types.h>
#include <sys/signal.h>
+#include <err.h>
#include <inttypes.h>
#include <kvm.h>
#include <stdio.h>
+#include <stdlib.h>
+
+#include <machine/frame.h>
#include "kgdb.h"
+static struct kthr *first;
struct kthr *curkthr;
struct kthr *
kgdb_thr_first(void)
{
- return (NULL);
+ return (first);
}
struct kthr *
kgdb_thr_init(void)
{
- return (NULL);
+ struct nlist nl[2];
+ struct proc p;
+ struct thread td;
+ struct kthr *thr;
+ uintptr_t paddr, tdaddr;
+
+ nl[0].n_name = (char *)(uintptr_t)"_allproc";
+ nl[1].n_name = NULL;
+ if (kvm_nlist(kvm, nl) != 0) {
+ warnx(kvm_geterr(kvm));
+ return (NULL);
+ }
+ kvm_read(kvm, nl[0].n_value, &paddr, sizeof(paddr));
+
+ while (paddr != 0) {
+ kvm_read(kvm, paddr, &p, sizeof(p));
+ tdaddr = (uintptr_t)TAILQ_FIRST(&p.p_threads);
+ while (tdaddr != 0) {
+ kvm_read(kvm, tdaddr, &td, sizeof(td));
+ if (td.td_last_frame != NULL) {
+ thr = malloc(sizeof(*thr));
+ thr->next = first;
+ thr->kaddr = tdaddr;
+ thr->td_frame = td.td_last_frame;
+ thr->td_kstack = td.td_kstack;
+ thr->td_tid = td.td_tid;
+ first = thr;
+ }
+ tdaddr = (uintptr_t)TAILQ_NEXT(&td, td_plist);
+ }
+ paddr = (uintptr_t)LIST_NEXT(&p, p_list);
+ }
+ curkthr = first;
+ return (first);
}
struct kthr *
-kgdb_thr_lookup(int tid __unused)
+kgdb_thr_lookup(int tid)
{
- return (NULL);
+ struct kthr *thr;
+
+ thr = first;
+ while (thr != NULL && thr->td_tid != tid)
+ thr = thr->next;
+ return (thr);
}
struct kthr *
-kgdb_thr_next(struct kthr *thr __unused)
+kgdb_thr_next(struct kthr *thr)
{
- return (NULL);
+ return (thr->next);
}
struct kthr *
-kgdb_thr_select(struct kthr *thr __unused)
+kgdb_thr_select(struct kthr *thr)
{
- return (NULL);
+ struct kthr *pcur;
+
+ pcur = curkthr;
+ curkthr = thr;
+ return (pcur);
}
More information about the p4-projects
mailing list