X-Git-Url: https://repo.jachan.dev/binutils.git/blobdiff_plain/a9762ec78a53fbe9209fe1654db42df0cd328d50..fb14de7bbddf9dc2f97af953b95b5aa5ea9889c4:/gdb/solib-pa64.c diff --git a/gdb/solib-pa64.c b/gdb/solib-pa64.c index 599f3f305f..70dc51af23 100644 --- a/gdb/solib-pa64.c +++ b/gdb/solib-pa64.c @@ -1,6 +1,6 @@ /* 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. @@ -36,15 +36,18 @@ #include "gdbcore.h" #include "target.h" #include "inferior.h" +#include "regcache.h" #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 @@ -123,8 +126,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) @@ -159,6 +162,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, @@ -317,13 +323,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) @@ -355,8 +360,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, @@ -410,7 +422,8 @@ pa64_solib_create_inferior_hook (void) Also note the breakpoint is the second instruction in the routine. */ - load_addr = read_pc () - tmp_bfd->start_address; + load_addr = regcache_read_pc (get_current_regcache ()) + - tmp_bfd->start_address; sym_addr = bfd_lookup_symbol (tmp_bfd, "__dld_break"); sym_addr = load_addr + sym_addr + 4; @@ -449,12 +462,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; @@ -524,7 +531,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. */ @@ -657,9 +664,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; @@ -667,7 +675,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 */ @@ -676,7 +684,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. */