aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Pluzhnikov <ppluzhnikov@google.com>2009-10-22 20:20:27 +0000
committerPaul Pluzhnikov <ppluzhnikov@google.com>2009-10-22 20:20:27 +0000
commit65a97ab329d81a01b410d7b49ec41fd1b7652439 (patch)
tree7c5983119fb3e0fe19985afd1a030d707ac843cf
parent02506ff1ad948dc6cd941c91ea3c3aa28831f03d (diff)
downloadgdb-65a97ab329d81a01b410d7b49ec41fd1b7652439.zip
gdb-65a97ab329d81a01b410d7b49ec41fd1b7652439.tar.gz
gdb-65a97ab329d81a01b410d7b49ec41fd1b7652439.tar.bz2
2009-10-22 Paul Pluzhnikov <ppluzhnikov@google.com>
PR gdb/10819 * dwarf2-frame.c (find_cie): Don't call bsearch on empty cie_table. * objfiles.c (find_pc_section): Likewise. (update_section_map): Don't allocate empty table.
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/dwarf2-frame.c8
-rw-r--r--gdb/objfiles.c16
3 files changed, 31 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2951bae..f30822c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2009-10-22 Paul Pluzhnikov <ppluzhnikov@google.com>
+
+ PR gdb/10819
+ * dwarf2-frame.c (find_cie): Don't call bsearch on empty cie_table.
+ * objfiles.c (find_pc_section): Likewise.
+ (update_section_map): Don't allocate empty table.
+
2009-10-16 Hui Zhu <teawater@gmail.com>
Michael Snyder <msnyder@msnyder-server.eng.vmware.com>
diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
index 9c464ba..5e9be2c 100644
--- a/gdb/dwarf2-frame.c
+++ b/gdb/dwarf2-frame.c
@@ -1525,6 +1525,14 @@ find_cie (struct dwarf2_cie_table *cie_table, ULONGEST cie_pointer)
{
struct dwarf2_cie **p_cie;
+ /* The C standard (ISO/IEC 9899:TC2) requires the BASE argument to
+ bsearch be non-NULL. */
+ if (cie_table->entries == NULL)
+ {
+ gdb_assert (cie_table->num_entries == 0);
+ return NULL;
+ }
+
p_cie = bsearch (&cie_pointer, cie_table->entries, cie_table->num_entries,
sizeof (cie_table->entries[0]), bsearch_cie_cmp);
if (p_cie != NULL)
diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 13a8c55..03a49a9 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -1113,6 +1113,14 @@ update_section_map (struct program_space *pspace,
if (insert_section_p (objfile->obfd, s->the_bfd_section))
alloc_size += 1;
+ /* This happens on detach/attach (e.g. in gdb.base/attach.exp). */
+ if (alloc_size == 0)
+ {
+ *pmap = NULL;
+ *pmap_size = 0;
+ return;
+ }
+
map = xmalloc (alloc_size * sizeof (*map));
i = 0;
@@ -1175,6 +1183,14 @@ find_pc_section (CORE_ADDR pc)
pspace_info->objfiles_changed_p = 0;
}
+ /* The C standard (ISO/IEC 9899:TC2) requires the BASE argument to
+ bsearch be non-NULL. */
+ if (pspace_info->sections == NULL)
+ {
+ gdb_assert (pspace_info->num_sections == 0);
+ return NULL;
+ }
+
sp = (struct obj_section **) bsearch (&pc,
pspace_info->sections,
pspace_info->num_sections,