* doc/observer.texi (executable_changed): New observer.
* symtab.c: Include "observer.h". (find_main_name): New function. (main_name): If name_of_main is unset, then compute it using find_main_name. (symtab_observer_executable_changed): New function. (_initialize_symtab): Attach executable_changed observer. * exec.c: Include "observer.h". (exec_file_attach): Emit executable_changed notification. * symfile.c: Include "observer.h". (reread_symbols): Send an executable_changed if appropriate. * Makefile.in (exec.o): Add dependency on observer.h. (symfile.o): Likewise. (symtab.o): Likewise.
This commit is contained in:
parent
9a6351f1d2
commit
ea53e89f14
6 changed files with 88 additions and 8 deletions
|
@ -1,3 +1,20 @@
|
||||||
|
2005-03-07 Joel Brobecker <brobecker@adacore.com>
|
||||||
|
|
||||||
|
* doc/observer.texi (executable_changed): New observer.
|
||||||
|
* symtab.c: Include "observer.h".
|
||||||
|
(find_main_name): New function.
|
||||||
|
(main_name): If name_of_main is unset, then compute it
|
||||||
|
using find_main_name.
|
||||||
|
(symtab_observer_executable_changed): New function.
|
||||||
|
(_initialize_symtab): Attach executable_changed observer.
|
||||||
|
* exec.c: Include "observer.h".
|
||||||
|
(exec_file_attach): Emit executable_changed notification.
|
||||||
|
* symfile.c: Include "observer.h".
|
||||||
|
(reread_symbols): Send an executable_changed if appropriate.
|
||||||
|
* Makefile.in (exec.o): Add dependency on observer.h.
|
||||||
|
(symfile.o): Likewise.
|
||||||
|
(symtab.o): Likewise.
|
||||||
|
|
||||||
2005-03-07 Daniel Jacobowitz <dan@codesourcery.com>
|
2005-03-07 Daniel Jacobowitz <dan@codesourcery.com>
|
||||||
|
|
||||||
* findvar.c (read_var_value): Don't allocate V when it will not
|
* findvar.c (read_var_value): Don't allocate V when it will not
|
||||||
|
|
|
@ -1903,7 +1903,7 @@ exceptions.o: exceptions.c $(defs_h) $(exceptions_h) $(breakpoint_h) \
|
||||||
exec.o: exec.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) $(gdbcmd_h) \
|
exec.o: exec.c $(defs_h) $(frame_h) $(inferior_h) $(target_h) $(gdbcmd_h) \
|
||||||
$(language_h) $(symfile_h) $(objfiles_h) $(completer_h) $(value_h) \
|
$(language_h) $(symfile_h) $(objfiles_h) $(completer_h) $(value_h) \
|
||||||
$(exec_h) $(readline_h) $(gdb_string_h) $(gdbcore_h) $(gdb_stat_h) \
|
$(exec_h) $(readline_h) $(gdb_string_h) $(gdbcore_h) $(gdb_stat_h) \
|
||||||
$(xcoffsolib_h)
|
$(xcoffsolib_h) $(observer_h)
|
||||||
expprint.o: expprint.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression_h) \
|
expprint.o: expprint.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(expression_h) \
|
||||||
$(value_h) $(language_h) $(parser_defs_h) $(user_regs_h) $(target_h) \
|
$(value_h) $(language_h) $(parser_defs_h) $(user_regs_h) $(target_h) \
|
||||||
$(gdb_string_h) $(block_h)
|
$(gdb_string_h) $(block_h)
|
||||||
|
@ -2614,7 +2614,7 @@ symfile.o: symfile.c $(defs_h) $(bfdlink_h) $(symtab_h) $(gdbtypes_h) \
|
||||||
$(complaints_h) $(demangle_h) $(inferior_h) $(filenames_h) \
|
$(complaints_h) $(demangle_h) $(inferior_h) $(filenames_h) \
|
||||||
$(gdb_stabs_h) $(gdb_obstack_h) $(completer_h) $(bcache_h) \
|
$(gdb_stabs_h) $(gdb_obstack_h) $(completer_h) $(bcache_h) \
|
||||||
$(hashtab_h) $(readline_h) $(gdb_assert_h) $(block_h) \
|
$(hashtab_h) $(readline_h) $(gdb_assert_h) $(block_h) \
|
||||||
$(gdb_string_h) $(gdb_stat_h)
|
$(gdb_string_h) $(gdb_stat_h) $(observer_h)
|
||||||
symfile-mem.o: symfile-mem.c $(defs_h) $(symtab_h) $(gdbcore_h) \
|
symfile-mem.o: symfile-mem.c $(defs_h) $(symtab_h) $(gdbcore_h) \
|
||||||
$(objfiles_h) $(exceptions_h) $(gdbcmd_h) $(target_h) $(value_h) \
|
$(objfiles_h) $(exceptions_h) $(gdbcmd_h) $(target_h) $(value_h) \
|
||||||
$(symfile_h) $(observer_h) $(auxv_h) $(elf_common_h)
|
$(symfile_h) $(observer_h) $(auxv_h) $(elf_common_h)
|
||||||
|
@ -2629,7 +2629,7 @@ symtab.o: symtab.c $(defs_h) $(symtab_h) $(gdbtypes_h) $(gdbcore_h) \
|
||||||
$(language_h) $(demangle_h) $(inferior_h) $(linespec_h) $(source_h) \
|
$(language_h) $(demangle_h) $(inferior_h) $(linespec_h) $(source_h) \
|
||||||
$(filenames_h) $(objc_lang_h) $(ada_lang_h) $(hashtab_h) \
|
$(filenames_h) $(objc_lang_h) $(ada_lang_h) $(hashtab_h) \
|
||||||
$(gdb_obstack_h) $(block_h) $(dictionary_h) $(gdb_string_h) \
|
$(gdb_obstack_h) $(block_h) $(dictionary_h) $(gdb_string_h) \
|
||||||
$(gdb_stat_h) $(cp_abi_h)
|
$(gdb_stat_h) $(cp_abi_h) $(observer_h)
|
||||||
target.o: target.c $(defs_h) $(gdb_string_h) $(target_h) $(gdbcmd_h) \
|
target.o: target.c $(defs_h) $(gdb_string_h) $(target_h) $(gdbcmd_h) \
|
||||||
$(symtab_h) $(inferior_h) $(bfd_h) $(symfile_h) $(objfiles_h) \
|
$(symtab_h) $(inferior_h) $(bfd_h) $(symfile_h) $(objfiles_h) \
|
||||||
$(gdb_wait_h) $(dcache_h) $(regcache_h) $(gdb_assert_h) $(gdbcore_h)
|
$(gdb_wait_h) $(dcache_h) $(regcache_h) $(gdb_assert_h) $(gdbcore_h)
|
||||||
|
|
|
@ -83,6 +83,13 @@ The inferior has stopped for real.
|
||||||
The target's register contents have changed.
|
The target's register contents have changed.
|
||||||
@end deftypefun
|
@end deftypefun
|
||||||
|
|
||||||
|
@deftypefun void executable_changed (void *@var{unused_args})
|
||||||
|
The executable being debugged by GDB has changed: The user decided
|
||||||
|
to debug a different program, or the program he was debugging has
|
||||||
|
been modified since being loaded by the debugger (by being recompiled,
|
||||||
|
for instance).
|
||||||
|
@end deftypefun
|
||||||
|
|
||||||
@deftypefun void inferior_created (struct target_ops *@var{objfile}, int @var{from_tty})
|
@deftypefun void inferior_created (struct target_ops *@var{objfile}, int @var{from_tty})
|
||||||
@value{GDBN} has just connected to an inferior. For @samp{run},
|
@value{GDBN} has just connected to an inferior. For @samp{run},
|
||||||
@value{GDBN} calls this observer while the inferior is still stopped
|
@value{GDBN} calls this observer while the inferior is still stopped
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "completer.h"
|
#include "completer.h"
|
||||||
#include "value.h"
|
#include "value.h"
|
||||||
#include "exec.h"
|
#include "exec.h"
|
||||||
|
#include "observer.h"
|
||||||
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include "readline/readline.h"
|
#include "readline/readline.h"
|
||||||
|
@ -276,6 +277,7 @@ exec_file_attach (char *filename, int from_tty)
|
||||||
(*deprecated_exec_file_display_hook) (filename);
|
(*deprecated_exec_file_display_hook) (filename);
|
||||||
}
|
}
|
||||||
bfd_cache_close_all ();
|
bfd_cache_close_all ();
|
||||||
|
observer_notify_executable_changed (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process the first arg in ARGS as the new exec file.
|
/* Process the first arg in ARGS as the new exec file.
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#include "readline/readline.h"
|
#include "readline/readline.h"
|
||||||
#include "gdb_assert.h"
|
#include "gdb_assert.h"
|
||||||
#include "block.h"
|
#include "block.h"
|
||||||
|
#include "observer.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -2013,7 +2014,13 @@ reread_symbols (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reread_one)
|
if (reread_one)
|
||||||
clear_symtab_users ();
|
{
|
||||||
|
clear_symtab_users ();
|
||||||
|
/* At least one objfile has changed, so we can consider that
|
||||||
|
the executable we're debugging has changed too. */
|
||||||
|
observer_notify_executable_changed (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
55
gdb/symtab.c
55
gdb/symtab.c
|
@ -55,6 +55,7 @@
|
||||||
#include "gdb_stat.h"
|
#include "gdb_stat.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include "cp-abi.h"
|
#include "cp-abi.h"
|
||||||
|
#include "observer.h"
|
||||||
|
|
||||||
/* Prototypes for local functions */
|
/* Prototypes for local functions */
|
||||||
|
|
||||||
|
@ -4092,15 +4093,59 @@ set_main_name (const char *name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Deduce the name of the main procedure, and set NAME_OF_MAIN
|
||||||
|
accordingly. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
find_main_name (void)
|
||||||
|
{
|
||||||
|
char *new_main_name;
|
||||||
|
|
||||||
|
/* Try to see if the main procedure is in Ada. */
|
||||||
|
/* FIXME: brobecker/2005-03-07: Another way of doing this would
|
||||||
|
be to add a new method in the language vector, and call this
|
||||||
|
method for each language until one of them returns a non-empty
|
||||||
|
name. This would allow us to remove this hard-coded call to
|
||||||
|
an Ada function. It is not clear that this is a better approach
|
||||||
|
at this point, because all methods need to be written in a way
|
||||||
|
such that false positives never be returned. For instance, it is
|
||||||
|
important that a method does not return a wrong name for the main
|
||||||
|
procedure if the main procedure is actually written in a different
|
||||||
|
language. It is easy to guaranty this with Ada, since we use a
|
||||||
|
special symbol generated only when the main in Ada to find the name
|
||||||
|
of the main procedure. It is difficult however to see how this can
|
||||||
|
be guarantied for languages such as C, for instance. This suggests
|
||||||
|
that order of call for these methods becomes important, which means
|
||||||
|
a more complicated approach. */
|
||||||
|
new_main_name = ada_main_name ();
|
||||||
|
if (new_main_name != NULL)
|
||||||
|
{
|
||||||
|
set_main_name (new_main_name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The languages above didn't identify the name of the main procedure.
|
||||||
|
Fallback to "main". */
|
||||||
|
set_main_name ("main");
|
||||||
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
main_name (void)
|
main_name (void)
|
||||||
{
|
{
|
||||||
if (name_of_main != NULL)
|
if (name_of_main == NULL)
|
||||||
return name_of_main;
|
find_main_name ();
|
||||||
else
|
|
||||||
return "main";
|
return name_of_main;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Handle ``executable_changed'' events for the symtab module. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
symtab_observer_executable_changed (void *unused)
|
||||||
|
{
|
||||||
|
/* NAME_OF_MAIN may no longer be the same, so reset it for now. */
|
||||||
|
set_main_name (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
_initialize_symtab (void)
|
_initialize_symtab (void)
|
||||||
|
@ -4143,4 +4188,6 @@ All global and static variable names, or those matching REGEXP."));
|
||||||
/* Initialize the one built-in type that isn't language dependent... */
|
/* Initialize the one built-in type that isn't language dependent... */
|
||||||
builtin_type_error = init_type (TYPE_CODE_ERROR, 0, 0,
|
builtin_type_error = init_type (TYPE_CODE_ERROR, 0, 0,
|
||||||
"<unknown type>", (struct objfile *) NULL);
|
"<unknown type>", (struct objfile *) NULL);
|
||||||
|
|
||||||
|
observer_attach_executable_changed (symtab_observer_executable_changed);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue