Commit | Line | Data |
---|---|---|
746ebfe8 PW |
1 | # This testcase is part of GDB, the GNU debugger. |
2 | ||
3 | # Copyright 2019 Free Software Foundation, Inc. | |
4 | ||
5 | # This program is free software; you can redistribute it and/or modify | |
6 | # it under the terms of the GNU General Public License as published by | |
7 | # the Free Software Foundation; either version 3 of the License, or | |
8 | # (at your option) any later version. | |
9 | # | |
10 | # This program is distributed in the hope that it will be useful, | |
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | # GNU General Public License for more details. | |
14 | # | |
15 | # You should have received a copy of the GNU General Public License | |
16 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | ||
18 | # Test the "default-args" arguments and completion of alias command. | |
19 | ||
20 | load_lib completion-support.exp | |
21 | ||
22 | standard_testfile .c | |
23 | ||
24 | if {[build_executable "failed to prepare" $testfile $srcfile debug]} { | |
25 | return -1 | |
26 | } | |
27 | ||
28 | clean_restart $binfile | |
29 | ||
30 | # Basic/core tests using user-visible commands. | |
31 | with_test_prefix "basics" { | |
32 | # Define an alias to pretty print something. | |
33 | gdb_test "print g_s" " = {a = 1, b = 2, c = 3}" "simple print" | |
34 | gdb_test_no_output "alias PP = print -pretty --" "alias PP" | |
35 | gdb_test "help PP" "print, PP, inspect, p\r\n alias PP = print -pretty --\r\n.*" | |
36 | gdb_test "PP g_s" \ | |
37 | [multi_line \ | |
38 | " = {" \ | |
39 | " a = 1," \ | |
40 | " b = 2," \ | |
41 | " c = 3" \ | |
42 | "}"] | |
43 | ||
44 | # Define an alias of frame apply all with some default args. | |
45 | gdb_test_no_output "alias frame apply tout = frame apply all -past-entry -past-main" \ | |
46 | "alias frame apply tout" | |
47 | gdb_test "help frame apply tout" \ | |
48 | "frame apply all, frame apply tout\r\n alias frame apply tout = frame apply all -past-entry -past-main\r\n.*" | |
49 | ||
50 | # Show all aliases. | |
51 | gdb_test "help aliases" \ | |
52 | [multi_line \ | |
53 | "User-defined aliases of other commands." \ | |
54 | "" \ | |
55 | "List of commands:" \ | |
56 | "" \ | |
57 | "PP -- Print value of expression EXP." \ | |
58 | " alias PP = print -pretty --" \ | |
59 | "frame apply tout -- Apply a command to all frames." \ | |
60 | " alias frame apply tout = frame apply all -past-entry -past-main" \ | |
61 | ".*" ] \ | |
62 | "help aliases" | |
63 | } | |
64 | ||
65 | # Check errors. | |
66 | with_test_prefix "errors" { | |
67 | # Try an unknown root setting. | |
68 | gdb_test "alias wrong = xxxx yyyy -someoption" \ | |
69 | "Undefined command: \"xxxx\". Try \"help\"\\." | |
70 | ||
71 | # Try ambiguous command. | |
72 | gdb_test "alias wrong = a" \ | |
73 | "Ambiguous command \"a\":.*" "ambiguous a" | |
74 | gdb_test "alias wrong = frame a" \ | |
75 | "Ambiguous frame command \"a\":.*" "ambiguous frame a" | |
76 | } | |
77 | ||
78 | ||
79 | # Check completion. | |
80 | with_test_prefix "completion" { | |
81 | test_gdb_complete_unique \ | |
82 | "alias set pri" \ | |
83 | "alias set print" | |
84 | ||
85 | test_gdb_complete_unique \ | |
86 | "alias set print items = set pri" \ | |
87 | "alias set print items = set print" | |
88 | ||
89 | test_gdb_complete_unique \ | |
90 | "alias set print items = set print ele" \ | |
91 | "alias set print items = set print elements" | |
92 | ||
93 | test_gdb_complete_unique \ | |
94 | "alias btfu = backt" \ | |
95 | "alias btfu = backtrace" | |
96 | ||
97 | test_gdb_complete_unique \ | |
98 | "alias btfu = backtrace -fu" \ | |
99 | "alias btfu = backtrace -full" | |
100 | ||
101 | test_gdb_complete_unique \ | |
102 | "alias btfu = backtrace -full -past-e" \ | |
103 | "alias btfu = backtrace -full -past-entry" | |
104 | ||
105 | gdb_test_no_output "alias btfu = backtrace -full -past-entry" \ | |
106 | "alias btfu" | |
107 | ||
108 | } | |
109 | ||
110 | # Check alias of alias. | |
111 | with_test_prefix "alias_of_alias" { | |
112 | # Verify we can alias an alias that has no default args. | |
113 | # We allow an alias of an alias, to be backward compatible with | |
114 | # GDB 9.1 . | |
115 | gdb_test_no_output "alias aaa = backtrace" | |
116 | gdb_test_no_output "alias bbb = backtrace" | |
117 | ||
118 | # Verify that we cannot define an alias of an alias that has default args. | |
119 | gdb_test_no_output "alias ccc = backtrace -full" | |
120 | gdb_test "alias ddd = ccc" \ | |
121 | "Cannot define an alias of an alias that has default args" | |
122 | ||
123 | } |