gdb: add target_ops::supports_displaced_step
[deliverable/binutils-gdb.git] / gdb / buildsym-legacy.c
CommitLineData
0baae8db 1/* Legacy support routines for building symbol tables in GDB's internal format.
b811d2c2 2 Copyright (C) 1986-2020 Free Software Foundation, Inc.
0baae8db
TT
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19#include "defs.h"
20#include "buildsym-legacy.h"
0d12e84c 21#include "symtab.h"
0baae8db
TT
22
23/* The work-in-progress of the compunit we are building.
24 This is created first, before any subfiles by start_symtab. */
25
26static struct buildsym_compunit *buildsym_compunit;
27
28void
29record_debugformat (const char *format)
30{
31 buildsym_compunit->record_debugformat (format);
32}
33
34void
35record_producer (const char *producer)
36{
37 buildsym_compunit->record_producer (producer);
38}
39
40\f
41
42/* See buildsym.h. */
43
44void
45set_last_source_file (const char *name)
46{
47 gdb_assert (buildsym_compunit != nullptr || name == nullptr);
48 if (buildsym_compunit != nullptr)
49 buildsym_compunit->set_last_source_file (name);
50}
51
52/* See buildsym.h. */
53
54const char *
55get_last_source_file ()
56{
57 if (buildsym_compunit == nullptr)
58 return nullptr;
59 return buildsym_compunit->get_last_source_file ();
60}
61
62/* See buildsym.h. */
63
64void
65set_last_source_start_addr (CORE_ADDR addr)
66{
67 gdb_assert (buildsym_compunit != nullptr);
68 buildsym_compunit->set_last_source_start_addr (addr);
69}
70
71/* See buildsym.h. */
72
73CORE_ADDR
74get_last_source_start_addr ()
75{
76 gdb_assert (buildsym_compunit != nullptr);
77 return buildsym_compunit->get_last_source_start_addr ();
78}
79
80/* See buildsym.h. */
81
82struct using_direct **
83get_local_using_directives ()
84{
85 gdb_assert (buildsym_compunit != nullptr);
86 return buildsym_compunit->get_local_using_directives ();
87}
88
89/* See buildsym.h. */
90
91void
92set_local_using_directives (struct using_direct *new_local)
93{
94 gdb_assert (buildsym_compunit != nullptr);
95 buildsym_compunit->set_local_using_directives (new_local);
96}
97
98/* See buildsym.h. */
99
100struct using_direct **
101get_global_using_directives ()
102{
103 gdb_assert (buildsym_compunit != nullptr);
104 return buildsym_compunit->get_global_using_directives ();
105}
106
107/* See buildsym.h. */
108
109bool
110outermost_context_p ()
111{
112 gdb_assert (buildsym_compunit != nullptr);
113 return buildsym_compunit->outermost_context_p ();
114}
115
116/* See buildsym.h. */
117
118struct context_stack *
119get_current_context_stack ()
120{
121 gdb_assert (buildsym_compunit != nullptr);
122 return buildsym_compunit->get_current_context_stack ();
123}
124
125/* See buildsym.h. */
126
127int
128get_context_stack_depth ()
129{
130 gdb_assert (buildsym_compunit != nullptr);
131 return buildsym_compunit->get_context_stack_depth ();
132}
133
134/* See buildsym.h. */
135
136struct subfile *
137get_current_subfile ()
138{
139 gdb_assert (buildsym_compunit != nullptr);
140 return buildsym_compunit->get_current_subfile ();
141}
142
143/* See buildsym.h. */
144
145struct pending **
146get_local_symbols ()
147{
148 gdb_assert (buildsym_compunit != nullptr);
149 return buildsym_compunit->get_local_symbols ();
150}
151
152/* See buildsym.h. */
153
154struct pending **
155get_file_symbols ()
156{
157 gdb_assert (buildsym_compunit != nullptr);
158 return buildsym_compunit->get_file_symbols ();
159}
160
161/* See buildsym.h. */
162
163struct pending **
164get_global_symbols ()
165{
166 gdb_assert (buildsym_compunit != nullptr);
167 return buildsym_compunit->get_global_symbols ();
168}
169
170void
171start_subfile (const char *name)
172{
173 gdb_assert (buildsym_compunit != nullptr);
174 buildsym_compunit->start_subfile (name);
175}
176
177void
178patch_subfile_names (struct subfile *subfile, const char *name)
179{
180 gdb_assert (buildsym_compunit != nullptr);
181 buildsym_compunit->patch_subfile_names (subfile, name);
182}
183
184void
185push_subfile ()
186{
187 gdb_assert (buildsym_compunit != nullptr);
188 buildsym_compunit->push_subfile ();
189}
190
191const char *
192pop_subfile ()
193{
194 gdb_assert (buildsym_compunit != nullptr);
195 return buildsym_compunit->pop_subfile ();
196}
197
0baae8db
TT
198/* Delete the buildsym compunit. */
199
200static void
201free_buildsym_compunit (void)
202{
203 if (buildsym_compunit == NULL)
204 return;
205 delete buildsym_compunit;
206 buildsym_compunit = NULL;
207}
208
0baae8db
TT
209struct compunit_symtab *
210end_symtab (CORE_ADDR end_addr, int section)
211{
212 gdb_assert (buildsym_compunit != nullptr);
213 struct compunit_symtab *result
214 = buildsym_compunit->end_symtab (end_addr, section);
215 free_buildsym_compunit ();
216 return result;
217}
218
0baae8db
TT
219struct context_stack *
220push_context (int desc, CORE_ADDR valu)
221{
222 gdb_assert (buildsym_compunit != nullptr);
223 return buildsym_compunit->push_context (desc, valu);
224}
225
226struct context_stack
227pop_context ()
228{
229 gdb_assert (buildsym_compunit != nullptr);
230 return buildsym_compunit->pop_context ();
231}
232
233struct block *
234finish_block (struct symbol *symbol, struct pending_block *old_blocks,
235 const struct dynamic_prop *static_link,
236 CORE_ADDR start, CORE_ADDR end)
237{
238 gdb_assert (buildsym_compunit != nullptr);
239 return buildsym_compunit->finish_block (symbol, old_blocks, static_link,
240 start, end);
241}
242
243void
244record_block_range (struct block *block, CORE_ADDR start,
245 CORE_ADDR end_inclusive)
246{
247 gdb_assert (buildsym_compunit != nullptr);
248 buildsym_compunit->record_block_range (block, start, end_inclusive);
249}
250
251void
252record_line (struct subfile *subfile, int line, CORE_ADDR pc)
253{
254 gdb_assert (buildsym_compunit != nullptr);
8c95582d
AB
255 /* Assume every line entry is a statement start, that is a good place to
256 put a breakpoint for that line number. */
257 buildsym_compunit->record_line (subfile, line, pc, true);
0baae8db
TT
258}
259
260/* Start a new symtab for a new source file in OBJFILE. Called, for example,
261 when a stabs symbol of type N_SO is seen, or when a DWARF
262 TAG_compile_unit DIE is seen. It indicates the start of data for
263 one original source file.
264
265 NAME is the name of the file (cannot be NULL). COMP_DIR is the
266 directory in which the file was compiled (or NULL if not known).
267 START_ADDR is the lowest address of objects in the file (or 0 if
268 not known). LANGUAGE is the language of the source file, or
269 language_unknown if not known, in which case it'll be deduced from
270 the filename. */
271
272struct compunit_symtab *
273start_symtab (struct objfile *objfile, const char *name, const char *comp_dir,
274 CORE_ADDR start_addr, enum language language)
275{
276 /* These should have been reset either by successful completion of building
277 a symtab, or by the scoped_free_pendings destructor. */
278 gdb_assert (buildsym_compunit == nullptr);
279
280 buildsym_compunit = new struct buildsym_compunit (objfile, name, comp_dir,
281 language, start_addr);
282
283 return buildsym_compunit->get_compunit_symtab ();
284}
285
286/* Restart compilation for a symtab.
287 CUST is the result of end_expandable_symtab.
288 NAME, START_ADDR are the source file we are resuming with.
289
290 This is used when a symtab is built from multiple sources.
291 The symtab is first built with start_symtab/end_expandable_symtab
292 and then for each additional piece call restart_symtab/augment_*_symtab.
293 Note: At the moment there is only augment_type_symtab. */
294
295void
296restart_symtab (struct compunit_symtab *cust,
297 const char *name, CORE_ADDR start_addr)
298{
299 /* These should have been reset either by successful completion of building
300 a symtab, or by the scoped_free_pendings destructor. */
301 gdb_assert (buildsym_compunit == nullptr);
302
303 buildsym_compunit
304 = new struct buildsym_compunit (COMPUNIT_OBJFILE (cust),
305 name,
306 COMPUNIT_DIRNAME (cust),
307 compunit_language (cust),
308 start_addr,
309 cust);
310}
311
312/* See buildsym.h. */
313
314struct compunit_symtab *
315buildsym_compunit_symtab (void)
316{
317 gdb_assert (buildsym_compunit != NULL);
318
319 return buildsym_compunit->get_compunit_symtab ();
320}
321
322/* See buildsym.h. */
323
324struct macro_table *
325get_macro_table (void)
326{
0baae8db
TT
327 gdb_assert (buildsym_compunit != NULL);
328 return buildsym_compunit->get_macro_table ();
329}
330
331/* At end of reading syms, or in case of quit, ensure everything
332 associated with building symtabs is freed.
333
334 N.B. This is *not* intended to be used when building psymtabs. Some debug
335 info readers call this anyway, which is harmless if confusing. */
336
337scoped_free_pendings::~scoped_free_pendings ()
338{
339 free_buildsym_compunit ();
340}
80e649fc
TT
341
342/* See buildsym-legacy.h. */
343
344struct buildsym_compunit *
345get_buildsym_compunit ()
346{
347 gdb_assert (buildsym_compunit != nullptr);
348 return buildsym_compunit;
349}
This page took 0.183384 seconds and 4 git commands to generate.