]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.mi/mi-info-sources.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-info-sources.exp
CommitLineData
213516ef 1# Copyright 2021-2023 Free Software Foundation, Inc.
0e350a05
AB
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# Test the -file-list-exec-source-files command.
17
18load_lib mi-support.exp
19set MIFLAGS "-i=mi"
20
21standard_testfile .c -base.c
22
98bf5c02 23if {[build_executable $testfile.exp $testfile \
0e350a05
AB
24 [list $srcfile $srcfile2] debug]} {
25 untested $testfile.exp
26 return -1
27}
28
29mi_clean_restart $binfile
30
c33be6de
TV
31set readnow_p [mi_readnow]
32
0e350a05
AB
33mi_runto_main
34
c33be6de
TV
35# Unload symbols for shared libraries to prevent
36# 'ERROR: internal buffer is full'.
37mi_gdb_test "nosharedlibrary" ".*\\^done" "nosharedlibrary"
38
0e350a05
AB
39# Helper to build expected MI output pattern for a list. NAME is the
40# name of the list (which can be the empty string) and args is one
41# or more strings representing the fields of the list, which will be
42# joined with a comma.
43#
44# If any of the fields in args matches ".*" then the comma before and
45# after are dropped from the final pattern.
46proc mi_list { name args } {
47 set str ""
48
49 if { $name != "" } {
50 set str "${name}="
51 }
52
53 set pattern ""
54 foreach a $args {
55 if { [string length $pattern] > 0 } {
56 if { [string range $pattern end-1 end] != ".*" \
57 && [string range $a 0 1] != ".*" } {
58 set pattern "${pattern},"
59 }
60 }
61 set pattern "${pattern}${a}"
62 }
63 set str "$str\\\[${pattern}\\\]"
64 return ${str}
65}
66
67# Helper to build expected MI output pattern for a tuple. NAME is the
68# name of the tuple (which can be the empty string) and args is one
69# or more strings representing the fields of the tuple, which will be
70# joined with a comma.
71#
72# If any of the fields in args matches ".*" then the comma before and
73# after are dropped from the final pattern.
74proc mi_tuple { name args } {
75 set str ""
76
77 if { $name != "" } {
78 set str "${name}="
79 }
80
81 set pattern ""
82 foreach a $args {
83 if { [string length $pattern] > 0 } {
84 if { [string range $pattern end-1 end] != ".*" \
85 && [string range $a 0 1] != ".*" } {
86 set pattern "${pattern},"
87 }
88 }
89 set pattern "${pattern}${a}"
90 }
91 set str "$str\\{${pattern}\\}"
92 return ${str}
93}
94
95# Helper to build expected MI output pattern for a single field. NAME
96# is the name of the field, and PATTERN matches the fields contents.
97# This proc will add quotes around PATTERN.
98proc mi_field { name pattern } {
99 set str ""
100
101 if { $name != "" } {
102 set str "${name}="
103 }
104
105 set str "$str\"${pattern}\""
106 return ${str}
107}
108
109# Run tests on '-file-list-exec-source-files'. DEBUG_FULLY_READ is either the string
110# "true" or "false" and indicates if the GDB will have read all the
111# debug for the test program or not yet.
112proc check_info_sources { debug_fully_read } {
113
114 with_test_prefix "debug_read=${debug_fully_read}" {
115
116 if { $debug_fully_read } {
c33be6de
TV
117 set p1 \
118 [mi_list "files" \
119 ".*" \
120 [mi_tuple "" \
121 [mi_field "file" "\[^\"\]+/mi-info-sources-base\\.c"] \
122 [mi_field "fullname" "\[^\"\]+/mi-info-sources-base\\.c"] \
123 [mi_field "debug-fully-read" "${debug_fully_read}"]] \
124 ".*"]
125 set p2 \
126 [mi_list "files" \
127 ".*" \
128 [mi_tuple "" \
129 [mi_field "file" "\[^\"\]+/mi-info-sources\\.c"] \
130 [mi_field "fullname" "\[^\"\]+/mi-info-sources\\.c"] \
131 [mi_field "debug-fully-read" "true"]] \
132 ".*"]
0e350a05 133 } else {
c33be6de
TV
134 set p1 \
135 [mi_list "files" \
136 ".*" \
137 [mi_tuple "" \
138 [mi_field "file" "\[^\"\]+/mi-info-sources\\.c"] \
139 [mi_field "fullname" "\[^\"\]+/mi-info-sources\\.c"] \
140 [mi_field "debug-fully-read" "true"]] \
141 ".*"]
142 set p2 \
143 [mi_list "files" \
144 ".*" \
145 [mi_tuple "" \
146 [mi_field "file" "\[^\"\]+/mi-info-sources-base\\.c"] \
147 [mi_field "fullname" "\[^\"\]+/mi-info-sources-base\\.c"] \
148 [mi_field "debug-fully-read" "${debug_fully_read}"]] \
149 ".*"]
0e350a05 150 }
c33be6de
TV
151
152 mi_gdb_test "-file-list-exec-source-files" ".*\\^done,${p1}" \
153 "-file-list-exec-source-files, src1"
154 mi_gdb_test "-file-list-exec-source-files" ".*\\^done,${p2}" \
155 "-file-list-exec-source-files, src2"
0e350a05
AB
156
157 set p [mi_list "files" \
158 [mi_tuple "" \
159 [mi_field "file" "\[^\"\]+/mi-info-sources-base\\.c"] \
160 [mi_field "fullname" "\[^\"\]+/mi-info-sources-base\\.c"] \
161 [mi_field "debug-fully-read" "${debug_fully_read}"]]]
162 mi_gdb_test "-file-list-exec-source-files --basename -- base" ".*\\^done,${p}" \
163 "-file-list-exec-source-files --basename -- base"
1fb1ce02
AB
164
165 # Figure out the value for the 'debug-info' field.
166 if {${debug_fully_read} == "true"} {
167 set debug_info "fully-read"
168 } else {
169 set debug_info "partially-read"
170 }
171
172 set p [mi_list "files" \
173 [mi_tuple "" \
c33be6de 174 [mi_field "filename" "\[^\"\]+/mi-info-sources(\.debug)?"] \
1fb1ce02
AB
175 [mi_field "debug-info" "${debug_info}"] \
176 [mi_list "sources" \
177 ".*" \
178 [mi_tuple "" \
179 [mi_field "file" "\[^\"\]+/mi-info-sources\\.c"] \
180 [mi_field "fullname" "\[^\"\]+/mi-info-sources\\.c"] \
181 [mi_field "debug-fully-read" "true"]] \
182 ".*"]]]
183 mi_gdb_test "-file-list-exec-source-files --group-by-objfile" \
184 ".*\\^done,${p}" \
185 "-file-list-exec-source-files --group-by-objfile, look for mi-info-sources.c"
186
187 set p [mi_list "files" \
188 [mi_tuple "" \
c33be6de 189 [mi_field "filename" "\[^\"\]+/mi-info-sources(\.debug)?"] \
1fb1ce02
AB
190 [mi_field "debug-info" "${debug_info}"] \
191 [mi_list "sources" \
192 ".*" \
193 [mi_tuple "" \
194 [mi_field "file" "\[^\"\]+/mi-info-sources-base\\.c"] \
195 [mi_field "fullname" "\[^\"\]+/mi-info-sources-base\\.c"] \
196 [mi_field "debug-fully-read" "${debug_fully_read}"]] \
197 ".*"]]]
198 mi_gdb_test "-file-list-exec-source-files --group-by-objfile" \
199 ".*\\^done,${p}" \
200 "-file-list-exec-source-files --group-by-objfile, look for mi-info-sources-base.c"
0e350a05
AB
201 }
202}
203
c33be6de
TV
204if { ! $readnow_p } {
205 check_info_sources "false"
206}
0e350a05
AB
207
208mi_continue_to "some_other_func"
209
c33be6de
TV
210# Force "fully-read".
211mi_gdb_test "maint expand-symtabs"
212
0e350a05 213check_info_sources "true"