f6978de9f5
* gdb.ada/assign_1.exp: Use ".*" instead of "" as wildcard regexp. * gdb.ada/boolean_expr.exp: * gdb.ada/frame_args.exp: Ditto. * gdb.ada/lang_switch.exp: Ditto. * gdb.ada/ptype_arith_binop.exp: Ditto. * gdb.ada/ref_param.exp: Ditto. * gdb.ada/type_coercion.exp:Ditto. * gdb.asm/asm-source.exp: Ditto. * gdb.base/attach.exp: Ditto. * gdb.base/bitfields2.exp: Ditto. * gdb.base/call-signal-resume.exp: Ditto. * gdb.base/callfuncs.exp: Ditto. * gdb.base/commands.exp: Ditto. * gdb.base/dbx.exp: Ditto. * gdb.base/default.exp: Ditto. * gdb.base/dump.exp: Ditto. * gdb.base/exprs.exp: Ditto. * gdb.base/freebpcmd.exp: Ditto. * gdb.base/interrupt.exp: Ditto. * gdb.base/list.exp: Ditto. * gdb.base/long_long.exp: Ditto. * gdb.base/maint.exp: Ditto. * gdb.base/ptype.exp: Ditto. * gdb.base/return.exp: Ditto. * gdb.base/setshow.exp: Ditto. * gdb.base/sigbpt.exp: Ditto. * gdb.base/sigrepeat.exp: Ditto. * gdb.cp/classes.exp: Ditto. * gdb.dwarf2/dw2-restore.exp: Ditto. * gdb.gdb/selftest.exp: Ditto. * gdb.multi/base.exp: Ditto. * gdb.multi/bkpt-multi-exec.exp: Ditto. * gdb.python/py-block.exp: Ditto. * gdb.python/py-prettyprint.exp: Ditto. * gdb.python/py-template.exp: Ditto. * gdb.server/ext-attach.exp: Ditto. * gdb.server/ext-run.exp: Ditto. * gdb.server/server-mon.exp: Ditto. * gdb.threads/fork-thread-pending.exp: Ditto. * gdb.threads/hand-call-in-threads.exp: Ditto. * gdb.threads/interrupted-hand-call.exp: Ditto. * gdb.threads/linux-dp.exp: Ditto. * gdb.threads/manythreads.exp: Ditto. * gdb.threads/print-threads.exp: Ditto. * gdb.threads/pthreads.exp: Ditto. * gdb.threads/schedlock.exp: Ditto. * gdb.threads/thread-unwindonsignal.exp: Ditto. * gdb.threads/threadapply.exp: Ditto.
151 lines
5.1 KiB
Text
151 lines
5.1 KiB
Text
# Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# This file is part of the GDB testsuite. It tests Python-based
|
|
# pretty-printing for the CLI.
|
|
|
|
if $tracelevel then {
|
|
strace $tracelevel
|
|
}
|
|
|
|
set testfile "py-prettyprint"
|
|
set srcfile ${testfile}.c
|
|
set binfile ${objdir}/${subdir}/${testfile}
|
|
|
|
# Start with a fresh gdb.
|
|
gdb_exit
|
|
gdb_start
|
|
|
|
# Skip all tests if Python scripting is not enabled.
|
|
if { [skip_python_tests] } { continue }
|
|
|
|
# Run a command in GDB, and report a failure if a Python exception is thrown.
|
|
# If report_pass is true, report a pass if no exception is thrown.
|
|
proc gdb_py_test_silent_cmd {cmd name report_pass} {
|
|
global gdb_prompt
|
|
|
|
gdb_test_multiple $cmd $name {
|
|
-re "Traceback.*$gdb_prompt $" { fail $name }
|
|
-re "$gdb_prompt $" { if $report_pass { pass $name } }
|
|
}
|
|
}
|
|
|
|
proc run_lang_tests {lang} {
|
|
global srcdir subdir srcfile binfile testfile hex
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug $lang"] != "" } {
|
|
untested "Couldn't compile ${srcfile} in $lang mode"
|
|
return -1
|
|
}
|
|
|
|
set nl "\[\r\n\]+"
|
|
|
|
# Start with a fresh gdb.
|
|
gdb_exit
|
|
gdb_start
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
|
gdb_load ${binfile}
|
|
|
|
if ![runto_main ] then {
|
|
perror "couldn't run to breakpoint"
|
|
return
|
|
}
|
|
|
|
gdb_test_no_output "set print pretty on"
|
|
|
|
gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \
|
|
".*Breakpoint.*"
|
|
gdb_test "continue" ".*Breakpoint.*"
|
|
|
|
set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py]
|
|
|
|
gdb_test_no_output "python execfile ('${remote_python_file}')"
|
|
|
|
gdb_test "print ss" " = a=< a=<1> b=<$hex>> b=< a=<2> b=<$hex>>"
|
|
gdb_test "print ssa\[1\]" " = a=< a=<5> b=<$hex>> b=< a=<6> b=<$hex>>"
|
|
gdb_test "print ssa" " = {a=< a=<3> b=<$hex>> b=< a=<4> b=<$hex>>, a=< a=<5> b=<$hex>> b=< a=<6> b=<$hex>>}"
|
|
|
|
if {$lang == "c++"} {
|
|
gdb_test "print cps" "= a=<8> b=<$hex>"
|
|
gdb_test "print cpss" " = {$nl *zss = 9, *$nl *s = a=<10> b=<$hex>$nl}"
|
|
gdb_test "print cpssa\[0\]" " = {$nl *zss = 11, *$nl *s = a=<12> b=<$hex>$nl}"
|
|
gdb_test "print cpssa\[1\]" " = {$nl *zss = 13, *$nl *s = a=<14> b=<$hex>$nl}"
|
|
gdb_test "print cpssa" " = {{$nl *zss = 11, *$nl *s = a=<12> b=<$hex>$nl *}, {$nl *zss = 13, *$nl *s = a=<14> b=<$hex>$nl *}}"
|
|
gdb_test "print sss" "= a=<15> b=< a=<8> b=<$hex>>"
|
|
gdb_test "print ref" "= a=<15> b=< a=<8> b=<$hex>>"
|
|
gdb_test "print derived" \
|
|
" = \{.*<Vbase1> = pp class name: Vbase1.*<Vbase2> = \{.*<VirtualTest> = pp value variable is: 1,.*members of Vbase2:.*_vptr.Vbase2 = $hex.*<Vbase3> = \{.*members of Vbase3.*members of Derived:.*value = 2.*"
|
|
gdb_test "print ns " "\"embedded\\\\000null\\\\000string\""
|
|
gdb_py_test_silent_cmd "set print elements 3" "" 1
|
|
gdb_test "print ns" "emb\.\.\.."
|
|
gdb_py_test_silent_cmd "set print elements 10" "" 1
|
|
gdb_test "print ns" "embedded\\\\000n\.\.\.."
|
|
gdb_py_test_silent_cmd "set print elements 200" "" 1
|
|
}
|
|
|
|
gdb_test "print x" " = \"this is x\""
|
|
gdb_test "print cstring" " = \"const string\""
|
|
|
|
gdb_test "print estring" "\"embedded x\\\\201\\\\202\\\\203\\\\204\""
|
|
gdb_test "print c" " = container \"container\" with 2 elements = {$nl *.0. = 23,$nl *.1. = 72$nl}"
|
|
|
|
gdb_test "print nstype" " = {$nl *.0. = 7,$nl *.1. = 42$nl}"
|
|
gdb_test "continue" "Program exited normally\."
|
|
|
|
remote_file host delete ${remote_python_file}
|
|
}
|
|
|
|
run_lang_tests "c"
|
|
run_lang_tests "c++"
|
|
|
|
# Run various other tests.
|
|
|
|
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable "debug"] != "" } {
|
|
untested "Couldn't compile ${srcfile}"
|
|
return -1
|
|
}
|
|
|
|
# Start with a fresh gdb.
|
|
gdb_exit
|
|
gdb_start
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
|
gdb_load ${binfile}
|
|
|
|
if ![runto_main ] then {
|
|
perror "couldn't run to breakpoint"
|
|
return
|
|
}
|
|
|
|
gdb_test "b [gdb_get_line_number {break to inspect} ${testfile}.c ]" \
|
|
".*Breakpoint.*"
|
|
gdb_test "continue" ".*Breakpoint.*"
|
|
|
|
set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py]
|
|
|
|
gdb_test_no_output "python execfile ('${remote_python_file}')"
|
|
|
|
gdb_test "print ss" " = a=< a=<1> b=<$hex>> b=< a=<2> b=<$hex>>" \
|
|
"print ss enabled #1"
|
|
|
|
gdb_test_no_output "python disable_lookup_function ()"
|
|
|
|
gdb_test "print ss" " = {a = {a = 1, b = $hex}, b = {a = 2, b = $hex}}" \
|
|
"print ss disabled"
|
|
|
|
gdb_test_no_output "python enable_lookup_function ()"
|
|
|
|
gdb_test "print ss" " = a=< a=<1> b=<$hex>> b=< a=<2> b=<$hex>>" \
|
|
"print ss enabled #2"
|
|
|
|
remote_file host delete ${remote_python_file}
|