From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14901 invoked by alias); 6 Aug 2004 20:42:45 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 14841 invoked from network); 6 Aug 2004 20:42:44 -0000 Received: from unknown (HELO biscayne-one-station.mit.edu) (18.7.7.80) by sourceware.org with SMTP; 6 Aug 2004 20:42:44 -0000 Received: from melbourne-city-street.mit.edu (MELBOURNE-CITY-STREET.MIT.EDU [18.7.21.86]) by biscayne-one-station.mit.edu (8.12.4/8.9.2) with ESMTP id i76KghRU004697 for ; Fri, 6 Aug 2004 16:42:43 -0400 (EDT) Received: from contents-vnder-pressvre.mit.edu (CONTENTS-VNDER-PRESSVRE.MIT.EDU [18.7.16.67]) (authenticated bits=56) (User authenticated as nathanw@ATHENA.MIT.EDU) by melbourne-city-street.mit.edu (8.12.4/8.12.4) with ESMTP id i76KggOn029521 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Fri, 6 Aug 2004 16:42:42 -0400 (EDT) Received: (from nathanw@localhost) by contents-vnder-pressvre.mit.edu (8.12.9) id i76Kgg8e014739; Fri, 6 Aug 2004 16:42:42 -0400 (EDT) To: gdb-patches@sources.redhat.com Subject: [RFA] struct lwp in bsd-kvm.c From: "Nathan J. Williams" Organization: Wasabi Systems, Inc. Date: Fri, 06 Aug 2004 20:42:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2004-08/txt/msg00174.txt.bz2 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 * configure.in: Test for struct lwp in * 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 defines `struct lwp`. +AC_CACHE_CHECK([for struct lwp], gdb_cv_struct_lwp, +[AC_TRY_COMPILE([#include +#include ], [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 degines `struct reg'. AC_CACHE_CHECK([for struct reg in machine/reg.h], gdb_cv_struct_reg, [AC_TRY_COMPILE([#include 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));