This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA] struct lwp in bsd-kvm.c
- From: "Nathan J. Williams" <nathanw at wasabisystems dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: 06 Aug 2004 16:42:42 -0400
- Subject: [RFA] struct lwp in bsd-kvm.c
- Organization: Wasabi Systems, Inc.
Modern NetBSD (-current and 2.0 and later) have a struct lwp that
holds execution state, including the pcb. This patch adds an autoconf
test to check for the presence of struct lwp, and changes the "kvm
proc" command to add the offset of l_addr in struct lwp to the address
supplied, if they are found. This makes the command name slightly
misleading, but it doesn't seem worth renaming.
This is necessary to even compile bsd-kvm.c on modern NetBSD systems,
as struct proc no longer has a p_addr field.
OK to commit?
(I'm not clear what the protocol is for dealing with regenerating
configure and config.in)
- Nathan
2004-08-06 Nathan J. Williams <nathanw@wasabisystems.com>
* configure.in: Test for struct lwp in <sys/lwp.h>
* bsd-kvm.c (bsd_kvm_proc_cmd): If HAVE_STRUCT_LWP is defined, use
the offset of l_addr in struct lwp.
Index: configure.in
===================================================================
RCS file: /cvs/src/src/gdb/configure.in,v
retrieving revision 1.160
diff -u -r1.160 configure.in
--- configure.in 30 Jul 2004 14:30:08 -0000 1.160
+++ configure.in 6 Aug 2004 20:34:30 -0000
@@ -553,6 +553,16 @@
[Define to 1 if your system has td_pcb in struct thread.])
fi
+# See if <sys/lwp.h> defines `struct lwp`.
+AC_CACHE_CHECK([for struct lwp], gdb_cv_struct_lwp,
+[AC_TRY_COMPILE([#include <sys/param.h>
+#include <sys/lwp.h>], [struct lwp l;],
+gdb_cv_struct_lwp=yes, gdb_cv_struct_lwp=no)])
+if test $gdb_cv_struct_lwp = yes; then
+ AC_DEFINE(HAVE_STRUCT_LWP, 1,
+ [Define to 1 if your system has struct lwp.])
+fi
+
# See if <machine/reg.h> degines `struct reg'.
AC_CACHE_CHECK([for struct reg in machine/reg.h], gdb_cv_struct_reg,
[AC_TRY_COMPILE([#include <sys/types.h>
Index: bsd-kvm.c
===================================================================
RCS file: /cvs/src/src/gdb/bsd-kvm.c,v
retrieving revision 1.4
diff -u -r1.4 bsd-kvm.c
--- bsd-kvm.c 3 Jul 2004 13:17:33 -0000 1.4
+++ bsd-kvm.c 6 Aug 2004 20:34:30 -0000
@@ -228,7 +229,11 @@
error ("No kernel memory image.");
addr = parse_and_eval_address (arg);
+#ifdef HAVE_STRUCT_LWP
+ addr += offsetof (struct lwp, l_addr);
+#else
addr += offsetof (struct proc, p_addr);
+#endif
if (kvm_read (core_kd, addr, &bsd_kvm_paddr, sizeof bsd_kvm_paddr) == -1)
error ("%s", kvm_geterr (core_kd));