aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorGuinevere Larsen <blarsen@redhat.com>2024-01-22 10:13:52 +0100
committerGuinevere Larsen <blarsen@redhat.com>2024-01-23 17:00:40 +0100
commit4fe1a40c7c464bde0212aa859774fe59fb71ccfe (patch)
tree0a18ec45e7c6da33c1765231db0eb83317bcbc40 /gdb/cli
parent9ccb91f0c207ab7eeca777f93b9f5cb2de6dd815 (diff)
downloadbinutils-4fe1a40c7c464bde0212aa859774fe59fb71ccfe.zip
binutils-4fe1a40c7c464bde0212aa859774fe59fb71ccfe.tar.gz
binutils-4fe1a40c7c464bde0212aa859774fe59fb71ccfe.tar.bz2
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>
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-cmds.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 8cadd63..cfe7b71 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -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. */