Change attr_form_is_block to be a method
[deliverable/binutils-gdb.git] / gdb / dwarf2 / attribute.h
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. */
33 struct 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. */
42 struct attribute
43 {
44 /* Read the given attribute value as an address, taking the
45 attribute's form into account. */
46 CORE_ADDR value_as_address () const;
47
48 /* Return non-zero if ATTR's value is a section offset --- classes
49 lineptr, loclistptr, macptr or rangelistptr --- or zero, otherwise.
50 You may use DW_UNSND (attr) to retrieve such offsets.
51
52 Section 7.5.4, "Attribute Encodings", explains that no attribute
53 may have a value that belongs to more than one of these classes; it
54 would be ambiguous if we did, because we use the same forms for all
55 of them. */
56
57 bool form_is_section_offset () const;
58
59 /* Return non-zero if ATTR's value falls in the 'constant' class, or
60 zero otherwise. When this function returns true, you can apply
61 dwarf2_get_attr_constant_value to it.
62
63 However, note that for some attributes you must check
64 attr_form_is_section_offset before using this test. DW_FORM_data4
65 and DW_FORM_data8 are members of both the constant class, and of
66 the classes that contain offsets into other debug sections
67 (lineptr, loclistptr, macptr or rangelistptr). The DWARF spec says
68 that, if an attribute's can be either a constant or one of the
69 section offset classes, DW_FORM_data4 and DW_FORM_data8 should be
70 taken as section offsets, not constants.
71
72 DW_FORM_data16 is not considered as dwarf2_get_attr_constant_value
73 cannot handle that. */
74
75 bool form_is_constant () const;
76
77 /* DW_ADDR is always stored already as sect_offset; despite for the forms
78 besides DW_FORM_ref_addr it is stored as cu_offset in the DWARF file. */
79
80 bool form_is_ref () const;
81
82 /* Check if the attribute's form is a DW_FORM_block*
83 if so return true else false. */
84
85 bool form_is_block () const;
86
87
88 ENUM_BITFIELD(dwarf_attribute) name : 16;
89 ENUM_BITFIELD(dwarf_form) form : 15;
90
91 /* Has DW_STRING already been updated by dwarf2_canonicalize_name? This
92 field should be in u.str (existing only for DW_STRING) but it is kept
93 here for better struct attribute alignment. */
94 unsigned int string_is_canonical : 1;
95
96 union
97 {
98 const char *str;
99 struct dwarf_block *blk;
100 ULONGEST unsnd;
101 LONGEST snd;
102 CORE_ADDR addr;
103 ULONGEST signature;
104 }
105 u;
106 };
107
108 /* Get at parts of an attribute structure. */
109
110 #define DW_STRING(attr) ((attr)->u.str)
111 #define DW_STRING_IS_CANONICAL(attr) ((attr)->string_is_canonical)
112 #define DW_UNSND(attr) ((attr)->u.unsnd)
113 #define DW_BLOCK(attr) ((attr)->u.blk)
114 #define DW_SND(attr) ((attr)->u.snd)
115 #define DW_ADDR(attr) ((attr)->u.addr)
116 #define DW_SIGNATURE(attr) ((attr)->u.signature)
117
118 #endif /* GDB_DWARF2_ATTRIBUTE_H */
This page took 0.032667 seconds and 4 git commands to generate.