OLD | NEW |
1 # Copyright (C) 2010-2012 Free Software Foundation, Inc. | 1 # Copyright (C) 2010-2012 Free Software Foundation, Inc. |
2 | 2 |
3 # This program is free software; you can redistribute it and/or modify | 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 | 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 | 5 # the Free Software Foundation; either version 3 of the License, or |
6 # (at your option) any later version. | 6 # (at your option) any later version. |
7 # | 7 # |
8 # This program is distributed in the hope that it will be useful, | 8 # This program is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
12 # | 12 # |
13 # You should have received a copy of the GNU General Public License | 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/>. | 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | 15 |
16 # This file is part of the GDB testsuite. It tests Python-based | 16 # This file is part of the GDB testsuite. It tests Python-based |
17 # pretty-printing for the CLI. | 17 # pretty-printing for the CLI. |
18 | 18 |
19 if $tracelevel then { | |
20 strace $tracelevel | |
21 } | |
22 | |
23 if [is_remote host] { | 19 if [is_remote host] { |
24 untested "py-pp-maint.exp can only be run locally" | 20 untested "py-pp-maint.exp can only be run locally" |
25 return -1 | 21 return -1 |
26 } | 22 } |
27 | 23 |
28 load_lib gdb-python.exp | 24 load_lib gdb-python.exp |
29 | 25 |
30 set testfile "py-pp-maint" | 26 standard_testfile |
31 set srcfile ${testfile}.c | |
32 set binfile ${objdir}/${subdir}/${testfile} | |
33 | 27 |
34 # Start with a fresh gdb. | 28 if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} { |
35 gdb_exit | 29 return -1 |
36 gdb_start | 30 } |
37 | 31 |
38 # Skip all tests if Python scripting is not enabled. | 32 # Skip all tests if Python scripting is not enabled. |
39 if { [skip_python_tests] } { continue } | 33 if { [skip_python_tests] } { continue } |
40 | 34 |
41 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debu
g"] != "" } { | |
42 untested "Couldn't compile ${srcfile}" | |
43 return -1 | |
44 } | |
45 | |
46 gdb_reinitialize_dir $srcdir/$subdir | |
47 gdb_load ${binfile} | |
48 | |
49 if ![runto_main ] then { | 35 if ![runto_main ] then { |
50 fail "Can't run to main" | 36 fail "Can't run to main" |
51 return -1 | 37 return -1 |
52 } | 38 } |
53 | 39 |
54 gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \ | 40 gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \ |
55 ".*Breakpoint.*" | 41 ".*Breakpoint.*" |
56 gdb_test "continue" ".*Breakpoint.*" | 42 gdb_test "continue" ".*Breakpoint.*" |
57 | 43 |
58 set python_file ${srcdir}/${subdir}/${testfile}.py | 44 set python_file ${srcdir}/${subdir}/${testfile}.py |
59 | 45 |
60 gdb_test_no_output "python execfile ('${python_file}')" "" | 46 gdb_test_no_output "python execfile ('${python_file}')" "" |
61 | 47 |
62 gdb_test "info pretty-printer" \ | 48 gdb_test "info pretty-printer" \ |
63 {.*function_lookup_test.*pp-test.*struct ss.*} | 49 {.*function_lookup_test.*pp-test.*struct ss.*} |
64 | 50 |
65 gdb_test "info pretty-printer global .*function" \ | 51 gdb_test "info pretty-printer global .*function" \ |
66 {.*function_lookup_test.*} | 52 {.*function_lookup_test.*} |
67 | 53 |
68 gdb_test "info pretty-printer .* pp-test" \ | 54 gdb_test "info pretty-printer .* pp-test" \ |
69 {.*pp-test.*struct ss.*} | 55 {.*pp-test.*struct ss.*} |
70 | 56 |
71 gdb_test "print flt" " = x=<42> y=<43>" \ | 57 gdb_test "print flt" " = x=<42> y=<43>" \ |
72 "print flt enabled #1" | 58 "print flt enabled #1" |
73 | 59 |
74 gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \ | 60 gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \ |
75 "print ss enabled #1" | 61 "print ss enabled #1" |
76 | 62 |
| 63 set num_pp 6 |
| 64 |
77 gdb_test "disable pretty-printer" \ | 65 gdb_test "disable pretty-printer" \ |
78 "5 printers disabled.*0 of 5 printers enabled" | 66 "$num_pp printers disabled.*0 of $num_pp printers enabled" |
79 | 67 |
80 gdb_test "enable pretty-printer" \ | 68 gdb_test "enable pretty-printer" \ |
81 "5 printers enabled.*5 of 5 printers enabled" | 69 "$num_pp printers enabled.*$num_pp of $num_pp printers enabled" |
82 | 70 |
83 gdb_test "disable pretty-printer global" \ | 71 gdb_test "disable pretty-printer global" \ |
84 "5 printers disabled.*0 of 5 printers enabled" | 72 "$num_pp printers disabled.*0 of $num_pp printers enabled" |
85 | 73 |
86 gdb_test "enable pretty-printer" \ | 74 gdb_test "enable pretty-printer" \ |
87 "5 printers enabled.*5 of 5 printers enabled" | 75 "$num_pp printers enabled.*$num_pp of $num_pp printers enabled" |
88 | 76 |
89 gdb_test "disable pretty-printer global lookup_function_lookup_test" \ | 77 gdb_test "disable pretty-printer global lookup_function_lookup_test" \ |
90 "1 printer disabled.*4 of 5 printers enabled" | 78 "1 printer disabled.*[expr $num_pp - 1] of $num_pp printers enabled" |
91 | 79 |
92 gdb_test "disable pretty-printer global pp-test;.*" \ | 80 gdb_test "disable pretty-printer global pp-test;.*" \ |
93 "4 printers disabled.*0 of 5 printers enabled" | 81 "[expr $num_pp - 1] printers disabled.*0 of $num_pp printers enabled" |
94 | 82 |
95 gdb_test "info pretty-printer global .*function" \ | 83 gdb_test "info pretty-printer global .*function" \ |
96 {.*function_lookup_test \[disabled\].*} | 84 {.*function_lookup_test \[disabled\].*} |
97 | 85 |
98 gdb_test "info pretty-printer .* pp-test" \ | 86 gdb_test "info pretty-printer .* pp-test" \ |
99 {.*pp-test.*struct ss \[disabled\].*} | 87 {.*pp-test.*struct ss \[disabled\].*} |
100 | 88 |
101 gdb_test "print flt" " = {x = 42, y = 43}" \ | 89 gdb_test "print flt" " = {x = 42, y = 43}" \ |
102 "print flt disabled" | 90 "print flt disabled" |
103 | 91 |
104 gdb_test "print ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \ | 92 gdb_test "print ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \ |
105 "print ss disabled" | 93 "print ss disabled" |
106 | 94 |
107 gdb_test "enable pretty-printer global lookup_function_lookup_test" \ | 95 gdb_test "enable pretty-printer global lookup_function_lookup_test" \ |
108 "1 printer enabled.*1 of 5 printers enabled" | 96 "1 printer enabled.*1 of $num_pp printers enabled" |
109 | 97 |
110 # This doesn't enable any printers because each subprinter in the collection | 98 # This doesn't enable any printers because each subprinter in the collection |
111 # is still individually disabled. But this is still needed, to enable the | 99 # is still individually disabled. But this is still needed, to enable the |
112 # collection itself. | 100 # collection itself. |
113 gdb_test "enable pretty-printer global pp-test" \ | 101 gdb_test "enable pretty-printer global pp-test" \ |
114 "0 printers enabled.*1 of 5 printers enabled" | 102 "0 printers enabled.*1 of $num_pp printers enabled" |
115 | 103 |
116 gdb_test "enable pretty-printer global pp-test;.*ss.*" \ | 104 gdb_test "enable pretty-printer global pp-test;.*ss.*" \ |
117 "2 printers enabled.*3 of 5 printers enabled" | 105 "2 printers enabled.*[expr $num_pp - 3] of $num_pp printers enabled" |
118 | 106 |
119 gdb_test "enable pretty-printer global pp-test;.*s.*" \ | 107 gdb_test "enable pretty-printer global pp-test;.*s.*" \ |
120 "2 printers enabled.*5 of 5 printers enabled" | 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" |
121 | 112 |
122 gdb_test "info pretty-printer" \ | 113 gdb_test "info pretty-printer" \ |
123 {.*function_lookup_test.*pp-test.*struct ss.*} | 114 {.*function_lookup_test.*pp-test.*struct ss.*} |
124 | 115 |
125 gdb_test "print flt" " = x=<42> y=<43>" \ | 116 gdb_test "print flt" " = x=<42> y=<43>" \ |
126 "print flt re-enabled" | 117 "print flt re-enabled" |
127 | 118 |
128 gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \ | 119 gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \ |
129 "print ss re-enabled" | 120 "print ss re-enabled" |
| 121 |
| 122 gdb_test "print (enum flag_enum) (FLAG_1)" \ |
| 123 " = 0x1 .FLAG_1." \ |
| 124 "print FLAG_1" |
| 125 |
| 126 gdb_test "print (enum flag_enum) (FLAG_1 | FLAG_3)" \ |
| 127 " = 0x5 .FLAG_1 | FLAG_3." \ |
| 128 "print FLAG_1 | FLAG_3" |
| 129 |
| 130 gdb_test "print (enum flag_enum) (4 + 8)" \ |
| 131 " = 0xc .FLAG_1 | <unknown: 0x8>." \ |
| 132 "print FLAG_1 | 8" |
OLD | NEW |