]>
Commit | Line | Data |
---|---|---|
1d506c26 | 1 | # Copyright (C) 2010-2024 Free Software Foundation, Inc. |
7b51bc51 DE |
2 | |
3 | # This program is free software; you can redistribute it and/or modify | |
4 | # it under the terms of the GNU General Public License as published by | |
5 | # the Free Software Foundation; either version 3 of the License, or | |
6 | # (at your option) any later version. | |
7 | # | |
8 | # This program is distributed in the hope that it will be useful, | |
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | # GNU General Public License for more details. | |
12 | # | |
13 | # You should have received a copy of the GNU General Public License | |
14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | # This file is part of the GDB testsuite. It tests Python-based | |
17 | # pretty-printing for the CLI. | |
18 | ||
52c0551e | 19 | require {!is_remote host} |
7b51bc51 DE |
20 | |
21 | load_lib gdb-python.exp | |
22 | ||
d82e5429 | 23 | require allow_python_tests |
79749205 | 24 | |
b4a58790 | 25 | standard_testfile |
7b51bc51 | 26 | |
5b362f04 | 27 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { |
7b51bc51 DE |
28 | return -1 |
29 | } | |
30 | ||
b0e16ca5 | 31 | if {![runto_main]} { |
7b51bc51 DE |
32 | return -1 |
33 | } | |
34 | ||
7b51bc51 DE |
35 | gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \ |
36 | ".*Breakpoint.*" | |
37 | gdb_test "continue" ".*Breakpoint.*" | |
38 | ||
74c2c1f4 | 39 | set python_file [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py] |
7b51bc51 | 40 | |
72ca0410 | 41 | gdb_test_no_output "source ${python_file}" "load python file" |
7b51bc51 DE |
42 | |
43 | gdb_test "info pretty-printer" \ | |
44 | {.*function_lookup_test.*pp-test.*struct ss.*} | |
45 | ||
46 | gdb_test "info pretty-printer global .*function" \ | |
47 | {.*function_lookup_test.*} | |
48 | ||
49 | gdb_test "info pretty-printer .* pp-test" \ | |
50 | {.*pp-test.*struct ss.*} | |
51 | ||
52 | gdb_test "print flt" " = x=<42> y=<43>" \ | |
53 | "print flt enabled #1" | |
54 | ||
55 | gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \ | |
56 | "print ss enabled #1" | |
57 | ||
09748966 | 58 | set num_pp 7 |
cafec441 | 59 | |
7b51bc51 | 60 | gdb_test "disable pretty-printer" \ |
cafec441 | 61 | "$num_pp printers disabled.*0 of $num_pp printers enabled" |
7b51bc51 | 62 | |
4e04c971 | 63 | gdb_test "enable pretty-printer" \ |
8b12ded4 AB |
64 | "$num_pp printers enabled.*$num_pp of $num_pp printers enabled" \ |
65 | "first enable of all pretty printers" | |
4e04c971 | 66 | |
7b51bc51 | 67 | gdb_test "disable pretty-printer global" \ |
cafec441 | 68 | "$num_pp printers disabled.*0 of $num_pp printers enabled" |
4e04c971 DE |
69 | |
70 | gdb_test "enable pretty-printer" \ | |
8b12ded4 AB |
71 | "$num_pp printers enabled.*$num_pp of $num_pp printers enabled" \ |
72 | "second enable of all pretty printers" | |
7b51bc51 DE |
73 | |
74 | gdb_test "disable pretty-printer global lookup_function_lookup_test" \ | |
cafec441 | 75 | "1 printer disabled.*[expr $num_pp - 1] of $num_pp printers enabled" |
7b51bc51 | 76 | |
4e04c971 | 77 | gdb_test "disable pretty-printer global pp-test;.*" \ |
09748966 | 78 | "[expr $num_pp - 2] printers disabled.*1 of $num_pp printers enabled" |
7b51bc51 DE |
79 | |
80 | gdb_test "info pretty-printer global .*function" \ | |
8b12ded4 AB |
81 | {.*function_lookup_test \[disabled\].*} \ |
82 | "info pretty-printer for function, pretty-printer is disabled" | |
7b51bc51 DE |
83 | |
84 | gdb_test "info pretty-printer .* pp-test" \ | |
8b12ded4 AB |
85 | {.*pp-test.*struct ss \[disabled\].*} \ |
86 | "info pretty-printer for pp-test, pretty-printer is disabled" | |
7b51bc51 DE |
87 | |
88 | gdb_test "print flt" " = {x = 42, y = 43}" \ | |
89 | "print flt disabled" | |
90 | ||
91 | gdb_test "print ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \ | |
92 | "print ss disabled" | |
93 | ||
94 | gdb_test "enable pretty-printer global lookup_function_lookup_test" \ | |
09748966 | 95 | "1 printer enabled.*2 of $num_pp printers enabled" |
7b51bc51 DE |
96 | |
97 | # This doesn't enable any printers because each subprinter in the collection | |
98 | # is still individually disabled. But this is still needed, to enable the | |
99 | # collection itself. | |
100 | gdb_test "enable pretty-printer global pp-test" \ | |
09748966 | 101 | "0 printers enabled.*2 of $num_pp printers enabled" |
7b51bc51 | 102 | |
4e04c971 | 103 | gdb_test "enable pretty-printer global pp-test;.*ss.*" \ |
cafec441 | 104 | "2 printers enabled.*[expr $num_pp - 3] of $num_pp printers enabled" |
7b51bc51 | 105 | |
4e04c971 | 106 | gdb_test "enable pretty-printer global pp-test;.*s.*" \ |
cafec441 TT |
107 | "2 printers enabled.*[expr $num_pp - 1] of $num_pp printers enabled" |
108 | ||
109 | gdb_test "enable pretty-printer global pp-test;.*" \ | |
110 | "1 printer enabled.*$num_pp of $num_pp printers enabled" | |
7b51bc51 DE |
111 | |
112 | gdb_test "info pretty-printer" \ | |
8b12ded4 AB |
113 | {.*function_lookup_test.*pp-test.*struct ss.*} \ |
114 | "info pretty-printer after re-enabling" | |
7b51bc51 DE |
115 | |
116 | gdb_test "print flt" " = x=<42> y=<43>" \ | |
117 | "print flt re-enabled" | |
118 | ||
119 | gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \ | |
120 | "print ss re-enabled" | |
cafec441 | 121 | |
5f5dfff6 SM |
122 | gdb_test_exact "print (enum flag_enum) (FOO_1)" \ |
123 | { = 0x1 [FOO_1]} | |
cafec441 | 124 | |
5f5dfff6 SM |
125 | gdb_test_exact "print (enum flag_enum) (BAR_3)" \ |
126 | { = 0x40 [BAR_3]} | |
cafec441 | 127 | |
5f5dfff6 SM |
128 | gdb_test_exact "print (enum flag_enum) (BAR_2 | FOO_2)" \ |
129 | { = 0x22 [FOO_2 | BAR_2]} | |
130 | ||
131 | gdb_test_exact "print (enum flag_enum) (FOO_1 | FOO_2 | FOO_3)" \ | |
132 | { = 0x7 [FOO_1 | FOO_2 | FOO_3]} | |
133 | ||
134 | gdb_test_exact "print (enum flag_enum) (FOO_MASK)" \ | |
135 | { = 0x7 [FOO_1 | FOO_2 | FOO_3]} | |
136 | ||
137 | gdb_test_exact "print (enum flag_enum) (FOO_MASK | (BAR_MASK & ~BAR_2))" \ | |
138 | { = 0x57 [FOO_1 | FOO_2 | FOO_3 | BAR_1 | BAR_3]} | |
139 | ||
140 | gdb_test_exact "print (enum flag_enum) (0x4 + 0x8)" \ | |
141 | { = 0xc [FOO_3 | <unknown: 0x8>]} |