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