From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27186 invoked by alias); 14 Jan 2011 16:54:51 -0000 Received: (qmail 27175 invoked by uid 22791); 14 Jan 2011 16:54:50 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,MSGID_MULTIPLE_AT,TW_BJ X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.153) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 14 Jan 2011 16:54:45 +0000 Received: from md2.u-strasbg.fr (md2.u-strasbg.fr [IPv6:2001:660:2402::187]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id p0EGsKL9087846 ; Fri, 14 Jan 2011 17:54:20 +0100 (CET) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms2.u-strasbg.fr [130.79.204.11]) by md2.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id p0EGsKa9091721 ; Fri, 14 Jan 2011 17:54:20 +0100 (CET) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from E6510Muller (gw-ics.u-strasbg.fr [130.79.210.225]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.4/jtpda-5.5pre1) with ESMTP id p0EGsJWN046637 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO) ; Fri, 14 Jan 2011 17:54:20 +0100 (CET) (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: "'Joel Brobecker'" Cc: References: <000f01cbb401$1093cdc0$31bb6940$@muller@ics-cnrs.unistra.fr> <20110114163035.GQ2504@adacore.com> In-Reply-To: <20110114163035.GQ2504@adacore.com> Subject: [RFC-v2] Fix hpux_major_release variable setting Date: Fri, 14 Jan 2011 16:59:00 -0000 Message-ID: <000001cbb40b$b03b3020$10b19060$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-01/txt/msg00334.txt.bz2 Thanks for your comments, I hope the patch below addresses all comments/suggestions that you made. Concerning the description of the variable, I just removed 'in native conditions.' as you added 'On native systems, ' at the start of the sentence. 2011-01-14 Pierre Muller * solib-som.h (hpux_major_release): Declare variable here. * solib-som.c: Remove header. (DEFAULT_HPUX_MAJOR_RELEASE): New macro. (hpux_major_release): Make global, change default value to DEFAULT_HPUX_MAJOR_RELEASE. (get_hpux_major_release): Simply return HPUX_MAJOR_RELEASE. * hppa-hpux-nat.c: Add include. Add "solib-som.h" header. (set_hpux_major_release): New function. (_initialize_hppa_hpux_nat): Call set_hpux_major_release. Index: src/gdb/solib-som.h =================================================================== RCS file: /cvs/src/src/gdb/solib-som.h,v retrieving revision 1.9 diff -u -p -r1.9 solib-som.h --- src/gdb/solib-som.h 1 Jan 2011 15:33:15 -0000 1.9 +++ src/gdb/solib-som.h 14 Jan 2011 15:18:22 -0000 @@ -25,6 +25,8 @@ struct objfile; struct section_offsets; struct gdbarch; +extern int hpux_major_release; + void som_solib_select (struct gdbarch *gdbarch); int som_solib_section_offsets (struct objfile *objfile, Index: src/gdb/solib-som.c =================================================================== RCS file: /cvs/src/src/gdb/solib-som.c,v retrieving revision 1.34 diff -u -p -r1.34 solib-som.c --- src/gdb/solib-som.c 11 Jan 2011 21:53:24 -0000 1.34 +++ src/gdb/solib-som.c 14 Jan 2011 15:18:22 -0000 @@ -32,7 +32,6 @@ #include "solib.h" #include "solib-som.h" -#include #include #undef SOLIB_SOM_DBG @@ -131,24 +130,23 @@ som_relocate_section_addresses (struct s ; } -/* Get HP-UX major release number. Returns zero if the - release is not known. */ -static int -get_hpux_major_release (void) -{ - static int hpux_major_release = -1; +/* Variable storing HP-UX major release number. - if (hpux_major_release == -1) - { - struct utsname x; - char *p; + On non-native system, simply assume that the major release number + is 11. On native systems, hppa-hpux-nat.c initialization code + sets this number to the real one on startup. + + We cannot compute this value here, because we need to make a native + call to "uname". We are are not allowed to do that from here, as + this file is used for both native and cross debugging. */ - uname (&x); - p = strchr (x.release, '.'); - hpux_major_release = p ? atoi (p + 1) : 0; - } +#define DEFAULT_HPUX_MAJOR_RELEASE 11 +int hpux_major_release = DEFAULT_HPUX_MAJOR_RELEASE; +static int +get_hpux_major_release (void) +{ return hpux_major_release; } Index: src/gdb/hppa-hpux-nat.c =================================================================== RCS file: /cvs/src/src/gdb/hppa-hpux-nat.c,v retrieving revision 1.22 diff -u -p -r1.22 hppa-hpux-nat.c --- src/gdb/hppa-hpux-nat.c 14 Jan 2011 13:38:24 -0000 1.22 +++ src/gdb/hppa-hpux-nat.c 14 Jan 2011 15:18:22 -0000 @@ -25,6 +25,7 @@ #include "gdb_assert.h" #include +#include #include #ifdef HAVE_TTRACE @@ -32,6 +33,7 @@ #endif #include "hppa-tdep.h" +#include "solib-som.h" #include "inf-ptrace.h" #include "inf-ttrace.h" @@ -233,6 +235,21 @@ hppa_hpux_store_inferior_registers (stru hppa_hpux_store_register (regcache, regnum); } +/* Set hpux_major_release variable to the value retrieved from a call to + uname function. */ + +static void +set_hpux_major_release () +{ + struct utsname x; + char *p; + + uname (&x); + p = strchr (x.release, '.'); + if (p) + hpux_major_release = atoi (p + 1); +} + /* Prevent warning from -Wmissing-prototypes. */ @@ -243,6 +260,8 @@ _initialize_hppa_hpux_nat (void) { struct target_ops *t; + set_hpux_major_release (); + #ifdef HAVE_TTRACE t = inf_ttrace_target (); #else