Debian Codegraph @

src/bin/dwarfdump/dd_globals.h

raw
1 /*
2 Copyright (C) 2000,2004,2005 Silicon Graphics, Inc. All Rights Reserved.
3 Portions Copyright (C) 2007-2020 David Anderson. All Rights Reserved.
4 Portions Copyright 2012-2018 SN Systems Ltd. All rights reserved.
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of version 2 of the GNU General
8 Public License as published by the Free Software Foundation.
9
10 This program is distributed in the hope that it would be
11 useful, but WITHOUT ANY WARRANTY; without even the implied
12 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 PURPOSE.
14
15 Further, this software is distributed without any warranty
16 that it is free of the rightful claim of any third person
17 regarding infringement or the like. Any license provided
18 herein, whether implied or otherwise, applies only to this
19 software file. Patent licenses, if any, provided herein
20 do not apply to combinations of this program with other
21 software, or any other product whatsoever.
22
23 You should have received a copy of the GNU General Public
24 License along with this program; if not, write the Free
25 Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
26 Boston MA 02110-1301, USA.
27 */
28
29 #ifndef globals_INCLUDED
30 #define globals_INCLUDED
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #define DWARF_SECNAME_BUFFER_SIZE 50
36 #define ESB_FIXED_ALLOC_SIZE 300
37
38 /* Used to avoid leakage when we hide errors.
39 Use carefully: doing err when you mean
40 *err will not be caught by the compiler
41 and will not do what one wants.
42 Using *err when err is correct will
43 be caught by the compiler. You are warned. */
44 #define DROP_ERROR_INSTANCE(d,r,e) \
45 do { \
46 if ((r) == DW_DLV_ERROR) { \
47 if (e) { \
48 dwarf_dealloc_error((d),(e)); \
49 (e) = 0; \
50 } else { \
51 report_caller_error_drop_error((r), \
52 __LINE__,__FILE__); \
53 } \
54 } \
55 } while(0)
56
57 /* Used in very few places here. */
58 #define DW_DLV_BADOFFSET (~(Dwarf_Off)0)
59
60 /* Version 5 returns DW_AT_decl_file differently
61 than earlier versions */
62 #define DWVERSION4 4
63 #define DWVERSION5 5
64
65 /* FALSE for the flags means off */
66 #define LOHIPC_SAWADDR 1
67 #define LOHIPC_SAWOFFSET 2
68 struct LoHiPc_s {
69 Dwarf_Unsigned lopc;
70
71 /* hival is either an address if sawhi ==LOHIPC_SAWADDR
72 or an offset if sawhi_flag == LOWHIPC_SAWOFFSET.
73 or zero (sawhi_flag == FALSE)*/
74 Dwarf_Unsigned hival;
75
76 /* The result of adding lopc to hival. */
77 Dwarf_Unsigned hifinal;
78
79 /* non-zero if DW_AT_lowpc seen */
80 Dwarf_Small sawlo_flag;
81
82 /* non-zero if DW_AT_high_pc seen
83 defaults FALSE, otherwise is
84 LOHIPC_SAWADDR or LOHIPC_SAWOFFSET */
85 Dwarf_Small sawhi_flag;
86
87 /* If non-zero, hifinal is set to the hipc address
88 Defaults to FALSE*/
89 Dwarf_Small havefinal_flag;
90 };
91
92 typedef struct LoHiPc_s LoHiPc;
93
94 /* Calculate wasted space */
95 extern void calculate_attributes_usage(Dwarf_Half attr,
96 Dwarf_Half theform,
97 Dwarf_Unsigned value);
98
99 extern Dwarf_Bool is_strstrnocase(const char *data,
100 const char *pattern);
101
102 /* Process TAGs for checking mode and reset pRangesInfo table
103 if appropriate. */
104 extern void tag_specific_globals_setup(Dwarf_Debug dbg,
105 Dwarf_Half val,int die_indent_level);
106
107 extern int simple_err_return_msg_either_action(int res,
108 const char *msg);
109 extern int simple_err_return_action(int res,const char *msg);
110 extern int simple_err_only_return_action(int res,const char *msg);
111 extern void print_error_and_continue (const char * msg,
112 int res, Dwarf_Error err);
113 extern void print_error (Dwarf_Debug dbg, const char * msg,
114 int res, Dwarf_Error err);
115
116 extern int print_line_numbers_this_cu (Dwarf_Debug dbg,
117 Dwarf_Die in_die,
118 char **srcfiles,
119 Dwarf_Signed cnt,
120 Dwarf_Error *err);
121
122 extern int print_ranges(Dwarf_Debug dbg);
123 extern int print_raw_all_rnglists(Dwarf_Debug dbg, Dwarf_Error *err);
124 extern int print_raw_all_loclists(Dwarf_Debug dbg, Dwarf_Error *err);
125 extern int print_pubnames_style(Dwarf_Debug dbg,
126 int category,Dwarf_Error *);
127 extern int print_infos (Dwarf_Debug dbg,Dwarf_Bool is_info,
128 Dwarf_Error *);
129 extern int print_abbrevs (Dwarf_Debug dbg,Dwarf_Error *);
130 extern int print_strings (Dwarf_Debug dbg,Dwarf_Error *);
131 extern int print_aranges (Dwarf_Debug dbg,Dwarf_Error *);
132 extern int print_static_funcs(Dwarf_Debug dbg,Dwarf_Error *);
133 extern int print_static_vars(Dwarf_Debug dbg,Dwarf_Error *);
134 enum type_type_e {SGI_TYPENAME, DWARF_PUBTYPES} ;
135 extern int print_types(Dwarf_Debug dbg,enum type_type_e type_type,
136 Dwarf_Error *);
137 extern int print_weaknames(Dwarf_Debug dbg, Dwarf_Error *);
138 extern int print_debug_names(Dwarf_Debug dbg,Dwarf_Error *);
139 int print_debug_sup(Dwarf_Debug dbg, Dwarf_Error *error);
140 extern int print_debug_addr(Dwarf_Debug dbg, Dwarf_Error *error);
141 int print_all_abbrevs_for_cu(Dwarf_Debug dbg,
142 Dwarf_Unsigned offset,
143 Dwarf_Unsigned abbrev_num_in,
144 Dwarf_Unsigned *length_out,
145 Dwarf_Unsigned *abbrev_num_out,
146 Dwarf_Error *error);
147
148 /* Space used to record range information */
149 extern void allocate_range_array_info(void);
150 extern void release_range_array_info(void);
151 extern void record_range_array_info_entry(Dwarf_Off die_off,
152 Dwarf_Off range_off);
153 extern int check_range_array_info(Dwarf_Debug dbg,
154 Dwarf_Die die, Dwarf_Error *);
155
156 int should_skip_this_cu(Dwarf_Debug dbg,Dwarf_Bool *,
157 Dwarf_Die cu_die);
158
159 int get_address_size_and_max(Dwarf_Debug dbg,
160 Dwarf_Half * size,
161 Dwarf_Addr * max,
162 Dwarf_Error *err);
163
164 /* Returns the producer of the CU */
165 int get_cu_name(Dwarf_Debug dbg,Dwarf_Die cu_die,
166 Dwarf_Off dieprint_cu_offset,
167 char **short_name,char **long_name,
168 Dwarf_Error *err);
169
170 /* Get number of abbreviations for a CU */
171 extern void get_abbrev_array_info(Dwarf_Debug dbg,
172 Dwarf_Unsigned offset);
173 /* Validate an abbreviation */
174 extern void validate_abbrev_code(Dwarf_Unsigned abbrev_code);
175
176 extern int print_one_die(
177 Dwarf_Debug dbg,
178 Dwarf_Die die,
179 Dwarf_Off dieprint_cu_offset,
180 Dwarf_Bool print_information,
181 int die_indent_level,
182 char **srcfiles,
183 Dwarf_Signed cnt,
184 Dwarf_Bool *an_attr_duplicated,
185 Dwarf_Bool ignore_die_stack,
186 Dwarf_Error *err);
187
188 /* Check for specific compiler */
189 extern Dwarf_Bool checking_this_compiler(void);
190 extern void update_compiler_target(const char *producer_name);
191 extern void add_cu_name_compiler_target(char *name);
192
193 /* General error reporting routines. These were
194 macros for a short time and when changed into functions
195 they kept (for now) their capitalization.
196 The capitalization will likely change. */
197 extern void PRINT_CU_INFO(void);
198 extern void DWARF_CHECK_COUNT(Dwarf_Check_Categories category,
199 int inc);
200 extern void DWARF_ERROR_COUNT(Dwarf_Check_Categories category,
201 int inc);
202 extern void DWARF_CHECK_ERROR_PRINT_CU(void);
203 #define DWARF_CHECK_ERROR(c,d) DWARF_CHECK_ERROR3(c,d,0,0)
204 #define DWARF_CHECK_ERROR2(c,d,e) DWARF_CHECK_ERROR3(c,d,e,0)
205 extern void DWARF_CHECK_ERROR3(Dwarf_Check_Categories category,
206 const char *str1, const char *str2, const char *strexpl);
207
208 extern int print_macinfo_by_offset(Dwarf_Debug dbg,
209 Dwarf_Die cudie,Dwarf_Unsigned offset,Dwarf_Error *);
210
211 void ranges_esb_string_destructor(void);
212 void global_destructors(void);
213 void destruct_abbrev_array(void);
214
215 int get_proc_name_by_die(Dwarf_Debug dbg,
216 Dwarf_Die die, Dwarf_Addr low_pc,
217 struct esb_s *proc_name,
218 Dwarf_Die *cu_die_for_print_frames,
219 void **pcMap,
220 Dwarf_Error *err);
221
222 extern void dump_block(char *prefix, char *data, Dwarf_Signed len);
223
224 extern int print_gdb_index(Dwarf_Debug dbg,Dwarf_Error *err);
225 extern int print_debugfission_index(Dwarf_Debug dbg,
226 const char *type, Dwarf_Error *);
227
228 void clean_up_die_esb(void);
229
230 int print_macros_5style_this_cu(Dwarf_Debug dbg, Dwarf_Die cu_die,
231 char **srcfiles,
232 Dwarf_Signed cnt,
233 int do_print_dwarf /* not relying on gf_do_print_dwarf here */,
234 int descend_into_imports /* TRUE means follow imports */,
235 Dwarf_Bool in_import_list /* helps make print readable */,
236 Dwarf_Unsigned offset,
237 Dwarf_Error *);
238
239 /* Detailed attributes encoding space */
240 int print_attributes_encoding(Dwarf_Debug dbg,Dwarf_Error *);
241
242 /* Detailed tag and attributes usage */
243 int print_tag_attributes_usage(void);
244 void record_tag_usage(Dwarf_Half tag);
245 void reset_usage_rate_tag_trees(void);
246
247 int print_section_groups_data(Dwarf_Debug dbg,Dwarf_Error *);
248 void update_section_flags_per_groups(void);
249 void groups_restore_subsidiary_flags(void);
250
251 int legal_tag_attr_combination(Dwarf_Half tag,
252 Dwarf_Half attr);
253 int legal_tag_tree_combination(Dwarf_Half parent_tag,
254 Dwarf_Half child_tag);
255
256 int print_str_offsets_section(Dwarf_Debug dbg,Dwarf_Error *);
257
258 void print_any_harmless_errors(Dwarf_Debug dbg);
259
260 void print_secname(Dwarf_Debug dbg,const char *secname);
261
262 void report_caller_error_drop_error(int dwdlv,
263 int line, char *filename);
264
265 /* encoding_type_func used in print_die.c and
266 print_lopc_hipc_attr.c */
267 typedef const char *(*encoding_type_func)
268 (unsigned,int doprintingonerr);
269 int dd_get_integer_and_name(Dwarf_Debug dbg,
270 Dwarf_Attribute attrib,
271 Dwarf_Unsigned * uval_out,
272 const char *attr_name,
273 struct esb_s* string_out,
274 encoding_type_func val_as_string,
275 Dwarf_Error * err,
276 int show_form);
277
278 int print_original_loclist_linecodes(Dwarf_Bool checking,
279 const char * tagname,
280 const char * attrname,
281 unsigned int llent,
282 Dwarf_Small lle_value,
283 Dwarf_Addr base_address,
284 Dwarf_Addr rawlopc,
285 Dwarf_Addr rawhipc,
286 Dwarf_Bool debug_addr_unavailable,
287 Dwarf_Addr lopc,
288 Dwarf_Addr hipc,
289 Dwarf_Unsigned locdesc_offset,
290 struct esb_s * ebsp,
291 Dwarf_Bool * bError);
292 int print_llex_linecodes(Dwarf_Bool checking,
293 const char * tagname,
294 const char * attrname,
295 unsigned int llent,
296 Dwarf_Small lle_value,
297 Dwarf_Addr base_address,
298 Dwarf_Addr rawlopc,
299 Dwarf_Addr rawhipc,
300 Dwarf_Bool debug_addr_unavailable,
301 Dwarf_Addr lopc,
302 Dwarf_Addr hipc,
303 Dwarf_Unsigned locdesc_offset,
304 struct esb_s * ebsp,
305 Dwarf_Bool * bError);
306 int print_debug_loclists_linecodes(Dwarf_Bool checking,
307 const char * tagname,
308 const char * attrname,
309 unsigned int llent,
310 Dwarf_Small lle_value,
311 Dwarf_Unsigned lle_byte_count,
312 Dwarf_Addr base_address,
313 Dwarf_Addr rawlopc,
314 Dwarf_Addr rawhipc,
315 Dwarf_Bool debug_addr_unavailable,
316 Dwarf_Addr lopc,
317 Dwarf_Addr hipc,
318 Dwarf_Unsigned locdesc_offset,
319 struct esb_s * ebsp,
320 Dwarf_Bool * bError);
321 void loc_error_check(
322 const char *tagname,
323 const char *attrname,
324 Dwarf_Addr lopcfinal,
325 Dwarf_Addr rawlopc,
326 Dwarf_Addr hipcfinal,
327 Dwarf_Addr rawhipc,
328 Dwarf_Unsigned offset,
329 Dwarf_Addr base_address,
330 Dwarf_Bool *bError);
331 int print_hipc_lopc_attribute(Dwarf_Debug dbg,
332 Dwarf_Half tag,
333 Dwarf_Die die,
334 Dwarf_Unsigned dieprint_cu_goffset,
335 char ** srcfiles,
336 Dwarf_Signed cnt,
337 Dwarf_Attribute attrib,
338 Dwarf_Half attr,
339 Dwarf_Unsigned max_address,
340 LoHiPc *lohipc,
341 struct esb_s *valname,
342 Dwarf_Error *err);
343 int dd_trace_abstract_origin_etc(
344 Dwarf_Debug dbg,
345 Dwarf_Half tag,
346 Dwarf_Die die,
347 Dwarf_Off dieprint_cu_offset,
348 Dwarf_Half theform,
349 Dwarf_Half attrnum,
350 Dwarf_Attribute attrib,
351 char ** srcfiles,
352 Dwarf_Signed srcfiles_cnt,
353 struct esb_s *valname,
354 struct esb_s *esb_extra,
355 int die_indent_level,
356 int pd_dwarf_names_print_on_error,
357 Dwarf_Error *err);
358 int
359 dd_traverse_one_die(Dwarf_Debug dbg,
360 Dwarf_Attribute attrib,
361 Dwarf_Die die,
362 Dwarf_Off dieprint_cu_goffset,
363 Dwarf_Bool is_info,
364 char **srcfiles, Dwarf_Signed cnt,
365 int die_indent_level,
366 Dwarf_Error *err);
367 void
368 dd_do_dump_visited_info(int level, Dwarf_Off loff,Dwarf_Off goff,
369 Dwarf_Off cu_die_goff,
370 const char *atname, const char *valname);
371 int
372 dd_print_sig8_target(Dwarf_Debug dbg,
373 Dwarf_Attribute attrib,
374 int die_indent_level,
375 char **srcfiles,
376 Dwarf_Signed srcfiles_cnt,
377 struct esb_s * valname,
378 Dwarf_Error *err);
379
380 Dwarf_Bool dd_form_refers_local_info(Dwarf_Half form);
381
382 #ifdef __cplusplus
383 }
384 #endif
385
386 #endif /* globals_INCLUDED */