2003-09-11 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gdb / block.h
CommitLineData
fe898f56
DC
1/* Code dealing with blocks for GDB.
2
3 Copyright 2003 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 2 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, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22#ifndef BLOCK_H
23#define BLOCK_H
24
25/* Opaque declarations. */
26
27struct symbol;
28struct symtab;
9219021c
DC
29struct block_namespace_info;
30struct using_direct;
31struct obstack;
de4f826b 32struct dictionary;
fe898f56
DC
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
60struct 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; 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
de4f826b
DC
81 /* This is used to store the symbols in the block. */
82
83 struct dictionary *dict;
84
9219021c
DC
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
fe898f56
DC
101 /* Version of GCC used to compile the function corresponding
102 to this block, or 0 if not compiled with GCC. When possible,
103 GCC should be compatible with the native compiler, or if that
104 is not feasible, the differences should be fixed during symbol
105 reading. As of 16 Apr 93, this flag is never used to distinguish
106 between gcc2 and the native compiler.
107
108 If there is no function corresponding to this block, this meaning
109 of this flag is undefined. */
110
111 unsigned char gcc_compile_flag;
fe898f56
DC
112};
113
114#define BLOCK_START(bl) (bl)->startaddr
115#define BLOCK_END(bl) (bl)->endaddr
116#define BLOCK_FUNCTION(bl) (bl)->function
117#define BLOCK_SUPERBLOCK(bl) (bl)->superblock
118#define BLOCK_GCC_COMPILED(bl) (bl)->gcc_compile_flag
de4f826b 119#define BLOCK_DICT(bl) (bl)->dict
9219021c 120#define BLOCK_NAMESPACE(bl) (bl)->language_specific.cplus_specific.namespace
fe898f56 121
de4f826b
DC
122/* Macro to loop through all symbols in a block BL, in no particular
123 order. ITER helps keep track of the iteration, and should be a
124 struct dict_iterator. SYM points to the current symbol. */
fe898f56 125
de4f826b
DC
126#define ALL_BLOCK_SYMBOLS(block, iter, sym) \
127 ALL_DICT_SYMBOLS (BLOCK_DICT (block), iter, sym)
fe898f56 128
fe898f56
DC
129struct blockvector
130{
131 /* Number of blocks in the list. */
132 int nblocks;
133 /* The blocks themselves. */
134 struct block *block[1];
135};
136
137#define BLOCKVECTOR_NBLOCKS(blocklist) (blocklist)->nblocks
138#define BLOCKVECTOR_BLOCK(blocklist,n) (blocklist)->block[n]
139
140/* Special block numbers */
141
142#define GLOBAL_BLOCK 0
143#define STATIC_BLOCK 1
144#define FIRST_LOCAL_BLOCK 2
145
0cf566ec 146extern struct symbol *block_function (const struct block *);
fe898f56 147
0cf566ec 148extern int contained_in (const struct block *, const struct block *);
fe898f56
DC
149
150extern struct blockvector *blockvector_for_pc (CORE_ADDR, int *);
151
152extern struct blockvector *blockvector_for_pc_sect (CORE_ADDR, asection *,
153 int *, struct symtab *);
154
155extern struct block *block_for_pc (CORE_ADDR);
156
157extern struct block *block_for_pc_sect (CORE_ADDR, asection *);
158
1fcb5155
DC
159extern const char *block_scope (const struct block *block);
160
9219021c
DC
161extern void block_set_scope (struct block *block, const char *scope,
162 struct obstack *obstack);
163
1fcb5155
DC
164extern struct using_direct *block_using (const struct block *block);
165
9219021c
DC
166extern void block_set_using (struct block *block,
167 struct using_direct *using,
168 struct obstack *obstack);
169
89a9d1b1
DC
170extern const struct block *block_static_block (const struct block *block);
171
1fcb5155
DC
172extern const struct block *block_global_block (const struct block *block);
173
fe898f56 174#endif /* BLOCK_H */
This page took 0.070267 seconds and 4 git commands to generate.