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