svn commit: r210852 - head/gnu/usr.bin/gdb/kgdb

John Baldwin jhb at FreeBSD.org
Wed Aug 4 21:02:05 UTC 2010


Author: jhb
Date: Wed Aug  4 21:02:04 2010
New Revision: 210852
URL: http://svn.freebsd.org/changeset/base/210852

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

Modified:
  head/gnu/usr.bin/gdb/kgdb/kgdb.h
  head/gnu/usr.bin/gdb/kgdb/kthr.c
  head/gnu/usr.bin/gdb/kgdb/trgt_i386.c

Modified: head/gnu/usr.bin/gdb/kgdb/kgdb.h
==============================================================================
--- head/gnu/usr.bin/gdb/kgdb/kgdb.h	Wed Aug  4 16:37:50 2010	(r210851)
+++ head/gnu/usr.bin/gdb/kgdb/kgdb.h	Wed Aug  4 21:02:04 2010	(r210852)
@@ -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)

Modified: head/gnu/usr.bin/gdb/kgdb/kthr.c
==============================================================================
--- head/gnu/usr.bin/gdb/kgdb/kthr.c	Wed Aug  4 16:37:50 2010	(r210851)
+++ head/gnu/usr.bin/gdb/kgdb/kthr.c	Wed Aug  4 21:02:04 2010	(r210852)
@@ -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)) {

Modified: head/gnu/usr.bin/gdb/kgdb/trgt_i386.c
==============================================================================
--- head/gnu/usr.bin/gdb/kgdb/trgt_i386.c	Wed Aug  4 16:37:50 2010	(r210851)
+++ head/gnu/usr.bin/gdb/kgdb/trgt_i386.c	Wed Aug  4 21:02:04 2010	(r210852)
@@ -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));


More information about the svn-src-head mailing list