aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog11
-rw-r--r--gdb/exec.c20
-rw-r--r--gdb/exec.h5
-rw-r--r--gdb/solib.c8
-rw-r--r--gdb/target.h6
5 files changed, 37 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7dcdbed..964b6fd 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,16 @@
2012-08-22 Tom Tromey <tromey@redhat.com>
+ * exec.c (exec_close, exec_file_attach): Update.
+ (add_to_section_table): Initialize 'key' field.
+ (add_target_sections, remove_target_sections): Add 'key' argument.
+ * exec.h (add_target_sections, remove_target_sections): Add
+ 'key' argument.
+ * solib.c (solib_map_sections, update_solib_list, clear_solib)
+ (reload_shared_libraries_1): Update.
+ * target.h (struct target_section) <key>: New field.
+
+2012-08-22 Tom Tromey <tromey@redhat.com>
+
* cli/cli-cmds.c (filter_sals): Handle nelts == 0 case.
2012-08-21 Pierre Muller <muller@ics.u-strasbg.fr>
diff --git a/gdb/exec.c b/gdb/exec.c
index e076609..de1b0b6 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -107,7 +107,7 @@ exec_close (void)
exec_bfd = NULL;
exec_bfd_mtime = 0;
- remove_target_sections (abfd);
+ remove_target_sections (&exec_bfd, abfd);
}
}
@@ -284,7 +284,7 @@ exec_file_attach (char *filename, int from_tty)
/* Add the executable's sections to the current address spaces'
list of sections. This possibly pushes the exec_ops
target. */
- add_target_sections (sections, sections_end);
+ add_target_sections (&exec_bfd, sections, sections_end);
xfree (sections);
/* Tell display code (if any) about the changed file name. */
@@ -378,6 +378,7 @@ add_to_section_table (bfd *abfd, struct bfd_section *asect,
if (!(aflag & SEC_ALLOC))
return;
+ (*table_pp)->key = NULL;
(*table_pp)->bfd = abfd;
(*table_pp)->the_bfd_section = asect;
(*table_pp)->addr = bfd_section_vma (abfd, asect);
@@ -438,7 +439,8 @@ build_section_table (struct bfd *some_bfd, struct target_section **start,
current set of target sections. */
void
-add_target_sections (struct target_section *sections,
+add_target_sections (void *key,
+ struct target_section *sections,
struct target_section *sections_end)
{
int count;
@@ -449,9 +451,13 @@ add_target_sections (struct target_section *sections,
if (count > 0)
{
int space = resize_section_table (table, count);
+ int i;
- memcpy (table->sections + space,
- sections, count * sizeof (sections[0]));
+ for (i = 0; i < count; ++i)
+ {
+ table->sections[space + i] = sections[i];
+ table->sections[space + i].key = key;
+ }
/* If these are the first file sections we can provide memory
from, push the file_stratum target. */
@@ -466,14 +472,14 @@ add_target_sections (struct target_section *sections,
/* Remove all target sections taken from ABFD. */
void
-remove_target_sections (bfd *abfd)
+remove_target_sections (void *key, bfd *abfd)
{
struct target_section *src, *dest;
struct target_section_table *table = current_target_sections;
dest = table->sections;
for (src = table->sections; src < table->sections_end; src++)
- if (src->bfd != abfd)
+ if (src->key != key || src->bfd != abfd)
{
/* Keep this section. */
if (dest < src)
diff --git a/gdb/exec.h b/gdb/exec.h
index a0f9eab..c5bb2a8 100644
--- a/gdb/exec.h
+++ b/gdb/exec.h
@@ -83,12 +83,13 @@ extern void exec_set_section_address (const char *, int, CORE_ADDR);
/* Remove all target sections taken from ABFD. */
-extern void remove_target_sections (bfd *abfd);
+extern void remove_target_sections (void *key, bfd *abfd);
/* Add the sections array defined by [SECTIONS..SECTIONS_END[ to the
current set of target sections. */
-extern void add_target_sections (struct target_section *sections,
+extern void add_target_sections (void *key,
+ struct target_section *sections,
struct target_section *sections_end);
/* Prints info about all sections defined in the TABLE. ABFD is
diff --git a/gdb/solib.c b/gdb/solib.c
index 73773f1..3081f35 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -504,7 +504,7 @@ solib_map_sections (struct so_list *so)
section tables. Do this immediately after mapping the object so
that later nodes in the list can query this object, as is needed
in solib-osf.c. */
- add_target_sections (so->sections, so->sections_end);
+ add_target_sections (so, so->sections, so->sections_end);
return 1;
}
@@ -772,7 +772,7 @@ update_solib_list (int from_tty, struct target_ops *target)
/* Some targets' section tables might be referring to
sections from so->abfd; remove them. */
- remove_target_sections (gdb->abfd);
+ remove_target_sections (gdb, gdb->abfd);
free_so (gdb);
gdb = *gdb_link;
@@ -1154,7 +1154,7 @@ clear_solib (void)
so_list_head = so->next;
observer_notify_solib_unloaded (so);
if (so->abfd)
- remove_target_sections (so->abfd);
+ remove_target_sections (so, so->abfd);
free_so (so);
}
@@ -1247,7 +1247,7 @@ reload_shared_libraries_1 (int from_tty)
if (so->objfile && ! (so->objfile->flags & OBJF_USERLOADED)
&& !solib_used (so))
free_objfile (so->objfile);
- remove_target_sections (so->abfd);
+ remove_target_sections (so, so->abfd);
free_so_symbols (so);
}
diff --git a/gdb/target.h b/gdb/target.h
index 95cfbe2..382dacb 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -1804,6 +1804,12 @@ struct target_section
struct bfd_section *the_bfd_section;
+ /* A given BFD may appear multiple times in the target section
+ list, so each BFD is associated with a given key. The key is
+ just some convenient pointer that can be used to differentiate
+ the BFDs. These are managed only by convention. */
+ void *key;
+
bfd *bfd; /* BFD file pointer */
};