Create dwarf2/attribute.[ch]
[deliverable/binutils-gdb.git] / gdb / dwarf2 / attribute.h
CommitLineData
162dce55
TT
1/* DWARF attributes
2
3 Copyright (C) 1994-2020 Free Software Foundation, Inc.
4
5 Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology,
6 Inc. with support from Florida State University (under contract
7 with the Ada Joint Program Office), and Silicon Graphics, Inc.
8 Initial contribution by Brent Benson, Harris Computer Systems, Inc.,
9 based on Fred Fish's (Cygnus Support) implementation of DWARF 1
10 support.
11
12 This file is part of GDB.
13
14 This program is free software; you can redistribute it and/or modify
15 it under the terms of the GNU General Public License as published by
16 the Free Software Foundation; either version 3 of the License, or
17 (at your option) any later version.
18
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program. If not, see <http://www.gnu.org/licenses/>. */
26
27#ifndef GDB_DWARF2_ATTRIBUTE_H
28#define GDB_DWARF2_ATTRIBUTE_H
29
30#include "dwarf2.h"
31
32/* Blocks are a bunch of untyped bytes. */
33struct dwarf_block
34{
35 size_t size;
36
37 /* Valid only if SIZE is not zero. */
38 const gdb_byte *data;
39};
40
41/* Attributes have a name and a value. */
42struct attribute
43{
44 ENUM_BITFIELD(dwarf_attribute) name : 16;
45 ENUM_BITFIELD(dwarf_form) form : 15;
46
47 /* Has DW_STRING already been updated by dwarf2_canonicalize_name? This
48 field should be in u.str (existing only for DW_STRING) but it is kept
49 here for better struct attribute alignment. */
50 unsigned int string_is_canonical : 1;
51
52 union
53 {
54 const char *str;
55 struct dwarf_block *blk;
56 ULONGEST unsnd;
57 LONGEST snd;
58 CORE_ADDR addr;
59 ULONGEST signature;
60 }
61 u;
62};
63
64/* Get at parts of an attribute structure. */
65
66#define DW_STRING(attr) ((attr)->u.str)
67#define DW_STRING_IS_CANONICAL(attr) ((attr)->string_is_canonical)
68#define DW_UNSND(attr) ((attr)->u.unsnd)
69#define DW_BLOCK(attr) ((attr)->u.blk)
70#define DW_SND(attr) ((attr)->u.snd)
71#define DW_ADDR(attr) ((attr)->u.addr)
72#define DW_SIGNATURE(attr) ((attr)->u.signature)
73
74/* Read the given attribute value as an address, taking the attribute's
75 form into account. */
76
77extern CORE_ADDR attr_value_as_address (struct attribute *attr);
78
79/* Check if the attribute's form is a DW_FORM_block*
80 if so return true else false. */
81
82extern int attr_form_is_block (const struct attribute *attr);
83
84/* Return non-zero if ATTR's value is a section offset --- classes
85 lineptr, loclistptr, macptr or rangelistptr --- or zero, otherwise.
86 You may use DW_UNSND (attr) to retrieve such offsets.
87
88 Section 7.5.4, "Attribute Encodings", explains that no attribute
89 may have a value that belongs to more than one of these classes; it
90 would be ambiguous if we did, because we use the same forms for all
91 of them. */
92
93extern int attr_form_is_section_offset (const struct attribute *attr);
94
95/* Return non-zero if ATTR's value falls in the 'constant' class, or
96 zero otherwise. When this function returns true, you can apply
97 dwarf2_get_attr_constant_value to it.
98
99 However, note that for some attributes you must check
100 attr_form_is_section_offset before using this test. DW_FORM_data4
101 and DW_FORM_data8 are members of both the constant class, and of
102 the classes that contain offsets into other debug sections
103 (lineptr, loclistptr, macptr or rangelistptr). The DWARF spec says
104 that, if an attribute's can be either a constant or one of the
105 section offset classes, DW_FORM_data4 and DW_FORM_data8 should be
106 taken as section offsets, not constants.
107
108 DW_FORM_data16 is not considered as dwarf2_get_attr_constant_value
109 cannot handle that. */
110
111extern int attr_form_is_constant (const struct attribute *attr);
112
113/* DW_ADDR is always stored already as sect_offset; despite for the forms
114 besides DW_FORM_ref_addr it is stored as cu_offset in the DWARF file. */
115
116extern int attr_form_is_ref (const struct attribute *attr);
117
118#endif /* GDB_DWARF2_ATTRIBUTE_H */
This page took 0.029448 seconds and 4 git commands to generate.