Debian Codegraph @

src/lib/libdwarf/dwarf_macro5.h

raw
1 /*
2 Copyright (C) 2015-2023 David Anderson. All Rights Reserved.
3
4 This program is free software; you can redistribute it
5 and/or modify it under the terms of version 2.1 of the
6 GNU Lesser General Public License as published by the Free
7 Software Foundation.
8
9 This program is distributed in the hope that it would be
10 useful, but WITHOUT ANY WARRANTY; without even the implied
11 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE.
13
14 Further, this software is distributed without any warranty
15 that it is free of the rightful claim of any third person
16 regarding infringement or the like. Any license provided
17 herein, whether implied or otherwise, applies only to this
18 software file. Patent licenses, if any, provided herein
19 do not apply to combinations of this program with other
20 software, or any other product whatsoever.
21
22 You should have received a copy of the GNU Lesser General
23 Public License along with this program; if not, write the
24 Free Software Foundation, Inc., 51 Franklin Street - Fifth
25 Floor, Boston MA 02110-1301, USA.
26
27 */
28
29 /*
30 dwarf_macro5.h
31 For the DWARF5 .debug_macro section
32 (also appears as an extension to DWARF4)
33 */
34
35 struct Dwarf_Macro_Forms_s {
36 /* Code means DW_MACRO_define etc. */
37 Dwarf_Small mf_code;
38
39 /* How many entries in mf_formbytes array. */
40 Dwarf_Small mf_formcount;
41
42 /* Never free these, these are in the object file memory */
43 const Dwarf_Small * mf_formbytes;
44 };
45
46 struct Dwarf_Macro_OperationsList_s {
47 unsigned mol_count;
48 struct Dwarf_Macro_Forms_s * mol_data;
49 };
50
51 struct Dwarf_Macro_Operator_s {
52 /* mo_opcode == mo_form->mf_code unless it is
53 the final 0 byte in which case all 3 values
54 are zero */
55 Dwarf_Small mo_opcode;
56
57 struct Dwarf_Macro_Forms_s * mo_form;
58
59 /* Points at the first byte of the data, meaning
60 it points one-past the macro operation code byte. */
61 Dwarf_Small * mo_data;
62 };
63
64 #define MACRO_OFFSET_SIZE_FLAG 1
65 #define MACRO_LINE_OFFSET_FLAG 2
66 #define MACRO_OP_TABLE_FLAG 4
67 #define DW_MACRO_VERSION4 4 /* GNU Extension for DWARF 4 */
68 #define DW_MACRO_VERSION5 5 /* DWARF 5 */
69
70 /* Could be reordered to be most space efficient.
71 That might be a little harder to read. Hmm. */
72 struct Dwarf_Macro_Context_s {
73 Dwarf_Unsigned mc_sentinel;
74 Dwarf_Half mc_version_number;
75
76 /* Section_offset in .debug_macro of macro header */
77 Dwarf_Unsigned mc_section_offset;
78 Dwarf_Unsigned mc_section_size;
79
80 /* Total length of the macro data for this
81 macro unit.
82 Calculated, not part of header. */
83 Dwarf_Unsigned mc_total_length;
84
85 Dwarf_Half mc_macro_header_length;
86
87 Dwarf_Small mc_flags;
88
89 /* If DW_MACRO_start_file is in the operators of this
90 table then the mc_debug_line_offset must be present from
91 the header. */
92 Dwarf_Unsigned mc_debug_line_offset;
93
94 /* the following three set from the bits in mc_flags */
95 /* If 1, offsets 64 bits */
96 Dwarf_Bool mc_offset_size_flag;
97
98 /* if 1, debug_line offset is present. */
99 Dwarf_Bool mc_debug_line_offset_flag;
100
101 /* 4 or 8, depending on mc_offset_size_flag */
102 Dwarf_Small mc_offset_size;
103
104 /* If one the operands/opcodes (mc_opcode_forms) table is present
105 in the header. If not we use a default table.
106
107 Even when there are operands in the header
108 the standardops may or may not be
109 defined in the header. */
110 Dwarf_Bool mc_operands_table_flag;
111
112 /* Count of the Dwarf_Macro_Forms_s structs pointed to by
113 mc_opcode_forms. These from the header. */
114 Dwarf_Small mc_opcode_count;
115 struct Dwarf_Macro_Forms_s *mc_opcode_forms;
116
117 /* mc_ops must be free()d, but pointers inside
118 mc_ops are to static or section data so must not
119 be freed. */
120 Dwarf_Unsigned mc_macro_ops_count;
121 Dwarf_Unsigned mc_ops_data_length;
122 struct Dwarf_Macro_Operator_s *mc_ops;
123
124 Dwarf_Small * mc_macro_header;
125 Dwarf_Small * mc_macro_ops;
126
127 /* These are malloc space, not _dwarf_get_alloc()
128 so the DW_DLA_MACRO_CONTEXT dealloc will
129 free them. */
130 char ** mc_srcfiles;
131 Dwarf_Signed mc_srcfiles_count;
132
133 /* These are from CU DIE attribute names.
134 They may be NULL or point at data in
135 a dwarf section. Do not free().
136 This attempts to make up for the lack of a
137 base file name
138 in DWARF2,3,4 line tables.
139 */
140 const char * mc_at_comp_dir;
141 const char * mc_at_name;
142 /* The following is malloc,so macro_context_s destructor
143 needs to free it. */
144 const char * mc_file_path;
145
146 Dwarf_Debug mc_dbg;
147 Dwarf_CU_Context mc_cu_context;
148 };
149
150 int _dwarf_macro_constructor(Dwarf_Debug dbg, void *m);
151 void _dwarf_macro_destructor(void *m);