aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorGuinevere Larsen <blarsen@redhat.com>2023-09-19 14:06:49 +0200
committerGuinevere Larsen <blarsen@redhat.com>2023-09-19 14:06:49 +0200
commit12f567bcb640285b0afab74e2ac8d471a175722d (patch)
tree1a9dd294547fd00c16f8d307a9dd141f2154281b /gdb/cli
parent5d69d9edc4fa357ab20a3eba6dd072f176505919 (diff)
downloadbinutils-12f567bcb640285b0afab74e2ac8d471a175722d.zip
binutils-12f567bcb640285b0afab74e2ac8d471a175722d.tar.gz
binutils-12f567bcb640285b0afab74e2ac8d471a175722d.tar.bz2
gdb/cli: fixes to newly added "list ." command
After the series that added this command was pushed, Pedro mentioned that the news description could easily be misinterpreted, as well as some code and test improvements that should be made. While fixing the test, I realized that code repetition wasn't happening as it should, so I took care of that too. Approved-By: Andrew Burgess <aburgess@redhat.com> Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-cmds.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 0fa24fd..b801e21 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -1272,10 +1272,10 @@ list_command (const char *arg, int from_tty)
print_source_lines (cursal.symtab, range, 0);
}
- /* "l ." lists the default location again. */
+ /* "list ." lists the default location again. */
else if (arg[0] == '.')
{
- try
+ if (target_has_stack ())
{
/* Find the current line by getting the PC of the currently
selected frame, and finding the line associated to it. */
@@ -1283,19 +1283,19 @@ list_command (const char *arg, int from_tty)
CORE_ADDR curr_pc = get_frame_pc (frame);
cursal = find_pc_line (curr_pc, 0);
}
- catch (const gdb_exception &e)
+ else
{
- /* If there was an exception above, it means the inferior
- is not running, so reset the current source location to
- the default. */
+ /* The inferior is not running, so reset the current source
+ location to the default (usually the main function). */
clear_current_source_symtab_and_line ();
set_default_source_symtab_and_line ();
cursal = get_current_source_symtab_and_line ();
}
list_around_line (arg, cursal);
- /* Advance argument so just pressing "enter" after using "list ."
+ /* Set the repeat args so just pressing "enter" after using "list ."
will print the following lines instead of the same lines again. */
- arg++;
+ if (from_tty)
+ set_repeat_arguments ("");
}
return;
@@ -2805,9 +2805,9 @@ and send its output to SHELL_COMMAND."));
= add_com ("list", class_files, list_command, _("\
List specified function or line.\n\
With no argument, lists ten more lines after or around previous listing.\n\
-\"list .\" lists ten lines arond where the inferior is stopped.\n\
\"list +\" lists the ten lines following a previous ten-line listing.\n\
\"list -\" lists the ten lines before a previous ten-line listing.\n\
+\"list .\" lists ten lines around the point of execution in the current frame.\n\
One argument specifies a line, and ten lines are listed around that line.\n\
Two arguments with comma between specify starting and ending lines to list.\n\
Lines can be specified in these ways:\n\