aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2019-06-13 00:06:54 +0100
committerPedro Alves <palves@redhat.com>2019-06-13 00:23:25 +0100
commit6665660a411ead049daa85cac5c629d637e22044 (patch)
tree7a28a95777f94ced2128db5f8fd0067021eda951 /gdb/testsuite
parentf7e13587eaf1e2d433e21ac0a9e413a98e53652d (diff)
downloadgdb-6665660a411ead049daa85cac5c629d637e22044.zip
gdb-6665660a411ead049daa85cac5c629d637e22044.tar.gz
gdb-6665660a411ead049daa85cac5c629d637e22044.tar.bz2
Make "thread apply" use the gdb::option framework
Similarly to the "frame apply" patch, this makes the "thread apply" family of commands -- "thread apply TID", "thread apply all" and "taas" use the gdb::option framework for '-'-style options. No new options are added, but there are some user-visible changes: - Can now abbreviate and complete "-ascending" - We now have a completer for "thread apply" commands Can now complete options ("thread apply all -[TAB]"), and also, 'thread apply all COMMAND[TAB]' now does what you'd expect, by making use of the new complete_command routine. - "help" output tweaked with auto-generated option descriptions: ~~~ Usage: thread apply all [OPTION]... COMMAND Prints per-inferior thread number and target system's thread id followed by COMMAND output. By default, an error raised during the execution of COMMAND aborts "thread apply". Options: -ascending Call COMMAND for all threads in ascending order. The default is descending order. -q Disables printing the thread information. -c Print any error raised by COMMAND and continue. -s Silently ignore any errors or empty output produced by COMMAND. ~~~ The "By default ..." sentence is new as well. gdb/ChangeLog: 2019-06-13 Pedro Alves <palves@redhat.com> * thread.c: Include "cli/cli-option.h". (tp_array_compar_ascending): Global. (tp_array_compar): Delete function. (tp_array_compar_ascending, tp_array_compar_descending): New functions. (ascending_option_def, qcs_flag_option_def) (thr_qcs_flags_option_defs) (make_thread_apply_all_options_def_group) (make_thread_apply_options_def_group): New. (thread_apply_all_command): Use gdb::option::process_options. (thread_apply_command_completer) (thread_apply_all_command_completer): New. (thread_apply_command): Use gdb::option::process_options. (_initialize_thread): Delete THREAD_APPLY_FLAGS_HELP, replace it with a new THREAD_APPLY_OPTION_HELP. Use gdb::option::build_help to generate help text of "thread apply". Adjust "taas"'s help. * tid-parse.c (tid_range_parser::in_thread_range): New method. * tid-parse.h (tid_range_parser::in_thread_range): New method. gdb/testsuite/ChangeLog: 2019-06-13 Pedro Alves <palves@redhat.com> * gdb.base/options.exp (test-thread-apply): New. (top level): Call it.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.base/options.exp95
2 files changed, 97 insertions, 3 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index fbdff33..3a3a6e8 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2019-06-13 Pedro Alves <palves@redhat.com>
+ * gdb.base/options.exp (test-thread-apply): New.
+ (top level): Call it.
+
+2019-06-13 Pedro Alves <palves@redhat.com>
+
* gdb.base/options.exp (test-frame-apply): New.
(top level): Test print commands with different "frame apply"
prefixes.
diff --git a/gdb/testsuite/gdb.base/options.exp b/gdb/testsuite/gdb.base/options.exp
index 195bbb1..4570c2a 100644
--- a/gdb/testsuite/gdb.base/options.exp
+++ b/gdb/testsuite/gdb.base/options.exp
@@ -28,6 +28,8 @@
# - frame apply
# - faas
# - tfaas
+# - thread apply
+# - taas
load_lib completion-support.exp
@@ -371,6 +373,87 @@ proc_with_prefix test-frame-apply {} {
}
}
+# Basic option-machinery + "thread apply" command integration tests.
+proc_with_prefix test-thread-apply {} {
+
+ test_gdb_complete_unique "thread apply all" "thread apply all"
+ test_gdb_complete_unique "taas" "taas"
+
+ gdb_test "thread apply 1-" \
+ "inverted range"
+ test_gdb_complete_none "frame apply level 1-"
+
+ foreach cmd {
+ "thread apply all"
+ "thread apply 1"
+ "taas"
+ } {
+ test_gdb_completion_offers_commands "$cmd "
+
+ # taas is silent on command error by design. This procedure
+ # hides the difference. EXPECTED_RE is only considered when
+ # not testing with "taas".
+ proc test_invalid_cmd {cmd arg expected_re} {
+ if {$cmd != "taas"} {
+ gdb_test "$cmd$arg" $expected_re
+ } else {
+ gdb_test_no_output "$cmd$arg"
+ }
+ }
+
+ gdb_test "$cmd -" "Ambiguous option at: -"
+
+ if {$cmd != "thread apply 1"} {
+ test_gdb_complete_multiple "$cmd " "-" "" {
+ "-ascending"
+ "-c"
+ "-q"
+ "-s"
+ }
+ } else {
+ # "-ascending" only works with "all".
+ test_gdb_complete_multiple "$cmd " "-" "" {
+ "-c"
+ "-q"
+ "-s"
+ }
+ }
+
+ if {$cmd == "thread apply all" || $cmd == "taas"} {
+ set errmsg \
+ "Please specify a command at the end of 'thread apply all'"
+ } elseif {$cmd == "thread apply 1"} {
+ set errmsg \
+ "Please specify a command following the thread ID list"
+ } else {
+ error "unexpected cmd: $cmd"
+ }
+
+ with_test_prefix "no-trailing-space" {
+ gdb_test "$cmd --" $errmsg
+ test_gdb_complete_unique "$cmd --" "$cmd --"
+ }
+
+ with_test_prefix "trailing-space" {
+ gdb_test "$cmd -- " $errmsg
+ test_gdb_completion_offers_commands "$cmd -- "
+ }
+
+ # '-' is a valid TUI command.
+ test_invalid_cmd "$cmd" " -- -" \
+ "Cannot enable the TUI when output is not a terminal"
+ test_gdb_complete_unique \
+ "$cmd -- -" \
+ "$cmd -- -"
+
+ test_invalid_cmd $cmd " -foo" \
+ "Undefined command: \"-foo\". Try \"help\"\\."
+ test_gdb_complete_none "$cmd -foo"
+
+ test_gdb_completion_offers_commands "$cmd -c "
+ }
+}
+
# Miscellaneous tests.
proc_with_prefix test-misc {variant} {
global all_options
@@ -808,14 +891,17 @@ foreach_with_prefix cmd {
}
# Run the print integration tests, both as "standalone", and under
-# "frame apply". The latter checks that the "frame apply ... COMMAND"
-# commands recurse the completion machinery for COMMAND completion
-# correctly.
+# "frame/thread apply". The latter checks that the "frame/thread
+# apply ... COMMAND" commands recurse the completion machinery for
+# COMMAND completion correctly.
foreach prefix {
""
"frame apply all "
"frame apply 1 "
"frame apply level 0 "
+ "thread apply all "
+ "thread apply 1 "
+ "thread apply 1 frame apply 1 "
} {
test-print $prefix
}
@@ -832,3 +918,6 @@ test-backtrace
# Basic "frame apply" integration tests.
test-frame-apply
+
+# Basic "thread apply" integration tests.
+test-thread-apply