This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] Use "<unknown>" instead of NULL when a symbol isn't found


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]