1 # Copyright
2018-2019 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
/>.
18 # This test verifies that the commands
19 #
info [functions|variables|types
]
20 # respect the
'set language auto|ada|c' setting
, whatever the language
21 # of the current frame.
22 # Similarly
, checks that rbreak reports its results respecting
25 standard_ada_testfile proc_in_ada
27 # gnat normalizes proc_in_ada source file when compiling.
28 # As the
'info' commands results are sorted by absolute path names
, also normalize
29 # the some_c source file to ensure that the
'info' results are always
30 # giving Ada results first.
31 set csrcfile
[file normalize $
{srcdir
}/$
{subdir
}/$
{testdir
}/$
{cfile
}.c
]
32 set cobject
[standard_output_file $
{cfile
}.o
]
34 if { [gdb_compile
"${csrcfile}" "${cobject}" object [list debug]] != "" } {
35 untested
"failed to compile"
38 if {[gdb_compile_ada
"${srcfile}" "${binfile}" executable [list debug]] != "" } {
39 untested
"failed to compile"
43 clean_restart $
{testfile
}
45 set bp_location
[gdb_get_line_number
"STOP" ${testdir}/some_c.c]
46 if ![runto
"some_c.c:$bp_location"] then {
47 fail
"can't run to some_c.c STOP location"
51 set func_in_c
(c_syntax
) "${decimal}: void proc_in_c\\\(void\\\);"
52 set func_in_c
(ada_syntax
) "${decimal}: procedure proc_in_c;"
53 set func_in_ada
(c_syntax
) "${decimal}: void proc_in_ada\\\(void\\\);"
54 set func_in_ada
(ada_syntax
) "${decimal}: procedure proc_in_ada;"
56 set type_in_c
(c_syntax
) [multi_line \
57 "${decimal}: typedef struct {" \
58 " int some_component_in_c;" \
60 set type_in_c
(ada_syntax
) [multi_line \
61 "${decimal}: record" \
62 " some_component_in_c: int;" \
64 set type_in_ada
(c_syntax
) "${decimal}: struct global_pack__some_type_in_ada;"
65 set type_in_ada
(ada_syntax
) "${decimal}: global_pack.some_type_in_ada;"
67 set var_in_c
(c_syntax
) "${decimal}: some_type_in_c some_struct_in_c;"
68 set var_in_c
(ada_syntax
) "${decimal}: some_struct_in_c: some_type_in_c;"
69 set var_in_ada
(c_syntax
) "${decimal}: struct global_pack__some_type_in_ada global_pack.some_struct_in_ada;"
70 set var_in_ada
(ada_syntax
) "${decimal}: global_pack.some_struct_in_ada: global_pack.some_type_in_ada;"
72 set rbreak_func_in_c
(c_syntax
) "void proc_in_c\\\(void\\\);"
73 set rbreak_func_in_c
(ada_syntax
) "procedure proc_in_c;"
74 set rbreak_func_in_ada
(c_syntax
) "void proc_in_ada\\\(void\\\);"
75 set rbreak_func_in_ada
(ada_syntax
) "procedure proc_in_ada;"
78 foreach_with_prefix language_choice
{ "auto" "ada" "c" } {
80 # Check that switching to the desired language_choice when the selected
81 # frame has the same language
(or the desired language is auto
) gives no
82 # warning. Also
set the expected matches
for the various commands
84 if {$language_choice
== "auto"} {
85 gdb_test
"frame 0" "#0 .*" "select frame with lang c"
87 set ada_match ada_syntax
88 } elseif
{$language_choice
== "ada"} {
89 gdb_test
"frame 1" "#1 .*" "select frame with lang ada"
90 set c_match ada_syntax
91 set ada_match ada_syntax
92 } elseif
{$language_choice
== "c"} {
93 gdb_test
"frame 0" "#0 .*" "select frame with lang c"
95 set ada_match c_syntax
97 error
"unexpected language choice"
99 gdb_test_no_output
"set language $language_choice" "set language language_choice"
110 with_test_prefix
"frame=$frame, frame_lang=$frame_lang" {
112 gdb_test
"frame $frame" "#$frame .*" "select frame"
114 gdb_test
"info functions proc_in_" \
116 "All functions matching regular expression \"proc_in_\":" \
118 "File .*proc_in_ada.adb:" \
119 $func_in_ada
($ada_match
) \
125 gdb_test
"info types some_type" \
127 "All types matching regular expression \"some_type\":" \
129 "File .*global_pack.ads:" \
130 $type_in_ada
($ada_match
)\
136 gdb_test
"info variables some_struct" \
138 "All variables matching regular expression \"some_struct\":" \
140 "File .*global_pack.ads:" \
141 $var_in_ada
($ada_match
) \
147 gdb_test
"rbreak proc_in_" \
149 "Breakpoint.*file .*proc_in_ada.adb,.*" \
150 $rbreak_func_in_ada
($ada_match
) \
151 "Breakpoint.*file .*some_c.c,.*" \
152 $rbreak_func_in_c
($c_match
)