1 /* Build symbol tables in GDB's internal format - legacy APIs
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/>. */
19 #if !defined (LEGACY_BUILDSYM_H)
20 #define LEGACY_BUILDSYM_H 1
24 /* This module provides definitions used for creating and adding to
25 the symbol table. These routines are called from various symbol-
26 file-reading routines. This file holds the legacy API, which
27 relies on a global variable to work properly. New or maintained
28 symbol readers should use the builder API in buildsym.h.
30 The basic way this module is used is as follows:
32 scoped_free_pendings free_pending;
33 cust = start_symtab (...);
34 ... read debug info ...
35 cust = end_symtab (...);
37 The compunit symtab pointer ("cust") is returned from both start_symtab
38 and end_symtab to simplify the debug info readers.
40 There are minor variations on this, e.g., dwarf2read.c splits end_symtab
41 into two calls: end_symtab_get_static_block, end_symtab_from_static_block,
42 but all debug info readers follow this basic flow.
44 Reading DWARF Type Units is another variation:
46 scoped_free_pendings free_pending;
47 cust = start_symtab (...);
48 ... read debug info ...
49 cust = end_expandable_symtab (...);
51 And then reading subsequent Type Units within the containing "Comp Unit"
52 will use a second flow:
54 scoped_free_pendings free_pending;
55 cust = restart_symtab (...);
56 ... read debug info ...
57 cust = augment_type_symtab (...);
59 dbxread.c and xcoffread.c use another variation:
61 scoped_free_pendings free_pending;
62 cust = start_symtab (...);
63 ... read debug info ...
64 cust = end_symtab (...);
65 ... start_symtab + read + end_symtab repeated ...
68 class scoped_free_pendings
72 scoped_free_pendings () = default;
73 ~scoped_free_pendings ();
75 DISABLE_COPY_AND_ASSIGN (scoped_free_pendings
);
78 extern struct block
*finish_block (struct symbol
*symbol
,
79 struct pending_block
*old_blocks
,
80 const struct dynamic_prop
*static_link
,
84 extern void record_block_range (struct block
*,
85 CORE_ADDR start
, CORE_ADDR end_inclusive
);
87 extern void start_subfile (const char *name
);
89 extern void patch_subfile_names (struct subfile
*subfile
, const char *name
);
91 extern void push_subfile ();
93 extern const char *pop_subfile ();
95 extern struct block
*end_symtab_get_static_block (CORE_ADDR end_addr
,
99 extern struct compunit_symtab
*
100 end_symtab_from_static_block (struct block
*static_block
,
101 int section
, int expandable
);
103 extern struct compunit_symtab
*end_symtab (CORE_ADDR end_addr
, int section
);
105 extern struct compunit_symtab
*end_expandable_symtab (CORE_ADDR end_addr
,
108 extern void augment_type_symtab (void);
110 extern struct context_stack
*push_context (int desc
, CORE_ADDR valu
);
112 extern struct context_stack
pop_context ();
114 extern record_line_ftype record_line
;
116 extern struct compunit_symtab
*start_symtab (struct objfile
*objfile
,
118 const char *comp_dir
,
119 CORE_ADDR start_addr
,
120 enum language language
);
122 extern void restart_symtab (struct compunit_symtab
*cust
,
123 const char *name
, CORE_ADDR start_addr
);
125 /* Record the name of the debug format in the current pending symbol
126 table. FORMAT must be a string with a lifetime at least as long as
127 the symtab's objfile. */
129 extern void record_debugformat (const char *format
);
131 /* Record the name of the debuginfo producer (usually the compiler) in
132 the current pending symbol table. PRODUCER must be a string with a
133 lifetime at least as long as the symtab's objfile. */
135 extern void record_producer (const char *producer
);
137 /* Set the name of the last source file. NAME is copied by this
140 extern void set_last_source_file (const char *name
);
142 /* Fetch the name of the last source file. */
144 extern const char *get_last_source_file (void);
146 /* Return the compunit symtab object.
147 It is only valid to call this between calls to start_symtab and the
148 end_symtab* functions. */
150 extern struct compunit_symtab
*buildsym_compunit_symtab (void);
152 /* Return the macro table.
153 Initialize it if this is the first use.
154 It is only valid to call this between calls to start_symtab and the
155 end_symtab* functions. */
157 extern struct macro_table
*get_macro_table (void);
159 /* Set the last source start address. Can only be used between
160 start_symtab and end_symtab* calls. */
162 extern void set_last_source_start_addr (CORE_ADDR addr
);
164 /* Get the last source start address. Can only be used between
165 start_symtab and end_symtab* calls. */
167 extern CORE_ADDR
get_last_source_start_addr ();
169 /* Return the local using directives. */
171 extern struct using_direct
**get_local_using_directives ();
173 /* Set the list of local using directives. */
175 extern void set_local_using_directives (struct using_direct
*new_local
);
177 /* Return the global using directives. */
179 extern struct using_direct
**get_global_using_directives ();
181 /* True if the context stack is empty. */
183 extern bool outermost_context_p ();
185 /* Return the top of the context stack, or nullptr if there is an
188 extern struct context_stack
*get_current_context_stack ();
190 /* Return the context stack depth. */
192 extern int get_context_stack_depth ();
194 /* Return the current subfile. */
196 extern struct subfile
*get_current_subfile ();
198 /* Return the local symbol list. */
200 extern struct pending
**get_local_symbols ();
202 /* Return the file symbol list. */
204 extern struct pending
**get_file_symbols ();
206 /* Return the global symbol list. */
208 extern struct pending
**get_global_symbols ();
210 /* Return the current buildsym_compunit. */
212 extern struct buildsym_compunit
*get_buildsym_compunit ();
214 #endif /* defined (LEGACY_BUILDSYM_H) */