gdb:
[deliverable/binutils-gdb.git] / gdb / solib-pa64.c
index bccb52d695a1a49ee5a8a96dda313f55c2975662..9cbf5a63539d06f8dd577e6c923665244cde8097 100644 (file)
@@ -1,12 +1,12 @@
 /* Handle PA64 shared libraries for GDB, the GNU Debugger.
 
-   Copyright (C) 2004, 2007 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -15,9 +15,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    HP in their infinite stupidity choose not to use standard ELF dynamic
    linker interfaces.  They also choose not to make their ELF dymamic
 
 #include "hppa-tdep.h"
 #include "solist.h"
+#include "solib.h"
 #include "solib-pa64.h"
 
 #undef SOLIB_PA64_DBG
 
-/* If we are building for a SOM-only target, then we don't need this.  */
-#ifndef PA_SOM_ONLY
+/* We can build this file only when running natively on 64-bit HP/UX.
+   We check for that by checking for the elf_hp.h header file.  */
+#if defined(HAVE_ELF_HP_H) && defined(__LP64__)
 
 /* FIXME: kettenis/20041213: These includes should be eliminated.  */
 #include <dlfcn.h>
@@ -125,8 +125,8 @@ pa64_target_read_memory (void *buffer, CORE_ADDR ptr, size_t bufsiz, int ident)
 
    This must happen after dld starts running, so we can't do it in
    read_dynamic_info.  Record the fact that we have loaded the
-   descriptor.  If the library is archive bound, then return zero, else
-   return nonzero.  */
+   descriptor.  If the library is archive bound or the load map
+   hasn't been setup, then return zero; else return nonzero.  */
 
 static int
 read_dld_descriptor (void)
@@ -161,6 +161,9 @@ read_dld_descriptor (void)
       error (_("Error while reading in load map pointer."));
     }
 
+  if (!dld_cache.load_map)
+    return 0;
+
   /* Read in the dld load module descriptor */
   if (dlgetmodinfo (-1, 
                    &dld_cache.dld_desc,
@@ -211,7 +214,7 @@ read_dynamic_info (asection *dyninfo_sect, dld_cache_t *dld_cache_p)
       CORE_ADDR        dyn_ptr;
       char *pbuf;
 
-      pbuf = alloca (TARGET_PTR_BIT / HOST_CHAR_BIT);
+      pbuf = alloca (gdbarch_ptr_bit (current_gdbarch) / HOST_CHAR_BIT);
       dyn_tag = bfd_h_get_64 (symfile_objfile->obfd, 
                              (bfd_byte*) &x_dynp->d_tag);
 
@@ -319,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)
@@ -357,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,
@@ -451,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;
@@ -526,7 +529,7 @@ pa64_open_symbol_file_object (void *from_ttyp)
   char *dll_path;
 
   if (symfile_objfile)
-    if (!query ("Attempt to reload symbols from process? "))
+    if (!query (_("Attempt to reload symbols from process? ")))
       return 0;
 
   /* Read in the load map pointer if we have not done so already.  */
@@ -659,9 +662,10 @@ _initialize_pa64_solib (void)
   memset (&dld_cache, 0, sizeof (dld_cache));
 }
 
-void pa64_solib_select (struct gdbarch_tdep *tdep)
+void pa64_solib_select (struct gdbarch *gdbarch)
 {
-  current_target_so_ops = &pa64_so_ops;
+  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+  set_solib_ops (gdbarch, &pa64_so_ops);
 
   tdep->solib_thread_start_addr = pa64_solib_thread_start_addr;
   tdep->solib_get_got_by_pc = pa64_solib_get_got_by_pc;
@@ -669,7 +673,7 @@ void pa64_solib_select (struct gdbarch_tdep *tdep)
   tdep->solib_get_text_base = pa64_solib_get_text_base;
 }
 
-#else /* PA_SOM_ONLY */
+#else /* HAVE_ELF_HP_H */
 
 extern initialize_file_ftype _initialize_pa64_solib; /* -Wmissing-prototypes */
 
@@ -678,7 +682,7 @@ _initialize_pa64_solib (void)
 {
 }
 
-void pa64_solib_select (struct gdbarch_tdep *tdep)
+void pa64_solib_select (struct gdbarch *gdbarch)
 {
   /* For a SOM-only target, there is no pa64 solib support.  This is needed
      for hppa-hpux-tdep.c to build.  */
This page took 0.058519 seconds and 4 git commands to generate.