aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2019-06-13 00:06:52 +0100
committerPedro Alves <palves@redhat.com>2019-06-13 00:08:09 +0100
commitb9a3f8429b012b753e30a4222bd8e4cbba019fad (patch)
tree516f7f5df8e8313958056dc96dece16a0e0009a5 /gdb/testsuite
parent3844e605e61777555aed09ab8ce88db2da95bc0b (diff)
downloadfsf-binutils-gdb-b9a3f8429b012b753e30a4222bd8e4cbba019fad.zip
fsf-binutils-gdb-b9a3f8429b012b753e30a4222bd8e4cbba019fad.tar.gz
fsf-binutils-gdb-b9a3f8429b012b753e30a4222bd8e4cbba019fad.tar.bz2
Fix TID parser bug
I noticed this inconsistency in the error messages below: (gdb) print --1 Left operand of assignment is not an lvalue. (gdb) thread apply 1 print --1 Thread 1 (Thread 0x7ffff7fb6740 (LWP 17805)): inverted range The "inverted range" error happens because get_number_trailer returns 0 to indicate error, but number_or_range_parser::get_number is not checking for that. I tried detected the error there, but that doesn't work because number_of_range_parser is used in places that _do_ want to legitimately handle 0. IMO we should fix get_number_trailer's interface or use something else when we want to parse 0 too. I've decided to fix it in a different way, similarly to how number_or_range_parser::finished was changed in commit 529c08b25ec7 ("Add helper functions parse_flags and parse_flags_qcs"). Seems like a good change, even if we tweaked number_or_range_parser::get_number, as it simplifies thread_apply_command and makes them consistent with number_or_range_parser::finished(). We now get the same error message in both cases: (gdb) print --1 Left operand of assignment is not an lvalue. (gdb) thread apply 1 print --1 Thread 1 (Thread 0x7ffff7fb6740 (LWP 17805)): Left operand of assignment is not an lvalue. gdb/ChangeLog: 2019-06-13 Pedro Alves <palves@redhat.com> * thread.c (thread_apply_command): Adjust TID parsing. * tid-parse.c (tid_range_parser::finished): Ensure parsing end is detected before end of string. (tid_is_in_list): Error out if LIST is invalid. gdb/testsuite/ChangeLog: 2019-06-13 Pedro Alves <palves@redhat.com> * gdb.multi/tids.exp: Adjust expected output. Add "thread apply 1 foo --1" test.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.multi/tids.exp16
2 files changed, 19 insertions, 2 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 1a07266..5590bf9 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2019-06-13 Pedro Alves <palves@redhat.com>
+
+ * gdb.multi/tids.exp: Adjust expected output. Add "thread apply 1
+ foo --1" test.
+
2019-06-11 Bernhard Heckel <bernhard.heckel@intel.com>
* gdb.fortran/block-data.f: New.
diff --git a/gdb/testsuite/gdb.multi/tids.exp b/gdb/testsuite/gdb.multi/tids.exp
index 617a1b0..3b0e1c1 100644
--- a/gdb/testsuite/gdb.multi/tids.exp
+++ b/gdb/testsuite/gdb.multi/tids.exp
@@ -350,8 +350,13 @@ with_test_prefix "two inferiors" {
thr_apply_info_thr_error "${prefix}1-" "inverted range"
thr_apply_info_thr_error "${prefix}2-1" "inverted range"
thr_apply_info_thr_error "${prefix}2-\$one" "inverted range"
- thr_apply_info_thr_error "${prefix}-1" "negative value"
- thr_apply_info_thr_error "${prefix}-\$one" "negative value"
+ if {$prefix == ""} {
+ thr_apply_info_thr_error "${prefix}-1" "Invalid thread ID: -1"
+ thr_apply_info_thr_error "${prefix}-\$one" "Invalid thread ID: -\\\$one"
+ } else {
+ thr_apply_info_thr_error "${prefix}-1" "negative value"
+ thr_apply_info_thr_error "${prefix}-\$one" "negative value"
+ }
thr_apply_info_thr_error "${prefix}\$minus_one" \
"negative value: ${prefix_re}\\\$minus_one"
@@ -374,6 +379,13 @@ with_test_prefix "two inferiors" {
gdb_test "thread apply 1.*" $output
}
+ # Check that thread ID list parsing stops at the non-number token
+ # "foo" in a corner case where the "foo" is followed by hyphens.
+ # In this corner case, GDB used to skip past "foo", and then parse
+ # "--1" as a tid range for the current inferior.
+ gdb_test "thread apply 1 foo --1" \
+ "Undefined command: \"foo\". Try \"help\"\\."
+
# Check that we do parse the inferior number and don't confuse it.
gdb_test "info threads 3.1" \
"No threads match '3.1'\."