Fix gdb.trace/entry-values.exp for thumb mode
[deliverable/binutils-gdb.git] / gdb / block.h
1 /* Code dealing with blocks for GDB.
2
3 Copyright (C) 2003-2014 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 #ifndef BLOCK_H
21 #define BLOCK_H
22
23 #include "dictionary.h"
24
25 /* Opaque declarations. */
26
27 struct symbol;
28 struct symtab;
29 struct block_namespace_info;
30 struct using_direct;
31 struct obstack;
32 struct addrmap;
33
34 /* All of the name-scope contours of the program
35 are represented by `struct block' objects.
36 All of these objects are pointed to by the blockvector.
37
38 Each block represents one name scope.
39 Each lexical context has its own block.
40
41 The blockvector begins with some special blocks.
42 The GLOBAL_BLOCK contains all the symbols defined in this compilation
43 whose scope is the entire program linked together.
44 The STATIC_BLOCK contains all the symbols whose scope is the
45 entire compilation excluding other separate compilations.
46 Blocks starting with the FIRST_LOCAL_BLOCK are not special.
47
48 Each block records a range of core addresses for the code that
49 is in the scope of the block. The STATIC_BLOCK and GLOBAL_BLOCK
50 give, for the range of code, the entire range of code produced
51 by the compilation that the symbol segment belongs to.
52
53 The blocks appear in the blockvector
54 in order of increasing starting-address,
55 and, within that, in order of decreasing ending-address.
56
57 This implies that within the body of one function
58 the blocks appear in the order of a depth-first tree walk. */
59
60 struct block
61 {
62
63 /* Addresses in the executable code that are in this block. */
64
65 CORE_ADDR startaddr;
66 CORE_ADDR endaddr;
67
68 /* The symbol that names this block, if the block is the body of a
69 function (real or inlined); otherwise, zero. */
70
71 struct symbol *function;
72
73 /* The `struct block' for the containing block, or 0 if none.
74
75 The superblock of a top-level local block (i.e. a function in the
76 case of C) is the STATIC_BLOCK. The superblock of the
77 STATIC_BLOCK is the GLOBAL_BLOCK. */
78
79 struct block *superblock;
80
81 /* This is used to store the symbols in the block. */
82
83 struct dictionary *dict;
84
85 /* Used for language-specific info. */
86
87 union
88 {
89 struct
90 {
91 /* Contains information about namespace-related info relevant to
92 this block: using directives and the current namespace
93 scope. */
94
95 struct block_namespace_info *namespace;
96 }
97 cplus_specific;
98 }
99 language_specific;
100 };
101
102 /* The global block is singled out so that we can provide a back-link
103 to the primary symtab. */
104
105 struct global_block
106 {
107 /* The block. */
108
109 struct block block;
110
111 /* This holds a pointer to the primary symtab holding this
112 block. */
113
114 struct symtab *symtab;
115 };
116
117 #define BLOCK_START(bl) (bl)->startaddr
118 #define BLOCK_END(bl) (bl)->endaddr
119 #define BLOCK_FUNCTION(bl) (bl)->function
120 #define BLOCK_SUPERBLOCK(bl) (bl)->superblock
121 #define BLOCK_DICT(bl) (bl)->dict
122 #define BLOCK_NAMESPACE(bl) (bl)->language_specific.cplus_specific.namespace
123
124 struct blockvector
125 {
126 /* Number of blocks in the list. */
127 int nblocks;
128 /* An address map mapping addresses to blocks in this blockvector.
129 This pointer is zero if the blocks' start and end addresses are
130 enough. */
131 struct addrmap *map;
132 /* The blocks themselves. */
133 struct block *block[1];
134 };
135
136 #define BLOCKVECTOR_NBLOCKS(blocklist) (blocklist)->nblocks
137 #define BLOCKVECTOR_BLOCK(blocklist,n) (blocklist)->block[n]
138 #define BLOCKVECTOR_MAP(blocklist) ((blocklist)->map)
139
140 extern struct symbol *block_linkage_function (const struct block *);
141
142 extern struct symbol *block_containing_function (const struct block *);
143
144 extern int block_inlined_p (const struct block *block);
145
146 extern int contained_in (const struct block *, const struct block *);
147
148 extern const struct blockvector *blockvector_for_pc (CORE_ADDR,
149 const struct block **);
150
151 extern const struct blockvector *blockvector_for_pc_sect (CORE_ADDR,
152 struct obj_section *,
153 const struct block **,
154 struct symtab *);
155
156 extern int blockvector_contains_pc (const struct blockvector *bv, CORE_ADDR pc);
157
158 extern struct call_site *call_site_for_pc (struct gdbarch *gdbarch,
159 CORE_ADDR pc);
160
161 extern const struct block *block_for_pc (CORE_ADDR);
162
163 extern const struct block *block_for_pc_sect (CORE_ADDR, struct obj_section *);
164
165 extern const char *block_scope (const struct block *block);
166
167 extern void block_set_scope (struct block *block, const char *scope,
168 struct obstack *obstack);
169
170 extern struct using_direct *block_using (const struct block *block);
171
172 extern void block_set_using (struct block *block,
173 struct using_direct *using,
174 struct obstack *obstack);
175
176 extern const struct block *block_static_block (const struct block *block);
177
178 extern const struct block *block_global_block (const struct block *block);
179
180 extern struct block *allocate_block (struct obstack *obstack);
181
182 extern struct block *allocate_global_block (struct obstack *obstack);
183
184 extern void set_block_symtab (struct block *, struct symtab *);
185
186 /* A block iterator. This structure should be treated as though it
187 were opaque; it is only defined here because we want to support
188 stack allocation of iterators. */
189
190 struct block_iterator
191 {
192 /* If we're iterating over a single block, this holds the block.
193 Otherwise, it holds the canonical symtab. */
194
195 union
196 {
197 struct symtab *symtab;
198 const struct block *block;
199 } d;
200
201 /* If we're iterating over a single block, this is always -1.
202 Otherwise, it holds the index of the current "included" symtab in
203 the canonical symtab (that is, d.symtab->includes[idx]), with -1
204 meaning the canonical symtab itself. */
205
206 int idx;
207
208 /* Which block, either static or global, to iterate over. If this
209 is FIRST_LOCAL_BLOCK, then we are iterating over a single block.
210 This is used to select which field of 'd' is in use. */
211
212 enum block_enum which;
213
214 /* The underlying dictionary iterator. */
215
216 struct dict_iterator dict_iter;
217 };
218
219 /* Initialize ITERATOR to point at the first symbol in BLOCK, and
220 return that first symbol, or NULL if BLOCK is empty. */
221
222 extern struct symbol *block_iterator_first (const struct block *block,
223 struct block_iterator *iterator);
224
225 /* Advance ITERATOR, and return the next symbol, or NULL if there are
226 no more symbols. Don't call this if you've previously received
227 NULL from block_iterator_first or block_iterator_next on this
228 iteration. */
229
230 extern struct symbol *block_iterator_next (struct block_iterator *iterator);
231
232 /* Initialize ITERATOR to point at the first symbol in BLOCK whose
233 SYMBOL_SEARCH_NAME is NAME (as tested using strcmp_iw), and return
234 that first symbol, or NULL if there are no such symbols. */
235
236 extern struct symbol *block_iter_name_first (const struct block *block,
237 const char *name,
238 struct block_iterator *iterator);
239
240 /* Advance ITERATOR to point at the next symbol in BLOCK whose
241 SYMBOL_SEARCH_NAME is NAME (as tested using strcmp_iw), or NULL if
242 there are no more such symbols. Don't call this if you've
243 previously received NULL from block_iterator_first or
244 block_iterator_next on this iteration. And don't call it unless
245 ITERATOR was created by a previous call to block_iter_name_first
246 with the same NAME. */
247
248 extern struct symbol *block_iter_name_next (const char *name,
249 struct block_iterator *iterator);
250
251 /* Initialize ITERATOR to point at the first symbol in BLOCK whose
252 SYMBOL_SEARCH_NAME is NAME, as tested using COMPARE (which must use
253 the same conventions as strcmp_iw and be compatible with any
254 block hashing function), and return that first symbol, or NULL
255 if there are no such symbols. */
256
257 extern struct symbol *block_iter_match_first (const struct block *block,
258 const char *name,
259 symbol_compare_ftype *compare,
260 struct block_iterator *iterator);
261
262 /* Advance ITERATOR to point at the next symbol in BLOCK whose
263 SYMBOL_SEARCH_NAME is NAME, as tested using COMPARE (see
264 block_iter_match_first), or NULL if there are no more such symbols.
265 Don't call this if you've previously received NULL from
266 block_iterator_match_first or block_iterator_match_next on this
267 iteration. And don't call it unless ITERATOR was created by a
268 previous call to block_iter_match_first with the same NAME and COMPARE. */
269
270 extern struct symbol *block_iter_match_next (const char *name,
271 symbol_compare_ftype *compare,
272 struct block_iterator *iterator);
273
274 /* Macro to loop through all symbols in a block BL, in no particular
275 order. ITER helps keep track of the iteration, and should be a
276 struct block_iterator. SYM points to the current symbol. */
277
278 #define ALL_BLOCK_SYMBOLS(block, iter, sym) \
279 for ((sym) = block_iterator_first ((block), &(iter)); \
280 (sym); \
281 (sym) = block_iterator_next (&(iter)))
282
283 #endif /* BLOCK_H */
This page took 0.035295 seconds and 4 git commands to generate.