]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.python/py-pp-maint.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.python / py-pp-maint.exp
1 # Copyright (C) 2010-2024 Free Software Foundation, Inc.
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
19 require {!is_remote host}
20
21 load_lib gdb-python.exp
22
23 require allow_python_tests
24
25 standard_testfile
26
27 if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
28 return -1
29 }
30
31 if {![runto_main]} {
32 return -1
33 }
34
35 gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \
36 ".*Breakpoint.*"
37 gdb_test "continue" ".*Breakpoint.*"
38
39 set python_file [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
40
41 gdb_test_no_output "source ${python_file}" "load python file"
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
58 set num_pp 7
59
60 gdb_test "disable pretty-printer" \
61 "$num_pp printers disabled.*0 of $num_pp printers enabled"
62
63 gdb_test "enable pretty-printer" \
64 "$num_pp printers enabled.*$num_pp of $num_pp printers enabled" \
65 "first enable of all pretty printers"
66
67 gdb_test "disable pretty-printer global" \
68 "$num_pp printers disabled.*0 of $num_pp printers enabled"
69
70 gdb_test "enable pretty-printer" \
71 "$num_pp printers enabled.*$num_pp of $num_pp printers enabled" \
72 "second enable of all pretty printers"
73
74 gdb_test "disable pretty-printer global lookup_function_lookup_test" \
75 "1 printer disabled.*[expr $num_pp - 1] of $num_pp printers enabled"
76
77 gdb_test "disable pretty-printer global pp-test;.*" \
78 "[expr $num_pp - 2] printers disabled.*1 of $num_pp printers enabled"
79
80 gdb_test "info pretty-printer global .*function" \
81 {.*function_lookup_test \[disabled\].*} \
82 "info pretty-printer for function, pretty-printer is disabled"
83
84 gdb_test "info pretty-printer .* pp-test" \
85 {.*pp-test.*struct ss \[disabled\].*} \
86 "info pretty-printer for pp-test, pretty-printer is disabled"
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" \
95 "1 printer enabled.*2 of $num_pp printers enabled"
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" \
101 "0 printers enabled.*2 of $num_pp printers enabled"
102
103 gdb_test "enable pretty-printer global pp-test;.*ss.*" \
104 "2 printers enabled.*[expr $num_pp - 3] of $num_pp printers enabled"
105
106 gdb_test "enable pretty-printer global pp-test;.*s.*" \
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"
111
112 gdb_test "info pretty-printer" \
113 {.*function_lookup_test.*pp-test.*struct ss.*} \
114 "info pretty-printer after re-enabling"
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"
121
122 gdb_test_exact "print (enum flag_enum) (FOO_1)" \
123 { = 0x1 [FOO_1]}
124
125 gdb_test_exact "print (enum flag_enum) (BAR_3)" \
126 { = 0x40 [BAR_3]}
127
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>]}