Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
To: <gdb-patches@sourceware.org>
Subject: [RFC] Fix hpux_major_release variable setting
Date: Fri, 14 Jan 2011 16:09:00 -0000	[thread overview]
Message-ID: <000f01cbb401$1093cdc0$31bb6940$@muller@ics-cnrs.unistra.fr> (raw)

  As discussed a while ago,
there was an issue when trying to compile
GDB with --enable-targets=all
for mingw64.

  This was linked to the fact that sys/utsname.h
header doesn't exist for mingw64,
but solib-som.c code wrongly calls
uname even if it is not a native hpux system.

  The patch below fixes that problem
by moving the call to uname to hppa-hpux-nat.c

  Is this patch OK?

  I am unsure about the way to move it
to the header... Would it be better to
declare it without external in the header?
  This would then mean that I should also
move DEFAULT_HPUX_MAJOR_RELEASE macro to the header,
but it would have the advantage of allowing
to not use hard-coded 11 in _initialize_hppa_hpux_nat.
  
  Tested on x86_64 linux machine,
no regression found.


Pierre Muller
GDB pascal language maintainer

projecttype:gdb
revision:HEAD
email:muller@ics.u-strasbg.fr
 
2011-01-14  Pierre Muller  <muller@ics.u-strasbg.fr>

	* solib-som.h (hpux_major_release): Declare variable here.
	* solib-som.c:  Remove <sys/utsname.h> 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 <sys/utsname.h> include.
	Add "solib-som.h" header.
	(_initialize_hppa_hpux_nat): Set hpux_major_release variable by
	analyzis of uname call return.

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
@@ -26,13 +26,14 @@
 #include "gdbcore.h"
 #include "target.h"
 #include "inferior.h"
+#include "command.h"
+#include "gdbcmd.h"
 
 #include "hppa-tdep.h"
 #include "solist.h"
 #include "solib.h"
 #include "solib-som.h"
 
-#include <sys/utsname.h>
 #include <string.h>
 
 #undef SOLIB_SOM_DBG 
@@ -131,24 +132,18 @@ som_relocate_section_addresses (struct s
     ;
 }
 
-/* Get HP-UX major release number.  Returns zero if the
-   release is not known.  */
+/* Variable storing HP-UX major release number.
+   On non native system, simply suppose that the major release number is
11.
+   hppa-hpux-nat.c initialization code sets this number to
+   the real one on startup in native conditions.  */
+
+#define DEFAULT_HPUX_MAJOR_RELEASE 11
+int
+hpux_major_release = DEFAULT_HPUX_MAJOR_RELEASE;
 
 static int
 get_hpux_major_release (void)
 {
-  static int hpux_major_release = -1;
-
-  if (hpux_major_release == -1)
-    {
-      struct utsname x;
-      char *p;
-
-      uname (&x);
-      p = strchr (x.release, '.');
-      hpux_major_release = p ? atoi (p + 1) : 0;
-    }
-
   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 <sys/ptrace.h>
+#include <sys/utsname.h>
 #include <machine/save_state.h>
 
 #ifdef HAVE_TTRACE
@@ -32,6 +33,7 @@
 #endif
 
 #include "hppa-tdep.h"
+#include "solib-som.h"
 #include "inf-ptrace.h"
 #include "inf-ttrace.h"
 
@@ -242,7 +244,12 @@ void
 _initialize_hppa_hpux_nat (void)
 {
   struct target_ops *t;
+  struct utsname x;
+  char *p;
 
+  uname (&x);
+  p = strchr (x.release, '.');
+  hpux_major_release = p ? atoi (p + 1) : 11;
 #ifdef HAVE_TTRACE
   t = inf_ttrace_target ();
 #else


             reply	other threads:[~2011-01-14 15:38 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-14 16:09 Pierre Muller [this message]
2011-01-14 16:32 ` Joel Brobecker
2011-01-14 16:59   ` [RFC-v2] " Pierre Muller
2011-01-14 17:58     ` Joel Brobecker
2011-01-14 18:17     ` Pedro Alves
2011-01-14 18:52       ` Pierre Muller
2011-01-14 18:54         ` Michael Snyder
2011-01-14 19:22           ` Paul Koning
2011-01-14 19:52             ` Joel Brobecker
2011-01-14 21:49               ` [RFA] remove form feeds Michael Snyder
2011-01-14 21:51                 ` Tom Tromey
2011-01-14 21:54                   ` Doug Evans
2011-01-14 22:31                     ` Joel Brobecker
2011-01-14 23:55                       ` Michael Snyder
2011-01-15 11:42           ` [RFC-v2] Fix hpux_major_release variable setting Mark Kettenis

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='000f01cbb401$1093cdc0$31bb6940$@muller@ics-cnrs.unistra.fr' \
    --to=pierre.muller@ics-cnrs.unistra.fr \
    --cc=gdb-patches@sourceware.org \
    /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