/* Handle SVR4 shared libraries for GDB, the GNU Debugger.
- Copyright (C) 1990-2018 Free Software Foundation, Inc.
+ Copyright (C) 1990-2019 Free Software Foundation, Inc.
This file is part of GDB.
struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
CORE_ADDR addr = 0;
- TRY
+ try
{
addr = read_memory_typed_address (info->debug_base + lmo->r_map_offset,
ptr_type);
}
- CATCH (ex, RETURN_MASK_ERROR)
+ catch (const gdb_exception_error &ex)
{
exception_print (gdb_stderr, ex);
}
- END_CATCH
return addr;
}
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
ULONGEST version = 0;
- TRY
+ try
{
/* Check version, and return zero if `struct r_debug' doesn't have
the r_ldsomap member. */
= read_memory_unsigned_integer (info->debug_base + lmo->r_version_offset,
lmo->r_version_size, byte_order);
}
- CATCH (ex, RETURN_MASK_ERROR)
+ catch (const gdb_exception_error &ex)
{
exception_print (gdb_stderr, ex);
}
- END_CATCH
if (version < 2 || lmo->r_ldsomap_offset == -1)
return 0;
static int
svr4_parse_libraries (const char *document, struct svr4_library_list *list)
{
- struct cleanup *back_to = make_cleanup (svr4_free_library_list,
- &list->head);
+ auto cleanup = make_scope_exit ([&] ()
+ {
+ svr4_free_library_list (&list->head);
+ });
memset (list, 0, sizeof (*list));
list->tailp = &list->head;
svr4_library_list_elements, document, list) == 0)
{
/* Parsed successfully, keep the result. */
- discard_cleanups (back_to);
+ cleanup.release ();
return 1;
}
- do_cleanups (back_to);
return 0;
}
CORE_ADDR lm;
struct so_list *head = NULL;
struct so_list **link_ptr = &head;
- struct cleanup *back_to;
int ignore_first;
struct svr4_library_list library_list;
else
ignore_first = 1;
- back_to = make_cleanup (svr4_free_library_list, &head);
+ auto cleanup = make_scope_exit ([&] ()
+ {
+ svr4_free_library_list (&head);
+ });
/* Walk the inferior's link map list, and build our list of
`struct so_list' nodes. */
if (lm)
svr4_read_so_list (lm, 0, &link_ptr, 0);
- discard_cleanups (back_to);
+ cleanup.release ();
if (head == NULL)
return svr4_default_sos ();
if (objfile == symfile_objfile)
return info->main_lm_addr;
+ /* If OBJFILE is a separate debug object file, look for the
+ original object file. */
+ if (objfile->separate_debug_objfile_backlink != NULL)
+ objfile = objfile->separate_debug_objfile_backlink;
+
/* The other link map addresses may be found by examining the list
of shared libraries. */
for (so = master_so_list (); so; so = so->next)
arg0: Lmid_t lmid (mandatory)
arg1: struct r_debug *debug_base (mandatory)
arg2: struct link_map *new (optional, for incremental updates) */
- TRY
+ try
{
probe_argc = pa->prob->get_argument_count (frame);
}
- CATCH (ex, RETURN_MASK_ERROR)
+ catch (const gdb_exception_error &ex)
{
exception_print (gdb_stderr, ex);
probe_argc = 0;
}
- END_CATCH
/* If get_argument_count throws an exception, probe_argc will be set
to zero. However, if pa->prob does not have arguments, then
ones set up for the probes-based interface are adequate. */
static void
-disable_probes_interface_cleanup (void *arg)
+disable_probes_interface ()
{
struct svr4_info *info = get_svr4_info ();
struct svr4_info *info = get_svr4_info ();
struct probe_and_action *pa;
enum probe_action action;
- struct cleanup *old_chain;
struct value *val = NULL;
CORE_ADDR pc, debug_base, lm = 0;
struct frame_info *frame = get_current_frame ();
/* If anything goes wrong we revert to the original linker
interface. */
- old_chain = make_cleanup (disable_probes_interface_cleanup, NULL);
+ auto cleanup = make_scope_exit (disable_probes_interface);
pc = regcache_read_pc (get_current_regcache ());
pa = solib_event_probe_at (info, pc);
if (pa == NULL)
- {
- do_cleanups (old_chain);
- return;
- }
+ return;
action = solib_event_probe_action (pa);
if (action == PROBES_INTERFACE_FAILED)
- {
- do_cleanups (old_chain);
- return;
- }
+ return;
if (action == DO_NOTHING)
{
- discard_cleanups (old_chain);
+ cleanup.release ();
return;
}
scoped_restore inhibit_updates
= inhibit_section_map_updates (current_program_space);
- TRY
+ try
{
val = pa->prob->evaluate_argument (1, frame);
}
- CATCH (ex, RETURN_MASK_ERROR)
+ catch (const gdb_exception_error &ex)
{
exception_print (gdb_stderr, ex);
val = NULL;
}
- END_CATCH
if (val == NULL)
- {
- do_cleanups (old_chain);
- return;
- }
+ return;
debug_base = value_as_address (val);
if (debug_base == 0)
- {
- do_cleanups (old_chain);
- return;
- }
+ return;
/* Always locate the debug struct, in case it moved. */
info->debug_base = 0;
if (locate_base (info) == 0)
- {
- do_cleanups (old_chain);
- return;
- }
+ return;
/* GDB does not currently support libraries loaded via dlmopen
into namespaces other than the initial one. We must ignore
if (action == UPDATE_OR_RELOAD)
{
- TRY
+ try
{
val = pa->prob->evaluate_argument (2, frame);
}
- CATCH (ex, RETURN_MASK_ERROR)
+ catch (const gdb_exception_error &ex)
{
exception_print (gdb_stderr, ex);
- do_cleanups (old_chain);
return;
}
- END_CATCH
if (val != NULL)
lm = value_as_address (val);
if (action == FULL_RELOAD)
{
if (!solist_update_full (info))
- {
- do_cleanups (old_chain);
- return;
- }
+ return;
}
- discard_cleanups (old_chain);
+ cleanup.release ();
}
/* Helper function for svr4_update_solib_event_breakpoints. */
mechanism to find the dynamic linker's base address. */
gdb_bfd_ref_ptr tmp_bfd;
- TRY
+ try
{
tmp_bfd = solib_bfd_open (interp_name);
}
- CATCH (ex, RETURN_MASK_ALL)
+ catch (const gdb_exception &ex)
{
}
- END_CATCH
if (tmp_bfd == NULL)
goto bkpt_at_symbol;
}
if (abfd == NULL || scan_dyntag (DT_SYMBOLIC, abfd, NULL, NULL) != 1)
- return (struct block_symbol) {NULL, NULL};
+ return {};
return lookup_global_symbol_from_objfile (objfile, name, domain);
}