]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
* solib-pa64.c (pa64_solib_create_inferior_hook): Don't set
authorDave Anglin <dave.anglin@nrc.ca>
Sat, 9 Aug 2008 18:21:59 +0000 (18:21 +0000)
committerDave Anglin <dave.anglin@nrc.ca>
Sat, 9 Aug 2008 18:21:59 +0000 (18:21 +0000)
DT_HP_DEBUG_PRIVATE.  Add warning if DT_HP_DEBUG_PRIVATE is not set.
Revise comment.
(pa64_current_sos): Remove map private warning warning.
* solib-som.c: Include string.h and sys/utsname.h.
(get_hpux_major_release): New function.
(som_solib_create_inferior_hook): Read dynamic linker header.  Warn
about shared library private mapping on HP-UX 11 and later.  Only force
private mapping of shared libraries on HP-UX 10 and earlier.
(link_map_start): Delete warning.

gdb/ChangeLog
gdb/solib-pa64.c
gdb/solib-som.c

index 7db01e5efff8bf1e1c9c5f6493896fc7bc7c002c..930a30cda69fe6c4933811ae17c6a1e4565d46cd 100644 (file)
@@ -1,3 +1,16 @@
+2008-08-09  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
+
+       * solib-pa64.c (pa64_solib_create_inferior_hook): Don't set
+       DT_HP_DEBUG_PRIVATE.  Add warning if DT_HP_DEBUG_PRIVATE is not set.
+       Revise comment.
+       (pa64_current_sos): Remove map private warning warning.
+       * solib-som.c: Include string.h and sys/utsname.h.
+       (get_hpux_major_release): New function.
+       (som_solib_create_inferior_hook): Read dynamic linker header.  Warn
+       about shared library private mapping on HP-UX 11 and later.  Only force
+       private mapping of shared libraries on HP-UX 10 and earlier.
+       (link_map_start): Delete warning.
+
 2008-08-09  Xuepeng Guo  <xuepeng.guo@intel.com>
            H.J. Lu  <hongjiu.lu@intel.com>
            Mark Kettenis <kettenis@gnu.org>
index af04b4de818c2b1b736e6f02a0d3e0d2bba14465..772b5dfc7b5ad4e109aa7b0a5caf551c27d487da 100644 (file)
@@ -322,13 +322,12 @@ bfd_lookup_symbol (bfd *abfd, char *symname)
    to tell the dynamic linker that a private copy of the library is
    needed (so GDB can set breakpoints in the library).
 
-   We need to set two flag bits in this routine.
-
-     DT_HP_DEBUG_PRIVATE to indicate that shared libraries should be
-     mapped private.
-
-     DT_HP_DEBUG_CALLBACK to indicate that we want the dynamic linker to
-     call the breakpoint routine for significant events.  */
+   We need to set DT_HP_DEBUG_CALLBACK to indicate that we want the
+   dynamic linker to call the breakpoint routine for significant events.
+   We used to set DT_HP_DEBUG_PRIVATE to indicate that shared libraries
+   should be mapped private.  However, this flag can be set using
+   "chatr +dbg enable".  Not setting DT_HP_DEBUG_PRIVATE allows debugging
+   with shared libraries mapped shareable.  */
 
 static void
 pa64_solib_create_inferior_hook (void)
@@ -360,8 +359,15 @@ pa64_solib_create_inferior_hook (void)
   if (! read_dynamic_info (shlib_info, &dld_cache))
     error (_("Unable to read the .dynamic section."));
 
+  /* If the libraries were not mapped private, warn the user.  */
+  if ((dld_cache.dld_flags & DT_HP_DEBUG_PRIVATE) == 0)
+    warning
+      (_("Private mapping of shared library text was not specified\n"
+        "by the executable; setting a breakpoint in a shared library which\n"
+        "is not privately mapped will not work.  See the HP-UX 11i v3 chatr\n"
+        "manpage for methods to privately map shared library text."));
+
   /* Turn on the flags we care about.  */
-  dld_cache.dld_flags |= DT_HP_DEBUG_PRIVATE;
   dld_cache.dld_flags |= DT_HP_DEBUG_CALLBACK;
   status = target_write_memory (dld_cache.dld_flags_addr,
                                (char *) &dld_cache.dld_flags,
@@ -454,12 +460,6 @@ pa64_current_sos (void)
     if (! read_dld_descriptor ())
       return NULL;
 
-  /* If the libraries were not mapped private, warn the user.  */
-  if ((dld_cache.dld_flags & DT_HP_DEBUG_PRIVATE) == 0)
-    warning (_("The shared libraries were not privately mapped; setting a\n"
-            "breakpoint in a shared library will not work until you rerun "
-            "the program.\n"));
-
   for (dll_index = -1; ; dll_index++)
     {
       struct load_module_desc dll_desc;
index 247ada36645ac601f50666f7c822b08917a8c05c..4d876ffd49aa1545f045e0f860baf938f2db346c 100644 (file)
@@ -30,6 +30,9 @@
 #include "solist.h"
 #include "solib.h"
 
+#include <sys/utsname.h>
+#include <string.h>
+
 #undef SOLIB_SOM_DBG 
 
 /* These ought to be defined in some public interface, but aren't.  They
@@ -125,6 +128,38 @@ som_relocate_section_addresses (struct so_list *so,
     ;
 }
 
+/* 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;
+
+  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;
+}
+
+/* DL header flag defines.  */
+#define SHLIB_TEXT_PRIVATE_ENABLE 0x4000
+
+/* The DL header is documented in <shl.h>.  We are only interested
+   in the flags field to determine whether the executable wants shared
+   libraries mapped private.  */
+struct {
+    short junk[37];
+    short flags;
+} dl_header;
+
 /* This hook gets called just before the first instruction in the
    inferior process is executed.
 
@@ -170,6 +205,10 @@ som_solib_create_inferior_hook (void)
   if (bfd_section_size (symfile_objfile->obfd, shlib_info) == 0)
     return;
 
+  /* Read the DL header.  */
+  bfd_get_section_contents (symfile_objfile->obfd, shlib_info,
+                           (char *) &dl_header, 0, sizeof (dl_header));
+
   have_endo = 0;
   /* Slam the pid of the process into __d_pid.
 
@@ -274,8 +313,22 @@ keep_going:
     error (_("Unable to read __dld_flags."));
   dld_flags = extract_unsigned_integer (buf, 4);
 
+  /* If the libraries were not mapped private on HP-UX 11 and later, warn
+     the user.  On HP-UX 10 and earlier, there is no easy way to specify
+     that shared libraries should be privately mapped.  So, we just force
+     private mapping.  */
+  if (get_hpux_major_release () >= 11
+      && (dl_header.flags & SHLIB_TEXT_PRIVATE_ENABLE) == 0
+      && (dld_flags & DLD_FLAGS_MAPPRIVATE) == 0)
+    warning
+      (_("Private mapping of shared library text was not specified\n"
+        "by the executable; setting a breakpoint in a shared library which\n"
+        "is not privately mapped will not work.  See the HP-UX 11i v3 chatr\n"
+        "manpage for methods to privately map shared library text."));
+
   /* Turn on the flags we care about.  */
-  dld_flags |= DLD_FLAGS_MAPPRIVATE;
+  if (get_hpux_major_release () < 11)
+    dld_flags |= DLD_FLAGS_MAPPRIVATE;
   if (have_endo)
     dld_flags |= DLD_FLAGS_HOOKVALID;
   store_unsigned_integer (buf, 4, dld_flags);
@@ -486,12 +539,6 @@ link_map_start (void)
   if ((dld_flags & DLD_FLAGS_LISTVALID) == 0)
     error (_("__dld_list is not valid according to __dld_flags."));
 
-  /* If the libraries were not mapped private, warn the user.  */
-  if ((dld_flags & DLD_FLAGS_MAPPRIVATE) == 0)
-    warning (_("The shared libraries were not privately mapped; setting a\n"
-            "breakpoint in a shared library will not work until you rerun the "
-            "program.\n"));
-
   sym = lookup_minimal_symbol ("__dld_list", NULL, NULL);
   if (!sym)
     {