From owner-freebsd-smp Fri Oct 4 22:31:13 1996 Return-Path: owner-smp Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id WAA26638 for smp-outgoing; Fri, 4 Oct 1996 22:31:13 -0700 (PDT) Received: from spinner.DIALix.COM (root@spinner.DIALix.COM [192.203.228.67]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id WAA26625 for ; Fri, 4 Oct 1996 22:31:04 -0700 (PDT) Received: from spinner.DIALix.COM (peter@localhost.DIALix.oz.au [127.0.0.1]) by spinner.DIALix.COM (8.8.0/8.8.0) with ESMTP id NAA00477 for ; Sat, 5 Oct 1996 13:30:59 +0800 (WST) Message-Id: <199610050530.NAA00477@spinner.DIALix.COM> To: smp@freebsd.org Subject: gdb -k patches for smp kernels Date: Sat, 05 Oct 1996 13:30:58 +0800 From: Peter Wemm Sender: owner-smp@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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 #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 */ @@ -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