Change kgdb_lookup() to resolve symbols via GDB instead of via libkvm(3).

This commit is contained in:
John Baldwin 2010-08-04 21:02:04 +00:00
parent 64dc04de68
commit 68819dae55
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=210852
3 changed files with 22 additions and 28 deletions

View File

@ -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)

View File

@ -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];
CORE_ADDR addr;
char *name;
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);
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)) {

View File

@ -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));