[PATCH v5 1/3] New remove-symbol-file command.

Doug Evans dje@google.com
Mon Jun 3 23:06:00 GMT 2013


On Fri, May 31, 2013 at 10:31 AM, Nicolas Blanc <nicolas.blanc@intel.com> wrote:
> New command for removing symbol files added via
> the add-symbol-file command.
>
> 2013-18-03  Nicolas Blanc  <nicolas.blanc@intel.com>
>
>         * breakpoint.c (disable_breakpoints_in_freed_objfile): New function for
>         disabling breakpoints in objfiles upon free_objfile notifications.
>         * objfiles.c (free_objfile): Notify free_objfile.
>         (is_addr_in_objfile): New query 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 for removing
>         dangling references upon notification of free_objfile.
>         * symfile.c (remove_symbol_file_command): New command for removing symbol
>         files.
>         (_initialize_symfile): Add remove-symbol-file.
> gdb/doc
>         * observer.texi: New free_objfile event.
>
> [...]
> +/* This function removes a symbol file that was added via add-symbol-file.  */
> +
> +static void
> +remove_symbol_file_command (char *args, int from_tty)
> +{
> +  CORE_ADDR addr = 0;
> +  struct objfile* objf;
> +  struct gdbarch *gdbarch = get_current_arch ();
> +
> +  dont_repeat ();
> +
> +  if (args == NULL)
> +    error (_("USAGE: remove-symbol-file <address>"));
> +
> +  addr = parse_and_eval_address (args);
> +
> +  ALL_OBJFILES (objf)
> +  {
> +    if (objf->flags & OBJF_USERLOADED && is_addr_in_objfile (addr, objf))
> +      break;
> +  }
> +
> +  if (objf == NULL)
> +    error (_("no user-added symbol file for 0x%s"),
> +          phex_nz (addr, sizeof (addr)));
> +
> +  if (from_tty
> +      && !query (_("Remove symbol table from file \"%s\"? "), objf->name))
> +    error (_("Not confirmed."));
> +
> +  free_objfile (objf);
> +  clear_symtab_users (0);
> +}

Hi.
I understand the reasoning for wanting to be able to specify an address.
ref: http://sourceware.org/ml/gdb-patches/2013-05/msg00992.html

Still, IWBN to be able to specify a file name.  Maybe even a regex.
That doesn't have to be implemented today, but IWBN to confirm it can
be added later without any trouble.
Presumably "remove-symbol-file -r" will cause an error, and thus
tomorrow we could implement "remove-symbol-file -r regex".
?

OTOH, one could have "remove-symbol-file file" or "remove-symbol-file
regex", and require the address version to be
specified as "remove-symbol-file -a addr".

Which will be more common?



More information about the Gdb-patches mailing list