1 # Copyright (C) 2010 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.
24 untested "py-pp-maint.exp can only be run locally"
28 load_lib gdb-python.exp
30 set testfile "py-pp-maint"
31 set srcfile ${testfile}.c
32 set binfile ${objdir}/${subdir}/${testfile}
34 # Start with a fresh gdb.
38 # Skip all tests if Python scripting is not enabled.
39 if { [skip_python_tests] } { continue }
41 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug"] != "" } {
42 untested "Couldn't compile ${srcfile}"
46 gdb_reinitialize_dir $srcdir/$subdir
49 if ![runto_main ] then {
50 fail "Can't run to main"
54 # Ensure sys.path, et.al. are initialized properly.
55 gdb_check_python_config
57 gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \
59 gdb_test "continue" ".*Breakpoint.*"
61 set python_file ${srcdir}/${subdir}/${testfile}.py
63 gdb_test_no_output "python execfile ('${python_file}')" ""
65 gdb_test "info pretty-printer" \
66 {.*function_lookup_test.*pp-test.*struct ss.*}
68 gdb_test "info pretty-printer global .*function" \
69 {.*function_lookup_test.*}
71 gdb_test "info pretty-printer .* pp-test" \
72 {.*pp-test.*struct ss.*}
74 gdb_test "print flt" " = x=<42> y=<43>" \
75 "print flt enabled #1"
77 gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \
80 gdb_test "disable pretty-printer" \
81 "5 printers disabled.*0 of 5 printers enabled"
83 gdb_test "enable pretty-printer" \
84 "5 printers enabled.*5 of 5 printers enabled"
86 gdb_test "disable pretty-printer global" \
87 "5 printers disabled.*0 of 5 printers enabled"
89 gdb_test "enable pretty-printer" \
90 "5 printers enabled.*5 of 5 printers enabled"
92 gdb_test "disable pretty-printer global lookup_function_lookup_test" \
93 "1 printer disabled.*4 of 5 printers enabled"
95 gdb_test "disable pretty-printer global pp-test;.*" \
96 "4 printers disabled.*0 of 5 printers enabled"
98 gdb_test "info pretty-printer global .*function" \
99 {.*function_lookup_test \[disabled\].*}
101 gdb_test "info pretty-printer .* pp-test" \
102 {.*pp-test.*struct ss \[disabled\].*}
104 gdb_test "print flt" " = {x = 42, y = 43}" \
107 gdb_test "print ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \
110 gdb_test "enable pretty-printer global lookup_function_lookup_test" \
111 "1 printer enabled.*1 of 5 printers enabled"
113 # This doesn't enable any printers because each subprinter in the collection
114 # is still individually disabled. But this is still needed, to enable the
116 gdb_test "enable pretty-printer global pp-test" \
117 "0 printers enabled.*1 of 5 printers enabled"
119 gdb_test "enable pretty-printer global pp-test;.*ss.*" \
120 "2 printers enabled.*3 of 5 printers enabled"
122 gdb_test "enable pretty-printer global pp-test;.*s.*" \
123 "2 printers enabled.*5 of 5 printers enabled"
125 gdb_test "info pretty-printer" \
126 {.*function_lookup_test.*pp-test.*struct ss.*}
128 gdb_test "print flt" " = x=<42> y=<43>" \
129 "print flt re-enabled"
131 gdb_test "print ss" " = a=<a=<1> b=<$hex>> b=<a=<2> b=<$hex>>" \
132 "print ss re-enabled"