1 1.1.1.7 christos # Copyright (C) 2008-2024 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 basic Guile features. 18 1.1 christos 19 1.1 christos load_lib gdb-guile.exp 20 1.1 christos 21 1.1.1.7 christos clean_restart 22 1.1.1.7 christos 23 1.1.1.7 christos set host_source2_scm [gdb_remote_download host $srcdir/$subdir/source2.scm] 24 1.1 christos 25 1.1 christos # Do this instead of the skip_guile_check. 26 1.1 christos # We want to do some tests when Guile is not present. 27 1.1 christos gdb_test_multiple "guile (display 23) (newline)" "verify guile support" { 28 1.1 christos -re "Undefined command.*$gdb_prompt $" { 29 1.1.1.3 christos unsupported "guile not supported." 30 1.1 christos return 31 1.1 christos } 32 1.1 christos -re "not supported.*$gdb_prompt $" { 33 1.1 christos unsupported "guile support is disabled" 34 1.1 christos 35 1.1 christos # If Guile is not supported, verify that sourcing a guile script 36 1.1 christos # causes an error. 37 1.1.1.7 christos gdb_test "source $host_source2_scm" \ 38 1.1 christos "Error in sourced command file:.*" \ 39 1.1 christos "source source2.scm when guile disabled" 40 1.1 christos 41 1.1 christos # Verify multi-line guile commands cause an error. 42 1.1 christos gdb_test_multiline "multi-line guile command" \ 43 1.1 christos "guile" "" \ 44 1.1 christos "(print 23)" "" \ 45 1.1 christos "end" "not supported.*" 46 1.1 christos 47 1.1 christos return 48 1.1 christos } 49 1.1 christos -re "$gdb_prompt $" {} 50 1.1 christos } 51 1.1 christos 52 1.1 christos gdb_install_guile_utils 53 1.1 christos gdb_install_guile_module 54 1.1 christos 55 1.1 christos gdb_test_multiline "multi-line guile command" \ 56 1.1 christos "guile" "" \ 57 1.1 christos "(print 23)" "" \ 58 1.1 christos "end" "= 23" 59 1.1 christos 60 1.1 christos gdb_test_multiline "show guile command" \ 61 1.1 christos "define zzq" "Type commands for definition of .* just \"end\"\\.*" \ 62 1.1 christos "guile" "" \ 63 1.1 christos "(print 23)" "" \ 64 1.1 christos "end" "" \ 65 1.1 christos "end" "" \ 66 1.1.1.7 christos "show user zzq" "User command \"zzq\":.* guile.*\\(print 23\\).* end\r\n" 67 1.1 christos 68 1.1.1.7 christos gdb_test "source $host_source2_scm" "yes" "source source2.scm" 69 1.1 christos 70 1.1.1.5 christos gdb_test "source -s source2.scm" "yes" 71 1.1 christos 72 1.1 christos gdb_test "guile (print (current-objfile))" "= #f" 73 1.1 christos gdb_test "guile (print (objfiles))" "= \\(\\)" 74 1.1 christos 75 1.1 christos gdb_test_no_output \ 76 1.1 christos {guile (define x (execute "printf \"%d\", 23" #:to-string #t))} 77 1.1 christos gdb_test "guile (print x)" "= 23" 78 1.1 christos 79 1.1 christos gdb_test_no_output "guile (define a (execute \"help\" #:to-string #t))" \ 80 1.1 christos "collect help from uiout" 81 1.1 christos 82 1.1.1.5 christos gdb_test "guile (print a)" "= .*aliases -- User-defined aliases of other commands.*" \ 83 1.1 christos "verify help to uiout" 84 1.1.1.6 christos 85 1.1.1.6 christos # Verify that we can source a guile script using ~ for the HOME directory. 86 1.1.1.7 christos if { ![is_remote host ] } { 87 1.1.1.7 christos save_vars { env(HOME) } { 88 1.1.1.7 christos # Create a new directory to act as a temporary HOME directory. 89 1.1.1.7 christos set tmp_home [standard_output_file tmp_home] 90 1.1.1.7 christos file mkdir $tmp_home 91 1.1.1.7 christos 92 1.1.1.7 christos # Copy the file we want to source into the new HOME directory. 93 1.1.1.7 christos gdb_remote_download host ${srcdir}/${subdir}/source2.scm \ 94 1.1.1.7 christos ${tmp_home}/source2.scm 95 1.1.1.7 christos 96 1.1.1.7 christos # Arrange to use the new HOME directory. 97 1.1.1.7 christos set env(HOME) $tmp_home 98 1.1.1.7 christos clean_restart 99 1.1.1.6 christos 100 1.1.1.7 christos # Finally, source the file out of our new HOME directory. 101 1.1.1.7 christos gdb_test "source ~/source2.scm" "yes" 102 1.1.1.7 christos } 103 1.1.1.6 christos } 104