GDB (API)
/home/stan/gdb/src/include/gdb/gdb-index.h
Go to the documentation of this file.
00001 /* Public attributes of the .gdb_index section.
00002    Copyright 2012-2013 Free Software Foundation, Inc.
00003 
00004    This file is part of GDB.
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 3 of the License, or
00009    (at your option) any later version.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00018 
00019 /* This file contains values for understanding the .gdb_index section
00020    needed by more than just GDB, e.g. readelf.  */
00021 
00022 #ifndef GDB_INDEX_H
00023 #define GDB_INDEX_H
00024 
00025 /* Each symbol in .gdb_index refers to a set of CUs that defines the symbol.
00026    Each CU is represented by a 32 bit number that is the index of the CU in
00027    the CU table, plus some attributes of the use of the symbol in that CU.
00028 
00029    The values are defined such that if all the bits are zero, then no
00030    special meaning is assigned to any of them.  This is done to preserve
00031    compatibility with older indices.  The way this is done is to specify
00032    that if the GDB_INDEX_SYMBOL_KIND value is zero then all other attribute
00033    bits must be zero.
00034 
00035     0-23  CU index
00036    24-27  reserved
00037    28-30  symbol kind
00038    31     0 == global, 1 == static
00039 
00040    Bits 24-27 are reserved because it's easier to relax restrictions than
00041    it is to impose them after the fact.  At present 24 bits to represent
00042    the CU index is plenty.  If we need more bits for the CU index or for
00043    attributes then we have them.  */
00044 
00045 /* Whether the symbol is in GLOBAL_BLOCK (== 0) or STATIC_BLOCK (== 1).  */
00046 #define GDB_INDEX_SYMBOL_STATIC_SHIFT 31
00047 #define GDB_INDEX_SYMBOL_STATIC_MASK 1
00048 #define GDB_INDEX_SYMBOL_STATIC_VALUE(cu_index) \
00049   (((cu_index) >> GDB_INDEX_SYMBOL_STATIC_SHIFT) & GDB_INDEX_SYMBOL_STATIC_MASK)
00050 #define GDB_INDEX_SYMBOL_STATIC_SET_VALUE(cu_index, value) \
00051   do { \
00052     (cu_index) |= (((value) & GDB_INDEX_SYMBOL_STATIC_MASK) \
00053                    << GDB_INDEX_SYMBOL_STATIC_SHIFT); \
00054   } while (0)
00055 
00056 /* The kind of the symbol.
00057    We don't use GDB's internal values as these numbers are published
00058    so that other tools can build and read .gdb_index.  */
00059 
00060 typedef enum {
00061   /* Special value to indicate no attributes are present.  */
00062   GDB_INDEX_SYMBOL_KIND_NONE = 0,
00063   GDB_INDEX_SYMBOL_KIND_TYPE = 1,
00064   GDB_INDEX_SYMBOL_KIND_VARIABLE = 2,
00065   GDB_INDEX_SYMBOL_KIND_FUNCTION = 3,
00066   GDB_INDEX_SYMBOL_KIND_OTHER = 4,
00067   /* We currently allocate 3 bits to record the symbol kind.
00068      Give the unused bits a value so gdb will print them sensibly.  */
00069   GDB_INDEX_SYMBOL_KIND_UNUSED5 = 5,
00070   GDB_INDEX_SYMBOL_KIND_UNUSED6 = 6,
00071   GDB_INDEX_SYMBOL_KIND_UNUSED7 = 7,
00072 } gdb_index_symbol_kind;
00073 
00074 #define GDB_INDEX_SYMBOL_KIND_SHIFT 28
00075 #define GDB_INDEX_SYMBOL_KIND_MASK 7
00076 #define GDB_INDEX_SYMBOL_KIND_VALUE(cu_index) \
00077   ((gdb_index_symbol_kind) (((cu_index) >> GDB_INDEX_SYMBOL_KIND_SHIFT) \
00078                             & GDB_INDEX_SYMBOL_KIND_MASK))
00079 #define GDB_INDEX_SYMBOL_KIND_SET_VALUE(cu_index, value) \
00080   do { \
00081     (cu_index) |= (((value) & GDB_INDEX_SYMBOL_KIND_MASK) \
00082                    << GDB_INDEX_SYMBOL_KIND_SHIFT); \
00083   } while (0)
00084 
00085 #define GDB_INDEX_RESERVED_SHIFT 24
00086 #define GDB_INDEX_RESERVED_MASK 15
00087 #define GDB_INDEX_RESERVED_VALUE(cu_index) \
00088   (((cu_index) >> GDB_INDEX_RESERVED_SHIFT) & GDB_INDEX_RESERVED_MASK)
00089 
00090 /* CU index.  */
00091 #define GDB_INDEX_CU_BITSIZE 24
00092 #define GDB_INDEX_CU_MASK ((1 << GDB_INDEX_CU_BITSIZE) - 1)
00093 #define GDB_INDEX_CU_VALUE(cu_index) ((cu_index) & GDB_INDEX_CU_MASK)
00094 #define GDB_INDEX_CU_SET_VALUE(cu_index, value) \
00095   do { \
00096     (cu_index) |= (value) & GDB_INDEX_CU_MASK; \
00097   } while (0)
00098 
00099 #endif /* GDB_INDEX_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines