This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Add NetBSD/sparc and OpenBSD/sparc libkvm support


Kernel memory image debugging for NetBSD/sparc and OpenBSD/sparc.

Committed,

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* sparcnbsd-nat.c: Include "gdbcore.h", "regcache.h",
	<sys/types.h>, <machine/pcb.h> and "bsd-kvm.h".
	(sparc32nbsd_supply_pcb): New function.
	(_initialize_sparcnbsd_nat): Enable libkvm interface.
	* Makefile.in (sparcnbsd-nat.o): Update dependencies.
	* config/sparc/nbsdelf.mh (NATDEPFILES): Add bsd-kvm.o.
	(LOADLIBES): New variable.

Index: sparcnbsd-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/sparcnbsd-nat.c,v
retrieving revision 1.4
diff -u -p -r1.4 sparcnbsd-nat.c
--- sparcnbsd-nat.c 3 Jan 2004 10:08:44 -0000 1.4
+++ sparcnbsd-nat.c 22 May 2004 22:33:15 -0000
@@ -20,10 +20,44 @@
    Boston, MA 02111-1307, USA.  */
 
 #include "defs.h"
+#include "gdbcore.h"
+#include "regcache.h"
 
 #include "sparc-tdep.h"
 #include "sparc-nat.h"
 
+/* Support for debugging kernel virtual memory images.  */
+
+#include <sys/types.h>
+#include <machine/pcb.h>
+
+#include "bsd-kvm.h"
+
+static int
+sparc32nbsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
+{
+  /* The following is true for NetBSD 1.6.2:
+
+     The pcb contains %sp, %sp, %psr and %wim.  From this information
+     we reconstruct the register state as it would look when we just
+     returned from cpu_switch().  */
+
+  /* The stack pointer shouldn't be zero.  */
+  if (pcb->pcb_sp == 0)
+    return 0;
+
+  regcache_raw_supply (regcache, SPARC_SP_REGNUM, &pcb->pcb_sp);
+  regcache_raw_supply (regcache, SPARC_O7_REGNUM, &pcb->pcb_pc);
+  regcache_raw_supply (regcache, SPARC32_PSR_REGNUM, &pcb->pcb_psr);
+  regcache_raw_supply (regcache, SPARC32_WIM_REGNUM, &pcb->pcb_wim);
+  regcache_raw_supply (regcache, SPARC32_PC_REGNUM, &pcb->pcb_pc);
+
+  sparc_supply_rwindow (regcache, pcb->pcb_sp, -1);
+
+  return 1;
+}
+
+
 /* Provide a prototype to silence -Wmissing-prototypes.  */
 void _initialize_sparcnbsd_nat (void);
 
@@ -31,4 +65,7 @@ void
 _initialize_sparcnbsd_nat (void)
 {
   sparc_gregset = &sparc32nbsd_gregset;
+
+  /* Support debugging kernel virtual memory images.  */
+  bsd_kvm_add_target (sparc32nbsd_supply_pcb);
 }
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.574
diff -u -p -r1.574 Makefile.in
--- Makefile.in 22 May 2004 17:21:35 -0000 1.574
+++ Makefile.in 22 May 2004 22:33:15 -0000
@@ -2394,7 +2394,8 @@ sparc-linux-tdep.o: sparc-linux-tdep.c $
 sparc-nat.o: sparc-nat.c $(defs_h) $(inferior_h) $(regcache_h) $(target_h) \
 	$(gdb_assert_h) $(gdb_string_h) $(gdb_wait_h) $(sparc_tdep_h) \
 	$(sparc_nat_h)
-sparcnbsd-nat.o: sparcnbsd-nat.c $(defs_h) $(sparc_tdep_h) $(sparc_nat_h)
+sparcnbsd-nat.o: sparcnbsd-nat.c $(defs_h) $(gdbcore_h) $(regcache_h) \
+	$(sparc_tdep_h) $(sparc_nat_h) $(bsd_kvm_h)
 sparcnbsd-tdep.o: sparcnbsd-tdep.c $(defs_h) $(floatformat_h) $(frame_h) \
 	$(frame_unwind_h) $(gdbcore_h) $(osabi_h) $(regcache_h) $(regset_h) \
 	$(solib_svr4_h) $(symtab_h) $(trad_frame_h) $(gdb_assert_h) \
Index: config/sparc/nbsdelf.mh
===================================================================
RCS file: /cvs/src/src/gdb/config/sparc/nbsdelf.mh,v
retrieving revision 1.11
diff -u -p -r1.11 nbsdelf.mh
--- config/sparc/nbsdelf.mh 3 Jan 2004 10:08:45 -0000 1.11
+++ config/sparc/nbsdelf.mh 22 May 2004 22:33:15 -0000
@@ -1,4 +1,6 @@
 # Host: NetBSD/sparc ELF
-NATDEPFILES= sparc-nat.o sparcnbsd-nat.o \
+NATDEPFILES= sparc-nat.o sparcnbsd-nat.o bsd-kvm.o \
 	fork-child.o infptrace.o inftarg.o
 NAT_FILE= nm-nbsd.h
+
+LOADLIBES= -lkvm


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]