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