/* Handle TIC6X (DSBT) shared libraries for GDB, the GNU Debugger.
- Copyright (C) 2010-2017 Free Software Foundation, Inc.
+ Copyright (C) 2010-2019 Free Software Foundation, Inc.
This file is part of GDB.
/* Decode int_elf32_dsbt_loadmap from BUF. */
static struct int_elf32_dsbt_loadmap *
-decode_loadmap (gdb_byte *buf)
+decode_loadmap (const gdb_byte *buf)
{
enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
- struct ext_elf32_dsbt_loadmap *ext_ldmbuf;
+ const struct ext_elf32_dsbt_loadmap *ext_ldmbuf;
struct int_elf32_dsbt_loadmap *int_ldmbuf;
int version, seg, nsegs;
byte_order);
}
- xfree (ext_ldmbuf);
return int_ldmbuf;
}
static void
dsbt_get_initial_loadmaps (void)
{
- gdb_byte *buf;
struct dsbt_info *info = get_dsbt_info ();
+ gdb::optional<gdb::byte_vector> buf
+ = target_read_alloc (current_top_target (), TARGET_OBJECT_FDPIC, "exec");
- if (0 >= target_read_alloc (¤t_target, TARGET_OBJECT_FDPIC,
- "exec", &buf))
+ if (!buf || buf->empty ())
{
info->exec_loadmap = NULL;
error (_("Error reading DSBT exec loadmap"));
}
- info->exec_loadmap = decode_loadmap (buf);
+ info->exec_loadmap = decode_loadmap (buf->data ());
if (solib_dsbt_debug)
dsbt_print_loadmap (info->exec_loadmap);
- if (0 >= target_read_alloc (¤t_target, TARGET_OBJECT_FDPIC,
- "interp", &buf))
+ buf = target_read_alloc (current_top_target (), TARGET_OBJECT_FDPIC, "exec");
+ if (!buf || buf->empty ())
{
info->interp_loadmap = NULL;
error (_("Error reading DSBT interp loadmap"));
}
- info->interp_loadmap = decode_loadmap (buf);
+ info->interp_loadmap = decode_loadmap (buf->data ());
if (solib_dsbt_debug)
dsbt_print_loadmap (info->interp_loadmap);
}
return 0;
}
-/* If no open symbol file, attempt to locate and open the main symbol
- file.
-
- If FROM_TTYP dereferences to a non-zero integer, allow messages to
- be printed. This parameter is a pointer rather than an int because
- open_symbol_file_object is called via catch_errors and
- catch_errors requires a pointer argument. */
+/* See solist.h. */
static int
-open_symbol_file_object (void *from_ttyp)
+open_symbol_file_object (int from_tty)
{
/* Unimplemented. */
return 0;
/* Locate the address of the first link map struct. */
lm_addr = lm_base ();
- /* We have at least one link map entry. Fetch the the lot of them,
+ /* We have at least one link map entry. Fetch the lot of them,
building the solist chain. */
while (lm_addr)
{
if (dsbt_index != 0)
{
int errcode;
- char *name_buf;
+ gdb::unique_xmalloc_ptr<char> name_buf;
struct int_elf32_dsbt_loadmap *loadmap;
struct so_list *sop;
CORE_ADDR addr;
{
if (solib_dsbt_debug)
fprintf_unfiltered (gdb_stdlog, "current_sos: name = %s\n",
- name_buf);
+ name_buf.get ());
- strncpy (sop->so_name, name_buf, SO_NAME_MAX_PATH_SIZE - 1);
+ strncpy (sop->so_name, name_buf.get (), SO_NAME_MAX_PATH_SIZE - 1);
sop->so_name[SO_NAME_MAX_PATH_SIZE - 1] = '\0';
- xfree (name_buf);
strcpy (sop->so_original_name, sop->so_name);
}
in the dynamic linker itself. */
gdb_bfd_ref_ptr tmp_bfd;
- TRY
+ try
{
tmp_bfd = solib_bfd_open (buf);
}
- CATCH (ex, RETURN_MASK_ALL)
+ catch (const gdb_exception &ex)
{
}
- END_CATCH
if (tmp_bfd == NULL)
{
dsbt_relocate_main_executable (void)
{
struct int_elf32_dsbt_loadmap *ldm;
- struct cleanup *old_chain;
- struct section_offsets *new_offsets;
int changed;
struct obj_section *osect;
struct dsbt_info *info = get_dsbt_info ();
info->main_executable_lm_info = new lm_info_dsbt;
info->main_executable_lm_info->map = ldm;
- new_offsets = XCNEWVEC (struct section_offsets,
- symfile_objfile->num_sections);
- old_chain = make_cleanup (xfree, new_offsets);
+ gdb::unique_xmalloc_ptr<struct section_offsets> new_offsets
+ (XCNEWVEC (struct section_offsets, symfile_objfile->num_sections));
changed = 0;
ALL_OBJFILE_OSECTIONS (symfile_objfile, osect)
}
if (changed)
- objfile_relocate (symfile_objfile, new_offsets);
-
- do_cleanups (old_chain);
+ objfile_relocate (symfile_objfile, new_offsets.get ());
/* Now that symfile_objfile has been relocated, we can compute the
GOT value and stash it away. */
struct target_so_ops dsbt_so_ops;
-/* Provide a prototype to silence -Wmissing-prototypes. */
-extern initialize_file_ftype _initialize_dsbt_solib;
-
void
_initialize_dsbt_solib (void)
{