old-cross-binutils/gdb/testsuite/gdb.python/py-value-cc.exp

106 lines
5 KiB
Text
Raw Normal View History

# Copyright (C) 2012-2016 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 the mechanism
# exposing values to Python.
if { [skip_cplus_tests] } { continue }
standard_testfile .cc
if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} {
return -1
}
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
if ![runto_main] {
return -1
}
gdb_breakpoint [gdb_get_line_number "Break here."]
gdb_continue_to_breakpoint "Break here" ".*Break here.*"
2012-12-10 Paul Koning <paul_koning@dell.com> * gdb.base/charset.exp: Change print syntax for Python 3 compatibility. * gdb.python/py-block.exp: Ditto. * gdb.python/py-breakpoint.exp: Ditto. * gdb.python/py-cmd.exp: Ditto. * gdb.python/py-events.py: Ditto. * gdb.python/py-finish-breakpoint.py: Ditto. * gdb.python/py-finish-breakpoint2.exp: Ditto. * gdb.python/py-finish-breakpoint2.py: Ditto. * gdb.python/py-frame-inline.exp: Ditto. * gdb.python/py-frame.exp: Ditto. * gdb.python/py-infthread.exp: Ditto. * gdb.python/py-objfile.exp: Ditto. * gdb.python/py-parameter.exp: Ditto. * gdb.python/py-progspace.exp: Ditto. * gdb.python/py-prompt.exp: Ditto. * gdb.python/py-symbol.exp: Ditto. * gdb.python/py-symtab.exp: Ditto. * gdb.python/py-template.exp: Ditto. * gdb.python/py-value-cc.exp: Ditto. * gdb.python/python.exp: Ditto. * gdb.python/source2.py: Ditto. * gdb.python/lib-types.exp: Change print syntax for Python 3 compatibility. Use sorted() function rather than sort() method. Accept either int or long values for enum values. * gdb.python/py-events.exp: Use exec(open(...).read()) instead of execfile for Python 3 compatibility. * gdb.python/py-evsignal.exp: Ditto. * gdb.python/py-evthreads.exp: Ditto. * gdb.python/py-mi.exp: Ditto. * gdb.python/py-pp-maint.exp: Ditto. * gdb.python/py-prettyprint.exp: Ditto. * gdb.python/py-finish-breakpoint.exp: Change print syntax for Python 3 compatibility. Skip tests for Python 2.4. * gdb.python/py-inferior.exp: Change print syntax for Python 3 compatibility. Use byte string rather than character string in memory write test if Python 3. * gdb.python/py-pp-maint.py: Change class declarations to "new class" syntax. * gdb.python/py-prettyprint.py: Change iterator class to generator function for Python 3 compatibility. Make all classes "new style". Fix indentation issue and stray semicolon. * gdb.python/py-shared.expChange print syntax for Python 3 compatibility. Define "long" if Python 3. * gdb.python/py-type.exp: Change print syntax for Python 3 compatibility. Accept either int or long values for enum values. * gdb.python/py-value.exp: Change print syntax for Python 3 compatibility. Skip "long" and "unicode" tests if Python 3. Accept either "type" or "class" in type checks. * lib/gdb.exp (gdb_py_is_py3k): New flag set if Python 3. (gdb_py_is_py24): New flag set if Python 2.4 or 2.5.
2012-12-10 21:22:21 +00:00
gdb_test "python print (str(gdb.parse_and_eval(\"a\").type))" "const A &"
gdb_test "python print (str(gdb.parse_and_eval(\"a\").referenced_value().type))" "const A"
gdb_test "python print (str(gdb.parse_and_eval(\"int_ref\").type))" "int &"
gdb_test "python print (str(gdb.parse_and_eval(\"int_ref\").referenced_value().type))" "int"
gdb_test "python print (str(gdb.parse_and_eval(\"int_ref\").referenced_value()))" "10"
gdb_test "python print (str(gdb.parse_and_eval(\"int_ptr_ref\").dereference().type))" "int"
gdb_test "python print (str(gdb.parse_and_eval(\"int_ptr_ref\").referenced_value().type))" "int_ptr"
gdb_test "python print (str(gdb.parse_and_eval(\"int_ptr_ref\").referenced_value().dereference()))" "10"
gdb_test "python print (str(gdb.parse_and_eval(\"int_ptr_ref\").referenced_value().referenced_value()))" "10"
# Tests for gdb.Value[gdb.Field]
gdb_test_no_output "python b = gdb.parse_and_eval('b')" "init b"
gdb_test_no_output "python b_fields = b.type.fields()" "init b_fields"
gdb_test_no_output "python b_obj = gdb.parse_and_eval('b_obj')" "init b_obj"
gdb_test_no_output "python b_ref = gdb.parse_and_eval('b_ref')" "init b_ref"
gdb_test_no_output "python b_td = gdb.parse_and_eval('b_td')" "init b_td"
gdb_test_no_output "python u = gdb.parse_and_eval('u')" "init u"
gdb_test_no_output "python u_fields = u.type.fields()" "init u_fields"
gdb_test_no_output "python x = gdb.parse_and_eval('x')" "init x"
gdb_test_no_output "python x_fields = x.type.fields()" "init x_fields"
gdb_test_no_output "python uu = gdb.parse_and_eval('uu')" "init uu"
gdb_test_no_output "python uu_fields = uu.type.fields()" "init uu_fields"
gdb_test_no_output "python x_ptr = gdb.parse_and_eval('x_ptr')" "init x_ptr"
gdb_test_no_output "python xtd = gdb.parse_and_eval('xtd')" "init xtd"
gdb_test "python print(b\[b_fields\[1\]\])" "97 'a'" "b.a via field"
gdb_test "python print(b\[b_fields\[1\]\])" "97 'a'" "b.a via field"
gdb_test "python print(b\[b_fields\[0\]\].type)" "A" \
"type of b's base class via field"
gdb_test "python print(b\[b_fields\[0\]\]\['a'\])" "10" "b.A::a via field"
gdb_test "python print(b_obj\[b_fields\[1\]\])" "98 'b'" "b_obj->a via field"
gdb_test "python print(b_obj\[b_fields\[0\]\].type.target())" "A" \
"type of b_obj's base class via field"
gdb_test "python print(b_obj\[b_fields\[0\]\]\['a'\])" "100" \
"b_obj->A::a via field"
gdb_test "python print(b_ref\[b_fields\[1\]\])" "98 'b'" "b_ref.a via field"
gdb_test "python print(b_ref\[b_fields\[0\]\].type.target())" "A" \
"type of b_ref's base class via field"
gdb_test "python print(b_ref\[b_fields\[0\]\]\['a'\])" "100" \
"b_ref.A::a via field"
gdb_test "python print(b_td\[b_fields\[1\]\])" "98 'b'" "b_td.a via field"
gdb_test "python print(b_td\[b_fields\[0\]\].type.target())" "A" \
"type of b_td's base class via field"
gdb_test "python print(b_td\[b_fields\[0\]\]\['a'\])" "100" \
"b_td.A::a via field"
gdb_test "python print(u\[u_fields\[0\]\])" "99.*" "u's first field via field"
gdb_test "python print(u\[u_fields\[1\]\])" "99.*" "u's second field via field"
gdb_test "python print(len(x_fields))" "2" "number for fields in u"
gdb_test "python print(x\[x_fields\[0\]\]\['x'\])" "101" "x.x via field"
gdb_test "python print(x\[x_fields\[1\]\]\['a'\])" "102" "x.a via field"
gdb_test "python print(x_ptr\[x_fields\[0\]\]\['x'\])" "101" "x_ptr->x via field"
gdb_test "python print(x_ptr\[x_fields\[1\]\]\['a'\])" "102" "x_ptr->a via field"
gdb_test "python print(xtd\[x_fields\[0\]\]\['x'\])" "101" "xtd->x via field"
gdb_test "python print(xtd\[x_fields\[1\]\]\['a'\])" "102" "xtd->a via field"
gdb_test "python print(len(uu_fields))" "2" "number of fields in uu"
gdb_test "python print(uu\[uu_fields\[0\]\]\['x'\])" "1000" "uu.x via field"
gdb_test "python print(uu\[uu_fields\[1\]\]\['a'\])" "1000" "uu.a via field"
# Test overloaded operators.
gdb_test_no_output "python a = gdb.parse_and_eval('a')" "init a"
gdb_test "python print(a + 5)" "10" "a + 5"