/* Handle SVR4 shared libraries for GDB, the GNU Debugger.
- Copyright (C) 1990-1996, 1998-2001, 2003-2012 Free Software
- Foundation, Inc.
+ Copyright (C) 1990-2013 Free Software Foundation, Inc.
This file is part of GDB.
if (target_read_memory (lm_addr, lm, lmo->link_map_size) != 0)
{
warning (_("Error reading shared library list entry at %s"),
- paddress (target_gdbarch, lm_addr)),
+ paddress (target_gdbarch (), lm_addr)),
lm_info = NULL;
}
else
{
- struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+ struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
lm_info = xzalloc (sizeof (*lm_info));
lm_info->lm_addr = lm_addr;
if (info_verbose)
printf_unfiltered (_("Using PIC (Position Independent Code) "
"prelink displacement %s for \"%s\".\n"),
- paddress (target_gdbarch, l_addr),
+ paddress (target_gdbarch (), l_addr),
so->so_name);
}
else
static gdb_byte *
read_program_header (int type, int *p_sect_size, int *p_arch_size)
{
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
CORE_ADDR at_phdr, at_phent, at_phnum, pt_phdr = 0;
int arch_size, sect_size;
CORE_ADDR sect_addr;
gdb_byte ptr_buf[8];
CORE_ADDR ptr_addr;
- ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+ ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
ptr_addr = dyn_addr + (buf - bufstart) + arch_size / 8;
if (target_read_memory (ptr_addr, ptr_buf, arch_size / 8) == 0)
dyn_ptr = extract_typed_address (ptr_buf, ptr_type);
static int
scan_dyntag_auxv (int dyntag, CORE_ADDR *ptr)
{
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
int sect_size, arch_size, step;
long dyn_tag;
CORE_ADDR dyn_ptr;
if (scan_dyntag (DT_MIPS_RLD_MAP, exec_bfd, &dyn_ptr)
|| scan_dyntag_auxv (DT_MIPS_RLD_MAP, &dyn_ptr))
{
- struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+ struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
gdb_byte *pbuf;
int pbuf_size = TYPE_LENGTH (ptr_type);
solib_svr4_r_map (struct svr4_info *info)
{
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
- struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+ struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
CORE_ADDR addr = 0;
volatile struct gdb_exception ex;
solib_svr4_r_brk (struct svr4_info *info)
{
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
- struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+ struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
return read_memory_typed_address (info->debug_base + lmo->r_brk_offset,
ptr_type);
solib_svr4_r_ldsomap (struct svr4_info *info)
{
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
- struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+ struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
ULONGEST version;
/* Check version, and return zero if `struct r_debug' doesn't have
CORE_ADDR ldsomap;
struct so_list *new;
struct cleanup *old_chain;
- struct link_map_offsets *lmo;
CORE_ADDR name_lm;
info = get_svr4_info ();
if (!ldsomap)
return 0;
- lmo = svr4_fetch_link_map_offsets ();
new = XZALLOC (struct so_list);
old_chain = make_cleanup (xfree, new);
new->lm_info = lm_info_read (ldsomap);
int errcode;
int from_tty = *(int *)from_ttyp;
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
- struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+ struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
int l_name_size = TYPE_LENGTH (ptr_type);
gdb_byte *l_name_buf = xmalloc (l_name_size);
struct cleanup *cleanups = make_cleanup (xfree, l_name_buf);
{
struct so_list *next = list->next;
- svr4_free_so (list);
+ free_so (list);
list = next;
}
}
for (; lm != 0; prev_lm = lm, lm = next_lm)
{
- struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
struct so_list *new;
struct cleanup *old_chain;
int errcode;
if (new->lm_info->l_prev != prev_lm)
{
warning (_("Corrupted shared library list: %s != %s"),
- paddress (target_gdbarch, prev_lm),
- paddress (target_gdbarch, new->lm_info->l_prev));
+ paddress (target_gdbarch (), prev_lm),
+ paddress (target_gdbarch (), new->lm_info->l_prev));
do_cleanups (old_chain);
break;
}
static CORE_ADDR
exec_entry_point (struct bfd *abfd, struct target_ops *targ)
{
+ CORE_ADDR addr;
+
/* KevinB wrote ... for most targets, the address returned by
bfd_get_start_address() is the entry point for the start
function. But, for some targets, bfd_get_start_address() returns
gdbarch_convert_from_func_ptr_addr(). The method
gdbarch_convert_from_func_ptr_addr() is the merely the identify
function for targets which don't use function descriptors. */
- return gdbarch_convert_from_func_ptr_addr (target_gdbarch,
+ addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
bfd_get_start_address (abfd),
targ);
+ return gdbarch_addr_bits_remove (target_gdbarch (), addr);
}
/* Helper function for gdb_bfd_lookup_symbol. */
struct obj_section *os;
sym_addr = gdbarch_addr_bits_remove
- (target_gdbarch, gdbarch_convert_from_func_ptr_addr (target_gdbarch,
+ (target_gdbarch (), gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
sym_addr,
¤t_target));
tmp_bfd = os->objfile->obfd;
load_addr = ANOFFSET (os->objfile->section_offsets,
- os->objfile->sect_index_text);
+ SECT_OFF_TEXT (os->objfile));
interp_sect = bfd_get_section_by_name (tmp_bfd, ".text");
if (interp_sect)
+ bfd_section_size (tmp_bfd, interp_sect);
}
- create_solib_event_breakpoint (target_gdbarch, sym_addr);
+ create_solib_event_breakpoint (target_gdbarch (), sym_addr);
return 1;
}
}
if (!load_addr_found)
if (target_auxv_search (¤t_target, AT_BASE, &load_addr) > 0)
{
- int addr_bit = gdbarch_addr_bit (target_gdbarch);
+ int addr_bit = gdbarch_addr_bit (target_gdbarch ());
/* Ensure LOAD_ADDR has proper sign in its possible upper bits so
that `+ load_addr' will overflow CORE_ADDR width not creating
if (!load_addr_found)
{
struct regcache *regcache
- = get_thread_arch_regcache (inferior_ptid, target_gdbarch);
+ = get_thread_arch_regcache (inferior_ptid, target_gdbarch ());
load_addr = (regcache_read_pc (regcache)
- exec_entry_point (tmp_bfd, tmp_bfd_target));
/* Convert 'sym_addr' from a function pointer to an address.
Because we pass tmp_bfd_target instead of the current
target, this will always produce an unrelocated value. */
- sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch,
+ sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
sym_addr,
tmp_bfd_target);
if (sym_addr != 0)
{
- create_solib_event_breakpoint (target_gdbarch, load_addr + sym_addr);
+ create_solib_event_breakpoint (target_gdbarch (), load_addr + sym_addr);
xfree (interp_name);
return 1;
}
if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0))
{
sym_addr = SYMBOL_VALUE_ADDRESS (msymbol);
- sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch,
+ sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
sym_addr,
¤t_target);
- create_solib_event_breakpoint (target_gdbarch, sym_addr);
+ create_solib_event_breakpoint (target_gdbarch (), sym_addr);
return 1;
}
}
if ((msymbol != NULL) && (SYMBOL_VALUE_ADDRESS (msymbol) != 0))
{
sym_addr = SYMBOL_VALUE_ADDRESS (msymbol);
- sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch,
+ sym_addr = gdbarch_convert_from_func_ptr_addr (target_gdbarch (),
sym_addr,
¤t_target);
- create_solib_event_breakpoint (target_gdbarch, sym_addr);
+ create_solib_event_breakpoint (target_gdbarch (), sym_addr);
return 1;
}
}
buf2 = read_program_headers_from_bfd (exec_bfd, &phdrs2_size);
if (buf != NULL && buf2 != NULL)
{
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
/* We are dealing with three different addresses. EXEC_BFD
represents current address in on-disk file. target memory content
printf_unfiltered (_("Using PIE (Position Independent Executable) "
"displacement %s for \"%s\".\n"),
- paddress (target_gdbarch, displacement),
+ paddress (target_gdbarch (), displacement),
bfd_get_filename (exec_bfd));
}
This function is responsible for discovering those names and
addresses, and saving sufficient information about them to allow
- their symbols to be read at a later time.
-
- FIXME
-
- Between enable_break() and disable_break(), this code does not
- properly handle hitting breakpoints which the user might have
- set in the startup code or in the dynamic linker itself. Proper
- handling will probably have to wait until the implementation is
- changed to use the "breakpoint handler function" method.
-
- Also, what if child has exit()ed? Must exit loop somehow. */
+ their symbols to be read at a later time. */
static void
svr4_solib_create_inferior_hook (int from_tty)
{
-#if defined(_SCO_DS)
- struct inferior *inf;
- struct thread_info *tp;
-#endif /* defined(_SCO_DS) */
struct svr4_info *info;
info = get_svr4_info ();
if (!enable_break (info, from_tty))
return;
-
-#if defined(_SCO_DS)
- /* SCO needs the loop below, other systems should be using the
- special shared library breakpoints and the shared library breakpoint
- service routine.
-
- Now run the target. It will eventually hit the breakpoint, at
- which point all of the libraries will have been mapped in and we
- can go groveling around in the dynamic linker structures to find
- out what we need to know about them. */
-
- inf = current_inferior ();
- tp = inferior_thread ();
-
- clear_proceed_status ();
- inf->control.stop_soon = STOP_QUIETLY;
- tp->suspend.stop_signal = GDB_SIGNAL_0;
- do
- {
- target_resume (pid_to_ptid (-1), 0, tp->suspend.stop_signal);
- wait_for_inferior ();
- }
- while (tp->suspend.stop_signal != GDB_SIGNAL_TRAP);
- inf->control.stop_soon = NO_STOP_QUIETLY;
-#endif /* defined(_SCO_DS) */
}
static void
static CORE_ADDR
svr4_truncate_ptr (CORE_ADDR addr)
{
- if (gdbarch_ptr_bit (target_gdbarch) == sizeof (CORE_ADDR) * 8)
+ if (gdbarch_ptr_bit (target_gdbarch ()) == sizeof (CORE_ADDR) * 8)
/* We don't need to truncate anything, and the bit twiddling below
will fail due to overflow problems. */
return addr;
else
- return addr & (((CORE_ADDR) 1 << gdbarch_ptr_bit (target_gdbarch)) - 1);
+ return addr & (((CORE_ADDR) 1 << gdbarch_ptr_bit (target_gdbarch ())) - 1);
}
static struct link_map_offsets *
svr4_fetch_link_map_offsets (void)
{
- struct solib_svr4_ops *ops = gdbarch_data (target_gdbarch, solib_svr4_data);
+ struct solib_svr4_ops *ops = gdbarch_data (target_gdbarch (), solib_svr4_data);
gdb_assert (ops->fetch_link_map_offsets);
return ops->fetch_link_map_offsets ();
static int
svr4_have_link_map_offsets (void)
{
- struct solib_svr4_ops *ops = gdbarch_data (target_gdbarch, solib_svr4_data);
+ struct solib_svr4_ops *ops = gdbarch_data (target_gdbarch (), solib_svr4_data);
return (ops->fetch_link_map_offsets != NULL);
}
{
solib_svr4_data = gdbarch_data_register_pre_init (solib_svr4_init);
solib_svr4_pspace_data
- = register_program_space_data_with_cleanup (svr4_pspace_data_cleanup);
+ = register_program_space_data_with_cleanup (NULL, svr4_pspace_data_cleanup);
svr4_so_ops.relocate_section_addresses = svr4_relocate_section_addresses;
svr4_so_ops.free_so = svr4_free_so;