aboutsummaryrefslogtreecommitdiff
path: root/gdb/symfile.c
diff options
context:
space:
mode:
authorNicolas Blanc <nicolas.blanc@intel.com>2013-07-17 11:33:45 +0200
committerNicolas Blanc <nicolas.blanc@intel.com>2013-10-29 10:56:27 +0100
commit76ad5e1e2a20f078a6fe4272a05a932755bd2cf5 (patch)
tree62a5d1ff629582c90ceb44e066e5ec0b552e37a3 /gdb/symfile.c
parent98297bf675da669930bacf6d0c08bc4d1a34df3e (diff)
downloadgdb-76ad5e1e2a20f078a6fe4272a05a932755bd2cf5.zip
gdb-76ad5e1e2a20f078a6fe4272a05a932755bd2cf5.tar.gz
gdb-76ad5e1e2a20f078a6fe4272a05a932755bd2cf5.tar.bz2
Create target sections for user-added symbol files.
Add the sections of the symbol files that are provided via 'add-symbol-file' to the set of current target sections. User-added sections are removed upon notification of free_objfile when their corresponding object file is deleted. 2013-10-29 Nicolas Blanc <nicolas.blanc@intel.com> * exec.h (add_target_sections_of_objfile): New declaration. * exec.c (add_target_sections_of_objfile): New function. * symfile.c (add_symbol_file_command): Update current target sections. (symfile_free_objfile): New function. (_initialize_symfile): Register observer for free_objfile events. Signed-off-by: Nicolas Blanc <nicolas.blanc@intel.com>
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r--gdb/symfile.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 0318466..e0a234c 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -57,6 +57,7 @@
#include "stack.h"
#include "gdb_bfd.h"
#include "cli/cli-utils.h"
+#include "target.h"
#include <sys/types.h>
#include <fcntl.h>
@@ -2206,6 +2207,7 @@ add_symbol_file_command (char *args, int from_tty)
int expecting_sec_name = 0;
int expecting_sec_addr = 0;
char **argv;
+ struct objfile *objf;
struct sect_opt
{
@@ -2332,8 +2334,10 @@ add_symbol_file_command (char *args, int from_tty)
if (from_tty && (!query ("%s", "")))
error (_("Not confirmed."));
- symbol_file_add (filename, from_tty ? SYMFILE_VERBOSE : 0,
- section_addrs, flags);
+ objf = symbol_file_add (filename, from_tty ? SYMFILE_VERBOSE : 0,
+ section_addrs, flags);
+
+ add_target_sections_of_objfile (objf);
/* Getting new symbols may change our opinion about what is
frameless. */
@@ -3819,11 +3823,23 @@ symfile_find_segment_sections (struct objfile *objfile)
free_symfile_segment_data (data);
}
+/* Listen for free_objfile events. */
+
+static void
+symfile_free_objfile (struct objfile *objfile)
+{
+ /* Remove the target sections of user-added objfiles. */
+ if (objfile != 0 && objfile->flags & OBJF_USERLOADED)
+ remove_target_sections ((void *) objfile);
+}
+
void
_initialize_symfile (void)
{
struct cmd_list_element *c;
+ observer_attach_free_objfile (symfile_free_objfile);
+
c = add_cmd ("symbol-file", class_files, symbol_file_command, _("\
Load symbol table from executable file FILE.\n\
The `file' command can also load symbol tables, as well as setting the file\n\