+2015-12-11 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * cli/cli-cmds.c (list_command): Check that the argument string is
+ a single character, either '+' or '-'.
+
2015-12-11 Andrew Burgess <andrew.burgess@embecosm.com>
* cli/cli-cmds.c (list_command): Move all handling of +/-
cleanup = make_cleanup (null_cleanup, NULL);
/* Pull in the current default source line if necessary. */
- if (arg == NULL || arg[0] == '+' || arg[0] == '-')
+ if (arg == NULL || ((arg[0] == '+' || arg[0] == '-') && arg[1] == '\0'))
{
set_default_source_symtab_and_line ();
cursal = get_current_source_symtab_and_line ();
}
/* "l" or "l +" lists next ten lines. */
- else if (arg == NULL || strcmp (arg, "+") == 0)
+ else if (arg == NULL || arg[0] == '+')
print_source_lines (cursal.symtab, cursal.line,
cursal.line + get_lines_to_list (), 0);
/* "l -" lists previous ten lines, the ones before the ten just
listed. */
- else if (strcmp (arg, "-") == 0)
+ else if (arg[0] == '-')
print_source_lines (cursal.symtab,
max (get_first_line_listed ()
- get_lines_to_list (), 1),
+2015-12-11 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * gdb.base/list.exp (test_list_invalid_args): New function,
+ defined, and called.
+
2015-12-11 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.base/list.exp (test_list): Make test names unique.
gdb_test "list ,5" "list ,5\r\n4\[ \t\]\[^\r\n\]*\r\n5\[ \t\]\[^\r\n\]*"
}
+proc test_list_invalid_args {} {
+ global binfile
+
+ clean_restart ${binfile}
+ gdb_test "list -INVALID" \
+ "invalid explicit location argument, \"-INVALID\"" \
+ "first use of \"list -INVALID\""
+ gdb_test "list -INVALID" \
+ "invalid explicit location argument, \"-INVALID\"" \
+ "second use of \"list -INVALID\""
+
+ clean_restart ${binfile}
+ gdb_test "list +INVALID" "Function \"\\+INVALID\" not defined." \
+ "first use of \"list +INVALID\""
+ gdb_test "list +INVALID" "Function \"\\+INVALID\" not defined." \
+ "second use of \"list +INVALID\""
+}
+
# Start with a fresh gdb.
gdb_exit
test_list_filename_and_function
test_forward_search
test_only_end
+ test_list_invalid_args
}
# Follows tests that require execution.