1 # Copyright (C) 2010-2012 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file is part of the GDB testsuite. It tests Python-based
17 # pretty-printing for the CLI.
20 untested "py-pp-maint.exp can only be run locally"
24 load_lib gdb-python.exp
26 set testfile "py-pp-maint"
27 set srcfile ${testfile}.c
28 set binfile ${objdir}/${subdir}/${testfile}
30 # Start with a fresh gdb.
34 # Skip all tests if Python scripting is not enabled.
35 if { [skip_python_tests] } { continue }
37 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug"] != "" } {
38 untested "Couldn't compile ${srcfile}"
42 gdb_reinitialize_dir $srcdir/$subdir
45 if ![runto_main ] then {
46 fail "Can't run to main"
50 gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \
52 gdb_test "continue" ".*Breakpoint.*"
54 set python_file ${srcdir}/${subdir}/${testfile}.py
56 gdb_test_no_output "python execfile ('${python_file}')" ""
58 gdb_test "info pretty-printer" \
59 {.*function_lookup_test.*pp-test.*struct ss.*}
61 gdb_test "info pretty-printer global .*function" \
62 {.*function_lookup_test.*}
64 gdb_test "info pretty-printer .* pp-test" \
65 {.*pp-test.*struct ss.*}
67 gdb_test "print flt" " = x=<42> y=<43>" \
68 "print flt enabled #1"
70 gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \
73 gdb_test "disable pretty-printer" \
74 "5 printers disabled.*0 of 5 printers enabled"
76 gdb_test "enable pretty-printer" \
77 "5 printers enabled.*5 of 5 printers enabled"
79 gdb_test "disable pretty-printer global" \
80 "5 printers disabled.*0 of 5 printers enabled"
82 gdb_test "enable pretty-printer" \
83 "5 printers enabled.*5 of 5 printers enabled"
85 gdb_test "disable pretty-printer global lookup_function_lookup_test" \
86 "1 printer disabled.*4 of 5 printers enabled"
88 gdb_test "disable pretty-printer global pp-test;.*" \
89 "4 printers disabled.*0 of 5 printers enabled"
91 gdb_test "info pretty-printer global .*function" \
92 {.*function_lookup_test \[disabled\].*}
94 gdb_test "info pretty-printer .* pp-test" \
95 {.*pp-test.*struct ss \[disabled\].*}
97 gdb_test "print flt" " = {x = 42, y = 43}" \
100 gdb_test "print ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \
103 gdb_test "enable pretty-printer global lookup_function_lookup_test" \
104 "1 printer enabled.*1 of 5 printers enabled"
106 # This doesn't enable any printers because each subprinter in the collection
107 # is still individually disabled. But this is still needed, to enable the
109 gdb_test "enable pretty-printer global pp-test" \
110 "0 printers enabled.*1 of 5 printers enabled"
112 gdb_test "enable pretty-printer global pp-test;.*ss.*" \
113 "2 printers enabled.*3 of 5 printers enabled"
115 gdb_test "enable pretty-printer global pp-test;.*s.*" \
116 "2 printers enabled.*5 of 5 printers enabled"
118 gdb_test "info pretty-printer" \
119 {.*function_lookup_test.*pp-test.*struct ss.*}
121 gdb_test "print flt" " = x=<42> y=<43>" \
122 "print flt re-enabled"
124 gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \
125 "print ss re-enabled"