aboutsummaryrefslogtreecommitdiff
path: root/gdb/symfile.c
diff options
context:
space:
mode:
authorNicolas Blanc <nicolas.blanc@intel.com>2013-03-12 11:10:18 +0100
committerNicolas Blanc <nicolas.blanc@intel.com>2013-10-29 10:56:07 +0100
commit63644780babdca3f40e1978a236b6cd78473c91b (patch)
tree03ed0d042a594a71df9c9921b1c8f9c1018675f0 /gdb/symfile.c
parent487ad57ccfe1434e21774117d20dfd9e23f12afa (diff)
downloadgdb-63644780babdca3f40e1978a236b6cd78473c91b.zip
gdb-63644780babdca3f40e1978a236b6cd78473c91b.tar.gz
gdb-63644780babdca3f40e1978a236b6cd78473c91b.tar.bz2
New remove-symbol-file command.
New command for removing symbol files added via the add-symbol-file command. 2013-10-29 Nicolas Blanc <nicolas.blanc@intel.com> * breakpoint.c (disable_breakpoints_in_freed_objfile): New function. * objfiles.c (free_objfile): Notify free_objfile. (is_addr_in_objfile): New function. * objfiles.h (is_addr_in_objfile): New declaration. * printcmd.c (clear_dangling_display_expressions): Act upon free_objfile events instead of solib_unloaded events. (_initialize_printcmd): Register observer for free_objfile instead of solib_unloaded notifications. * solib.c (remove_user_added_objfile): New function. * symfile.c (remove_symbol_file_command): New command. (_initialize_symfile): Add remove-symbol-file. gdb/doc * observer.texi: New free_objfile event. Signed-off-by: Nicolas Blanc <nicolas.blanc@intel.com>
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r--gdb/symfile.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c
index d260ff9..0318466 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2342,6 +2342,82 @@ add_symbol_file_command (char *args, int from_tty)
}
+/* This function removes a symbol file that was added via add-symbol-file. */
+
+static void
+remove_symbol_file_command (char *args, int from_tty)
+{
+ char **argv;
+ struct objfile *objf = NULL;
+ struct cleanup *my_cleanups;
+ struct program_space *pspace = current_program_space;
+ struct gdbarch *gdbarch = get_current_arch ();
+
+ dont_repeat ();
+
+ if (args == NULL)
+ error (_("remove-symbol-file: no symbol file provided"));
+
+ my_cleanups = make_cleanup (null_cleanup, NULL);
+
+ argv = gdb_buildargv (args);
+
+ if (strcmp (argv[0], "-a") == 0)
+ {
+ /* Interpret the next argument as an address. */
+ CORE_ADDR addr;
+
+ if (argv[1] == NULL)
+ error (_("Missing address argument"));
+
+ if (argv[2] != NULL)
+ error (_("Junk after %s"), argv[1]);
+
+ addr = parse_and_eval_address (argv[1]);
+
+ ALL_OBJFILES (objf)
+ {
+ if (objf != 0
+ && objf->flags & OBJF_USERLOADED
+ && objf->pspace == pspace && is_addr_in_objfile (addr, objf))
+ break;
+ }
+ }
+ else if (argv[0] != NULL)
+ {
+ /* Interpret the current argument as a file name. */
+ char *filename;
+
+ if (argv[1] != NULL)
+ error (_("Junk after %s"), argv[0]);
+
+ filename = tilde_expand (argv[0]);
+ make_cleanup (xfree, filename);
+
+ ALL_OBJFILES (objf)
+ {
+ if (objf != 0
+ && objf->flags & OBJF_USERLOADED
+ && objf->pspace == pspace
+ && filename_cmp (filename, objfile_name (objf)) == 0)
+ break;
+ }
+ }
+
+ if (objf == NULL)
+ error (_("No symbol file found"));
+
+ if (from_tty
+ && !query (_("Remove symbol table from file \"%s\"? "),
+ objfile_name (objf)))
+ error (_("Not confirmed."));
+
+ free_objfile (objf);
+ clear_symtab_users (0);
+
+ do_cleanups (my_cleanups);
+}
+
typedef struct objfile *objfilep;
DEF_VEC_P (objfilep);
@@ -3764,6 +3840,15 @@ with the text. SECT is a section name to be loaded at SECT_ADDR."),
&cmdlist);
set_cmd_completer (c, filename_completer);
+ c = add_cmd ("remove-symbol-file", class_files,
+ remove_symbol_file_command, _("\
+Remove a symbol file added via the add-symbol-file command.\n\
+Usage: remove-symbol-file FILENAME\n\
+ remove-symbol-file -a ADDRESS\n\
+The file to remove can be identified by its filename or by an address\n\
+that lies within the boundaries of this symbol file in memory."),
+ &cmdlist);
+
c = add_cmd ("load", class_files, load_command, _("\
Dynamically load FILE into the running program, and record its symbols\n\
for access from GDB.\n\