This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[Patch] Use "<unknown>" instead of NULL when a symbol isn't found
- From: Sterling Augustine <saugustine at google dot com>
- To: gdb-patches <gdb-patches at sourceware dot org>, Keith Seitz <keiths at redhat dot com>
- Date: Tue, 17 Dec 2013 11:21:40 -0800
- Subject: [Patch] Use "<unknown>" instead of NULL when a symbol isn't found
- Authentication-results: sourceware.org; auth=none
When parsing a linespec without an enclosing symbol, add_sal_to_sals
(linespec.c:888) assigns "canonical->suffix = NULL;", but then, in
decode_line_full (linespec.c:2462) we have
"gdb_assert(state->canonical_names[i].suffix != NULL);"
Although the case is hard to tickle--I only found it myself with an
object file with an erroneous line table entry--GDB shouldn't crash,
and recovery is quite straight-forward.
The following patch simply assigns the symbol name as "<unknown>"
instead of NULL, allowing the debugger to make forward progress in the
face of an erroneous debug line table entry.
Sterling
gdb/ChangeLog
2013-12-17 Sterling Augustine <saugustine@google.com>
* linespec.c (add_sal_to_sals): Use "<unknown>" when a symbol
isn't found.
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 9468f26..e8bc695 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -885,7 +885,7 @@ add_sal_to_sals (struct linespec_state *self,
if (symname != NULL)
canonical->suffix = xstrdup (symname);
else
- canonical->suffix = NULL;
+ canonical->suffix = xstrdup ("<unknown>");
canonical->symtab = NULL;
}
}