minor adjustments in gdb.python/py-block.exp
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.python / py-block.exp
1 # Copyright (C) 2010, 2011 Free Software Foundation, Inc.
2 #
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.
7 #
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.
12 #
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/>.
15
16 # This file is part of the GDB testsuite. It tests the mechanism
17 # exposing values to Python.
18
19 if $tracelevel then {
20 strace $tracelevel
21 }
22
23 load_lib gdb-python.exp
24
25 set testfile "py-block"
26 set srcfile ${testfile}.c
27 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
28 return -1
29 }
30
31 # Skip all tests if Python scripting is not enabled.
32 if { [skip_python_tests] } { continue }
33
34 if ![runto_main] then {
35 fail "Can't run to main"
36 return 0
37 }
38
39 global hex decimal
40 gdb_breakpoint [gdb_get_line_number "Block break here."]
41 gdb_continue_to_breakpoint "Block break here."
42
43 # Test initial innermost block.
44 gdb_py_test_silent_cmd "python frame = gdb.selected_frame()" "Get Frame" 0
45 gdb_py_test_silent_cmd "python block = frame.block()" "Get block" 0
46 gdb_test "python print block" "<gdb.Block object at $hex>" "Check block not None"
47 gdb_test "python print block.function" "None" "First anonymous block"
48 gdb_test "python print block.start" "${decimal}" "Check start not None"
49 gdb_test "python print block.end" "${decimal}" "Check end not None"
50
51 # Move up superblock(s) until we reach function block_func.
52 gdb_test_no_output "python block = block.superblock" "Get superblock"
53 gdb_test "python print block.function" "None" "Second anonymous block"
54 gdb_test_no_output "python block = block.superblock" "Get superblock 2"
55 gdb_test "python print block.function" "block_func" \
56 "Print superblock 2 function"
57
58 # Switch frames, then test for main block.
59 gdb_test "up" ".*"
60 gdb_py_test_silent_cmd "python frame = gdb.selected_frame()" "Get Frame 2" 0
61 gdb_py_test_silent_cmd "python block = frame.block()" "Get Frame 2's block" 0
62 gdb_test "python print block" "<gdb.Block object at $hex>" \
63 "Check Frame 2's block not None"
64 gdb_test "python print block.function" "main" "main block"
This page took 0.050369 seconds and 5 git commands to generate.