]>
Commit | Line | Data |
---|---|---|
213516ef | 1 | # Copyright (C) 2010-2023 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 | ||
7b51bc51 DE |
19 | if [is_remote host] { |
20 | untested "py-pp-maint.exp can only be run locally" | |
21 | return -1 | |
22 | } | |
23 | ||
24 | load_lib gdb-python.exp | |
25 | ||
b4a58790 | 26 | standard_testfile |
7b51bc51 | 27 | |
5b362f04 | 28 | if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { |
7b51bc51 DE |
29 | return -1 |
30 | } | |
31 | ||
b4a58790 TT |
32 | # Skip all tests if Python scripting is not enabled. |
33 | if { [skip_python_tests] } { continue } | |
7b51bc51 | 34 | |
b0e16ca5 | 35 | if {![runto_main]} { |
7b51bc51 DE |
36 | return -1 |
37 | } | |
38 | ||
7b51bc51 DE |
39 | gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \ |
40 | ".*Breakpoint.*" | |
41 | gdb_test "continue" ".*Breakpoint.*" | |
42 | ||
74c2c1f4 | 43 | set python_file [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py] |
7b51bc51 | 44 | |
72ca0410 | 45 | gdb_test_no_output "source ${python_file}" "load python file" |
7b51bc51 DE |
46 | |
47 | gdb_test "info pretty-printer" \ | |
48 | {.*function_lookup_test.*pp-test.*struct ss.*} | |
49 | ||
50 | gdb_test "info pretty-printer global .*function" \ | |
51 | {.*function_lookup_test.*} | |
52 | ||
53 | gdb_test "info pretty-printer .* pp-test" \ | |
54 | {.*pp-test.*struct ss.*} | |
55 | ||
56 | gdb_test "print flt" " = x=<42> y=<43>" \ | |
57 | "print flt enabled #1" | |
58 | ||
59 | gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \ | |
60 | "print ss enabled #1" | |
61 | ||
09748966 | 62 | set num_pp 7 |
cafec441 | 63 | |
7b51bc51 | 64 | gdb_test "disable pretty-printer" \ |
cafec441 | 65 | "$num_pp printers disabled.*0 of $num_pp printers enabled" |
7b51bc51 | 66 | |
4e04c971 | 67 | gdb_test "enable pretty-printer" \ |
8b12ded4 AB |
68 | "$num_pp printers enabled.*$num_pp of $num_pp printers enabled" \ |
69 | "first enable of all pretty printers" | |
4e04c971 | 70 | |
7b51bc51 | 71 | gdb_test "disable pretty-printer global" \ |
cafec441 | 72 | "$num_pp printers disabled.*0 of $num_pp printers enabled" |
4e04c971 DE |
73 | |
74 | gdb_test "enable pretty-printer" \ | |
8b12ded4 AB |
75 | "$num_pp printers enabled.*$num_pp of $num_pp printers enabled" \ |
76 | "second enable of all pretty printers" | |
7b51bc51 DE |
77 | |
78 | gdb_test "disable pretty-printer global lookup_function_lookup_test" \ | |
cafec441 | 79 | "1 printer disabled.*[expr $num_pp - 1] of $num_pp printers enabled" |
7b51bc51 | 80 | |
4e04c971 | 81 | gdb_test "disable pretty-printer global pp-test;.*" \ |
09748966 | 82 | "[expr $num_pp - 2] printers disabled.*1 of $num_pp printers enabled" |
7b51bc51 DE |
83 | |
84 | gdb_test "info pretty-printer global .*function" \ | |
8b12ded4 AB |
85 | {.*function_lookup_test \[disabled\].*} \ |
86 | "info pretty-printer for function, pretty-printer is disabled" | |
7b51bc51 DE |
87 | |
88 | gdb_test "info pretty-printer .* pp-test" \ | |
8b12ded4 AB |
89 | {.*pp-test.*struct ss \[disabled\].*} \ |
90 | "info pretty-printer for pp-test, pretty-printer is disabled" | |
7b51bc51 DE |
91 | |
92 | gdb_test "print flt" " = {x = 42, y = 43}" \ | |
93 | "print flt disabled" | |
94 | ||
95 | gdb_test "print ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \ | |
96 | "print ss disabled" | |
97 | ||
98 | gdb_test "enable pretty-printer global lookup_function_lookup_test" \ | |
09748966 | 99 | "1 printer enabled.*2 of $num_pp printers enabled" |
7b51bc51 DE |
100 | |
101 | # This doesn't enable any printers because each subprinter in the collection | |
102 | # is still individually disabled. But this is still needed, to enable the | |
103 | # collection itself. | |
104 | gdb_test "enable pretty-printer global pp-test" \ | |
09748966 | 105 | "0 printers enabled.*2 of $num_pp printers enabled" |
7b51bc51 | 106 | |
4e04c971 | 107 | gdb_test "enable pretty-printer global pp-test;.*ss.*" \ |
cafec441 | 108 | "2 printers enabled.*[expr $num_pp - 3] of $num_pp printers enabled" |
7b51bc51 | 109 | |
4e04c971 | 110 | gdb_test "enable pretty-printer global pp-test;.*s.*" \ |
cafec441 TT |
111 | "2 printers enabled.*[expr $num_pp - 1] of $num_pp printers enabled" |
112 | ||
113 | gdb_test "enable pretty-printer global pp-test;.*" \ | |
114 | "1 printer enabled.*$num_pp of $num_pp printers enabled" | |
7b51bc51 DE |
115 | |
116 | gdb_test "info pretty-printer" \ | |
8b12ded4 AB |
117 | {.*function_lookup_test.*pp-test.*struct ss.*} \ |
118 | "info pretty-printer after re-enabling" | |
7b51bc51 DE |
119 | |
120 | gdb_test "print flt" " = x=<42> y=<43>" \ | |
121 | "print flt re-enabled" | |
122 | ||
123 | gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \ | |
124 | "print ss re-enabled" | |
cafec441 | 125 | |
5f5dfff6 SM |
126 | gdb_test_exact "print (enum flag_enum) (FOO_1)" \ |
127 | { = 0x1 [FOO_1]} | |
cafec441 | 128 | |
5f5dfff6 SM |
129 | gdb_test_exact "print (enum flag_enum) (BAR_3)" \ |
130 | { = 0x40 [BAR_3]} | |
cafec441 | 131 | |
5f5dfff6 SM |
132 | gdb_test_exact "print (enum flag_enum) (BAR_2 | FOO_2)" \ |
133 | { = 0x22 [FOO_2 | BAR_2]} | |
134 | ||
135 | gdb_test_exact "print (enum flag_enum) (FOO_1 | FOO_2 | FOO_3)" \ | |
136 | { = 0x7 [FOO_1 | FOO_2 | FOO_3]} | |
137 | ||
138 | gdb_test_exact "print (enum flag_enum) (FOO_MASK)" \ | |
139 | { = 0x7 [FOO_1 | FOO_2 | FOO_3]} | |
140 | ||
141 | gdb_test_exact "print (enum flag_enum) (FOO_MASK | (BAR_MASK & ~BAR_2))" \ | |
142 | { = 0x57 [FOO_1 | FOO_2 | FOO_3 | BAR_1 | BAR_3]} | |
143 | ||
144 | gdb_test_exact "print (enum flag_enum) (0x4 + 0x8)" \ | |
145 | { = 0xc [FOO_3 | <unknown: 0x8>]} |