]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.guile/scm-symtab.exp
Fix more cases of improper test names
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.guile / scm-symtab.exp
1 # Copyright (C) 2010-2016 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.
17 # It tests the Guile symbol table support.
18
19 load_lib gdb-guile.exp
20
21 standard_testfile scm-symtab.c scm-symtab-2.c
22
23 if {[prepare_for_testing "failed to prepare" $testfile \
24 [list $srcfile $srcfile2] debug]} {
25 return
26 }
27
28 # Skip all tests if Guile scripting is not enabled.
29 if { [skip_guile_tests] } { continue }
30
31 if ![gdb_guile_runto_main] {
32 return
33 }
34
35 # Setup and get the symbol table.
36 set line_no [gdb_get_line_number "Block break here."]
37 gdb_breakpoint $line_no
38 gdb_continue_to_breakpoint "Block break here."
39 gdb_scm_test_silent_cmd "guile (define frame (selected-frame))" \
40 "get frame"
41 gdb_scm_test_silent_cmd "guile (define sal (frame-sal frame))" \
42 "get sal"
43 gdb_scm_test_silent_cmd "guile (define symtab (sal-symtab sal))" \
44 "get symtab"
45 gdb_scm_test_silent_cmd "guile (define global-block (symtab-global-block symtab))" \
46 "get global block"
47 gdb_scm_test_silent_cmd "guile (define static-block (symtab-static-block symtab))" \
48 "get static block"
49
50 gdb_scm_test_silent_cmd "guile (define global-symbols (map symbol-name (block-symbols global-block)))" \
51 "get global symbol names"
52 gdb_scm_test_silent_cmd "guile (define static-symbols (map symbol-name (block-symbols static-block)))" \
53 "get static symbol names"
54 gdb_scm_test_silent_cmd "guile (define global-isymbols '()) (define static-isymbols '())" \
55 "set up iterated symbol name lists"
56 # TODO: iterated symbols
57 gdb_scm_test_silent_cmd "step" "Step to the next line"
58 gdb_scm_test_silent_cmd "guile (define new-pc (sal-pc (frame-sal (selected-frame))))" \
59 "get new pc"
60
61 # Test sal.
62 gdb_test "guile (print (sal-symtab sal))" \
63 ".*gdb.guile/scm-symtab.c.*" "Test sal-symtab"
64 gdb_test "guile (print (sal-pc sal))" \
65 "${decimal}" "test sal-pc"
66 gdb_test "guile (print (= (sal-last sal) (- new-pc 1)))" \
67 "#t" "test sal-last"
68 gdb_test "guile (print (sal-line sal))" \
69 "$line_no" "test sal-line"
70 gdb_test "guile (print (sal-valid? sal))" \
71 "#t" "test sal-valid?"
72
73 # Test eq? on symtabs.
74 gdb_scm_test_silent_cmd "guile (define sal1 (frame-sal frame))" \
75 "get sal1"
76 gdb_scm_test_silent_cmd "guile (define sal2 (frame-sal (frame-older frame)))" \
77 "get sal2"
78 gdb_test "guile (print (eq? symtab (sal-symtab sal1)))" \
79 "= #t" "test eq? of equal symtabs"
80 gdb_test "guile (print (eq? symtab (sal-symtab sal2)))" \
81 "= #t" "test eq? of equal symtabs from different sals"
82 gdb_test "guile (print (eq? symtab (symbol-symtab (lookup-global-symbol \"func1\"))))" \
83 "= #f" "test eq? of not-equal symtabs"
84
85 # Test symbol table.
86 gdb_test "guile (print (symtab-filename symtab))" \
87 ".*gdb.guile/scm-symtab.c.*" "test symtab-filename"
88 gdb_test "guile (print (symtab-objfile symtab))" \
89 "#<gdb:objfile .*scm-symtab>" "test symtab-objfile"
90 gdb_test "guile (print (symtab-fullname symtab))" \
91 "testsuite/gdb.guile/scm-symtab.c.*" "test symtab-fullname"
92 gdb_test "guile (print (symtab-valid? symtab))" \
93 "#t" "test symtab-valid?"
94 gdb_test "guile (print (->bool (member \"qq\" global-symbols)))" \
95 "#t" "test qq in global symbols"
96 gdb_test "guile (print (->bool (member \"func\" global-symbols)))" \
97 "#t" "test func in global symbols"
98 gdb_test "guile (print (->bool (member \"main\" global-symbols)))" \
99 "#t" "test main in global symbols"
100 gdb_test "guile (print (->bool (member \"int\" static-symbols)))" \
101 "#t" "test int in static symbols"
102 gdb_test "guile (print (->bool (member \"char\" static-symbols)))" \
103 "#t" "test char in static symbols"
104 gdb_test "guile (print (->bool (member \"simple_struct\" static-symbols)))" \
105 "#t" "test simple_struct in static symbols"
106
107 # Test is_valid when the objfile is unloaded. This must be the last
108 # test as it unloads the object file in GDB.
109 gdb_unload
110 gdb_test "guile (print (sal-valid? sal))" \
111 "#f" "test sal-valid? after unloading"
112 gdb_test "guile (print (symtab-valid? symtab))" \
113 "#f" "test symtab-valid? after unloading"
114
115 gdb_test_no_output "guile (set! sal #f)" \
116 "test sal destructor"
117 gdb_test_no_output "guile (set! symtab #f)" \
118 "test symtab destructor"
119 gdb_test_no_output "guile (gc)" "GC to trigger destructors"
120
121 # Start with a fresh gdb.
122 clean_restart ${testfile}
123
124 # Test find-pc-line.
125 # The following tests require execution.
126
127 if ![gdb_guile_runto_main] {
128 return
129 }
130
131 runto [gdb_get_line_number "Break at func2 call site."]
132
133 gdb_scm_test_silent_cmd "guile (define line (sal-line (frame-sal (selected-frame))))" \
134 "get line number of func2 call site"
135 gdb_test "guile (print (= (sal-line (find-pc-line (frame-pc (selected-frame)))) line))" \
136 "#t" "test find-pc-line at func2 call site"
137
138 gdb_scm_test_silent_cmd "step" "step into func2"
139 gdb_scm_test_silent_cmd "up" "step out of func2"
140
141 gdb_test "guile (print (> (sal-line (find-pc-line (frame-pc (selected-frame)))) line))" \
142 "#t" "test find-pc-line with resume address"