Switch the license of all .exp files to GPLv3.
[deliverable/binutils-gdb.git] / gdb / block.h
1 /* Code dealing with blocks for GDB.
2
3 Copyright (C) 2003, 2007 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 /* Opaque declarations. */
24
25 struct symbol;
26 struct symtab;
27 struct block_namespace_info;
28 struct using_direct;
29 struct obstack;
30 struct dictionary;
31
32 /* All of the name-scope contours of the program
33 are represented by `struct block' objects.
34 All of these objects are pointed to by the blockvector.
35
36 Each block represents one name scope.
37 Each lexical context has its own block.
38
39 The blockvector begins with some special blocks.
40 The GLOBAL_BLOCK contains all the symbols defined in this compilation
41 whose scope is the entire program linked together.
42 The STATIC_BLOCK contains all the symbols whose scope is the
43 entire compilation excluding other separate compilations.
44 Blocks starting with the FIRST_LOCAL_BLOCK are not special.
45
46 Each block records a range of core addresses for the code that
47 is in the scope of the block. The STATIC_BLOCK and GLOBAL_BLOCK
48 give, for the range of code, the entire range of code produced
49 by the compilation that the symbol segment belongs to.
50
51 The blocks appear in the blockvector
52 in order of increasing starting-address,
53 and, within that, in order of decreasing ending-address.
54
55 This implies that within the body of one function
56 the blocks appear in the order of a depth-first tree walk. */
57
58 struct block
59 {
60
61 /* Addresses in the executable code that are in this block. */
62
63 CORE_ADDR startaddr;
64 CORE_ADDR endaddr;
65
66 /* The symbol that names this block, if the block is the body of a
67 function; otherwise, zero. */
68
69 struct symbol *function;
70
71 /* The `struct block' for the containing block, or 0 if none.
72
73 The superblock of a top-level local block (i.e. a function in the
74 case of C) is the STATIC_BLOCK. The superblock of the
75 STATIC_BLOCK is the GLOBAL_BLOCK. */
76
77 struct block *superblock;
78
79 /* This is used to store the symbols in the block. */
80
81 struct dictionary *dict;
82
83 /* Used for language-specific info. */
84
85 union
86 {
87 struct
88 {
89 /* Contains information about namespace-related info relevant to
90 this block: using directives and the current namespace
91 scope. */
92
93 struct block_namespace_info *namespace;
94 }
95 cplus_specific;
96 }
97 language_specific;
98
99 /* Version of GCC used to compile the function corresponding
100 to this block, or 0 if not compiled with GCC. When possible,
101 GCC should be compatible with the native compiler, or if that
102 is not feasible, the differences should be fixed during symbol
103 reading. As of 16 Apr 93, this flag is never used to distinguish
104 between gcc2 and the native compiler.
105
106 If there is no function corresponding to this block, this meaning
107 of this flag is undefined. */
108
109 unsigned char gcc_compile_flag;
110 };
111
112 #define BLOCK_START(bl) (bl)->startaddr
113 #define BLOCK_END(bl) (bl)->endaddr
114 #define BLOCK_FUNCTION(bl) (bl)->function
115 #define BLOCK_SUPERBLOCK(bl) (bl)->superblock
116 #define BLOCK_GCC_COMPILED(bl) (bl)->gcc_compile_flag
117 #define BLOCK_DICT(bl) (bl)->dict
118 #define BLOCK_NAMESPACE(bl) (bl)->language_specific.cplus_specific.namespace
119
120 /* Macro to loop through all symbols in a block BL, in no particular
121 order. ITER helps keep track of the iteration, and should be a
122 struct dict_iterator. SYM points to the current symbol. */
123
124 #define ALL_BLOCK_SYMBOLS(block, iter, sym) \
125 ALL_DICT_SYMBOLS (BLOCK_DICT (block), iter, sym)
126
127 struct blockvector
128 {
129 /* Number of blocks in the list. */
130 int nblocks;
131 /* The blocks themselves. */
132 struct block *block[1];
133 };
134
135 #define BLOCKVECTOR_NBLOCKS(blocklist) (blocklist)->nblocks
136 #define BLOCKVECTOR_BLOCK(blocklist,n) (blocklist)->block[n]
137
138 /* Special block numbers */
139
140 enum { GLOBAL_BLOCK = 0, STATIC_BLOCK = 1, FIRST_LOCAL_BLOCK = 2 };
141
142 extern struct symbol *block_function (const struct block *);
143
144 extern int contained_in (const struct block *, const struct block *);
145
146 extern struct blockvector *blockvector_for_pc (CORE_ADDR, int *);
147
148 extern struct blockvector *blockvector_for_pc_sect (CORE_ADDR, asection *,
149 int *, struct symtab *);
150
151 extern struct block *block_for_pc (CORE_ADDR);
152
153 extern struct block *block_for_pc_sect (CORE_ADDR, asection *);
154
155 extern const char *block_scope (const struct block *block);
156
157 extern void block_set_scope (struct block *block, const char *scope,
158 struct obstack *obstack);
159
160 extern struct using_direct *block_using (const struct block *block);
161
162 extern void block_set_using (struct block *block,
163 struct using_direct *using,
164 struct obstack *obstack);
165
166 extern const struct block *block_static_block (const struct block *block);
167
168 extern const struct block *block_global_block (const struct block *block);
169
170 extern struct block *allocate_block (struct obstack *obstack);
171
172 #endif /* BLOCK_H */
This page took 0.032681 seconds and 4 git commands to generate.