Commit | Line | Data |
---|---|---|
42a4f53d | 1 | # Copyright (C) 2010-2019 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 DE |
34 | |
35 | if ![runto_main ] then { | |
bc6c7af4 | 36 | fail "can't run to main" |
7b51bc51 DE |
37 | return -1 |
38 | } | |
39 | ||
7b51bc51 DE |
40 | gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \ |
41 | ".*Breakpoint.*" | |
42 | gdb_test "continue" ".*Breakpoint.*" | |
43 | ||
44 | set python_file ${srcdir}/${subdir}/${testfile}.py | |
45 | ||
72ca0410 | 46 | gdb_test_no_output "source ${python_file}" "load python file" |
7b51bc51 DE |
47 | |
48 | gdb_test "info pretty-printer" \ | |
49 | {.*function_lookup_test.*pp-test.*struct ss.*} | |
50 | ||
51 | gdb_test "info pretty-printer global .*function" \ | |
52 | {.*function_lookup_test.*} | |
53 | ||
54 | gdb_test "info pretty-printer .* pp-test" \ | |
55 | {.*pp-test.*struct ss.*} | |
56 | ||
57 | gdb_test "print flt" " = x=<42> y=<43>" \ | |
58 | "print flt enabled #1" | |
59 | ||
60 | gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \ | |
61 | "print ss enabled #1" | |
62 | ||
09748966 | 63 | set num_pp 7 |
cafec441 | 64 | |
7b51bc51 | 65 | gdb_test "disable pretty-printer" \ |
cafec441 | 66 | "$num_pp printers disabled.*0 of $num_pp printers enabled" |
7b51bc51 | 67 | |
4e04c971 | 68 | gdb_test "enable pretty-printer" \ |
cafec441 | 69 | "$num_pp printers enabled.*$num_pp of $num_pp printers enabled" |
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" \ | |
cafec441 | 75 | "$num_pp printers enabled.*$num_pp of $num_pp printers enabled" |
7b51bc51 DE |
76 | |
77 | gdb_test "disable pretty-printer global lookup_function_lookup_test" \ | |
cafec441 | 78 | "1 printer disabled.*[expr $num_pp - 1] of $num_pp printers enabled" |
7b51bc51 | 79 | |
4e04c971 | 80 | gdb_test "disable pretty-printer global pp-test;.*" \ |
09748966 | 81 | "[expr $num_pp - 2] printers disabled.*1 of $num_pp printers enabled" |
7b51bc51 DE |
82 | |
83 | gdb_test "info pretty-printer global .*function" \ | |
84 | {.*function_lookup_test \[disabled\].*} | |
85 | ||
86 | gdb_test "info pretty-printer .* pp-test" \ | |
87 | {.*pp-test.*struct ss \[disabled\].*} | |
88 | ||
89 | gdb_test "print flt" " = {x = 42, y = 43}" \ | |
90 | "print flt disabled" | |
91 | ||
92 | gdb_test "print ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \ | |
93 | "print ss disabled" | |
94 | ||
95 | gdb_test "enable pretty-printer global lookup_function_lookup_test" \ | |
09748966 | 96 | "1 printer enabled.*2 of $num_pp printers enabled" |
7b51bc51 DE |
97 | |
98 | # This doesn't enable any printers because each subprinter in the collection | |
99 | # is still individually disabled. But this is still needed, to enable the | |
100 | # collection itself. | |
101 | gdb_test "enable pretty-printer global pp-test" \ | |
09748966 | 102 | "0 printers enabled.*2 of $num_pp printers enabled" |
7b51bc51 | 103 | |
4e04c971 | 104 | gdb_test "enable pretty-printer global pp-test;.*ss.*" \ |
cafec441 | 105 | "2 printers enabled.*[expr $num_pp - 3] of $num_pp printers enabled" |
7b51bc51 | 106 | |
4e04c971 | 107 | gdb_test "enable pretty-printer global pp-test;.*s.*" \ |
cafec441 TT |
108 | "2 printers enabled.*[expr $num_pp - 1] of $num_pp printers enabled" |
109 | ||
110 | gdb_test "enable pretty-printer global pp-test;.*" \ | |
111 | "1 printer enabled.*$num_pp of $num_pp printers enabled" | |
7b51bc51 DE |
112 | |
113 | gdb_test "info pretty-printer" \ | |
114 | {.*function_lookup_test.*pp-test.*struct ss.*} | |
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>]} |