aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-09-05 12:09:43 -0600
committerTom Tromey <tromey@adacore.com>2025-02-20 07:50:55 -0700
commitbe6adf5b7597cb2eb1e7f07fbfd766a9d6ac42bb (patch)
tree1502444f7db717f0db46642ce28d832e2a202ec8 /gdb/testsuite
parent904d3768c88a6591204969826f47d706f6da504a (diff)
downloadbinutils-be6adf5b7597cb2eb1e7f07fbfd766a9d6ac42bb.zip
binutils-be6adf5b7597cb2eb1e7f07fbfd766a9d6ac42bb.tar.gz
binutils-be6adf5b7597cb2eb1e7f07fbfd766a9d6ac42bb.tar.bz2
Handle optional lines correctly in gdb.ada/complete.exp
While working on another series, I discovered that the existing code in gdb.ada/complete.exp that conditionally accepts a completion does not work correctly. The code assumes that wrapping a line in "(...)?" will make the entire line optional, but really this will only match a blank line. Meanwhile, I needed this same patch for a second series I'm working on, so I've pulled this out. As it only affects Ada, I am going to check it in.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/gdb.ada/complete.exp57
1 files changed, 37 insertions, 20 deletions
diff --git a/gdb/testsuite/gdb.ada/complete.exp b/gdb/testsuite/gdb.ada/complete.exp
index 6263c4e..70d4945 100644
--- a/gdb/testsuite/gdb.ada/complete.exp
+++ b/gdb/testsuite/gdb.ada/complete.exp
@@ -30,6 +30,17 @@ runto "foo.adb:$bp_location"
set eol "\r\n"
+# Like multi_line, but if a line is optional (like "(mumble)?"), then
+# insert the \r\n into the optional part.
+proc multi_line_with_optional {args} {
+ set result ""
+ foreach line $args {
+ append result [regsub -- "(\\)\\?)?$" $line "\r\n\\1"]
+ }
+ # Remove the final \r\n.
+ return [string range $result 0 end-2]
+}
+
# A convenience function that verifies that the "complete EXPR" command
# returns the EXPECTED_OUTPUT.
@@ -155,29 +166,35 @@ test_gdb_complete "external_ident" \
# Complete on the name of package.
test_gdb_complete "pck" \
- [multi_line "(p pck\\.ad\[sb\])?" \
- "(p pck\\.ad\[sb\])?" \
- "p pck.ambiguous_func" \
- "p pck.external_identical_one" \
- "p pck.inner.inside_variable" \
- "p pck.internal_capitalized" \
- "p pck.local_identical_one" \
- "p pck.local_identical_two" \
- "p pck.my_global_variable" \
- "p pck.proc" ]
+ [multi_line_with_optional \
+ "(p pck)?" \
+ "(p pck\\.ad\[sb\])?" \
+ "(p pck\\.ad\[sb\])?" \
+ "p pck.ambiguous_func" \
+ "p pck.external_identical_one" \
+ "(p pck.inner)?" \
+ "p pck.inner.inside_variable" \
+ "p pck.internal_capitalized" \
+ "p pck.local_identical_one" \
+ "p pck.local_identical_two" \
+ "p pck.my_global_variable" \
+ "p pck.proc" ]
# Complete on the name of a package followed by a dot:
test_gdb_complete "pck." \
- [multi_line "(p pck\\.ad\[sb\])?" \
- "(p pck\\.ad\[sb\])?" \
- "p pck.ambiguous_func" \
- "p pck.external_identical_one" \
- "p pck.inner.inside_variable" \
- "p pck.internal_capitalized" \
- "p pck.local_identical_one" \
- "p pck.local_identical_two" \
- "p pck.my_global_variable" \
- "p pck.proc" ]
+ [multi_line_with_optional \
+ "(p pck\\.)?" \
+ "(p pck\\.ad\[sb\])?" \
+ "(p pck\\.ad\[sb\])?" \
+ "p pck.ambiguous_func" \
+ "p pck.external_identical_one" \
+ "(p pck.inner)?" \
+ "p pck.inner.inside_variable" \
+ "p pck.internal_capitalized" \
+ "p pck.local_identical_one" \
+ "p pck.local_identical_two" \
+ "p pck.my_global_variable" \
+ "p pck.proc" ]
# Complete a mangled symbol name, but using the '<...>' notation.
test_gdb_complete "<pck__my" \