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/>. */
21 /* Local non-gdb includes. */
22 #include "buildsym-legacy.h"
24 /* The work-in-progress of the compunit we are building.
25 This is created first, before any subfiles by start_symtab. */
27 static struct buildsym_compunit
*buildsym_compunit
;
30 record_debugformat (const char *format
)
32 buildsym_compunit
->record_debugformat (format
);
36 record_producer (const char *producer
)
38 buildsym_compunit
->record_producer (producer
);
46 set_last_source_file (const char *name
)
48 gdb_assert (buildsym_compunit
!= nullptr || name
== nullptr);
49 if (buildsym_compunit
!= nullptr)
50 buildsym_compunit
->set_last_source_file (name
);
56 get_last_source_file ()
58 if (buildsym_compunit
== nullptr)
60 return buildsym_compunit
->get_last_source_file ();
66 set_last_source_start_addr (CORE_ADDR addr
)
68 gdb_assert (buildsym_compunit
!= nullptr);
69 buildsym_compunit
->set_last_source_start_addr (addr
);
75 get_last_source_start_addr ()
77 gdb_assert (buildsym_compunit
!= nullptr);
78 return buildsym_compunit
->get_last_source_start_addr ();
83 struct using_direct
**
84 get_local_using_directives ()
86 gdb_assert (buildsym_compunit
!= nullptr);
87 return buildsym_compunit
->get_local_using_directives ();
93 set_local_using_directives (struct using_direct
*new_local
)
95 gdb_assert (buildsym_compunit
!= nullptr);
96 buildsym_compunit
->set_local_using_directives (new_local
);
101 struct using_direct
**
102 get_global_using_directives ()
104 gdb_assert (buildsym_compunit
!= nullptr);
105 return buildsym_compunit
->get_global_using_directives ();
108 /* See buildsym.h. */
111 outermost_context_p ()
113 gdb_assert (buildsym_compunit
!= nullptr);
114 return buildsym_compunit
->outermost_context_p ();
117 /* See buildsym.h. */
119 struct context_stack
*
120 get_current_context_stack ()
122 gdb_assert (buildsym_compunit
!= nullptr);
123 return buildsym_compunit
->get_current_context_stack ();
126 /* See buildsym.h. */
129 get_context_stack_depth ()
131 gdb_assert (buildsym_compunit
!= nullptr);
132 return buildsym_compunit
->get_context_stack_depth ();
135 /* See buildsym.h. */
138 get_current_subfile ()
140 gdb_assert (buildsym_compunit
!= nullptr);
141 return buildsym_compunit
->get_current_subfile ();
144 /* See buildsym.h. */
149 gdb_assert (buildsym_compunit
!= nullptr);
150 return buildsym_compunit
->get_local_symbols ();
153 /* See buildsym.h. */
158 gdb_assert (buildsym_compunit
!= nullptr);
159 return buildsym_compunit
->get_file_symbols ();
162 /* See buildsym.h. */
165 get_global_symbols ()
167 gdb_assert (buildsym_compunit
!= nullptr);
168 return buildsym_compunit
->get_global_symbols ();
172 start_subfile (const char *name
)
174 gdb_assert (buildsym_compunit
!= nullptr);
175 buildsym_compunit
->start_subfile (name
);
179 patch_subfile_names (struct subfile
*subfile
, const char *name
)
181 gdb_assert (buildsym_compunit
!= nullptr);
182 buildsym_compunit
->patch_subfile_names (subfile
, name
);
188 gdb_assert (buildsym_compunit
!= nullptr);
189 buildsym_compunit
->push_subfile ();
195 gdb_assert (buildsym_compunit
!= nullptr);
196 return buildsym_compunit
->pop_subfile ();
199 /* Delete the buildsym compunit. */
202 free_buildsym_compunit (void)
204 if (buildsym_compunit
== NULL
)
206 delete buildsym_compunit
;
207 buildsym_compunit
= NULL
;
210 struct compunit_symtab
*
211 end_symtab (CORE_ADDR end_addr
, int section
)
213 gdb_assert (buildsym_compunit
!= nullptr);
214 struct compunit_symtab
*result
215 = buildsym_compunit
->end_symtab (end_addr
, section
);
216 free_buildsym_compunit ();
220 struct context_stack
*
221 push_context (int desc
, CORE_ADDR valu
)
223 gdb_assert (buildsym_compunit
!= nullptr);
224 return buildsym_compunit
->push_context (desc
, valu
);
230 gdb_assert (buildsym_compunit
!= nullptr);
231 return buildsym_compunit
->pop_context ();
235 finish_block (struct symbol
*symbol
, struct pending_block
*old_blocks
,
236 const struct dynamic_prop
*static_link
,
237 CORE_ADDR start
, CORE_ADDR end
)
239 gdb_assert (buildsym_compunit
!= nullptr);
240 return buildsym_compunit
->finish_block (symbol
, old_blocks
, static_link
,
245 record_block_range (struct block
*block
, CORE_ADDR start
,
246 CORE_ADDR end_inclusive
)
248 gdb_assert (buildsym_compunit
!= nullptr);
249 buildsym_compunit
->record_block_range (block
, start
, end_inclusive
);
253 record_line (struct subfile
*subfile
, int line
, CORE_ADDR pc
)
255 gdb_assert (buildsym_compunit
!= nullptr);
256 buildsym_compunit
->record_line (subfile
, line
, pc
);
259 /* Start a new symtab for a new source file in OBJFILE. Called, for example,
260 when a stabs symbol of type N_SO is seen, or when a DWARF
261 TAG_compile_unit DIE is seen. It indicates the start of data for
262 one original source file.
264 NAME is the name of the file (cannot be NULL). COMP_DIR is the
265 directory in which the file was compiled (or NULL if not known).
266 START_ADDR is the lowest address of objects in the file (or 0 if
267 not known). LANGUAGE is the language of the source file, or
268 language_unknown if not known, in which case it'll be deduced from
271 struct compunit_symtab
*
272 start_symtab (struct objfile
*objfile
, const char *name
, const char *comp_dir
,
273 CORE_ADDR start_addr
, enum language language
)
275 /* These should have been reset either by successful completion of building
276 a symtab, or by the scoped_free_pendings destructor. */
277 gdb_assert (buildsym_compunit
== nullptr);
279 buildsym_compunit
= new struct buildsym_compunit (objfile
, name
, comp_dir
,
280 language
, start_addr
);
282 return buildsym_compunit
->get_compunit_symtab ();
285 /* Restart compilation for a symtab.
286 CUST is the result of end_expandable_symtab.
287 NAME, START_ADDR are the source file we are resuming with.
289 This is used when a symtab is built from multiple sources.
290 The symtab is first built with start_symtab/end_expandable_symtab
291 and then for each additional piece call restart_symtab/augment_*_symtab.
292 Note: At the moment there is only augment_type_symtab. */
295 restart_symtab (struct compunit_symtab
*cust
,
296 const char *name
, CORE_ADDR start_addr
)
298 /* These should have been reset either by successful completion of building
299 a symtab, or by the scoped_free_pendings destructor. */
300 gdb_assert (buildsym_compunit
== nullptr);
303 = new struct buildsym_compunit (COMPUNIT_OBJFILE (cust
),
305 COMPUNIT_DIRNAME (cust
),
306 compunit_language (cust
),
311 /* See buildsym.h. */
313 struct compunit_symtab
*
314 buildsym_compunit_symtab (void)
316 gdb_assert (buildsym_compunit
!= NULL
);
318 return buildsym_compunit
->get_compunit_symtab ();
321 /* See buildsym.h. */
324 get_macro_table (void)
326 gdb_assert (buildsym_compunit
!= NULL
);
327 return buildsym_compunit
->get_macro_table ();
330 /* At end of reading syms, or in case of quit, ensure everything
331 associated with building symtabs is freed.
333 N.B. This is *not* intended to be used when building psymtabs. Some debug
334 info readers call this anyway, which is harmless if confusing. */
336 scoped_free_pendings::~scoped_free_pendings ()
338 free_buildsym_compunit ();
341 /* See buildsym-legacy.h. */
343 struct buildsym_compunit
*
344 get_buildsym_compunit ()
346 gdb_assert (buildsym_compunit
!= nullptr);
347 return buildsym_compunit
;
This page took 0.038572 seconds and 5 git commands to generate.