Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 05 Oct 1996 13:30:58 +0800
From:      Peter Wemm <peter@spinner.dialix.com>
To:        smp@freebsd.org
Subject:   gdb -k patches for smp kernels
Message-ID:  <199610050530.NAA00477@spinner.DIALix.COM>

next in thread | raw e-mail | index | archive | help
In order to run "gdb -k /kernel /dev/mem" on a smp kernel, you need the
following [crude, ugly, bogus, etc] patches:

Index: freebsd-nat.c
===================================================================
RCS file: /home/ncvs/src/gnu/usr.bin/gdb/gdb/freebsd-nat.c,v
retrieving revision 1.10
diff -u -r1.10 freebsd-nat.c
--- freebsd-nat.c	1996/06/08 11:03:19	1.10
+++ freebsd-nat.c	1996/07/18 19:34:07
@@ -29,6 +29,8 @@
 #include <sys/ptrace.h>
 
 #include "defs.h"
+#include "symtab.h"
+#include "inferior.h"
 
 /* this table must line up with REGISTER_NAMES in tm-i386v.h */
 /* symbols like 'tEAX' come from <machine/reg.h> */
@@ -351,6 +383,7 @@
 	struct stat stb;
 	CORE_ADDR addr;
 	int cfd;
+	struct minimal_symbol *sym;
 
 	if ((cfd = open(cfile, perm, 0)) < 0)
 		return (cfd);
@@ -363,7 +396,12 @@
 
 	physrd(cfd, ksym_lookup("IdlePTD") - KERNOFF, (char*)&sbr, sizeof sbr);
 	printf("IdlePTD %x\n", sbr);
-	curpcb = ksym_lookup("curpcb") - KERNOFF;
+		 
+	sym = lookup_minimal_symbol("SMPcurpcb", (struct objfile *)NULL);
+	if (sym != NULL)
+		curpcb = ksym_lookup("SMPcurpcb") - KERNOFF;
+	else
+		curpcb = ksym_lookup("curpcb") - KERNOFF;
 	physrd(cfd, curpcb, (char*)&curpcb, sizeof curpcb);
 	kstack = ksym_lookup("kstack");
 
Index: kcorelow.c
===================================================================
RCS file: /home/ncvs/src/gnu/usr.bin/gdb/gdb/kcorelow.c,v
retrieving revision 1.4
diff -u -r1.4 kcorelow.c
--- kcorelow.c	1995/05/30 04:57:22	1.4
+++ kcorelow.c	1996/07/18 08:44:48
@@ -86,7 +86,14 @@
 curProc()
 {
 	struct proc *p;
-	CORE_ADDR addr = ksym_lookup("curproc");
+	CORE_ADDR addr;
+	struct minimal_symbol *sym;                           
+
+	sym = lookup_minimal_symbol("SMPcurproc", (struct objfile *)NULL);
+	if (sym != NULL)
+		addr = ksym_lookup("SMPcurproc");
+	else
+		addr = ksym_lookup("curproc");
 
 	if (kvread(addr, &p))
 		error("cannot read proc pointer at %x\n", addr);

 I've been using these hacks for a while, even though they're not exactly
 correct, but they work for simple stuff (eg: read/modify data).  They
 adapt to the style of kernel, so these patches will work on both kernels
 if you are flipping back and forward from smp kernels like I am.

 -Peter




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199610050530.NAA00477>