source: trunk/libs/newlib/src/include/gdb/gdb-index.h @ 468

Last change on this file since 468 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 3.8 KB
Line 
1/* Public attributes of the .gdb_index section.
2   Copyright (C) 2012-2015 Free Software Foundation, Inc.
3
4   This file is part of GDB.
5
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.
10
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.
15
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/>.  */
18
19/* This file contains values for understanding the .gdb_index section
20   needed by more than just GDB, e.g. readelf.  */
21
22#ifndef GDB_INDEX_H
23#define GDB_INDEX_H
24
25/* Each symbol in .gdb_index refers to a set of CUs that defines the symbol.
26   Each CU is represented by a 32 bit number that is the index of the CU in
27   the CU table, plus some attributes of the use of the symbol in that CU.
28
29   The values are defined such that if all the bits are zero, then no
30   special meaning is assigned to any of them.  This is done to preserve
31   compatibility with older indices.  The way this is done is to specify
32   that if the GDB_INDEX_SYMBOL_KIND value is zero then all other attribute
33   bits must be zero.
34
35    0-23  CU index
36   24-27  reserved
37   28-30  symbol kind
38   31     0 == global, 1 == static
39
40   Bits 24-27 are reserved because it's easier to relax restrictions than
41   it is to impose them after the fact.  At present 24 bits to represent
42   the CU index is plenty.  If we need more bits for the CU index or for
43   attributes then we have them.  */
44
45/* Whether the symbol is in GLOBAL_BLOCK (== 0) or STATIC_BLOCK (== 1).  */
46#define GDB_INDEX_SYMBOL_STATIC_SHIFT 31
47#define GDB_INDEX_SYMBOL_STATIC_MASK 1
48#define GDB_INDEX_SYMBOL_STATIC_VALUE(cu_index) \
49  (((cu_index) >> GDB_INDEX_SYMBOL_STATIC_SHIFT) & GDB_INDEX_SYMBOL_STATIC_MASK)
50#define GDB_INDEX_SYMBOL_STATIC_SET_VALUE(cu_index, value) \
51  do { \
52    (cu_index) |= (((value) & GDB_INDEX_SYMBOL_STATIC_MASK) \
53                   << GDB_INDEX_SYMBOL_STATIC_SHIFT); \
54  } while (0)
55
56/* The kind of the symbol.
57   We don't use GDB's internal values as these numbers are published
58   so that other tools can build and read .gdb_index.  */
59
60typedef enum {
61  /* Special value to indicate no attributes are present.  */
62  GDB_INDEX_SYMBOL_KIND_NONE = 0,
63  GDB_INDEX_SYMBOL_KIND_TYPE = 1,
64  GDB_INDEX_SYMBOL_KIND_VARIABLE = 2,
65  GDB_INDEX_SYMBOL_KIND_FUNCTION = 3,
66  GDB_INDEX_SYMBOL_KIND_OTHER = 4,
67  /* We currently allocate 3 bits to record the symbol kind.
68     Give the unused bits a value so gdb will print them sensibly.  */
69  GDB_INDEX_SYMBOL_KIND_UNUSED5 = 5,
70  GDB_INDEX_SYMBOL_KIND_UNUSED6 = 6,
71  GDB_INDEX_SYMBOL_KIND_UNUSED7 = 7
72} gdb_index_symbol_kind;
73
74#define GDB_INDEX_SYMBOL_KIND_SHIFT 28
75#define GDB_INDEX_SYMBOL_KIND_MASK 7
76#define GDB_INDEX_SYMBOL_KIND_VALUE(cu_index) \
77  ((gdb_index_symbol_kind) (((cu_index) >> GDB_INDEX_SYMBOL_KIND_SHIFT) \
78                            & GDB_INDEX_SYMBOL_KIND_MASK))
79#define GDB_INDEX_SYMBOL_KIND_SET_VALUE(cu_index, value) \
80  do { \
81    (cu_index) |= (((value) & GDB_INDEX_SYMBOL_KIND_MASK) \
82                   << GDB_INDEX_SYMBOL_KIND_SHIFT); \
83  } while (0)
84
85#define GDB_INDEX_RESERVED_SHIFT 24
86#define GDB_INDEX_RESERVED_MASK 15
87#define GDB_INDEX_RESERVED_VALUE(cu_index) \
88  (((cu_index) >> GDB_INDEX_RESERVED_SHIFT) & GDB_INDEX_RESERVED_MASK)
89
90/* CU index.  */
91#define GDB_INDEX_CU_BITSIZE 24
92#define GDB_INDEX_CU_MASK ((1 << GDB_INDEX_CU_BITSIZE) - 1)
93#define GDB_INDEX_CU_VALUE(cu_index) ((cu_index) & GDB_INDEX_CU_MASK)
94#define GDB_INDEX_CU_SET_VALUE(cu_index, value) \
95  do { \
96    (cu_index) |= (value) & GDB_INDEX_CU_MASK; \
97  } while (0)
98
99#endif /* GDB_INDEX_H */
Note: See TracBrowser for help on using the repository browser.