[RFC] hpux code fix ( was [RFA 5/5] New patches to support --enable-targets=all for mingw64)

Pierre Muller pierre.muller@ics-cnrs.unistra.fr
Tue Sep 14 15:24:00 GMT 2010


  I finally wrote a patch that moves the
OS specific uname call to hppa-hpux-nat.c
and adds a new set/show command allowing to
override the default hpux_major_release version
(that I set to 11).

  The only trouble is that I have no way to 
test this patch for the native part...
The compilation with --enable-targets=all
works and the tdep parts seem to work as expected.

  Could someone test this out?

  Comments welcome,


Pierre Muller
Pascal language support maintainer for GDB

ChangeLog entry: 

2010-09-14  Pierre Muller  <muller@ics.u-strasbg.fr>

	* solib-som.h (hpux_major_release): Declare new external variable. 
	* hppa-hpux-nat.c: Add sys/utsname.h include.
	(_initialize_hppa_hpux_nat): Set default value of
	hpux_major_release to ouptut of uname call.
	* solib-som.c: Remove HPUX specific code.
	(DEFAULT_HPUX_MAJOR_RELEASE): New macro.
	(hpux_major_release): New global variable.
	(show_hpux_major_release): New function.
	(get_hpux_major_release): Simply return current HPUX_MAJOR_RELEASE.
	(_initialize_som_solib): Add new set/show commands hpux-major-release.


Index: solib-som.h
===================================================================
RCS file: /cvs/src/src/gdb/solib-som.h,v
retrieving revision 1.8
diff -u -p -r1.8 solib-som.h
--- solib-som.h	1 Jan 2010 07:31:41 -0000	1.8
+++ solib-som.h	14 Sep 2010 10:37:04 -0000
@@ -24,6 +24,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: hppa-hpux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-hpux-nat.c,v
retrieving revision 1.20
diff -u -p -r1.20 hppa-hpux-nat.c
--- hppa-hpux-nat.c	1 Jan 2010 07:31:33 -0000	1.20
+++ hppa-hpux-nat.c	14 Sep 2010 10:37:04 -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"
 
@@ -254,7 +256,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
Index: solib-som.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-som.c,v
retrieving revision 1.29
diff -u -p -r1.29 solib-som.c
--- solib-som.c	16 May 2010 23:49:58 -0000	1.29
+++ solib-som.c	14 Sep 2010 10:37:04 -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 
@@ -133,21 +134,22 @@ som_relocate_section_addresses (struct s
 /* Get HP-UX major release number.  Returns zero if the
    release is not known.  */
 
+#define DEFAULT_HPUX_MAJOR_RELEASE 11
+int
+hpux_major_release = DEFAULT_HPUX_MAJOR_RELEASE;
+
+static void
+show_hpux_major_release (struct ui_file *file, int from_tty,
+			  struct cmd_list_element *c, const char *value)
+{
+  fprintf_filtered (file, _("\
+Currently assumed major release version for HPUX is %d.\n"),
+		    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;
 }
 
@@ -810,6 +812,13 @@ _initialize_som_solib (void)
   som_so_ops.open_symbol_file_object = som_open_symbol_file_object;
   som_so_ops.in_dynsym_resolve_code = som_in_dynsym_resolve_code;
   som_so_ops.bfd_open = solib_bfd_open;
+  add_setshow_integer_cmd ("hpux-major-release", class_support,
+			   &hpux_major_release, _("\
+Set assumed HPUX major release version."), _("\
+Show assumed HPUX major release version."), NULL,
+			    NULL,
+			    show_hpux_major_release,
+			    &setlist, &showlist);
 }
 
 void



More information about the Gdb-patches mailing list