public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [Patch] Use "<unknown>" instead of NULL when a symbol isn't found
@ 2013-12-17 19:21 Sterling Augustine
  2013-12-19 18:11 ` Sterling Augustine
  2013-12-20 18:16 ` Tom Tromey
  0 siblings, 2 replies; 5+ messages in thread
From: Sterling Augustine @ 2013-12-17 19:21 UTC (permalink / raw)
  To: gdb-patches, Keith Seitz

[-- Attachment #1: Type: text/plain, Size: 769 bytes --]

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.

[-- Attachment #2: canonical.patch --]
[-- Type: text/x-patch, Size: 384 bytes --]

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;
 	}
     }

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-01-06 20:19 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-17 19:21 [Patch] Use "<unknown>" instead of NULL when a symbol isn't found Sterling Augustine
2013-12-19 18:11 ` Sterling Augustine
2013-12-20 18:16 ` Tom Tromey
2013-12-23 23:17   ` Sterling Augustine
2014-01-06 20:19     ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).