| OLD | NEW |
| 1 # Copyright (C) 2008-2012 Free Software Foundation, Inc. | 1 # Copyright (C) 2008-2012 Free Software Foundation, Inc. |
| 2 | 2 |
| 3 # This program is free software; you can redistribute it and/or modify | 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 | 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 | 5 # the Free Software Foundation; either version 3 of the License, or |
| 6 # (at your option) any later version. | 6 # (at your option) any later version. |
| 7 # | 7 # |
| 8 # This program is distributed in the hope that it will be useful, | 8 # This program is distributed in the hope that it will be useful, |
| 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
| 12 # | 12 # |
| 13 # You should have received a copy of the GNU General Public License | 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/>. | 14 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 15 | 15 |
| 16 # This file is part of the GDB testsuite. It tests the mechanism | 16 # This file is part of the GDB testsuite. It tests the mechanism |
| 17 # exposing values to Python. | 17 # exposing values to Python. |
| 18 | 18 |
| 19 if $tracelevel then { | |
| 20 strace $tracelevel | |
| 21 } | |
| 22 | |
| 23 load_lib gdb-python.exp | 19 load_lib gdb-python.exp |
| 24 | 20 |
| 25 set testfile "py-value" | 21 standard_testfile |
| 26 set srcfile ${testfile}.c | |
| 27 set binfile ${objdir}/${subdir}/${testfile} | |
| 28 | 22 |
| 29 # Build inferior to language specification. | 23 # Build inferior to language specification. |
| 30 proc build_inferior {exefile lang} { | 24 proc build_inferior {exefile lang} { |
| 31 global srcdir subdir srcfile testfile hex | 25 global srcdir subdir srcfile testfile hex |
| 32 | 26 |
| 33 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${exefile}" executable "de
bug $lang"] != "" } { | 27 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${exefile}" executable "de
bug $lang"] != "" } { |
| 34 untested "Couldn't compile ${srcfile} in $lang mode" | 28 untested "Couldn't compile ${srcfile} in $lang mode" |
| 35 return -1 | 29 return -1 |
| 36 } | 30 } |
| 37 } | 31 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 gdb_test "python print int (evalue)" "2" | 93 gdb_test "python print int (evalue)" "2" |
| 100 | 94 |
| 101 # Test pointer arithmethic | 95 # Test pointer arithmethic |
| 102 | 96 |
| 103 # First, obtain the pointers | 97 # First, obtain the pointers |
| 104 gdb_test "print (void *) 2" ".*" "" | 98 gdb_test "print (void *) 2" ".*" "" |
| 105 gdb_test_no_output "python a = gdb.history (0)" "" | 99 gdb_test_no_output "python a = gdb.history (0)" "" |
| 106 gdb_test "print (void *) 5" ".*" "" | 100 gdb_test "print (void *) 5" ".*" "" |
| 107 gdb_test_no_output "python b = gdb.history (0)" "" | 101 gdb_test_no_output "python b = gdb.history (0)" "" |
| 108 | 102 |
| 109 gdb_test "python print 'result = ' + str(a+5)" " = 0x7" "add pointer value wit
h python integer" | 103 gdb_test "python print 'result = ' + str(a+5)" " = 0x7( <.*>)?" "add pointer v
alue with python integer" |
| 110 gdb_test "python print 'result = ' + str(b-2)" " = 0x3" "subtract python integ
er from pointer value" | 104 gdb_test "python print 'result = ' + str(b-2)" " = 0x3( <.*>)?" "subtract pyth
on integer from pointer value" |
| 111 gdb_test "python print 'result = ' + str(b-a)" " = 3" "subtract two pointer va
lues" | 105 gdb_test "python print 'result = ' + str(b-a)" " = 3" "subtract two pointer va
lues" |
| 112 | 106 |
| 113 # Test some invalid operations. | 107 # Test some invalid operations. |
| 114 | 108 |
| 115 gdb_test_multiple "python print 'result = ' + str(i+'foo')" "catch error in py
thon type conversion" { | 109 gdb_test_multiple "python print 'result = ' + str(i+'foo')" "catch error in py
thon type conversion" { |
| 116 -re "Argument to arithmetic operation not a number or boolean.*$gdb_prompt
$" {pass "catch error in python type conversion"} | 110 -re "Argument to arithmetic operation not a number or boolean.*$gdb_prompt
$" {pass "catch error in python type conversion"} |
| 117 -re "result = .*$gdb_prompt $" {fail "catch error in pyth
on type conversion"} | 111 -re "result = .*$gdb_prompt $" {fail "catch error in pyth
on type conversion"} |
| 118 -re "$gdb_prompt $" {fail "catch error in pyth
on type conversion"} | 112 -re "$gdb_prompt $" {fail "catch error in pyth
on type conversion"} |
| 119 } | 113 } |
| 120 | 114 |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 } | 491 } |
| 498 | 492 |
| 499 test_value_in_inferior | 493 test_value_in_inferior |
| 500 test_inferior_function_call | 494 test_inferior_function_call |
| 501 test_lazy_strings | 495 test_lazy_strings |
| 502 test_value_after_death | 496 test_value_after_death |
| 503 | 497 |
| 504 # Test either C or C++ values. | 498 # Test either C or C++ values. |
| 505 test_subscript_regression "${binfile}" "c" | 499 test_subscript_regression "${binfile}" "c" |
| 506 test_subscript_regression "${binfile}-cxx" "c++" | 500 test_subscript_regression "${binfile}-cxx" "c++" |
| OLD | NEW |