1 # Copyright
(C
) 2009-2022 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.
17 # It tests the frame support in Guile.
19 load_lib gdb
-guile.exp
23 if { [prepare_for_testing
"failed to prepare" ${testfile} ${srcfile}] } {
27 # Skip all tests
if Guile scripting is not enabled.
28 if { [skip_guile_tests
] } { continue }
30 # The following tests require execution.
32 if ![gdb_guile_runto_main
] {
36 gdb_breakpoint
[gdb_get_line_number
"Block break here."]
37 gdb_continue_to_breakpoint
"Block break here."
38 gdb_scm_test_silent_cmd
"guile (define bf1 (selected-frame))" \
41 # Test frame
-architecture method.
42 gdb_scm_test_silent_cmd
"guile (define show-arch-str (execute \"show architecture\" #:to-string #t))" \
44 gdb_test
"guile (print (->bool (string-contains show-arch-str (arch-name (frame-arch bf1)))))" \
45 "#t" "test frame-arch"
47 # First test that read
-var is unaffected by PR
11036 changes.
48 gdb_test
"guile (print (frame-read-var bf1 \"i\"))" \
50 gdb_test
"guile (print (frame-read-var bf1 \"f\"))" \
52 gdb_test
"guile (print (frame-read-var bf1 \"b\"))" \
55 # Test the read
-var function in another block other than the current
56 # block
(in this case
, the super block
). Test thar read
-var is reading
57 # the correct variables of i and f but they are the correct value and type.
58 gdb_scm_test_silent_cmd
"guile (define sb (block-superblock (frame-block bf1)))" \
60 gdb_test
"guile (print (frame-read-var bf1 \"i\" #:block sb))" "1.1.*" \
62 gdb_test
"guile (print (value-type (frame-read-var bf1 \"i\" #:block sb)))" \
63 "double" "test double i"
64 gdb_test
"guile (print (frame-read-var bf1 \"f\" #:block sb))" \
65 "2.2.*" "test f = 2.2"
66 gdb_test
"guile (print (value-type (frame-read-var bf1 \"f\" #:block sb)))" \
67 "double" "test double f"
69 # And again test another outerblock
, this time testing
"i" is the
70 # correct value and type.
71 gdb_scm_test_silent_cmd
"guile (set! sb (block-superblock sb))" \
73 gdb_test
"guile (print (frame-read-var bf1 \"i\" #:block sb))" \
75 gdb_test
"guile (print (value-type (frame-read-var bf1 \"i\" #:block sb)))" \
79 gdb_continue_to_breakpoint
"breakpoint at f2"
80 gdb_scm_test_silent_cmd
"guile (define bframe (selected-frame))" \
81 "get bottom-most frame"
84 gdb_scm_test_silent_cmd
"guile (define f1 (selected-frame))" \
86 gdb_scm_test_silent_cmd
"guile (define f0 (frame-newer f1))" \
89 gdb_test
"guile (print (eq? f1 (newest-frame)))" \
90 #f
"selected frame -vs- newest frame"
91 gdb_test
"guile (print (eq? bframe (newest-frame)))" \
92 #t
"newest frame -vs- newest frame"
94 gdb_test
"guile (print (eq? f0 f1))" \
95 "#f" "test equality comparison (false)"
96 gdb_test
"guile (print (eq? f0 f0))" \
97 "#t" "test equality comparison (true)"
98 gdb_test
"guile (print (frame-valid? f0))" \
99 "#t" "test frame-valid?"
100 gdb_test
"guile (print (frame-name f0))" \
101 "f2" "test frame-name"
102 gdb_test
"guile (print (= (frame-type f0) NORMAL_FRAME))" \
103 "#t" "test frame-type"
104 gdb_test
"guile (print (= (frame-unwind-stop-reason f0) FRAME_UNWIND_NO_REASON))" \
105 "#t" "test frame-unwind-stop-reason"
106 gdb_test
"guile (print (unwind-stop-reason-string FRAME_UNWIND_INNER_ID))" \
107 "previous frame inner to this frame \\(corrupt stack\\?\\)" \
108 "test unwind-stop-reason-string"
109 gdb_test
"guile (print (format #f \"= ~A\" (frame-pc f0)))" \
110 "= \[0-9\]+" "test frame-pc"
111 gdb_test
"guile (print (format #f \"= ~A\" (eq? (frame-older f0) f1)))" \
112 "= #t" "test frame-older"
113 gdb_test
"guile (print (format #f \"= ~A\" (eq? (frame-newer f1) f0)))" \
114 "= #t" "test frame-newer"
115 gdb_test
"guile (print (frame-read-var f0 \"variable_which_surely_doesnt_exist\"))" \
116 "ERROR: .*: Out of range: variable not found: \"variable_which_surely_doesnt_exist\".*" \
117 "test frame-read-var - error"
118 gdb_test
"guile (print (format #f \"= ~A\" (frame-read-var f0 \"a\")))" \
119 "= 1" "test frame-read-var - success"
121 gdb_test
"guile (print (format #f \"= ~A\" (eq? (selected-frame) f1)))" \
122 "= #t" "test selected-frame"
124 # Can read SP register.
125 gdb_test
"guile (print (equal? (frame-read-register (selected-frame) \"sp\") (parse-and-eval \"\$sp\")))" \
126 "= #t" "test frame-read-register of sp"
128 # PC value obtained via read_register is as expected.
129 gdb_test
"guile (print (equal? (value->integer (frame-read-register f0 \"pc\")) (frame-pc f0)))" \
130 "= #t" "test frame-read-register of pc"
132 # Test arch
-specific register
name.
134 if {[is_amd64_regs_target
]} {
136 } elseif
{[is_x86_like_target
]} {
140 gdb_test
"guile (print (equal? (frame-read-register f0 \"pc\") (frame-read-register f0 \"$pc\")))" \
141 "= #t" "test frame-read-register of $pc"