ignore invalid DOF provider sections
[binutils-gdb.git] / gdb / testsuite / gdb.python / py-block.exp
blob80308cdff496e62d0942445285312c5cfc1135a9
1 # Copyright (C) 2010-2015 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 the mechanism
17 # exposing values to Python.
19 load_lib gdb-python.exp
21 standard_testfile
23 if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile}] } {
24 return -1
27 # Skip all tests if Python scripting is not enabled.
28 if { [skip_python_tests] } { continue }
30 if ![runto_main] then {
31 fail "Can't run to main"
32 return 0
35 global hex decimal
36 gdb_breakpoint [gdb_get_line_number "Block break here."]
37 gdb_continue_to_breakpoint "Block break here."
39 # Test initial innermost block.
40 gdb_py_test_silent_cmd "python frame = gdb.selected_frame()" "Get Frame" 0
41 gdb_py_test_silent_cmd "python block = frame.block()" "Get block" 0
42 gdb_test "python print (block)" "<gdb.Block object at $hex>" "Check block not None"
43 gdb_test "python print (block.function)" "None" "First anonymous block"
44 gdb_test "python print (block.start)" "${decimal}" "Check start not None"
45 gdb_test "python print (block.end)" "${decimal}" "Check end not None"
47 # Test global/static blocks
48 gdb_py_test_silent_cmd "python frame = gdb.selected_frame()" "Get Frame" 0
49 gdb_py_test_silent_cmd "python block = frame.block()" "Get block" 0
50 gdb_test "python print (block.is_global)" "False" "Not a global block"
51 gdb_test "python print (block.is_static)" "False" "Not a static block"
52 gdb_py_test_silent_cmd "python gblock = block.global_block" "Get block" 1
53 gdb_py_test_silent_cmd "python sblock = block.static_block" "Get block" 1
54 gdb_test "python print (gblock.is_global)" "True" "Is the global block"
55 gdb_test "python print (sblock.is_static)" "True" "Is the static block"
57 # Move up superblock(s) until we reach function block_func.
58 gdb_test_no_output "python block = block.superblock" "Get superblock"
59 gdb_test "python print (block.function)" "None" "Second anonymous block"
60 gdb_test_no_output "python block = block.superblock" "Get superblock 2"
61 gdb_test "python print (block.function)" "block_func" \
62 "Print superblock 2 function"
64 # Switch frames, then test for main block.
65 gdb_test "up" ".*"
66 gdb_py_test_silent_cmd "python frame = gdb.selected_frame()" "Get Frame 2" 0
67 gdb_py_test_silent_cmd "python block = frame.block()" "Get Frame 2's block" 0
68 gdb_test "python print (block)" "<gdb.Block object at $hex>" \
69 "Check Frame 2's block not None"
70 gdb_test "python print (block.function)" "main" "main block"
73 # Test Block is_valid. This must always be the last test in this
74 # testcase as it unloads the object file.
75 delete_breakpoints
76 gdb_py_test_silent_cmd "python frame = gdb.selected_frame()" "Get Frame" 0
77 gdb_py_test_silent_cmd "python block = frame.block()" "Get Frame block" 0
78 gdb_py_test_silent_cmd "python block_iter = iter (block)" "Get Frame block" 0
79 gdb_test "python print (block.is_valid())" "True" \
80 "Check block validity"
81 gdb_test "python print (block_iter.is_valid())" "True" \
82 "Check block validity"
83 gdb_unload
84 gdb_test "python print (block.is_valid())" "False" \
85 "Check block validity"
86 gdb_test "python print (block_iter.is_valid())" "False" \
87 "Check block validity"