forked from Imagelibrary/binutils-gdb
gdb: fix "list ." related crash
When a user attempts to use the "list ." command with an inferior that doesn't have debug symbols, GDB would crash. This was reported as PR gdb/31256. The crash would happen when attempting to get the current symtab_and_line for the stop location, because the symtab would return a null pointer and we'd attempt to dereference it to print the line. This commit fixes that by checking for an empty symtab and erroring out of the function if it happens. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31256 Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
@@ -1291,6 +1291,8 @@ list_command (const char *arg, int from_tty)
|
||||
set_default_source_symtab_and_line ();
|
||||
cursal = get_current_source_symtab_and_line ();
|
||||
}
|
||||
if (cursal.symtab == nullptr)
|
||||
error (_("No debug information available to print source lines."));
|
||||
list_around_line (arg, cursal);
|
||||
/* Set the repeat args so just pressing "enter" after using "list ."
|
||||
will print the following lines instead of the same lines again. */
|
||||
|
||||
Reference in New Issue
Block a user