Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Nathan J. Williams" <nathanw@wasabisystems.com>
To: gdb-patches@sources.redhat.com
Subject: [RFA] struct lwp in bsd-kvm.c
Date: Fri, 06 Aug 2004 20:42:00 -0000	[thread overview]
Message-ID: <mtu7jscath9.fsf@contents-vnder-pressvre.mit.edu> (raw)


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


             reply	other threads:[~2004-08-06 20:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-06 20:42 Nathan J. Williams [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mtu7jscath9.fsf@contents-vnder-pressvre.mit.edu \
    --to=nathanw@wasabisystems.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox