This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
FY: check for DW_STRING == NULL
- From: Tom Tromey <tromey at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 03 Mar 2011 10:32:19 -0700
- Subject: FY: check for DW_STRING == NULL
I'm checking this in.
This fixes PR gdb/12538.
The bug is that process_psymtab_comp_unit is not prepared for the case
where DW_STRING is NULL. However, this can happen due to some code in
read_indirect_string.
The decision to change an empty string to NULL in read_indirect_string
and read_direct_string seems like a strange one to me. However, it
looks somewhat tricky to fix, as there is a lot of code making
assumptions about this. So, in the interests of conservatism, I did not
attempt this.
Built and regtested on x86-64 (compile farm).
Tom
2011-03-03 Tom Tromey <tromey@redhat.com>
PR gdb/12538:
* dwarf2read.c (process_psymtab_comp_unit): Handle case where
DW_STRING is NULL.
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.504
diff -u -r1.504 dwarf2read.c
--- dwarf2read.c 2 Mar 2011 00:37:29 -0000 1.504
+++ dwarf2read.c 3 Mar 2011 17:29:55 -0000
@@ -3191,6 +3191,7 @@
struct attribute *attr;
CORE_ADDR best_lowpc = 0, best_highpc = 0;
struct die_reader_specs reader_specs;
+ const char *filename;
init_one_comp_unit (&cu, objfile);
back_to_inner = make_cleanup (free_stack_comp_unit, &cu);
@@ -3250,8 +3251,12 @@
/* Allocate a new partial symbol table structure. */
attr = dwarf2_attr (comp_unit_die, DW_AT_name, &cu);
+ if (attr == NULL || !DW_STRING (attr))
+ filename = "";
+ else
+ filename = DW_STRING (attr);
pst = start_psymtab_common (objfile, objfile->section_offsets,
- (attr != NULL) ? DW_STRING (attr) : "",
+ filename,
/* TEXTLOW and TEXTHIGH are set below. */
0,
objfile->global_psymbols.next,