/* 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.
#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 <dlfcn.h>
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)
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,
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)
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,
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;
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;
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. */
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;
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 */
{
}
-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. */