1 /* Legacy support routines for building symbol tables in GDB's internal format.
2 Copyright (C) 1986-2019 Free Software Foundation, Inc.
4 This file is part of GDB.
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.
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.
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/>. */
20 #include "buildsym-legacy.h"
22 /* The work-in-progress of the compunit we are building.
23 This is created first, before any subfiles by start_symtab. */
25 static struct buildsym_compunit
*buildsym_compunit
;
28 record_debugformat (const char *format
)
30 buildsym_compunit
->record_debugformat (format
);
34 record_producer (const char *producer
)
36 buildsym_compunit
->record_producer (producer
);
44 set_last_source_file (const char *name
)
46 gdb_assert (buildsym_compunit
!= nullptr || name
== nullptr);
47 if (buildsym_compunit
!= nullptr)
48 buildsym_compunit
->set_last_source_file (name
);
54 get_last_source_file ()
56 if (buildsym_compunit
== nullptr)
58 return buildsym_compunit
->get_last_source_file ();
64 set_last_source_start_addr (CORE_ADDR addr
)
66 gdb_assert (buildsym_compunit
!= nullptr);
67 buildsym_compunit
->set_last_source_start_addr (addr
);
73 get_last_source_start_addr ()
75 gdb_assert (buildsym_compunit
!= nullptr);
76 return buildsym_compunit
->get_last_source_start_addr ();
81 struct using_direct
**
82 get_local_using_directives ()
84 gdb_assert (buildsym_compunit
!= nullptr);
85 return buildsym_compunit
->get_local_using_directives ();
91 set_local_using_directives (struct using_direct
*new_local
)
93 gdb_assert (buildsym_compunit
!= nullptr);
94 buildsym_compunit
->set_local_using_directives (new_local
);
99 struct using_direct
**
100 get_global_using_directives ()
102 gdb_assert (buildsym_compunit
!= nullptr);
103 return buildsym_compunit
->get_global_using_directives ();
106 /* See buildsym.h. */
109 outermost_context_p ()
111 gdb_assert (buildsym_compunit
!= nullptr);
112 return buildsym_compunit
->outermost_context_p ();
115 /* See buildsym.h. */
117 struct context_stack
*
118 get_current_context_stack ()
120 gdb_assert (buildsym_compunit
!= nullptr);
121 return buildsym_compunit
->get_current_context_stack ();
124 /* See buildsym.h. */
127 get_context_stack_depth ()
129 gdb_assert (buildsym_compunit
!= nullptr);
130 return buildsym_compunit
->get_context_stack_depth ();
133 /* See buildsym.h. */
136 get_current_subfile ()
138 gdb_assert (buildsym_compunit
!= nullptr);
139 return buildsym_compunit
->get_current_subfile ();
142 /* See buildsym.h. */
147 gdb_assert (buildsym_compunit
!= nullptr);
148 return buildsym_compunit
->get_local_symbols ();
151 /* See buildsym.h. */
156 gdb_assert (buildsym_compunit
!= nullptr);
157 return buildsym_compunit
->get_file_symbols ();
160 /* See buildsym.h. */
163 get_global_symbols ()
165 gdb_assert (buildsym_compunit
!= nullptr);
166 return buildsym_compunit
->get_global_symbols ();
170 start_subfile (const char *name
)
172 gdb_assert (buildsym_compunit
!= nullptr);
173 buildsym_compunit
->start_subfile (name
);
177 patch_subfile_names (struct subfile
*subfile
, const char *name
)
179 gdb_assert (buildsym_compunit
!= nullptr);
180 buildsym_compunit
->patch_subfile_names (subfile
, name
);
186 gdb_assert (buildsym_compunit
!= nullptr);
187 buildsym_compunit
->push_subfile ();
193 gdb_assert (buildsym_compunit
!= nullptr);
194 return buildsym_compunit
->pop_subfile ();
197 /* Delete the buildsym compunit. */
200 free_buildsym_compunit (void)
202 if (buildsym_compunit
== NULL
)
204 delete buildsym_compunit
;
205 buildsym_compunit
= NULL
;
208 struct compunit_symtab
*
209 end_symtab (CORE_ADDR end_addr
, int section
)
211 gdb_assert (buildsym_compunit
!= nullptr);
212 struct compunit_symtab
*result
213 = buildsym_compunit
->end_symtab (end_addr
, section
);
214 free_buildsym_compunit ();
218 struct context_stack
*
219 push_context (int desc
, CORE_ADDR valu
)
221 gdb_assert (buildsym_compunit
!= nullptr);
222 return buildsym_compunit
->push_context (desc
, valu
);
228 gdb_assert (buildsym_compunit
!= nullptr);
229 return buildsym_compunit
->pop_context ();
233 finish_block (struct symbol
*symbol
, struct pending_block
*old_blocks
,
234 const struct dynamic_prop
*static_link
,
235 CORE_ADDR start
, CORE_ADDR end
)
237 gdb_assert (buildsym_compunit
!= nullptr);
238 return buildsym_compunit
->finish_block (symbol
, old_blocks
, static_link
,
243 record_block_range (struct block
*block
, CORE_ADDR start
,
244 CORE_ADDR end_inclusive
)
246 gdb_assert (buildsym_compunit
!= nullptr);
247 buildsym_compunit
->record_block_range (block
, start
, end_inclusive
);
251 record_line (struct subfile
*subfile
, int line
, CORE_ADDR pc
)
253 gdb_assert (buildsym_compunit
!= nullptr);
254 buildsym_compunit
->record_line (subfile
, line
, pc
);
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.
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
269 struct compunit_symtab
*
270 start_symtab (struct objfile
*objfile
, const char *name
, const char *comp_dir
,
271 CORE_ADDR start_addr
, enum language language
)
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);
277 buildsym_compunit
= new struct buildsym_compunit (objfile
, name
, comp_dir
,
278 language
, start_addr
);
280 return buildsym_compunit
->get_compunit_symtab ();
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.
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. */
293 restart_symtab (struct compunit_symtab
*cust
,
294 const char *name
, CORE_ADDR start_addr
)
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);
301 = new struct buildsym_compunit (COMPUNIT_OBJFILE (cust
),
303 COMPUNIT_DIRNAME (cust
),
304 compunit_language (cust
),
309 /* See buildsym.h. */
311 struct compunit_symtab
*
312 buildsym_compunit_symtab (void)
314 gdb_assert (buildsym_compunit
!= NULL
);
316 return buildsym_compunit
->get_compunit_symtab ();
319 /* See buildsym.h. */
322 get_macro_table (void)
324 gdb_assert (buildsym_compunit
!= NULL
);
325 return buildsym_compunit
->get_macro_table ();
328 /* At end of reading syms, or in case of quit, ensure everything
329 associated with building symtabs is freed.
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. */
334 scoped_free_pendings::~scoped_free_pendings ()
336 free_buildsym_compunit ();
339 /* See buildsym-legacy.h. */
341 struct buildsym_compunit
*
342 get_buildsym_compunit ()
344 gdb_assert (buildsym_compunit
!= nullptr);
345 return buildsym_compunit
;
This page took 0.036565 seconds and 4 git commands to generate.