From 76ad5e1e2a20f078a6fe4272a05a932755bd2cf5 Mon Sep 17 00:00:00 2001 From: Nicolas Blanc Date: Wed, 17 Jul 2013 11:33:45 +0200 Subject: 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 * 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 --- gdb/exec.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'gdb/exec.c') 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. */ -- cgit v1.1