Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] struct lwp in bsd-kvm.c
@ 2004-08-06 20:42 Nathan J. Williams
  2004-08-06 21:07 ` Mark Kettenis
  0 siblings, 1 reply; 5+ messages in thread
From: Nathan J. Williams @ 2004-08-06 20:42 UTC (permalink / raw)
  To: gdb-patches


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));


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-08-08 19:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-06 20:42 [RFA] struct lwp in bsd-kvm.c Nathan J. Williams
2004-08-06 21:07 ` Mark Kettenis
2004-08-08 16:58   ` Jason Thorpe
2004-08-08 18:11     ` Daniel Jacobowitz
2004-08-08 19:41     ` Andrew Cagney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox