1 1.5 christos # Copyright (C) 2010-2017 Free Software Foundation, Inc. 2 1.1 christos # 3 1.1 christos # This program is free software; you can redistribute it and/or modify 4 1.1 christos # it under the terms of the GNU General Public License as published by 5 1.1 christos # the Free Software Foundation; either version 3 of the License, or 6 1.1 christos # (at your option) any later version. 7 1.1 christos # 8 1.1 christos # This program is distributed in the hope that it will be useful, 9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 1.1 christos # GNU General Public License for more details. 12 1.1 christos # 13 1.1 christos # You should have received a copy of the GNU General Public License 14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 1.1 christos 16 1.1 christos # This file is part of the GDB testsuite. 17 1.1 christos # It tests the mechanism exposing blocks to Guile. 18 1.1 christos 19 1.1 christos load_lib gdb-guile.exp 20 1.1 christos 21 1.1 christos standard_testfile 22 1.1 christos 23 1.5 christos if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { 24 1.1 christos return -1 25 1.1 christos } 26 1.1 christos 27 1.1 christos # Skip all tests if Guile scripting is not enabled. 28 1.1 christos if { [skip_guile_tests] } { continue } 29 1.1 christos 30 1.1 christos if ![gdb_guile_runto_main] { 31 1.1 christos return 32 1.1 christos } 33 1.1 christos 34 1.1 christos gdb_breakpoint [gdb_get_line_number "Block break here."] 35 1.1 christos gdb_continue_to_breakpoint "Block break here." 36 1.1 christos 37 1.1 christos # Test initial innermost block. 38 1.1 christos gdb_scm_test_silent_cmd "guile (define frame (selected-frame))" \ 39 1.1 christos "Get frame inner" 40 1.1 christos gdb_scm_test_silent_cmd "guile (define block (frame-block frame))" \ 41 1.1 christos "Get block inner" 42 1.1 christos gdb_test "guile (print block)" "#<gdb:block $hex-$hex>" \ 43 1.1 christos "Check block not #f" 44 1.1 christos gdb_test "guile (print (block-function block))" \ 45 1.1 christos "#f" "First anonymous block" 46 1.1 christos gdb_test "guile (print (block-start block))" \ 47 1.1 christos "${decimal}" "Check start not #f" 48 1.1 christos gdb_test "guile (print (block-end block))" \ 49 1.1 christos "${decimal}" "Check end not #f" 50 1.1 christos 51 1.1 christos # Test eq?. 52 1.1 christos gdb_test "guile (print (eq? (frame-block frame) (frame-block frame)))" \ 53 1.1 christos "= #t" "Check eq? on same block" 54 1.1 christos gdb_test "guile (print (eq? block (block-global-block block)))" \ 55 1.1 christos "= #f" "Check eq? on different blocks" 56 1.1 christos 57 1.1 christos # Test global/static blocks. 58 1.1 christos gdb_scm_test_silent_cmd "guile (define frame (selected-frame))" \ 59 1.1 christos "Get frame for global/static" 60 1.1 christos gdb_scm_test_silent_cmd "guile (define block (frame-block frame))" \ 61 1.1 christos "Get block for global/static" 62 1.1 christos gdb_test "guile (print (block-global? block))" \ 63 1.1 christos "#f" "Not a global block" 64 1.1 christos gdb_test "guile (print (block-static? block))" \ 65 1.1 christos "#f" "Not a static block" 66 1.1 christos gdb_scm_test_silent_cmd "guile (define gblock (block-global-block block))" \ 67 1.1 christos "Get global block" 68 1.1 christos gdb_scm_test_silent_cmd "guile (define sblock (block-static-block block))" \ 69 1.1 christos "Get static block" 70 1.1 christos gdb_test "guile (print (block-global? gblock))" \ 71 1.1 christos "#t" "Is the global block" 72 1.1 christos gdb_test "guile (print (block-static? sblock))" \ 73 1.1 christos "#t" "Is the static block" 74 1.1 christos 75 1.1 christos # Move up superblock(s) until we reach function block_func. 76 1.1 christos gdb_test_no_output "guile (set! block (block-superblock block))" \ 77 1.1 christos "Get superblock" 78 1.1 christos gdb_test "guile (print (block-function block))" \ 79 1.1 christos "#f" "Second anonymous block" 80 1.1 christos gdb_test_no_output "guile (set! block (block-superblock block))" \ 81 1.1 christos "Get superblock 2" 82 1.1 christos gdb_test "guile (print (block-function block))" \ 83 1.1 christos "block_func" "Print superblock 2 function" 84 1.1 christos 85 1.1 christos # Switch frames, then test for main block. 86 1.1 christos gdb_test "up" ".*" 87 1.1 christos gdb_scm_test_silent_cmd "guile (define frame (selected-frame))" \ 88 1.1 christos "Get frame 2" 89 1.1 christos gdb_scm_test_silent_cmd "guile (define block (frame-block frame))" \ 90 1.1 christos "Get frame 2's block" 91 1.1 christos gdb_test "guile (print block)" "#<gdb:block main $hex-$hex>" \ 92 1.1 christos "Check Frame 2's block not #f" 93 1.1 christos gdb_test "guile (print (block-function block))" \ 94 1.1 christos "main" "main block" 95 1.1 christos 96 1.1 christos # Test block-valid?. This must always be the last test in this 97 1.1 christos # testcase as it unloads the object file. 98 1.1 christos delete_breakpoints 99 1.1 christos gdb_scm_test_silent_cmd "guile (define frame (selected-frame))" \ 100 1.1 christos "Get frame for valid?" 101 1.1 christos gdb_scm_test_silent_cmd "guile (define block (frame-block frame))" \ 102 1.1 christos "Get frame block for valid?" 103 1.1 christos gdb_test "guile (print (block-valid? block))" \ 104 1.1 christos "#t" "Check block validity" 105 1.1 christos gdb_unload 106 1.1 christos gdb_test "guile (print (block-valid? block))" \ 107 1.1 christos "#f" "Check block validity after unload" 108