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 16:58:55 +0100
commit0068bd6fb3579dd8df7561e038cb3fe27f122b0e (patch)
tree9d1c50273d00a9490e93f80fb101481c51924e8a /gdb/cli
parent047fa8cc1cc534f19428b18d3d0c50e8139d3335 (diff)
downloadgdb-0068bd6fb3579dd8df7561e038cb3fe27f122b0e.zip
gdb-0068bd6fb3579dd8df7561e038cb3fe27f122b0e.tar.gz
gdb-0068bd6fb3579dd8df7561e038cb3fe27f122b0e.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 c1c7834..df11f95 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. */