[commit] Fix crash of gdb save-index on a STABS file

Jan Kratochvil
2011-04-09T15:23:12Z

Hi,

checked in, index saving functions crashed on NULL psymtabs_addrmap.

Running gdb/testsuite/gdb.stabs/gdb11479.exp ...
-gdb compile failed, gdb/cc-with-index.sh: line 107: 3487 Segmentation fault (core dumped) $GDB --batch-silent -nx -ex "file $output_file" -ex "save gdb-index $output_dir"
-UNTESTED: gdb.stabs/gdb11479.exp: gdb11479.exp
-gdb compile failed, cc-with-index.sh: Index file gdb/testsuite.unix.-m32/gdb.stabs/gdb11479.gdb-index exists, won't clobber.
-UNTESTED: gdb.stabs/gdb11479.exp: gdb11479.exp
+PASS: gdb.stabs/gdb11479.exp: Set breakpoints forced_stabs
[...]
+PASS: gdb.stabs/gdb11479.exp: sizeof (e) in test natural_debug_format

No regressions on {x86_64,x86_64-m32,i686}-fedora15-linux-gnu.

There are some concerns what is a file uses both DWARF and STABS, it may
possibly currently have a regression with .gdb_index. But that is unrelated
to this patch.

Thanks,
Jan

http://sourceware.org/ml/gdb-cvs/2011-04/msg00061.html

--- src/gdb/ChangeLog 2011/04/09 11:15:28 1.12915
+++ src/gdb/ChangeLog 2011/04/09 15:20:37 1.12916
@@ -1,5 +1,11 @@
2011-04-09 Jan Kratochvil <jan.kratochvil@redhat.com>

+ Fix crash of gdb save-index on a STABS file.
+ * dwarf2read.c (write_psymtabs_to_index): Return also on no
+ PSYMTABS_ADDRMAP.
+
+2011-04-09 Jan Kratochvil <jan.kratochvil@redhat.com>
+
Fix DW_AT_accessibility compatibility with gcc-4.6+.
* dwarf2read.c: Include ctype.h.
(producer_is_gxx_lt_4_6, dwarf2_default_access_attribute): New
--- src/gdb/dwarf2read.c 2011/04/09 11:15:29 1.522
+++ src/gdb/dwarf2read.c 2011/04/09 15:20:38 1.523
@@ -15843,8 +15843,9 @@
htab_t cu_index_htab;
struct psymtab_cu_index_map *psymtab_cu_index_map;

- if (!objfile->psymtabs)
+ if (!objfile->psymtabs || !objfile->psymtabs_addrmap)
return;
+
if (dwarf2_per_objfile->using_index)
error (_("Cannot use an index to create the index"));