1 /* Legacy support routines for building symbol tables in GDB's internal format.
2 Copyright (C) 1986-2018 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 ();
198 end_symtab_get_static_block (CORE_ADDR end_addr
, int expandable
, int required
)
200 gdb_assert (buildsym_compunit
!= nullptr);
201 return buildsym_compunit
->end_symtab_get_static_block (end_addr
, expandable
,
205 /* Delete the buildsym compunit. */
208 free_buildsym_compunit (void)
210 if (buildsym_compunit
== NULL
)
212 delete buildsym_compunit
;
213 buildsym_compunit
= NULL
;
216 struct compunit_symtab
*
217 end_symtab_from_static_block (struct block
*static_block
,
218 int section
, int expandable
)
220 gdb_assert (buildsym_compunit
!= nullptr);
221 struct compunit_symtab
*result
222 = buildsym_compunit
->end_symtab_from_static_block (static_block
,
223 section
, expandable
);
224 free_buildsym_compunit ();
228 struct compunit_symtab
*
229 end_symtab (CORE_ADDR end_addr
, int section
)
231 gdb_assert (buildsym_compunit
!= nullptr);
232 struct compunit_symtab
*result
233 = buildsym_compunit
->end_symtab (end_addr
, section
);
234 free_buildsym_compunit ();
238 struct compunit_symtab
*
239 end_expandable_symtab (CORE_ADDR end_addr
, int section
)
241 gdb_assert (buildsym_compunit
!= nullptr);
242 struct compunit_symtab
*result
243 = buildsym_compunit
->end_expandable_symtab (end_addr
, section
);
244 free_buildsym_compunit ();
249 augment_type_symtab ()
251 gdb_assert (buildsym_compunit
!= nullptr);
252 buildsym_compunit
->augment_type_symtab ();
253 free_buildsym_compunit ();
256 struct context_stack
*
257 push_context (int desc
, CORE_ADDR valu
)
259 gdb_assert (buildsym_compunit
!= nullptr);
260 return buildsym_compunit
->push_context (desc
, valu
);
266 gdb_assert (buildsym_compunit
!= nullptr);
267 return buildsym_compunit
->pop_context ();
271 finish_block (struct symbol
*symbol
, struct pending_block
*old_blocks
,
272 const struct dynamic_prop
*static_link
,
273 CORE_ADDR start
, CORE_ADDR end
)
275 gdb_assert (buildsym_compunit
!= nullptr);
276 return buildsym_compunit
->finish_block (symbol
, old_blocks
, static_link
,
281 record_block_range (struct block
*block
, CORE_ADDR start
,
282 CORE_ADDR end_inclusive
)
284 gdb_assert (buildsym_compunit
!= nullptr);
285 buildsym_compunit
->record_block_range (block
, start
, end_inclusive
);
289 record_line (struct subfile
*subfile
, int line
, CORE_ADDR pc
)
291 gdb_assert (buildsym_compunit
!= nullptr);
292 buildsym_compunit
->record_line (subfile
, line
, pc
);
295 /* Start a new symtab for a new source file in OBJFILE. Called, for example,
296 when a stabs symbol of type N_SO is seen, or when a DWARF
297 TAG_compile_unit DIE is seen. It indicates the start of data for
298 one original source file.
300 NAME is the name of the file (cannot be NULL). COMP_DIR is the
301 directory in which the file was compiled (or NULL if not known).
302 START_ADDR is the lowest address of objects in the file (or 0 if
303 not known). LANGUAGE is the language of the source file, or
304 language_unknown if not known, in which case it'll be deduced from
307 struct compunit_symtab
*
308 start_symtab (struct objfile
*objfile
, const char *name
, const char *comp_dir
,
309 CORE_ADDR start_addr
, enum language language
)
311 /* These should have been reset either by successful completion of building
312 a symtab, or by the scoped_free_pendings destructor. */
313 gdb_assert (buildsym_compunit
== nullptr);
315 buildsym_compunit
= new struct buildsym_compunit (objfile
, name
, comp_dir
,
316 language
, start_addr
);
318 return buildsym_compunit
->get_compunit_symtab ();
321 /* Restart compilation for a symtab.
322 CUST is the result of end_expandable_symtab.
323 NAME, START_ADDR are the source file we are resuming with.
325 This is used when a symtab is built from multiple sources.
326 The symtab is first built with start_symtab/end_expandable_symtab
327 and then for each additional piece call restart_symtab/augment_*_symtab.
328 Note: At the moment there is only augment_type_symtab. */
331 restart_symtab (struct compunit_symtab
*cust
,
332 const char *name
, CORE_ADDR start_addr
)
334 /* These should have been reset either by successful completion of building
335 a symtab, or by the scoped_free_pendings destructor. */
336 gdb_assert (buildsym_compunit
== nullptr);
339 = new struct buildsym_compunit (COMPUNIT_OBJFILE (cust
),
341 COMPUNIT_DIRNAME (cust
),
342 compunit_language (cust
),
347 /* See buildsym.h. */
349 struct compunit_symtab
*
350 buildsym_compunit_symtab (void)
352 gdb_assert (buildsym_compunit
!= NULL
);
354 return buildsym_compunit
->get_compunit_symtab ();
357 /* See buildsym.h. */
360 get_macro_table (void)
362 struct objfile
*objfile
;
364 gdb_assert (buildsym_compunit
!= NULL
);
365 return buildsym_compunit
->get_macro_table ();
368 /* At end of reading syms, or in case of quit, ensure everything
369 associated with building symtabs is freed.
371 N.B. This is *not* intended to be used when building psymtabs. Some debug
372 info readers call this anyway, which is harmless if confusing. */
374 scoped_free_pendings::~scoped_free_pendings ()
376 free_buildsym_compunit ();
379 /* See buildsym-legacy.h. */
381 struct buildsym_compunit
*
382 get_buildsym_compunit ()
384 gdb_assert (buildsym_compunit
!= nullptr);
385 return buildsym_compunit
;
This page took 0.041086 seconds and 5 git commands to generate.