forked from Imagelibrary/binutils-gdb
gdb: add all_objfiles_removed observer
The new_objfile observer is currently used to indicate both when a new
objfile is added to program space (when passed non-nullptr) and when all
objfiles of a program space were just removed (when passed nullptr).
I think this is confusing (and Andrew apparently thinks so too [1]).
Add a new "all_objfiles_removed" observer to remove the second role from
"new_objfile".
Some existing users of new_objfile do nothing if the passed objfile is
nullptr. For them, we can simply drop the nullptr check. For others,
add a new all_objfiles_removed callback, and refactor things a bit to
keep the existing behavior as much as possible.
Some callbacks relied on current_program_space, and following
the refactoring now use either objfile->pspace or the pspace passed to
all_objfiles_removed. I think this should be relatively safe, and in
general a step in the right direction.
On the notify side, I found only one call site to change from
new_objfile to all_objfiles_removed, in clear_symtab_users. It is not
entirely clear to me that this is entirely correct. clear_symtab_users
appears to be called in spots that don't remove all objfiles
(functions finish_new_objfile, remove_symbol_file_command, reread_symbols,
do_module_cleanups). But I think that this patch at least makes the
current code clearer.
[1] a0a031bce0
Change-Id: Icb648f72862e056267f30f44dd439bd4ec766f13
Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
18
gdb/remote.c
18
gdb/remote.c
@@ -14963,14 +14963,12 @@ show_remote_cmd (const char *args, int from_tty)
|
||||
}
|
||||
}
|
||||
|
||||
/* Some change happened in PSPACE's objfile list (obfiles added or removed),
|
||||
offer all inferiors using that program space a change to look up symbols. */
|
||||
|
||||
/* Function to be called whenever a new objfile (shlib) is detected. */
|
||||
static void
|
||||
remote_new_objfile (struct objfile *objfile)
|
||||
remote_objfile_changed_check_symbols (program_space *pspace)
|
||||
{
|
||||
/* The objfile change happened in that program space. */
|
||||
program_space *pspace = current_program_space;
|
||||
|
||||
/* The affected program space is possibly shared by multiple inferiors.
|
||||
Consider sending a qSymbol packet for each of the inferiors using that
|
||||
program space. */
|
||||
@@ -15019,6 +15017,14 @@ remote_new_objfile (struct objfile *objfile)
|
||||
}
|
||||
}
|
||||
|
||||
/* Function to be called whenever a new objfile (shlib) is detected. */
|
||||
|
||||
static void
|
||||
remote_new_objfile (struct objfile *objfile)
|
||||
{
|
||||
remote_objfile_changed_check_symbols (objfile->pspace);
|
||||
}
|
||||
|
||||
/* Pull all the tracepoints defined on the target and create local
|
||||
data structures representing them. We don't want to create real
|
||||
tracepoints yet, we don't want to mess up the user's existing
|
||||
@@ -15333,6 +15339,8 @@ _initialize_remote ()
|
||||
|
||||
/* Hook into new objfile notification. */
|
||||
gdb::observers::new_objfile.attach (remote_new_objfile, "remote");
|
||||
gdb::observers::all_objfiles_removed.attach
|
||||
(remote_objfile_changed_check_symbols, "remote");
|
||||
|
||||
#if 0
|
||||
init_remote_threadtests ();
|
||||
|
||||
Reference in New Issue
Block a user