annotate include/gdb/gdb-index.h @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Public attributes of the .gdb_index section.
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
2 Copyright (C) 2012-2020 Free Software Foundation, Inc.
111
kono
parents:
diff changeset
3
kono
parents:
diff changeset
4 This file is part of GDB.
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 This program is free software; you can redistribute it and/or modify
kono
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
8 the Free Software Foundation; either version 3 of the License, or
kono
parents:
diff changeset
9 (at your option) any later version.
kono
parents:
diff changeset
10
kono
parents:
diff changeset
11 This program is distributed in the hope that it will be useful,
kono
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kono
parents:
diff changeset
14 GNU General Public License for more details.
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
18
kono
parents:
diff changeset
19 /* This file contains values for understanding the .gdb_index section
kono
parents:
diff changeset
20 needed by more than just GDB, e.g. readelf. */
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 #ifndef GDB_INDEX_H
kono
parents:
diff changeset
23 #define GDB_INDEX_H
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 /* Each symbol in .gdb_index refers to a set of CUs that defines the symbol.
kono
parents:
diff changeset
26 Each CU is represented by a 32 bit number that is the index of the CU in
kono
parents:
diff changeset
27 the CU table, plus some attributes of the use of the symbol in that CU.
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 The values are defined such that if all the bits are zero, then no
kono
parents:
diff changeset
30 special meaning is assigned to any of them. This is done to preserve
kono
parents:
diff changeset
31 compatibility with older indices. The way this is done is to specify
kono
parents:
diff changeset
32 that if the GDB_INDEX_SYMBOL_KIND value is zero then all other attribute
kono
parents:
diff changeset
33 bits must be zero.
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 0-23 CU index
kono
parents:
diff changeset
36 24-27 reserved
kono
parents:
diff changeset
37 28-30 symbol kind
kono
parents:
diff changeset
38 31 0 == global, 1 == static
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 Bits 24-27 are reserved because it's easier to relax restrictions than
kono
parents:
diff changeset
41 it is to impose them after the fact. At present 24 bits to represent
kono
parents:
diff changeset
42 the CU index is plenty. If we need more bits for the CU index or for
kono
parents:
diff changeset
43 attributes then we have them. */
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 /* Whether the symbol is in GLOBAL_BLOCK (== 0) or STATIC_BLOCK (== 1). */
kono
parents:
diff changeset
46 #define GDB_INDEX_SYMBOL_STATIC_SHIFT 31
kono
parents:
diff changeset
47 #define GDB_INDEX_SYMBOL_STATIC_MASK 1
kono
parents:
diff changeset
48 #define GDB_INDEX_SYMBOL_STATIC_VALUE(cu_index) \
kono
parents:
diff changeset
49 (((cu_index) >> GDB_INDEX_SYMBOL_STATIC_SHIFT) & GDB_INDEX_SYMBOL_STATIC_MASK)
kono
parents:
diff changeset
50 #define GDB_INDEX_SYMBOL_STATIC_SET_VALUE(cu_index, value) \
kono
parents:
diff changeset
51 do { \
kono
parents:
diff changeset
52 (cu_index) |= (((value) & GDB_INDEX_SYMBOL_STATIC_MASK) \
kono
parents:
diff changeset
53 << GDB_INDEX_SYMBOL_STATIC_SHIFT); \
kono
parents:
diff changeset
54 } while (0)
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 /* The kind of the symbol.
kono
parents:
diff changeset
57 We don't use GDB's internal values as these numbers are published
kono
parents:
diff changeset
58 so that other tools can build and read .gdb_index. */
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 typedef enum {
kono
parents:
diff changeset
61 /* Special value to indicate no attributes are present. */
kono
parents:
diff changeset
62 GDB_INDEX_SYMBOL_KIND_NONE = 0,
kono
parents:
diff changeset
63 GDB_INDEX_SYMBOL_KIND_TYPE = 1,
kono
parents:
diff changeset
64 GDB_INDEX_SYMBOL_KIND_VARIABLE = 2,
kono
parents:
diff changeset
65 GDB_INDEX_SYMBOL_KIND_FUNCTION = 3,
kono
parents:
diff changeset
66 GDB_INDEX_SYMBOL_KIND_OTHER = 4,
kono
parents:
diff changeset
67 /* We currently allocate 3 bits to record the symbol kind.
kono
parents:
diff changeset
68 Give the unused bits a value so gdb will print them sensibly. */
kono
parents:
diff changeset
69 GDB_INDEX_SYMBOL_KIND_UNUSED5 = 5,
kono
parents:
diff changeset
70 GDB_INDEX_SYMBOL_KIND_UNUSED6 = 6,
kono
parents:
diff changeset
71 GDB_INDEX_SYMBOL_KIND_UNUSED7 = 7
kono
parents:
diff changeset
72 } gdb_index_symbol_kind;
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 #define GDB_INDEX_SYMBOL_KIND_SHIFT 28
kono
parents:
diff changeset
75 #define GDB_INDEX_SYMBOL_KIND_MASK 7
kono
parents:
diff changeset
76 #define GDB_INDEX_SYMBOL_KIND_VALUE(cu_index) \
kono
parents:
diff changeset
77 ((gdb_index_symbol_kind) (((cu_index) >> GDB_INDEX_SYMBOL_KIND_SHIFT) \
kono
parents:
diff changeset
78 & GDB_INDEX_SYMBOL_KIND_MASK))
kono
parents:
diff changeset
79 #define GDB_INDEX_SYMBOL_KIND_SET_VALUE(cu_index, value) \
kono
parents:
diff changeset
80 do { \
kono
parents:
diff changeset
81 (cu_index) |= (((value) & GDB_INDEX_SYMBOL_KIND_MASK) \
kono
parents:
diff changeset
82 << GDB_INDEX_SYMBOL_KIND_SHIFT); \
kono
parents:
diff changeset
83 } while (0)
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 #define GDB_INDEX_RESERVED_SHIFT 24
kono
parents:
diff changeset
86 #define GDB_INDEX_RESERVED_MASK 15
kono
parents:
diff changeset
87 #define GDB_INDEX_RESERVED_VALUE(cu_index) \
kono
parents:
diff changeset
88 (((cu_index) >> GDB_INDEX_RESERVED_SHIFT) & GDB_INDEX_RESERVED_MASK)
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 /* CU index. */
kono
parents:
diff changeset
91 #define GDB_INDEX_CU_BITSIZE 24
kono
parents:
diff changeset
92 #define GDB_INDEX_CU_MASK ((1 << GDB_INDEX_CU_BITSIZE) - 1)
kono
parents:
diff changeset
93 #define GDB_INDEX_CU_VALUE(cu_index) ((cu_index) & GDB_INDEX_CU_MASK)
kono
parents:
diff changeset
94 #define GDB_INDEX_CU_SET_VALUE(cu_index, value) \
kono
parents:
diff changeset
95 do { \
kono
parents:
diff changeset
96 (cu_index) |= (value) & GDB_INDEX_CU_MASK; \
kono
parents:
diff changeset
97 } while (0)
kono
parents:
diff changeset
98
kono
parents:
diff changeset
99 #endif /* GDB_INDEX_H */