aboutsummaryrefslogtreecommitdiff
path: root/gdb/exec.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/exec.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/exec.c')
-rw-r--r--gdb/exec.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/gdb/exec.c b/gdb/exec.c
index 758cdc1..187c412 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -438,6 +438,51 @@ add_target_sections (void *owner,
}
}
+/* Add the sections of OBJFILE to the current set of target sections. */
+
+void
+add_target_sections_of_objfile (struct objfile *objfile)
+{
+ struct target_section_table *table = current_target_sections;
+ struct obj_section *osect;
+ int space;
+ unsigned count = 0;
+ struct target_section *ts;
+
+ if (objfile == NULL)
+ return;
+
+ /* Compute the number of sections to add. */
+ ALL_OBJFILE_OSECTIONS (objfile, osect)
+ {
+ if (bfd_get_section_size (osect->the_bfd_section) == 0)
+ continue;
+ count++;
+ }
+
+ if (count == 0)
+ return;
+
+ space = resize_section_table (table, count);
+
+ ts = table->sections + space;
+
+ ALL_OBJFILE_OSECTIONS (objfile, osect)
+ {
+ if (bfd_get_section_size (osect->the_bfd_section) == 0)
+ continue;
+
+ gdb_assert (ts < table->sections + space + count);
+
+ ts->addr = obj_section_addr (osect);
+ ts->endaddr = obj_section_endaddr (osect);
+ ts->the_bfd_section = osect->the_bfd_section;
+ ts->owner = (void *) objfile;
+
+ ts++;
+ }
+}
+
/* Remove all target sections owned by OWNER.
OWNER must be the same value passed to add_target_sections. */