diff options
author | jhb <jhb@FreeBSD.org> | 2010-08-04 21:02:04 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2010-08-04 21:02:04 +0000 |
commit | 04e092db6fe555a049d0a5b202e74b095217db9d (patch) | |
tree | f2773e2ace26a5f21c54ec5bd7fcb4fca9199255 /gnu/usr.bin/gdb/kgdb | |
parent | 4a7e2ba2a30ec826f16a4395bee5153ef9cd05e5 (diff) | |
download | FreeBSD-src-04e092db6fe555a049d0a5b202e74b095217db9d.zip FreeBSD-src-04e092db6fe555a049d0a5b202e74b095217db9d.tar.gz |
Change kgdb_lookup() to resolve symbols via GDB instead of via libkvm(3).
Diffstat (limited to 'gnu/usr.bin/gdb/kgdb')
-rw-r--r-- | gnu/usr.bin/gdb/kgdb/kgdb.h | 2 | ||||
-rw-r--r-- | gnu/usr.bin/gdb/kgdb/kthr.c | 42 | ||||
-rw-r--r-- | gnu/usr.bin/gdb/kgdb/trgt_i386.c | 8 |
3 files changed, 23 insertions, 29 deletions
diff --git a/gnu/usr.bin/gdb/kgdb/kgdb.h b/gnu/usr.bin/gdb/kgdb/kgdb.h index b9a5df6..e828f56 100644 --- a/gnu/usr.bin/gdb/kgdb/kgdb.h +++ b/gnu/usr.bin/gdb/kgdb/kgdb.h @@ -67,7 +67,7 @@ struct kthr *kgdb_thr_next(struct kthr *); struct kthr *kgdb_thr_select(struct kthr *); char *kgdb_thr_extra_thread_info(int); -uintptr_t kgdb_lookup(const char *sym); +CORE_ADDR kgdb_lookup(const char *sym); CORE_ADDR kgdb_parse_1(const char *, int); #define kgdb_parse(exp) kgdb_parse_1((exp), 0) diff --git a/gnu/usr.bin/gdb/kgdb/kthr.c b/gnu/usr.bin/gdb/kgdb/kthr.c index 1ab66eb..5036c9c 100644 --- a/gnu/usr.bin/gdb/kgdb/kthr.c +++ b/gnu/usr.bin/gdb/kgdb/kthr.c @@ -44,26 +44,25 @@ __FBSDID("$FreeBSD$"); #include "kgdb.h" #include <machine/pcb.h> -static uintptr_t dumppcb; +static CORE_ADDR dumppcb; static int dumptid; -static uintptr_t stoppcbs; +static CORE_ADDR stoppcbs; static __cpumask_t stopped_cpus; static struct kthr *first; struct kthr *curkthr; -uintptr_t +CORE_ADDR kgdb_lookup(const char *sym) { - struct nlist nl[2]; - - nl[0].n_type = N_UNDF; - nl[0].n_name = (char *)(uintptr_t)sym; - nl[1].n_name = NULL; - if (kvm_nlist(kvm, nl) != 0) - return (0); - return (nl[0].n_value); + CORE_ADDR addr; + char *name; + + asprintf(&name, "&%s", sym); + addr = kgdb_parse(name); + free(name); + return (addr); } struct kthr * @@ -78,7 +77,8 @@ kgdb_thr_init(void) struct proc p; struct thread td; struct kthr *kt; - uintptr_t addr, paddr; + CORE_ADDR addr; + uintptr_t paddr; while (first != NULL) { kt = first; @@ -86,32 +86,28 @@ kgdb_thr_init(void) free(kt); } - addr = kgdb_lookup("_allproc"); - if (addr == 0) { - warnx("kvm_nlist(_allproc): %s", kvm_geterr(kvm)); + addr = kgdb_lookup("allproc"); + if (addr == 0) return (NULL); - } kvm_read(kvm, addr, &paddr, sizeof(paddr)); - dumppcb = kgdb_lookup("_dumppcb"); - if (dumppcb == 0) { - warnx("kvm_nlist(_dumppcb): %s", kvm_geterr(kvm)); + dumppcb = kgdb_lookup("dumppcb"); + if (dumppcb == 0) return (NULL); - } - addr = kgdb_lookup("_dumptid"); + addr = kgdb_lookup("dumptid"); if (addr != 0) kvm_read(kvm, addr, &dumptid, sizeof(dumptid)); else dumptid = -1; - addr = kgdb_lookup("_stopped_cpus"); + addr = kgdb_lookup("stopped_cpus"); if (addr != 0) kvm_read(kvm, addr, &stopped_cpus, sizeof(stopped_cpus)); else stopped_cpus = 0; - stoppcbs = kgdb_lookup("_stoppcbs"); + stoppcbs = kgdb_lookup("stoppcbs"); while (paddr != 0) { if (kvm_read(kvm, paddr, &p, sizeof(p)) != sizeof(p)) { diff --git a/gnu/usr.bin/gdb/kgdb/trgt_i386.c b/gnu/usr.bin/gdb/kgdb/trgt_i386.c index 4a66906..aba8b65 100644 --- a/gnu/usr.bin/gdb/kgdb/trgt_i386.c +++ b/gnu/usr.bin/gdb/kgdb/trgt_i386.c @@ -136,7 +136,7 @@ kgdb_trgt_fetch_tss(void) if (kt == NULL || kt->cpu == NOCPU) return (0); - addr = kgdb_lookup("_gdt"); + addr = kgdb_lookup("gdt"); if (addr == 0) return (0); addr += (kt->cpu * NGDT + GPROC0_SEL) * sizeof(sd); @@ -159,11 +159,9 @@ kgdb_trgt_fetch_tss(void) * change it to be relative to cpu0prvpage instead. */ if (trunc_page(tss) == 0xffc00000) { - addr = kgdb_lookup("_cpu0prvpage"); - if (addr == 0) { - warnx("kvm_nlist(_cpu0prvpage): %s", kvm_geterr(kvm)); + addr = kgdb_lookup("cpu0prvpage"); + if (addr == 0) return (0); - } if (kvm_read(kvm, addr, &cpu0prvpage, sizeof(cpu0prvpage)) != sizeof(cpu0prvpage)) { warnx("kvm_read: %s", kvm_geterr(kvm)); |