]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - 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
CommitLineData
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 19require {!is_remote host}
7b51bc51
DE
20
21load_lib gdb-python.exp
22
d82e5429 23require allow_python_tests
79749205 24
b4a58790 25standard_testfile
7b51bc51 26
5b362f04 27if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
7b51bc51
DE
28 return -1
29}
30
b0e16ca5 31if {![runto_main]} {
7b51bc51
DE
32 return -1
33}
34
7b51bc51
DE
35gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \
36 ".*Breakpoint.*"
37gdb_test "continue" ".*Breakpoint.*"
38
74c2c1f4 39set python_file [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py]
7b51bc51 40
72ca0410 41gdb_test_no_output "source ${python_file}" "load python file"
7b51bc51
DE
42
43gdb_test "info pretty-printer" \
44 {.*function_lookup_test.*pp-test.*struct ss.*}
45
46gdb_test "info pretty-printer global .*function" \
47 {.*function_lookup_test.*}
48
49gdb_test "info pretty-printer .* pp-test" \
50 {.*pp-test.*struct ss.*}
51
52gdb_test "print flt" " = x=<42> y=<43>" \
53 "print flt enabled #1"
54
55gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \
56 "print ss enabled #1"
57
09748966 58set num_pp 7
cafec441 59
7b51bc51 60gdb_test "disable pretty-printer" \
cafec441 61 "$num_pp printers disabled.*0 of $num_pp printers enabled"
7b51bc51 62
4e04c971 63gdb_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 67gdb_test "disable pretty-printer global" \
cafec441 68 "$num_pp printers disabled.*0 of $num_pp printers enabled"
4e04c971
DE
69
70gdb_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
74gdb_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 77gdb_test "disable pretty-printer global pp-test;.*" \
09748966 78 "[expr $num_pp - 2] printers disabled.*1 of $num_pp printers enabled"
7b51bc51
DE
79
80gdb_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
84gdb_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
88gdb_test "print flt" " = {x = 42, y = 43}" \
89 "print flt disabled"
90
91gdb_test "print ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \
92 "print ss disabled"
93
94gdb_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.
100gdb_test "enable pretty-printer global pp-test" \
09748966 101 "0 printers enabled.*2 of $num_pp printers enabled"
7b51bc51 102
4e04c971 103gdb_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 106gdb_test "enable pretty-printer global pp-test;.*s.*" \
cafec441
TT
107 "2 printers enabled.*[expr $num_pp - 1] of $num_pp printers enabled"
108
109gdb_test "enable pretty-printer global pp-test;.*" \
110 "1 printer enabled.*$num_pp of $num_pp printers enabled"
7b51bc51
DE
111
112gdb_test "info pretty-printer" \
8b12ded4
AB
113 {.*function_lookup_test.*pp-test.*struct ss.*} \
114 "info pretty-printer after re-enabling"
7b51bc51
DE
115
116gdb_test "print flt" " = x=<42> y=<43>" \
117 "print flt re-enabled"
118
119gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \
120 "print ss re-enabled"
cafec441 121
5f5dfff6
SM
122gdb_test_exact "print (enum flag_enum) (FOO_1)" \
123 { = 0x1 [FOO_1]}
cafec441 124
5f5dfff6
SM
125gdb_test_exact "print (enum flag_enum) (BAR_3)" \
126 { = 0x40 [BAR_3]}
cafec441 127
5f5dfff6
SM
128gdb_test_exact "print (enum flag_enum) (BAR_2 | FOO_2)" \
129 { = 0x22 [FOO_2 | BAR_2]}
130
131gdb_test_exact "print (enum flag_enum) (FOO_1 | FOO_2 | FOO_3)" \
132 { = 0x7 [FOO_1 | FOO_2 | FOO_3]}
133
134gdb_test_exact "print (enum flag_enum) (FOO_MASK)" \
135 { = 0x7 [FOO_1 | FOO_2 | FOO_3]}
136
137gdb_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
140gdb_test_exact "print (enum flag_enum) (0x4 + 0x8)" \
141 { = 0xc [FOO_3 | <unknown: 0x8>]}