solib_map_sections (struct so_list *so)
{
const struct target_so_ops *ops = solib_ops (target_gdbarch ());
- char *filename;
struct target_section *p;
- struct cleanup *old_chain;
- filename = tilde_expand (so->so_name);
- old_chain = make_cleanup (xfree, filename);
- gdb_bfd_ref_ptr abfd (ops->bfd_open (filename));
- do_cleanups (old_chain);
+ gdb::unique_xmalloc_ptr<char> filename (tilde_expand (so->so_name));
+ gdb_bfd_ref_ptr abfd (ops->bfd_open (filename.get ()));
if (abfd == NULL)
return 0;
have not opened a symbol file, we may be able to get its
symbols now! */
if (inf->attach_flag && symfile_objfile == NULL)
- catch_errors (ops->open_symbol_file_object, &from_tty,
- "Error reading attached process's symbol file.\n",
- RETURN_MASK_ALL);
+ {
+ TRY
+ {
+ ops->open_symbol_file_object (from_tty);
+ }
+ CATCH (ex, RETURN_MASK_ALL)
+ {
+ exception_fprintf (gdb_stderr, ex,
+ "Error reading attached "
+ "process's symbol file.\n");
+ }
+ END_CATCH
+ }
}
/* GDB and the inferior's dynamic linker each maintain their own
/* Unless the user loaded it explicitly, free SO's objfile. */
if (gdb->objfile && ! (gdb->objfile->flags & OBJF_USERLOADED)
&& !solib_used (gdb))
- free_objfile (gdb->objfile);
+ delete gdb->objfile;
/* Some targets' section tables might be referring to
sections from so->abfd; remove them. */
/* Check for any newly added shared libraries if we're supposed to
be adding them automatically. Switch terminal for any messages
produced by breakpoint_re_set. */
- target_terminal_ours_for_output ();
+ target_terminal::ours_for_output ();
solib_add (NULL, 0, auto_solib_add);
- target_terminal_inferior ();
+ target_terminal::inferior ();
}
/* Reload shared libraries, but avoid reloading the same symbol file
reload_shared_libraries_1 (int from_tty)
{
struct so_list *so;
- struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
if (print_symbol_loading_p (from_tty, 0, 0))
printf_unfiltered (_("Loading symbols for shared libraries.\n"));
for (so = so_list_head; so != NULL; so = so->next)
{
- char *filename, *found_pathname = NULL;
+ char *found_pathname = NULL;
int was_loaded = so->symbols_loaded;
symfile_add_flags add_flags = SYMFILE_DEFER_BP_RESET;
if (from_tty)
add_flags |= SYMFILE_VERBOSE;
- filename = tilde_expand (so->so_original_name);
- make_cleanup (xfree, filename);
- gdb_bfd_ref_ptr abfd (solib_bfd_open (filename));
+ gdb::unique_xmalloc_ptr<char> filename
+ (tilde_expand (so->so_original_name));
+ gdb_bfd_ref_ptr abfd (solib_bfd_open (filename.get ()));
if (abfd != NULL)
- {
- found_pathname = xstrdup (bfd_get_filename (abfd.get ()));
- make_cleanup (xfree, found_pathname);
- }
+ found_pathname = bfd_get_filename (abfd.get ());
/* If this shared library is no longer associated with its previous
symbol file, close that. */
{
if (so->objfile && ! (so->objfile->flags & OBJF_USERLOADED)
&& !solib_used (so))
- free_objfile (so->objfile);
+ delete so->objfile;
remove_target_sections (so);
clear_so (so);
}
solib_read_symbols (so, add_flags);
}
}
-
- do_cleanups (old_chain);
}
static void
}
}
-extern initialize_file_ftype _initialize_solib; /* -Wmissing-prototypes */
-
void
_initialize_solib (void)
{