* gdb.objc/basicclass.exp: Use standard_testfile.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.python / py-pp-maint.exp
CommitLineData
c5a57081 1# Copyright (C) 2010-2012 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
19if [is_remote host] {
20 untested "py-pp-maint.exp can only be run locally"
21 return -1
22}
23
24load_lib gdb-python.exp
25
26set testfile "py-pp-maint"
27set srcfile ${testfile}.c
28set binfile ${objdir}/${subdir}/${testfile}
29
30# Start with a fresh gdb.
31gdb_exit
32gdb_start
33
34# Skip all tests if Python scripting is not enabled.
35if { [skip_python_tests] } { continue }
36
37if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug"] != "" } {
38 untested "Couldn't compile ${srcfile}"
39 return -1
40}
41
42gdb_reinitialize_dir $srcdir/$subdir
43gdb_load ${binfile}
44
45if ![runto_main ] then {
46 fail "Can't run to main"
47 return -1
48}
49
7b51bc51
DE
50gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \
51 ".*Breakpoint.*"
52gdb_test "continue" ".*Breakpoint.*"
53
54set python_file ${srcdir}/${subdir}/${testfile}.py
55
56gdb_test_no_output "python execfile ('${python_file}')" ""
57
58gdb_test "info pretty-printer" \
59 {.*function_lookup_test.*pp-test.*struct ss.*}
60
61gdb_test "info pretty-printer global .*function" \
62 {.*function_lookup_test.*}
63
64gdb_test "info pretty-printer .* pp-test" \
65 {.*pp-test.*struct ss.*}
66
67gdb_test "print flt" " = x=<42> y=<43>" \
68 "print flt enabled #1"
69
70gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \
71 "print ss enabled #1"
72
cafec441
TT
73set num_pp 6
74
7b51bc51 75gdb_test "disable pretty-printer" \
cafec441 76 "$num_pp printers disabled.*0 of $num_pp printers enabled"
7b51bc51 77
4e04c971 78gdb_test "enable pretty-printer" \
cafec441 79 "$num_pp printers enabled.*$num_pp of $num_pp printers enabled"
4e04c971 80
7b51bc51 81gdb_test "disable pretty-printer global" \
cafec441 82 "$num_pp printers disabled.*0 of $num_pp printers enabled"
4e04c971
DE
83
84gdb_test "enable pretty-printer" \
cafec441 85 "$num_pp printers enabled.*$num_pp of $num_pp printers enabled"
7b51bc51
DE
86
87gdb_test "disable pretty-printer global lookup_function_lookup_test" \
cafec441 88 "1 printer disabled.*[expr $num_pp - 1] of $num_pp printers enabled"
7b51bc51 89
4e04c971 90gdb_test "disable pretty-printer global pp-test;.*" \
cafec441 91 "[expr $num_pp - 1] printers disabled.*0 of $num_pp printers enabled"
7b51bc51
DE
92
93gdb_test "info pretty-printer global .*function" \
94 {.*function_lookup_test \[disabled\].*}
95
96gdb_test "info pretty-printer .* pp-test" \
97 {.*pp-test.*struct ss \[disabled\].*}
98
99gdb_test "print flt" " = {x = 42, y = 43}" \
100 "print flt disabled"
101
102gdb_test "print ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \
103 "print ss disabled"
104
105gdb_test "enable pretty-printer global lookup_function_lookup_test" \
cafec441 106 "1 printer enabled.*1 of $num_pp printers enabled"
7b51bc51
DE
107
108# This doesn't enable any printers because each subprinter in the collection
109# is still individually disabled. But this is still needed, to enable the
110# collection itself.
111gdb_test "enable pretty-printer global pp-test" \
cafec441 112 "0 printers enabled.*1 of $num_pp printers enabled"
7b51bc51 113
4e04c971 114gdb_test "enable pretty-printer global pp-test;.*ss.*" \
cafec441 115 "2 printers enabled.*[expr $num_pp - 3] of $num_pp printers enabled"
7b51bc51 116
4e04c971 117gdb_test "enable pretty-printer global pp-test;.*s.*" \
cafec441
TT
118 "2 printers enabled.*[expr $num_pp - 1] of $num_pp printers enabled"
119
120gdb_test "enable pretty-printer global pp-test;.*" \
121 "1 printer enabled.*$num_pp of $num_pp printers enabled"
7b51bc51
DE
122
123gdb_test "info pretty-printer" \
124 {.*function_lookup_test.*pp-test.*struct ss.*}
125
126gdb_test "print flt" " = x=<42> y=<43>" \
127 "print flt re-enabled"
128
129gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \
130 "print ss re-enabled"
cafec441
TT
131
132gdb_test "print (enum flag_enum) (FLAG_1)" \
133 " = 0x1 .FLAG_1." \
134 "print FLAG_1"
135
136gdb_test "print (enum flag_enum) (FLAG_1 | FLAG_3)" \
137 " = 0x5 .FLAG_1 | FLAG_3." \
138 "print FLAG_1 | FLAG_3"
139
140gdb_test "print (enum flag_enum) (4 + 8)" \
141 " = 0xc .FLAG_1 | <unknown: 0x8>." \
142 "print FLAG_1 | 8"
This page took 0.2399 seconds and 4 git commands to generate.