Bug Summary

File:build/gcc/dwarf2out.cc
Warning:line 11418, column 7
2nd function call argument is an uninitialized value

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-suse-linux -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name dwarf2out.cc -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model static -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/buildworker/marxinbox-gcc-clang-static-analyzer/objdir/gcc -resource-dir /usr/lib64/clang/15.0.7 -D IN_GCC -D HAVE_CONFIG_H -I . -I . -I /buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc -I /buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/. -I /buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/../include -I /buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/../libcpp/include -I /buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/../libcody -I /buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/../libdecnumber -I /buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/../libdecnumber/bid -I ../libdecnumber -I /buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/../libbacktrace -internal-isystem /usr/bin/../lib64/gcc/x86_64-suse-linux/13/../../../../include/c++/13 -internal-isystem /usr/bin/../lib64/gcc/x86_64-suse-linux/13/../../../../include/c++/13/x86_64-suse-linux -internal-isystem /usr/bin/../lib64/gcc/x86_64-suse-linux/13/../../../../include/c++/13/backward -internal-isystem /usr/lib64/clang/15.0.7/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib64/gcc/x86_64-suse-linux/13/../../../../x86_64-suse-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-narrowing -Wwrite-strings -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fdeprecated-macro -fdebug-compilation-dir=/buildworker/marxinbox-gcc-clang-static-analyzer/objdir/gcc -ferror-limit 19 -fno-rtti -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-output=plist-html -analyzer-config silence-checkers=core.NullDereference -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /buildworker/marxinbox-gcc-clang-static-analyzer/objdir/clang-static-analyzer/2023-03-27-141847-20772-1/report-QExKyx.plist -x c++ /buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc
1/* Output Dwarf2 format symbol table information from GCC.
2 Copyright (C) 1992-2023 Free Software Foundation, Inc.
3 Contributed by Gary Funck (gary@intrepid.com).
4 Derived from DWARF 1 implementation of Ron Guilmette (rfg@monkeys.com).
5 Extensively modified by Jason Merrill (jason@cygnus.com).
6
7This file is part of GCC.
8
9GCC is free software; you can redistribute it and/or modify it under
10the terms of the GNU General Public License as published by the Free
11Software Foundation; either version 3, or (at your option) any later
12version.
13
14GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15WARRANTY; without even the implied warranty of MERCHANTABILITY or
16FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17for more details.
18
19You should have received a copy of the GNU General Public License
20along with GCC; see the file COPYING3. If not see
21<http://www.gnu.org/licenses/>. */
22
23/* TODO: Emit .debug_line header even when there are no functions, since
24 the file numbers are used by .debug_info. Alternately, leave
25 out locations for types and decls.
26 Avoid talking about ctors and op= for PODs.
27 Factor out common prologue sequences into multiple CIEs. */
28
29/* The first part of this file deals with the DWARF 2 frame unwind
30 information, which is also used by the GCC efficient exception handling
31 mechanism. The second part, controlled only by an #ifdef
32 DWARF2_DEBUGGING_INFO, deals with the other DWARF 2 debugging
33 information. */
34
35/* DWARF2 Abbreviation Glossary:
36
37 CFA = Canonical Frame Address
38 a fixed address on the stack which identifies a call frame.
39 We define it to be the value of SP just before the call insn.
40 The CFA register and offset, which may change during the course
41 of the function, are used to calculate its value at runtime.
42
43 CFI = Call Frame Instruction
44 an instruction for the DWARF2 abstract machine
45
46 CIE = Common Information Entry
47 information describing information common to one or more FDEs
48
49 DIE = Debugging Information Entry
50
51 FDE = Frame Description Entry
52 information describing the stack call frame, in particular,
53 how to restore registers
54
55 DW_CFA_... = DWARF2 CFA call frame instruction
56 DW_TAG_... = DWARF2 DIE tag */
57
58#include "config.h"
59#include "system.h"
60#include "coretypes.h"
61#include "target.h"
62#include "function.h"
63#include "rtl.h"
64#include "tree.h"
65#include "memmodel.h"
66#include "tm_p.h"
67#include "stringpool.h"
68#include "insn-config.h"
69#include "ira.h"
70#include "cgraph.h"
71#include "diagnostic.h"
72#include "fold-const.h"
73#include "stor-layout.h"
74#include "varasm.h"
75#include "version.h"
76#include "flags.h"
77#include "rtlhash.h"
78#include "reload.h"
79#include "output.h"
80#include "expr.h"
81#include "dwarf2out.h"
82#include "dwarf2ctf.h"
83#include "dwarf2asm.h"
84#include "toplev.h"
85#include "md5.h"
86#include "tree-pretty-print.h"
87#include "print-rtl.h"
88#include "debug.h"
89#include "common/common-target.h"
90#include "langhooks.h"
91#include "lra.h"
92#include "dumpfile.h"
93#include "opts.h"
94#include "tree-dfa.h"
95#include "gdb/gdb-index.h"
96#include "rtl-iter.h"
97#include "stringpool.h"
98#include "attribs.h"
99#include "file-prefix-map.h" /* remap_debug_filename() */
100
101static void dwarf2out_source_line (unsigned int, unsigned int, const char *,
102 int, bool);
103static rtx_insn *last_var_location_insn;
104static rtx_insn *cached_next_real_insn;
105static void dwarf2out_decl (tree);
106static bool is_redundant_typedef (const_tree);
107
108#ifndef XCOFF_DEBUGGING_INFO0
109#define XCOFF_DEBUGGING_INFO0 0
110#endif
111
112#ifndef HAVE_XCOFF_DWARF_EXTRAS0
113#define HAVE_XCOFF_DWARF_EXTRAS0 0
114#endif
115
116#ifdef VMS_DEBUGGING_INFO
117int vms_file_stats_name (const char *, long long *, long *, char *, int *);
118
119/* Define this macro to be a nonzero value if the directory specifications
120 which are output in the debug info should end with a separator. */
121#define DWARF2_DIR_SHOULD_END_WITH_SEPARATOR0 1
122/* Define this macro to evaluate to a nonzero value if GCC should refrain
123 from generating indirect strings in DWARF2 debug information, for instance
124 if your target is stuck with an old version of GDB that is unable to
125 process them properly or uses VMS Debug. */
126#define DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET0 1
127#else
128#define DWARF2_DIR_SHOULD_END_WITH_SEPARATOR0 0
129#define DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET0 0
130#endif
131
132/* ??? Poison these here until it can be done generically. They've been
133 totally replaced in this file; make sure it stays that way. */
134#undef DWARF2_UNWIND_INFO
135#undef DWARF2_FRAME_INFO
136#if (GCC_VERSION(4 * 1000 + 2) >= 3000)
137 #pragma GCC poison DWARF2_UNWIND_INFO DWARF2_FRAME_INFO
138#endif
139
140/* The size of the target's pointer type. */
141#ifndef PTR_SIZE((((global_options.x_ix86_isa_flags & (1UL << 58)) !=
0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags & (1UL
<< 1)) != 0) ? 8 : 4))) / (8))
142#define PTR_SIZE((((global_options.x_ix86_isa_flags & (1UL << 58)) !=
0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags & (1UL
<< 1)) != 0) ? 8 : 4))) / (8))
(POINTER_SIZE(((global_options.x_ix86_isa_flags & (1UL << 58)) !=
0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags & (1UL
<< 1)) != 0) ? 8 : 4)))
/ BITS_PER_UNIT(8))
143#endif
144
145/* Array of RTXes referenced by the debugging information, which therefore
146 must be kept around forever. */
147static GTY(()) vec<rtx, va_gc> *used_rtx_array;
148
149/* A pointer to the base of a list of incomplete types which might be
150 completed at some later time. incomplete_types_list needs to be a
151 vec<tree, va_gc> *because we want to tell the garbage collector about
152 it. */
153static GTY(()) vec<tree, va_gc> *incomplete_types;
154
155/* Pointers to various DWARF2 sections. */
156static GTY(()) section *debug_info_section;
157static GTY(()) section *debug_skeleton_info_section;
158static GTY(()) section *debug_abbrev_section;
159static GTY(()) section *debug_skeleton_abbrev_section;
160static GTY(()) section *debug_aranges_section;
161static GTY(()) section *debug_addr_section;
162static GTY(()) section *debug_macinfo_section;
163static const char *debug_macinfo_section_name;
164static unsigned macinfo_label_base = 1;
165static GTY(()) section *debug_line_section;
166static GTY(()) section *debug_skeleton_line_section;
167static GTY(()) section *debug_loc_section;
168static GTY(()) section *debug_pubnames_section;
169static GTY(()) section *debug_pubtypes_section;
170static GTY(()) section *debug_str_section;
171static GTY(()) section *debug_line_str_section;
172static GTY(()) section *debug_str_dwo_section;
173static GTY(()) section *debug_str_offsets_section;
174static GTY(()) section *debug_ranges_section;
175static GTY(()) section *debug_ranges_dwo_section;
176static GTY(()) section *debug_frame_section;
177
178/* Maximum size (in bytes) of an artificially generated label. */
179#define MAX_ARTIFICIAL_LABEL_BYTES40 40
180
181/* According to the (draft) DWARF 3 specification, the initial length
182 should either be 4 or 12 bytes. When it's 12 bytes, the first 4
183 bytes are 0xffffffff, followed by the length stored in the next 8
184 bytes.
185
186 However, the SGI/MIPS ABI uses an initial length which is equal to
187 dwarf_offset_size. It is defined (elsewhere) accordingly. */
188
189#ifndef DWARF_INITIAL_LENGTH_SIZE(global_options.x_dwarf_offset_size == 4 ? 4 : 12)
190#define DWARF_INITIAL_LENGTH_SIZE(global_options.x_dwarf_offset_size == 4 ? 4 : 12) (dwarf_offset_sizeglobal_options.x_dwarf_offset_size == 4 ? 4 : 12)
191#endif
192
193#ifndef DWARF_INITIAL_LENGTH_SIZE_STR(global_options.x_dwarf_offset_size == 4 ? "-4" : "-12")
194#define DWARF_INITIAL_LENGTH_SIZE_STR(global_options.x_dwarf_offset_size == 4 ? "-4" : "-12") (dwarf_offset_sizeglobal_options.x_dwarf_offset_size == 4 ? "-4" : "-12")
195#endif
196
197/* Round SIZE up to the nearest BOUNDARY. */
198#define DWARF_ROUND(SIZE,BOUNDARY)((((SIZE) + (BOUNDARY) - 1) / (BOUNDARY)) * (BOUNDARY)) \
199 ((((SIZE) + (BOUNDARY) - 1) / (BOUNDARY)) * (BOUNDARY))
200
201/* CIE identifier. */
202#if HOST_BITS_PER_WIDE_INT64 >= 64
203#define DWARF_CIE_ID(unsigned long) (global_options.x_dwarf_offset_size == 4 ? 0xffffffff
: 0xffffffffffffffffULL)
\
204 (unsigned HOST_WIDE_INTlong) (dwarf_offset_sizeglobal_options.x_dwarf_offset_size == 4 ? DW_CIE_ID0xffffffff : DW64_CIE_ID0xffffffffffffffffULL)
205#else
206#define DWARF_CIE_ID(unsigned long) (global_options.x_dwarf_offset_size == 4 ? 0xffffffff
: 0xffffffffffffffffULL)
DW_CIE_ID0xffffffff
207#endif
208
209
210/* A vector for a table that contains frame description
211 information for each routine. */
212#define NOT_INDEXED(-1U) (-1U)
213#define NO_INDEX_ASSIGNED(-2U) (-2U)
214
215static GTY(()) vec<dw_fde_ref, va_gc> *fde_vec;
216
217struct GTY((for_user)) indirect_string_node {
218 const char *str;
219 unsigned int refcount;
220 enum dwarf_form form;
221 char *label;
222 unsigned int index;
223};
224
225struct indirect_string_hasher : ggc_ptr_hash<indirect_string_node>
226{
227 typedef const char *compare_type;
228
229 static hashval_t hash (indirect_string_node *);
230 static bool equal (indirect_string_node *, const char *);
231};
232
233static GTY (()) hash_table<indirect_string_hasher> *debug_str_hash;
234
235static GTY (()) hash_table<indirect_string_hasher> *debug_line_str_hash;
236
237/* With split_debug_info, both the comp_dir and dwo_name go in the
238 main object file, rather than the dwo, similar to the force_direct
239 parameter elsewhere but with additional complications:
240
241 1) The string is needed in both the main object file and the dwo.
242 That is, the comp_dir and dwo_name will appear in both places.
243
244 2) Strings can use four forms: DW_FORM_string, DW_FORM_strp,
245 DW_FORM_line_strp or DW_FORM_strx/GNU_str_index.
246
247 3) GCC chooses the form to use late, depending on the size and
248 reference count.
249
250 Rather than forcing the all debug string handling functions and
251 callers to deal with these complications, simply use a separate,
252 special-cased string table for any attribute that should go in the
253 main object file. This limits the complexity to just the places
254 that need it. */
255
256static GTY (()) hash_table<indirect_string_hasher> *skeleton_debug_str_hash;
257
258static GTY(()) int dw2_string_counter;
259
260/* True if the compilation unit places functions in more than one section. */
261static GTY(()) bool have_multiple_function_sections = false;
262
263/* The default cold text section. */
264static GTY(()) section *cold_text_section;
265
266/* True if currently in text section. */
267static GTY(()) bool in_text_section_p = false;
268
269/* Last debug-on location in corresponding section. */
270static GTY(()) const char *last_text_label;
271static GTY(()) const char *last_cold_label;
272
273/* Mark debug-on/off locations per section.
274 NULL means the section is not used at all. */
275static GTY(()) vec<const char *, va_gc> *switch_text_ranges;
276static GTY(()) vec<const char *, va_gc> *switch_cold_ranges;
277
278/* The DIE for C++14 'auto' in a function return type. */
279static GTY(()) dw_die_ref auto_die;
280
281/* The DIE for C++14 'decltype(auto)' in a function return type. */
282static GTY(()) dw_die_ref decltype_auto_die;
283
284/* Forward declarations for functions defined in this file. */
285
286static void output_call_frame_info (int);
287
288/* Personality decl of current unit. Used only when assembler does not support
289 personality CFI. */
290static GTY(()) rtx current_unit_personality;
291
292/* Whether an eh_frame section is required. */
293static GTY(()) bool do_eh_frame = false;
294
295/* .debug_rnglists next index. */
296static unsigned int rnglist_idx;
297
298/* Data and reference forms for relocatable data. */
299#define DW_FORM_data(global_options.x_dwarf_offset_size == 8 ? DW_FORM_data8 : DW_FORM_data4
)
(dwarf_offset_sizeglobal_options.x_dwarf_offset_size == 8 ? DW_FORM_data8 : DW_FORM_data4)
300#define DW_FORM_ref(global_options.x_dwarf_offset_size == 8 ? DW_FORM_ref8 : DW_FORM_ref4
)
(dwarf_offset_sizeglobal_options.x_dwarf_offset_size == 8 ? DW_FORM_ref8 : DW_FORM_ref4)
301
302#ifndef DEBUG_FRAME_SECTION".debug_frame"
303#define DEBUG_FRAME_SECTION".debug_frame" ".debug_frame"
304#endif
305
306#ifndef FUNC_BEGIN_LABEL"LFB"
307#define FUNC_BEGIN_LABEL"LFB" "LFB"
308#endif
309
310#ifndef FUNC_SECOND_SECT_LABEL"LFSB"
311#define FUNC_SECOND_SECT_LABEL"LFSB" "LFSB"
312#endif
313
314#ifndef FUNC_END_LABEL"LFE"
315#define FUNC_END_LABEL"LFE" "LFE"
316#endif
317
318#ifndef PROLOGUE_END_LABEL"LPE"
319#define PROLOGUE_END_LABEL"LPE" "LPE"
320#endif
321
322#ifndef EPILOGUE_BEGIN_LABEL"LEB"
323#define EPILOGUE_BEGIN_LABEL"LEB" "LEB"
324#endif
325
326#ifndef FRAME_BEGIN_LABEL"Lframe"
327#define FRAME_BEGIN_LABEL"Lframe" "Lframe"
328#endif
329#define CIE_AFTER_SIZE_LABEL"LSCIE" "LSCIE"
330#define CIE_END_LABEL"LECIE" "LECIE"
331#define FDE_LABEL"LSFDE" "LSFDE"
332#define FDE_AFTER_SIZE_LABEL"LASFDE" "LASFDE"
333#define FDE_END_LABEL"LEFDE" "LEFDE"
334#define LINE_NUMBER_BEGIN_LABEL"LSLT" "LSLT"
335#define LINE_NUMBER_END_LABEL"LELT" "LELT"
336#define LN_PROLOG_AS_LABEL"LASLTP" "LASLTP"
337#define LN_PROLOG_END_LABEL"LELTP" "LELTP"
338#define DIE_LABEL_PREFIX"DW" "DW"
339
340/* Match the base name of a file to the base name of a compilation unit. */
341
342static int
343matches_main_base (const char *path)
344{
345 /* Cache the last query. */
346 static const char *last_path = NULLnullptr;
347 static int last_match = 0;
348 if (path != last_path)
349 {
350 const char *base;
351 int length = base_of_path (path, &base);
352 last_path = path;
353 last_match = (length == main_input_baselengthglobal_options.x_main_input_baselength
354 && memcmp (base, main_input_basenameglobal_options.x_main_input_basename, length) == 0);
355 }
356 return last_match;
357}
358
359#ifdef DEBUG_DEBUG_STRUCT
360
361static int
362dump_struct_debug (tree type, enum debug_info_usage usage,
363 enum debug_struct_file criterion, int generic,
364 int matches, int result)
365{
366 /* Find the type name. */
367 tree type_decl = TYPE_STUB_DECL (type)(((contains_struct_check (((tree_class_check ((type), (tcc_type
), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 367, __FUNCTION__))), (TS_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 367, __FUNCTION__))->common.chain))
;
368 tree t = type_decl;
369 const char *name = 0;
370 if (TREE_CODE (t)((enum tree_code) (t)->base.code) == TYPE_DECL)
371 t = DECL_NAME (t)((contains_struct_check ((t), (TS_DECL_MINIMAL), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 371, __FUNCTION__))->decl_minimal.name)
;
372 if (t)
373 name = IDENTIFIER_POINTER (t)((const char *) (tree_check ((t), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 373, __FUNCTION__, (IDENTIFIER_NODE)))->identifier.id.str
)
;
374
375 fprintf (stderrstderr, " struct %d %s %s %s %s %d %p %s\n",
376 criterion,
377 DECL_IN_SYSTEM_HEADER (type_decl)(in_system_header_at (((contains_struct_check ((type_decl), (
TS_DECL_MINIMAL), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 377, __FUNCTION__))->decl_minimal.locus)))
? "sys" : "usr",
378 matches ? "bas" : "hdr",
379 generic ? "gen" : "ord",
380 usage == DINFO_USAGE_DFN ? ";" :
381 usage == DINFO_USAGE_DIR_USE ? "." : "*",
382 result,
383 (void*) type_decl, name);
384 return result;
385}
386#define DUMP_GSTRUCT(type, usage, criterion, generic, matches, result)(result) \
387 dump_struct_debug (type, usage, criterion, generic, matches, result)
388
389#else
390
391#define DUMP_GSTRUCT(type, usage, criterion, generic, matches, result)(result) \
392 (result)
393
394#endif
395
396/* Get the number of HOST_WIDE_INTs needed to represent the precision
397 of the number. */
398
399static unsigned int
400get_full_len (const wide_int &op)
401{
402 int prec = wi::get_precision (op);
403 return ((prec + HOST_BITS_PER_WIDE_INT64 - 1)
404 / HOST_BITS_PER_WIDE_INT64);
405}
406
407static bool
408should_emit_struct_debug (tree type, enum debug_info_usage usage)
409{
410 if (debug_info_levelglobal_options.x_debug_info_level <= DINFO_LEVEL_TERSE)
411 return false;
412
413 enum debug_struct_file criterion;
414 tree type_decl;
415 bool generic = lang_hooks.types.generic_p (type);
416
417 if (generic)
418 criterion = debug_struct_genericglobal_options.x_debug_struct_generic[usage];
419 else
420 criterion = debug_struct_ordinaryglobal_options.x_debug_struct_ordinary[usage];
421
422 if (criterion == DINFO_STRUCT_FILE_NONE)
423 return DUMP_GSTRUCT (type, usage, criterion, generic, false, false)(false);
424 if (criterion == DINFO_STRUCT_FILE_ANY)
425 return DUMP_GSTRUCT (type, usage, criterion, generic, false, true)(true);
426
427 type_decl = TYPE_STUB_DECL (TYPE_MAIN_VARIANT (type))(((contains_struct_check (((tree_class_check ((((tree_class_check
((type), (tcc_type), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 427, __FUNCTION__))->type_common.main_variant)), (tcc_type
), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 427, __FUNCTION__))), (TS_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 427, __FUNCTION__))->common.chain))
;
428
429 if (type_decl != NULLnullptr)
430 {
431 if (criterion == DINFO_STRUCT_FILE_SYS && DECL_IN_SYSTEM_HEADER (type_decl)(in_system_header_at (((contains_struct_check ((type_decl), (
TS_DECL_MINIMAL), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 431, __FUNCTION__))->decl_minimal.locus)))
)
432 return DUMP_GSTRUCT (type, usage, criterion, generic, false, true)(true);
433
434 if (matches_main_base (DECL_SOURCE_FILE (type_decl)((expand_location (((contains_struct_check ((type_decl), (TS_DECL_MINIMAL
), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 434, __FUNCTION__))->decl_minimal.locus))).file)
))
435 return DUMP_GSTRUCT (type, usage, criterion, generic, true, true)(true);
436 }
437
438 return DUMP_GSTRUCT (type, usage, criterion, generic, false, false)(false);
439}
440
441/* Switch [BACK] to eh_frame_section. If we don't have an eh_frame_section,
442 switch to the data section instead, and write out a synthetic start label
443 for collect2 the first time around. */
444
445static void
446switch_to_eh_frame_section (bool back ATTRIBUTE_UNUSED__attribute__ ((__unused__)))
447{
448 if (eh_frame_section == 0)
449 {
450 int flags;
451
452 if (EH_TABLES_CAN_BE_READ_ONLY1)
453 {
454 int fde_encoding;
455 int per_encoding;
456 int lsda_encoding;
457
458 fde_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1,asm_preferred_eh_data_format ((1), (0))
459 /*global=*/0)asm_preferred_eh_data_format ((1), (0));
460 per_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2,asm_preferred_eh_data_format ((2), (1))
461 /*global=*/1)asm_preferred_eh_data_format ((2), (1));
462 lsda_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0,asm_preferred_eh_data_format ((0), (0))
463 /*global=*/0)asm_preferred_eh_data_format ((0), (0));
464 flags = ((! flag_picglobal_options.x_flag_pic
465 || ((fde_encoding & 0x70) != DW_EH_PE_absptr0x00
466 && (fde_encoding & 0x70) != DW_EH_PE_aligned0x50
467 && (per_encoding & 0x70) != DW_EH_PE_absptr0x00
468 && (per_encoding & 0x70) != DW_EH_PE_aligned0x50
469 && (lsda_encoding & 0x70) != DW_EH_PE_absptr0x00
470 && (lsda_encoding & 0x70) != DW_EH_PE_aligned0x50))
471 ? 0 : SECTION_WRITE);
472 }
473 else
474 flags = SECTION_WRITE;
475
476#ifdef EH_FRAME_SECTION_NAME".eh_frame"
477 eh_frame_section = get_section (EH_FRAME_SECTION_NAME".eh_frame", flags, NULLnullptr);
478#else
479 eh_frame_section = ((flags == SECTION_WRITE)
480 ? data_section : readonly_data_section);
481#endif /* EH_FRAME_SECTION_NAME */
482 }
483
484 switch_to_section (eh_frame_section);
485
486#ifdef EH_FRAME_THROUGH_COLLECT2
487 /* We have no special eh_frame section. Emit special labels to guide
488 collect2. */
489 if (!back)
490 {
491 tree label = get_file_function_name ("F");
492 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE))if ((floor_log2 (((((global_options.x_ix86_isa_flags & (1UL
<< 58)) != 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags
& (1UL << 1)) != 0) ? 8 : 4))) / (8)))) != 0) fprintf
((asm_out_file), "\t.align %d\n", 1 << (floor_log2 (((
((global_options.x_ix86_isa_flags & (1UL << 58)) !=
0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags & (1UL
<< 1)) != 0) ? 8 : 4))) / (8)))))
;
493 targetm.asm_out.globalize_label (asm_out_file,
494 IDENTIFIER_POINTER (label)((const char *) (tree_check ((label), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 494, __FUNCTION__, (IDENTIFIER_NODE)))->identifier.id.str
)
);
495 ASM_OUTPUT_LABEL (asm_out_file, IDENTIFIER_POINTER (label))do { assemble_name ((asm_out_file), (((const char *) (tree_check
((label), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 495, __FUNCTION__, (IDENTIFIER_NODE)))->identifier.id.str
))); fputs (":\n", (asm_out_file)); } while (0)
;
496 }
497#endif
498}
499
500/* Switch [BACK] to the eh or debug frame table section, depending on
501 FOR_EH. */
502
503static void
504switch_to_frame_table_section (int for_eh, bool back)
505{
506 if (for_eh)
507 switch_to_eh_frame_section (back);
508 else
509 {
510 if (!debug_frame_section)
511 debug_frame_section = get_section (DEBUG_FRAME_SECTION".debug_frame",
512 SECTION_DEBUG, NULLnullptr);
513 switch_to_section (debug_frame_section);
514 }
515}
516
517/* Describe for the GTY machinery what parts of dw_cfi_oprnd1 are used. */
518
519enum dw_cfi_oprnd_type
520dw_cfi_oprnd1_desc (enum dwarf_call_frame_info cfi)
521{
522 switch (cfi)
523 {
524 case DW_CFA_nop:
525 case DW_CFA_GNU_window_save:
526 case DW_CFA_remember_state:
527 case DW_CFA_restore_state:
528 return dw_cfi_oprnd_unused;
529
530 case DW_CFA_set_loc:
531 case DW_CFA_advance_loc1:
532 case DW_CFA_advance_loc2:
533 case DW_CFA_advance_loc4:
534 case DW_CFA_MIPS_advance_loc8:
535 return dw_cfi_oprnd_addr;
536
537 case DW_CFA_offset:
538 case DW_CFA_offset_extended:
539 case DW_CFA_def_cfa:
540 case DW_CFA_offset_extended_sf:
541 case DW_CFA_def_cfa_sf:
542 case DW_CFA_restore:
543 case DW_CFA_restore_extended:
544 case DW_CFA_undefined:
545 case DW_CFA_same_value:
546 case DW_CFA_def_cfa_register:
547 case DW_CFA_register:
548 case DW_CFA_expression:
549 case DW_CFA_val_expression:
550 return dw_cfi_oprnd_reg_num;
551
552 case DW_CFA_def_cfa_offset:
553 case DW_CFA_GNU_args_size:
554 case DW_CFA_def_cfa_offset_sf:
555 return dw_cfi_oprnd_offset;
556
557 case DW_CFA_def_cfa_expression:
558 return dw_cfi_oprnd_loc;
559
560 default:
561 gcc_unreachable ()(fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 561, __FUNCTION__))
;
562 }
563}
564
565/* Describe for the GTY machinery what parts of dw_cfi_oprnd2 are used. */
566
567enum dw_cfi_oprnd_type
568dw_cfi_oprnd2_desc (enum dwarf_call_frame_info cfi)
569{
570 switch (cfi)
571 {
572 case DW_CFA_def_cfa:
573 case DW_CFA_def_cfa_sf:
574 case DW_CFA_offset:
575 case DW_CFA_offset_extended_sf:
576 case DW_CFA_offset_extended:
577 return dw_cfi_oprnd_offset;
578
579 case DW_CFA_register:
580 return dw_cfi_oprnd_reg_num;
581
582 case DW_CFA_expression:
583 case DW_CFA_val_expression:
584 return dw_cfi_oprnd_loc;
585
586 case DW_CFA_def_cfa_expression:
587 return dw_cfi_oprnd_cfa_loc;
588
589 default:
590 return dw_cfi_oprnd_unused;
591 }
592}
593
594/* Output one FDE. */
595
596static void
597output_fde (dw_fde_ref fde, bool for_eh, bool second,
598 char *section_start_label, int fde_encoding, char *augmentation,
599 bool any_lsda_needed, int lsda_encoding)
600{
601 const char *begin, *end;
602 static unsigned int j;
603 char l1[MAX_ARTIFICIAL_LABEL_BYTES40], l2[MAX_ARTIFICIAL_LABEL_BYTES40];
604
605 targetm.asm_out.emit_unwind_label (asm_out_file, fde->decl, for_eh,
606 /* empty */ 0);
607 targetm.asm_out.internal_label (asm_out_file, FDE_LABEL"LSFDE",
608 for_eh + j);
609 ASM_GENERATE_INTERNAL_LABEL (l1, FDE_AFTER_SIZE_LABEL, for_eh + j)do { char *__p; (l1)[0] = '*'; (l1)[1] = '.'; __p = stpcpy (&
(l1)[2], "LASFDE"); sprint_ul (__p, (unsigned long) (for_eh +
j)); } while (0)
;
610 ASM_GENERATE_INTERNAL_LABEL (l2, FDE_END_LABEL, for_eh + j)do { char *__p; (l2)[0] = '*'; (l2)[1] = '.'; __p = stpcpy (&
(l2)[2], "LEFDE"); sprint_ul (__p, (unsigned long) (for_eh + j
)); } while (0)
;
611 if (!XCOFF_DEBUGGING_INFO0 || for_eh)
612 {
613 if (DWARF_INITIAL_LENGTH_SIZE(global_options.x_dwarf_offset_size == 4 ? 4 : 12) - dwarf_offset_sizeglobal_options.x_dwarf_offset_size == 4 && !for_eh)
614 dw2_asm_output_data (4, 0xffffffff, "Initial length escape value"
615 " indicating 64-bit DWARF extension");
616 dw2_asm_output_delta (for_eh ? 4 : dwarf_offset_sizeglobal_options.x_dwarf_offset_size, l2, l1,
617 "FDE Length");
618 }
619 ASM_OUTPUT_LABEL (asm_out_file, l1)do { assemble_name ((asm_out_file), (l1)); fputs (":\n", (asm_out_file
)); } while (0)
;
620
621 if (for_eh)
622 dw2_asm_output_delta (4, l1, section_start_label, "FDE CIE offset");
623 else
624 dw2_asm_output_offset (dwarf_offset_sizeglobal_options.x_dwarf_offset_size, section_start_label,
625 debug_frame_section, "FDE CIE offset");
626
627 begin = second ? fde->dw_fde_second_begin : fde->dw_fde_begin;
628 end = second ? fde->dw_fde_second_end : fde->dw_fde_end;
629
630 if (for_eh)
631 {
632 rtx sym_ref = gen_rtx_SYMBOL_REF (Pmode, begin)gen_rtx_fmt_s0_stat ((SYMBOL_REF), (((global_options.x_ix86_pmode
== PMODE_DI ? (scalar_int_mode ((scalar_int_mode::from_int) E_DImode
)) : (scalar_int_mode ((scalar_int_mode::from_int) E_SImode))
))), ((begin)) )
;
633 SYMBOL_REF_FLAGS (sym_ref)(__extension__ ({ __typeof ((sym_ref)) const _rtx = ((sym_ref
)); if (((enum rtx_code) (_rtx)->code) != SYMBOL_REF) rtl_check_failed_flag
("SYMBOL_REF_FLAGS", _rtx, "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 633, __FUNCTION__); _rtx; }) ->u2.symbol_ref_flags)
|= SYMBOL_FLAG_LOCAL(1 << 1);
634 dw2_asm_output_encoded_addr_rtx (fde_encoding, sym_ref, false,
635 "FDE initial location");
636 dw2_asm_output_delta (size_of_encoded_value (fde_encoding),
637 end, begin, "FDE address range");
638 }
639 else
640 {
641 dw2_asm_output_addr (DWARF2_ADDR_SIZE(((((global_options.x_ix86_isa_flags & (1UL << 58))
!= 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags &
(1UL << 1)) != 0) ? 8 : 4))) + (8) - 1) / (8))
, begin, "FDE initial location");
642 dw2_asm_output_delta (DWARF2_ADDR_SIZE(((((global_options.x_ix86_isa_flags & (1UL << 58))
!= 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags &
(1UL << 1)) != 0) ? 8 : 4))) + (8) - 1) / (8))
, end, begin, "FDE address range");
643 }
644
645 if (augmentation[0])
646 {
647 if (any_lsda_needed)
648 {
649 int size = size_of_encoded_value (lsda_encoding);
650
651 if (lsda_encoding == DW_EH_PE_aligned0x50)
652 {
653 int offset = ( 4 /* Length */
654 + 4 /* CIE offset */
655 + 2 * size_of_encoded_value (fde_encoding)
656 + 1 /* Augmentation size */ );
657 int pad = -offset & (PTR_SIZE((((global_options.x_ix86_isa_flags & (1UL << 58)) !=
0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags & (1UL
<< 1)) != 0) ? 8 : 4))) / (8))
- 1);
658
659 size += pad;
660 gcc_assert (size_of_uleb128 (size) == 1)((void)(!(size_of_uleb128 (size) == 1) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 660, __FUNCTION__), 0 : 0))
;
661 }
662
663 dw2_asm_output_data_uleb128 (size, "Augmentation size");
664
665 if (fde->uses_eh_lsda)
666 {
667 ASM_GENERATE_INTERNAL_LABEL (l1, second ? "LLSDAC" : "LLSDA",do { char *__p; (l1)[0] = '*'; (l1)[1] = '.'; __p = stpcpy (&
(l1)[2], second ? "LLSDAC" : "LLSDA"); sprint_ul (__p, (unsigned
long) (fde->funcdef_number)); } while (0)
668 fde->funcdef_number)do { char *__p; (l1)[0] = '*'; (l1)[1] = '.'; __p = stpcpy (&
(l1)[2], second ? "LLSDAC" : "LLSDA"); sprint_ul (__p, (unsigned
long) (fde->funcdef_number)); } while (0)
;
669 dw2_asm_output_encoded_addr_rtx (lsda_encoding,
670 gen_rtx_SYMBOL_REF (Pmode, l1)gen_rtx_fmt_s0_stat ((SYMBOL_REF), (((global_options.x_ix86_pmode
== PMODE_DI ? (scalar_int_mode ((scalar_int_mode::from_int) E_DImode
)) : (scalar_int_mode ((scalar_int_mode::from_int) E_SImode))
))), ((l1)) )
,
671 false,
672 "Language Specific Data Area");
673 }
674 else
675 {
676 if (lsda_encoding == DW_EH_PE_aligned0x50)
677 ASM_OUTPUT_ALIGN (asm_out_file, floor_log2 (PTR_SIZE))if ((floor_log2 (((((global_options.x_ix86_isa_flags & (1UL
<< 58)) != 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags
& (1UL << 1)) != 0) ? 8 : 4))) / (8)))) != 0) fprintf
((asm_out_file), "\t.align %d\n", 1 << (floor_log2 (((
((global_options.x_ix86_isa_flags & (1UL << 58)) !=
0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags & (1UL
<< 1)) != 0) ? 8 : 4))) / (8)))))
;
678 dw2_asm_output_data (size_of_encoded_value (lsda_encoding), 0,
679 "Language Specific Data Area (none)");
680 }
681 }
682 else
683 dw2_asm_output_data_uleb128 (0, "Augmentation size");
684 }
685
686 /* Loop through the Call Frame Instructions associated with this FDE. */
687 fde->dw_fde_current_label = begin;
688 {
689 size_t from, until, i;
690
691 from = 0;
692 until = vec_safe_length (fde->dw_fde_cfi);
693
694 if (fde->dw_fde_second_begin == NULLnullptr)
695 ;
696 else if (!second)
697 until = fde->dw_fde_switch_cfi_index;
698 else
699 from = fde->dw_fde_switch_cfi_index;
700
701 for (i = from; i < until; i++)
702 output_cfi ((*fde->dw_fde_cfi)[i], fde, for_eh);
703 }
704
705 /* If we are to emit a ref/link from function bodies to their frame tables,
706 do it now. This is typically performed to make sure that tables
707 associated with functions are dragged with them and not discarded in
708 garbage collecting links. We need to do this on a per function basis to
709 cope with -ffunction-sections. */
710
711#ifdef ASM_OUTPUT_DWARF_TABLE_REF
712 /* Switch to the function section, emit the ref to the tables, and
713 switch *back* into the table section. */
714 switch_to_section (function_section (fde->decl));
715 ASM_OUTPUT_DWARF_TABLE_REF (section_start_label);
716 switch_to_frame_table_section (for_eh, true);
717#endif
718
719 /* Pad the FDE out to an address sized boundary. */
720 ASM_OUTPUT_ALIGN (asm_out_file,if ((floor_log2 ((for_eh ? ((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) / (
8)) : (((((global_options.x_ix86_isa_flags & (1UL <<
58)) != 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags &
(1UL << 1)) != 0) ? 8 : 4))) + (8) - 1) / (8))))) != 0
) fprintf ((asm_out_file), "\t.align %d\n", 1 << (floor_log2
((for_eh ? ((((global_options.x_ix86_isa_flags & (1UL <<
58)) != 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags &
(1UL << 1)) != 0) ? 8 : 4))) / (8)) : (((((global_options
.x_ix86_isa_flags & (1UL << 58)) != 0) ? 32 : ((8) *
(((global_options.x_ix86_isa_flags & (1UL << 1)) !=
0) ? 8 : 4))) + (8) - 1) / (8))))))
721 floor_log2 ((for_eh ? PTR_SIZE : DWARF2_ADDR_SIZE)))if ((floor_log2 ((for_eh ? ((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) / (
8)) : (((((global_options.x_ix86_isa_flags & (1UL <<
58)) != 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags &
(1UL << 1)) != 0) ? 8 : 4))) + (8) - 1) / (8))))) != 0
) fprintf ((asm_out_file), "\t.align %d\n", 1 << (floor_log2
((for_eh ? ((((global_options.x_ix86_isa_flags & (1UL <<
58)) != 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags &
(1UL << 1)) != 0) ? 8 : 4))) / (8)) : (((((global_options
.x_ix86_isa_flags & (1UL << 58)) != 0) ? 32 : ((8) *
(((global_options.x_ix86_isa_flags & (1UL << 1)) !=
0) ? 8 : 4))) + (8) - 1) / (8))))))
;
722 ASM_OUTPUT_LABEL (asm_out_file, l2)do { assemble_name ((asm_out_file), (l2)); fputs (":\n", (asm_out_file
)); } while (0)
;
723
724 j += 2;
725}
726
727/* Return true if frame description entry FDE is needed for EH. */
728
729static bool
730fde_needed_for_eh_p (dw_fde_ref fde)
731{
732 if (flag_asynchronous_unwind_tablesglobal_options.x_flag_asynchronous_unwind_tables)
733 return true;
734
735 if (TARGET_USES_WEAK_UNWIND_INFO0 && DECL_WEAK (fde->decl)((contains_struct_check ((fde->decl), (TS_DECL_WITH_VIS), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 735, __FUNCTION__))->decl_with_vis.weak_flag)
)
736 return true;
737
738 if (fde->uses_eh_lsda)
739 return true;
740
741 /* If exceptions are enabled, we have collected nothrow info. */
742 if (flag_exceptionsglobal_options.x_flag_exceptions && (fde->all_throwers_are_sibcalls || fde->nothrow))
743 return false;
744
745 return true;
746}
747
748/* Output the call frame information used to record information
749 that relates to calculating the frame pointer, and records the
750 location of saved registers. */
751
752static void
753output_call_frame_info (int for_eh)
754{
755 unsigned int i;
756 dw_fde_ref fde;
757 dw_cfi_ref cfi;
758 char l1[MAX_ARTIFICIAL_LABEL_BYTES40], l2[MAX_ARTIFICIAL_LABEL_BYTES40];
759 char section_start_label[MAX_ARTIFICIAL_LABEL_BYTES40];
760 bool any_lsda_needed = false;
761 char augmentation[6];
762 int augmentation_size;
763 int fde_encoding = DW_EH_PE_absptr0x00;
764 int per_encoding = DW_EH_PE_absptr0x00;
765 int lsda_encoding = DW_EH_PE_absptr0x00;
766 int return_reg;
767 rtx personality = NULLnullptr;
768 int dw_cie_version;
769
770 /* Don't emit a CIE if there won't be any FDEs. */
771 if (!fde_vec)
772 return;
773
774 /* Nothing to do if the assembler's doing it all. */
775 if (dwarf2out_do_cfi_asm ())
776 return;
777
778 /* If we don't have any functions we'll want to unwind out of, don't emit
779 any EH unwind information. If we make FDEs linkonce, we may have to
780 emit an empty label for an FDE that wouldn't otherwise be emitted. We
781 want to avoid having an FDE kept around when the function it refers to
782 is discarded. Example where this matters: a primary function template
783 in C++ requires EH information, an explicit specialization doesn't. */
784 if (for_eh)
785 {
786 bool any_eh_needed = false;
787
788 FOR_EACH_VEC_ELT (*fde_vec, i, fde)for (i = 0; (*fde_vec).iterate ((i), &(fde)); ++(i))
789 {
790 if (fde->uses_eh_lsda)
791 any_eh_needed = any_lsda_needed = true;
792 else if (fde_needed_for_eh_p (fde))
793 any_eh_needed = true;
794 else if (TARGET_USES_WEAK_UNWIND_INFO0)
795 targetm.asm_out.emit_unwind_label (asm_out_file, fde->decl, 1, 1);
796 }
797
798 if (!any_eh_needed)
799 return;
800 }
801
802 /* We're going to be generating comments, so turn on app. */
803 if (flag_debug_asmglobal_options.x_flag_debug_asm)
804 app_enable ();
805
806 /* Switch to the proper frame section, first time. */
807 switch_to_frame_table_section (for_eh, false);
808
809 ASM_GENERATE_INTERNAL_LABEL (section_start_label, FRAME_BEGIN_LABEL, for_eh)do { char *__p; (section_start_label)[0] = '*'; (section_start_label
)[1] = '.'; __p = stpcpy (&(section_start_label)[2], "Lframe"
); sprint_ul (__p, (unsigned long) (for_eh)); } while (0)
;
810 ASM_OUTPUT_LABEL (asm_out_file, section_start_label)do { assemble_name ((asm_out_file), (section_start_label)); fputs
(":\n", (asm_out_file)); } while (0)
;
811
812 /* Output the CIE. */
813 ASM_GENERATE_INTERNAL_LABEL (l1, CIE_AFTER_SIZE_LABEL, for_eh)do { char *__p; (l1)[0] = '*'; (l1)[1] = '.'; __p = stpcpy (&
(l1)[2], "LSCIE"); sprint_ul (__p, (unsigned long) (for_eh));
} while (0)
;
814 ASM_GENERATE_INTERNAL_LABEL (l2, CIE_END_LABEL, for_eh)do { char *__p; (l2)[0] = '*'; (l2)[1] = '.'; __p = stpcpy (&
(l2)[2], "LECIE"); sprint_ul (__p, (unsigned long) (for_eh));
} while (0)
;
815 if (!XCOFF_DEBUGGING_INFO0 || for_eh)
816 {
817 if (DWARF_INITIAL_LENGTH_SIZE(global_options.x_dwarf_offset_size == 4 ? 4 : 12) - dwarf_offset_sizeglobal_options.x_dwarf_offset_size == 4 && !for_eh)
818 dw2_asm_output_data (4, 0xffffffff,
819 "Initial length escape value indicating 64-bit DWARF extension");
820 dw2_asm_output_delta (for_eh ? 4 : dwarf_offset_sizeglobal_options.x_dwarf_offset_size, l2, l1,
821 "Length of Common Information Entry");
822 }
823 ASM_OUTPUT_LABEL (asm_out_file, l1)do { assemble_name ((asm_out_file), (l1)); fputs (":\n", (asm_out_file
)); } while (0)
;
824
825 /* Now that the CIE pointer is PC-relative for EH,
826 use 0 to identify the CIE. */
827 dw2_asm_output_data ((for_eh ? 4 : dwarf_offset_sizeglobal_options.x_dwarf_offset_size),
828 (for_eh ? 0 : DWARF_CIE_ID(unsigned long) (global_options.x_dwarf_offset_size == 4 ? 0xffffffff
: 0xffffffffffffffffULL)
),
829 "CIE Identifier Tag");
830
831 /* Use the CIE version 3 for DWARF3; allow DWARF2 to continue to
832 use CIE version 1, unless that would produce incorrect results
833 due to overflowing the return register column. */
834 return_reg = DWARF2_FRAME_REG_OUT (DWARF_FRAME_RETURN_COLUMN, for_eh)((((global_options.x_ix86_isa_flags & (1UL << 1)) !=
0) ? 16 : 8))
;
835 dw_cie_version = 1;
836 if (return_reg >= 256 || dwarf_versionglobal_options.x_dwarf_version > 2)
837 dw_cie_version = 3;
838 dw2_asm_output_data (1, dw_cie_version, "CIE Version");
839
840 augmentation[0] = 0;
841 augmentation_size = 0;
842
843 personality = current_unit_personality;
844 if (for_eh)
845 {
846 char *p;
847
848 /* Augmentation:
849 z Indicates that a uleb128 is present to size the
850 augmentation section.
851 L Indicates the encoding (and thus presence) of
852 an LSDA pointer in the FDE augmentation.
853 R Indicates a non-default pointer encoding for
854 FDE code pointers.
855 P Indicates the presence of an encoding + language
856 personality routine in the CIE augmentation. */
857
858 fde_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/1, /*global=*/0)asm_preferred_eh_data_format ((1), (0));
859 per_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2, /*global=*/1)asm_preferred_eh_data_format ((2), (1));
860 lsda_encoding = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/0)asm_preferred_eh_data_format ((0), (0));
861
862 p = augmentation + 1;
863 if (personality)
864 {
865 *p++ = 'P';
866 augmentation_size += 1 + size_of_encoded_value (per_encoding);
867 assemble_external_libcall (personality);
868 }
869 if (any_lsda_needed)
870 {
871 *p++ = 'L';
872 augmentation_size += 1;
873 }
874 if (fde_encoding != DW_EH_PE_absptr0x00)
875 {
876 *p++ = 'R';
877 augmentation_size += 1;
878 }
879 if (p > augmentation + 1)
880 {
881 augmentation[0] = 'z';
882 *p = '\0';
883 }
884
885 /* Ug. Some platforms can't do unaligned dynamic relocations at all. */
886 if (personality && per_encoding == DW_EH_PE_aligned0x50)
887 {
888 int offset = ( 4 /* Length */
889 + 4 /* CIE Id */
890 + 1 /* CIE version */
891 + strlen (augmentation) + 1 /* Augmentation */
892 + size_of_uleb128 (1) /* Code alignment */
893 + size_of_sleb128 (DWARF_CIE_DATA_ALIGNMENT(-((int) (((global_options.x_ix86_isa_flags & (1UL <<
1)) != 0) ? 8 : 4)))
)
894 + 1 /* RA column */
895 + 1 /* Augmentation size */
896 + 1 /* Personality encoding */ );
897 int pad = -offset & (PTR_SIZE((((global_options.x_ix86_isa_flags & (1UL << 58)) !=
0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags & (1UL
<< 1)) != 0) ? 8 : 4))) / (8))
- 1);
898
899 augmentation_size += pad;
900
901 /* Augmentations should be small, so there's scarce need to
902 iterate for a solution. Die if we exceed one uleb128 byte. */
903 gcc_assert (size_of_uleb128 (augmentation_size) == 1)((void)(!(size_of_uleb128 (augmentation_size) == 1) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 903, __FUNCTION__), 0 : 0))
;
904 }
905 }
906
907 dw2_asm_output_nstring (augmentation, -1, "CIE Augmentation");
908 if (dw_cie_version >= 4)
909 {
910 dw2_asm_output_data (1, DWARF2_ADDR_SIZE(((((global_options.x_ix86_isa_flags & (1UL << 58))
!= 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags &
(1UL << 1)) != 0) ? 8 : 4))) + (8) - 1) / (8))
, "CIE Address Size");
911 dw2_asm_output_data (1, 0, "CIE Segment Size");
912 }
913 dw2_asm_output_data_uleb128 (1, "CIE Code Alignment Factor");
914 dw2_asm_output_data_sleb128 (DWARF_CIE_DATA_ALIGNMENT(-((int) (((global_options.x_ix86_isa_flags & (1UL <<
1)) != 0) ? 8 : 4)))
,
915 "CIE Data Alignment Factor");
916
917 if (dw_cie_version == 1)
918 dw2_asm_output_data (1, return_reg, "CIE RA Column");
919 else
920 dw2_asm_output_data_uleb128 (return_reg, "CIE RA Column");
921
922 if (augmentation[0])
923 {
924 dw2_asm_output_data_uleb128 (augmentation_size, "Augmentation size");
925 if (personality)
926 {
927 dw2_asm_output_data (1, per_encoding, "Personality (%s)",
928 eh_data_format_name (per_encoding));
929 dw2_asm_output_encoded_addr_rtx (per_encoding,
930 personality,
931 true, NULLnullptr);
932 }
933
934 if (any_lsda_needed)
935 dw2_asm_output_data (1, lsda_encoding, "LSDA Encoding (%s)",
936 eh_data_format_name (lsda_encoding));
937
938 if (fde_encoding != DW_EH_PE_absptr0x00)
939 dw2_asm_output_data (1, fde_encoding, "FDE Encoding (%s)",
940 eh_data_format_name (fde_encoding));
941 }
942
943 FOR_EACH_VEC_ELT (*cie_cfi_vec, i, cfi)for (i = 0; (*cie_cfi_vec).iterate ((i), &(cfi)); ++(i))
944 output_cfi (cfi, NULLnullptr, for_eh);
945
946 /* Pad the CIE out to an address sized boundary. */
947 ASM_OUTPUT_ALIGN (asm_out_file,if ((floor_log2 (for_eh ? ((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) / (
8)) : (((((global_options.x_ix86_isa_flags & (1UL <<
58)) != 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags &
(1UL << 1)) != 0) ? 8 : 4))) + (8) - 1) / (8)))) != 0)
fprintf ((asm_out_file), "\t.align %d\n", 1 << (floor_log2
(for_eh ? ((((global_options.x_ix86_isa_flags & (1UL <<
58)) != 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags &
(1UL << 1)) != 0) ? 8 : 4))) / (8)) : (((((global_options
.x_ix86_isa_flags & (1UL << 58)) != 0) ? 32 : ((8) *
(((global_options.x_ix86_isa_flags & (1UL << 1)) !=
0) ? 8 : 4))) + (8) - 1) / (8)))))
948 floor_log2 (for_eh ? PTR_SIZE : DWARF2_ADDR_SIZE))if ((floor_log2 (for_eh ? ((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) / (
8)) : (((((global_options.x_ix86_isa_flags & (1UL <<
58)) != 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags &
(1UL << 1)) != 0) ? 8 : 4))) + (8) - 1) / (8)))) != 0)
fprintf ((asm_out_file), "\t.align %d\n", 1 << (floor_log2
(for_eh ? ((((global_options.x_ix86_isa_flags & (1UL <<
58)) != 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags &
(1UL << 1)) != 0) ? 8 : 4))) / (8)) : (((((global_options
.x_ix86_isa_flags & (1UL << 58)) != 0) ? 32 : ((8) *
(((global_options.x_ix86_isa_flags & (1UL << 1)) !=
0) ? 8 : 4))) + (8) - 1) / (8)))))
;
949 ASM_OUTPUT_LABEL (asm_out_file, l2)do { assemble_name ((asm_out_file), (l2)); fputs (":\n", (asm_out_file
)); } while (0)
;
950
951 /* Loop through all of the FDE's. */
952 FOR_EACH_VEC_ELT (*fde_vec, i, fde)for (i = 0; (*fde_vec).iterate ((i), &(fde)); ++(i))
953 {
954 unsigned int k;
955
956 /* Don't emit EH unwind info for leaf functions that don't need it. */
957 if (for_eh && !fde_needed_for_eh_p (fde))
958 continue;
959
960 for (k = 0; k < (fde->dw_fde_second_begin ? 2 : 1); k++)
961 output_fde (fde, for_eh, k, section_start_label, fde_encoding,
962 augmentation, any_lsda_needed, lsda_encoding);
963 }
964
965 if (for_eh && targetm.terminate_dw2_eh_frame_info)
966 dw2_asm_output_data (4, 0, "End of Table");
967
968 /* Turn off app to make assembly quicker. */
969 if (flag_debug_asmglobal_options.x_flag_debug_asm)
970 app_disable ();
971}
972
973/* Emit .cfi_startproc and .cfi_personality/.cfi_lsda if needed. */
974
975static void
976dwarf2out_do_cfi_startproc (bool second)
977{
978 int enc;
979 rtx ref;
980
981 fprintf (asm_out_file, "\t.cfi_startproc\n");
982
983 targetm.asm_out.post_cfi_startproc (asm_out_file, current_function_decl);
984
985 /* .cfi_personality and .cfi_lsda are only relevant to DWARF2
986 eh unwinders. */
987 if (targetm_common.except_unwind_info (&global_options) != UI_DWARF2)
988 return;
989
990 rtx personality = get_personality_function (current_function_decl);
991
992 if (personality)
993 {
994 enc = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/2, /*global=*/1)asm_preferred_eh_data_format ((2), (1));
995 ref = personality;
996
997 /* ??? The GAS support isn't entirely consistent. We have to
998 handle indirect support ourselves, but PC-relative is done
999 in the assembler. Further, the assembler can't handle any
1000 of the weirder relocation types. */
1001 if (enc & DW_EH_PE_indirect0x80)
1002 {
1003 if (targetm.asm_out.make_eh_symbol_indirect != NULLnullptr)
1004 ref = targetm.asm_out.make_eh_symbol_indirect (ref, true);
1005 else
1006 ref = dw2_force_const_mem (ref, true);
1007 }
1008
1009 fprintf (asm_out_file, "\t.cfi_personality %#x,", enc);
1010 output_addr_const (asm_out_file, ref);
1011 fputc ('\n', asm_out_file);
1012 }
1013
1014 if (crtl(&x_rtl)->uses_eh_lsda)
1015 {
1016 char lab[MAX_ARTIFICIAL_LABEL_BYTES40];
1017
1018 enc = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/0)asm_preferred_eh_data_format ((0), (0));
1019 ASM_GENERATE_INTERNAL_LABEL (lab, second ? "LLSDAC" : "LLSDA",do { char *__p; (lab)[0] = '*'; (lab)[1] = '.'; __p = stpcpy (
&(lab)[2], second ? "LLSDAC" : "LLSDA"); sprint_ul (__p, (
unsigned long) (((cfun + 0)->funcdef_no))); } while (0)
1020 current_function_funcdef_no)do { char *__p; (lab)[0] = '*'; (lab)[1] = '.'; __p = stpcpy (
&(lab)[2], second ? "LLSDAC" : "LLSDA"); sprint_ul (__p, (
unsigned long) (((cfun + 0)->funcdef_no))); } while (0)
;
1021 ref = gen_rtx_SYMBOL_REF (Pmode, lab)gen_rtx_fmt_s0_stat ((SYMBOL_REF), (((global_options.x_ix86_pmode
== PMODE_DI ? (scalar_int_mode ((scalar_int_mode::from_int) E_DImode
)) : (scalar_int_mode ((scalar_int_mode::from_int) E_SImode))
))), ((lab)) )
;
1022 SYMBOL_REF_FLAGS (ref)(__extension__ ({ __typeof ((ref)) const _rtx = ((ref)); if (
((enum rtx_code) (_rtx)->code) != SYMBOL_REF) rtl_check_failed_flag
("SYMBOL_REF_FLAGS", _rtx, "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 1022, __FUNCTION__); _rtx; }) ->u2.symbol_ref_flags)
= SYMBOL_FLAG_LOCAL(1 << 1);
1023
1024 if (enc & DW_EH_PE_indirect0x80)
1025 {
1026 if (targetm.asm_out.make_eh_symbol_indirect != NULLnullptr)
1027 ref = targetm.asm_out.make_eh_symbol_indirect (ref, true);
1028 else
1029 ref = dw2_force_const_mem (ref, true);
1030 }
1031
1032 fprintf (asm_out_file, "\t.cfi_lsda %#x,", enc);
1033 output_addr_const (asm_out_file, ref);
1034 fputc ('\n', asm_out_file);
1035 }
1036}
1037
1038/* Allocate CURRENT_FDE. Immediately initialize all we can, noting that
1039 this allocation may be done before pass_final. */
1040
1041dw_fde_ref
1042dwarf2out_alloc_current_fde (void)
1043{
1044 dw_fde_ref fde;
1045
1046 fde = ggc_cleared_alloc<dw_fde_node> ();
1047 fde->decl = current_function_decl;
1048 fde->funcdef_number = current_function_funcdef_no((cfun + 0)->funcdef_no);
1049 fde->fde_index = vec_safe_length (fde_vec);
1050 fde->all_throwers_are_sibcalls = crtl(&x_rtl)->all_throwers_are_sibcalls;
1051 fde->uses_eh_lsda = crtl(&x_rtl)->uses_eh_lsda;
1052 fde->nothrow = crtl(&x_rtl)->nothrow;
1053 fde->drap_reg = INVALID_REGNUM(~(unsigned int) 0);
1054 fde->vdrap_reg = INVALID_REGNUM(~(unsigned int) 0);
1055
1056 /* Record the FDE associated with this function. */
1057 cfun(cfun + 0)->fde = fde;
1058 vec_safe_push (fde_vec, fde);
1059
1060 return fde;
1061}
1062
1063/* Output a marker (i.e. a label) for the beginning of a function, before
1064 the prologue. */
1065
1066void
1067dwarf2out_begin_prologue (unsigned int line ATTRIBUTE_UNUSED__attribute__ ((__unused__)),
1068 unsigned int column ATTRIBUTE_UNUSED__attribute__ ((__unused__)),
1069 const char *file ATTRIBUTE_UNUSED__attribute__ ((__unused__)))
1070{
1071 char label[MAX_ARTIFICIAL_LABEL_BYTES40];
1072 char * dup_label;
1073 dw_fde_ref fde;
1074 section *fnsec;
1075 bool do_frame;
1076
1077 current_function_func_begin_label = NULLnullptr;
1078
1079 do_frame = dwarf2out_do_frame ();
1080
1081 /* ??? current_function_func_begin_label is also used by except.cc for
1082 call-site information. We must emit this label if it might be used. */
1083 if (!do_frame
1084 && (!flag_exceptionsglobal_options.x_flag_exceptions
1085 || targetm_common.except_unwind_info (&global_options) == UI_SJLJ))
1086 return;
1087
1088 fnsec = function_section (current_function_decl);
1089 switch_to_section (fnsec);
1090 ASM_GENERATE_INTERNAL_LABEL (label, FUNC_BEGIN_LABEL,do { char *__p; (label)[0] = '*'; (label)[1] = '.'; __p = stpcpy
(&(label)[2], "LFB"); sprint_ul (__p, (unsigned long) ((
(cfun + 0)->funcdef_no))); } while (0)
1091 current_function_funcdef_no)do { char *__p; (label)[0] = '*'; (label)[1] = '.'; __p = stpcpy
(&(label)[2], "LFB"); sprint_ul (__p, (unsigned long) ((
(cfun + 0)->funcdef_no))); } while (0)
;
1092 ASM_OUTPUT_DEBUG_LABEL (asm_out_file, FUNC_BEGIN_LABEL,(*targetm.asm_out.internal_label) (asm_out_file, "LFB", ((cfun
+ 0)->funcdef_no))
1093 current_function_funcdef_no)(*targetm.asm_out.internal_label) (asm_out_file, "LFB", ((cfun
+ 0)->funcdef_no))
;
1094 dup_label = xstrdup (label);
1095 current_function_func_begin_label = dup_label;
1096
1097 /* We can elide FDE allocation if we're not emitting frame unwind info. */
1098 if (!do_frame)
1099 return;
1100
1101 /* Unlike the debug version, the EH version of frame unwind info is a per-
1102 function setting so we need to record whether we need it for the unit. */
1103 do_eh_frame |= dwarf2out_do_eh_frame ();
1104
1105 /* Cater to the various TARGET_ASM_OUTPUT_MI_THUNK implementations that
1106 emit insns as rtx but bypass the bulk of rest_of_compilation, which
1107 would include pass_dwarf2_frame. If we've not created the FDE yet,
1108 do so now. */
1109 fde = cfun(cfun + 0)->fde;
1110 if (fde == NULLnullptr)
1111 fde = dwarf2out_alloc_current_fde ();
1112
1113 /* Initialize the bits of CURRENT_FDE that were not available earlier. */
1114 fde->dw_fde_begin = dup_label;
1115 fde->dw_fde_current_label = dup_label;
1116 fde->in_std_section = (fnsec == text_section
1117 || (cold_text_section && fnsec == cold_text_section));
1118 fde->ignored_debug = DECL_IGNORED_P (current_function_decl)((contains_struct_check ((current_function_decl), (TS_DECL_COMMON
), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 1118, __FUNCTION__))->decl_common.ignored_flag)
;
1119 in_text_section_p = fnsec == text_section;
1120
1121 /* We only want to output line number information for the genuine dwarf2
1122 prologue case, not the eh frame case. */
1123#ifdef DWARF2_DEBUGGING_INFO1
1124 if (file)
1125 dwarf2out_source_line (line, column, file, 0, true);
1126#endif
1127
1128 if (dwarf2out_do_cfi_asm ())
1129 dwarf2out_do_cfi_startproc (false);
1130 else
1131 {
1132 rtx personality = get_personality_function (current_function_decl);
1133 if (!current_unit_personality)
1134 current_unit_personality = personality;
1135
1136 /* We cannot keep a current personality per function as without CFI
1137 asm, at the point where we emit the CFI data, there is no current
1138 function anymore. */
1139 if (personality && current_unit_personality != personality)
1140 sorry ("multiple EH personalities are supported only with assemblers "
1141 "supporting %<.cfi_personality%> directive");
1142 }
1143}
1144
1145/* Output a marker (i.e. a label) for the end of the generated code
1146 for a function prologue. This gets called *after* the prologue code has
1147 been generated. */
1148
1149void
1150dwarf2out_vms_end_prologue (unsigned int line ATTRIBUTE_UNUSED__attribute__ ((__unused__)),
1151 const char *file ATTRIBUTE_UNUSED__attribute__ ((__unused__)))
1152{
1153 char label[MAX_ARTIFICIAL_LABEL_BYTES40];
1154
1155 /* Output a label to mark the endpoint of the code generated for this
1156 function. */
1157 ASM_GENERATE_INTERNAL_LABEL (label, PROLOGUE_END_LABEL,do { char *__p; (label)[0] = '*'; (label)[1] = '.'; __p = stpcpy
(&(label)[2], "LPE"); sprint_ul (__p, (unsigned long) ((
(cfun + 0)->funcdef_no))); } while (0)
1158 current_function_funcdef_no)do { char *__p; (label)[0] = '*'; (label)[1] = '.'; __p = stpcpy
(&(label)[2], "LPE"); sprint_ul (__p, (unsigned long) ((
(cfun + 0)->funcdef_no))); } while (0)
;
1159 ASM_OUTPUT_DEBUG_LABEL (asm_out_file, PROLOGUE_END_LABEL,(*targetm.asm_out.internal_label) (asm_out_file, "LPE", ((cfun
+ 0)->funcdef_no))
1160 current_function_funcdef_no)(*targetm.asm_out.internal_label) (asm_out_file, "LPE", ((cfun
+ 0)->funcdef_no))
;
1161 cfun(cfun + 0)->fde->dw_fde_vms_end_prologue = xstrdup (label);
1162}
1163
1164/* Output a marker (i.e. a label) for the beginning of the generated code
1165 for a function epilogue. This gets called *before* the prologue code has
1166 been generated. */
1167
1168void
1169dwarf2out_vms_begin_epilogue (unsigned int line ATTRIBUTE_UNUSED__attribute__ ((__unused__)),
1170 const char *file ATTRIBUTE_UNUSED__attribute__ ((__unused__)))
1171{
1172 dw_fde_ref fde = cfun(cfun + 0)->fde;
1173 char label[MAX_ARTIFICIAL_LABEL_BYTES40];
1174
1175 if (fde->dw_fde_vms_begin_epilogue)
1176 return;
1177
1178 /* Output a label to mark the endpoint of the code generated for this
1179 function. */
1180 ASM_GENERATE_INTERNAL_LABEL (label, EPILOGUE_BEGIN_LABEL,do { char *__p; (label)[0] = '*'; (label)[1] = '.'; __p = stpcpy
(&(label)[2], "LEB"); sprint_ul (__p, (unsigned long) ((
(cfun + 0)->funcdef_no))); } while (0)
1181 current_function_funcdef_no)do { char *__p; (label)[0] = '*'; (label)[1] = '.'; __p = stpcpy
(&(label)[2], "LEB"); sprint_ul (__p, (unsigned long) ((
(cfun + 0)->funcdef_no))); } while (0)
;
1182 ASM_OUTPUT_DEBUG_LABEL (asm_out_file, EPILOGUE_BEGIN_LABEL,(*targetm.asm_out.internal_label) (asm_out_file, "LEB", ((cfun
+ 0)->funcdef_no))
1183 current_function_funcdef_no)(*targetm.asm_out.internal_label) (asm_out_file, "LEB", ((cfun
+ 0)->funcdef_no))
;
1184 fde->dw_fde_vms_begin_epilogue = xstrdup (label);
1185}
1186
1187/* Mark the ranges of non-debug subsections in the std text sections. */
1188
1189static void
1190mark_ignored_debug_section (dw_fde_ref fde, bool second)
1191{
1192 bool std_section;
1193 const char *begin_label, *end_label;
1194 const char **last_end_label;
1195 vec<const char *, va_gc> **switch_ranges;
1196
1197 if (second)
1198 {
1199 std_section = fde->second_in_std_section;
1200 begin_label = fde->dw_fde_second_begin;
1201 end_label = fde->dw_fde_second_end;
1202 }
1203 else
1204 {
1205 std_section = fde->in_std_section;
1206 begin_label = fde->dw_fde_begin;
1207 end_label = fde->dw_fde_end;
1208 }
1209
1210 if (!std_section)
1211 return;
1212
1213 if (in_text_section_p)
1214 {
1215 last_end_label = &last_text_label;
1216 switch_ranges = &switch_text_ranges;
1217 }
1218 else
1219 {
1220 last_end_label = &last_cold_label;
1221 switch_ranges = &switch_cold_ranges;
1222 }
1223
1224 if (fde->ignored_debug)
1225 {
1226 if (*switch_ranges && !(vec_safe_length (*switch_ranges) & 1))
1227 vec_safe_push (*switch_ranges, *last_end_label);
1228 }
1229 else
1230 {
1231 *last_end_label = end_label;
1232
1233 if (!*switch_ranges)
1234 vec_alloc (*switch_ranges, 16);
1235 else if (vec_safe_length (*switch_ranges) & 1)
1236 vec_safe_push (*switch_ranges, begin_label);
1237 }
1238}
1239
1240/* Output a marker (i.e. a label) for the absolute end of the generated code
1241 for a function definition. This gets called *after* the epilogue code has
1242 been generated. */
1243
1244void
1245dwarf2out_end_epilogue (unsigned int line ATTRIBUTE_UNUSED__attribute__ ((__unused__)),
1246 const char *file ATTRIBUTE_UNUSED__attribute__ ((__unused__)))
1247{
1248 dw_fde_ref fde;
1249 char label[MAX_ARTIFICIAL_LABEL_BYTES40];
1250
1251 last_var_location_insn = NULLnullptr;
1252 cached_next_real_insn = NULLnullptr;
1253
1254 if (dwarf2out_do_cfi_asm ())
1255 fprintf (asm_out_file, "\t.cfi_endproc\n");
1256
1257 /* Output a label to mark the endpoint of the code generated for this
1258 function. */
1259 ASM_GENERATE_INTERNAL_LABEL (label, FUNC_END_LABEL,do { char *__p; (label)[0] = '*'; (label)[1] = '.'; __p = stpcpy
(&(label)[2], "LFE"); sprint_ul (__p, (unsigned long) ((
(cfun + 0)->funcdef_no))); } while (0)
1260 current_function_funcdef_no)do { char *__p; (label)[0] = '*'; (label)[1] = '.'; __p = stpcpy
(&(label)[2], "LFE"); sprint_ul (__p, (unsigned long) ((
(cfun + 0)->funcdef_no))); } while (0)
;
1261 ASM_OUTPUT_LABEL (asm_out_file, label)do { assemble_name ((asm_out_file), (label)); fputs (":\n", (
asm_out_file)); } while (0)
;
1262 fde = cfun(cfun + 0)->fde;
1263 gcc_assert (fde != NULL)((void)(!(fde != nullptr) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 1263, __FUNCTION__), 0 : 0))
;
1264 if (fde->dw_fde_second_begin == NULLnullptr)
1265 fde->dw_fde_end = xstrdup (label);
1266
1267 mark_ignored_debug_section (fde, fde->dw_fde_second_begin != NULLnullptr);
1268}
1269
1270void
1271dwarf2out_frame_finish (void)
1272{
1273 /* Output call frame information. */
1274 if (targetm.debug_unwind_info () == UI_DWARF2)
1275 output_call_frame_info (0);
1276
1277 /* Output another copy for the unwinder. */
1278 if (do_eh_frame)
1279 output_call_frame_info (1);
1280}
1281
1282static void var_location_switch_text_section (void);
1283static void set_cur_line_info_table (section *);
1284
1285void
1286dwarf2out_switch_text_section (void)
1287{
1288 char label[MAX_ARTIFICIAL_LABEL_BYTES40];
1289 section *sect;
1290 dw_fde_ref fde = cfun(cfun + 0)->fde;
1291
1292 gcc_assert (cfun && fde && fde->dw_fde_second_begin == NULL)((void)(!((cfun + 0) && fde && fde->dw_fde_second_begin
== nullptr) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 1292, __FUNCTION__), 0 : 0))
;
1293
1294 ASM_GENERATE_INTERNAL_LABEL (label, FUNC_SECOND_SECT_LABEL,do { char *__p; (label)[0] = '*'; (label)[1] = '.'; __p = stpcpy
(&(label)[2], "LFSB"); sprint_ul (__p, (unsigned long) (
((cfun + 0)->funcdef_no))); } while (0)
1295 current_function_funcdef_no)do { char *__p; (label)[0] = '*'; (label)[1] = '.'; __p = stpcpy
(&(label)[2], "LFSB"); sprint_ul (__p, (unsigned long) (
((cfun + 0)->funcdef_no))); } while (0)
;
1296
1297 fde->dw_fde_second_begin = ggc_strdup (label)ggc_alloc_string ((label), -1 );
1298 if (!in_cold_section_p)
1299 {
1300 fde->dw_fde_end = crtl(&x_rtl)->subsections.cold_section_end_label;
1301 fde->dw_fde_second_end = crtl(&x_rtl)->subsections.hot_section_end_label;
1302 }
1303 else
1304 {
1305 fde->dw_fde_end = crtl(&x_rtl)->subsections.hot_section_end_label;
1306 fde->dw_fde_second_end = crtl(&x_rtl)->subsections.cold_section_end_label;
1307 }
1308 have_multiple_function_sections = true;
1309
1310 if (dwarf2out_do_cfi_asm ())
1311 fprintf (asm_out_file, "\t.cfi_endproc\n");
1312
1313 mark_ignored_debug_section (fde, false);
1314
1315 /* Now do the real section switch. */
1316 sect = current_function_section ();
1317 switch_to_section (sect);
1318
1319 fde->second_in_std_section
1320 = (sect == text_section
1321 || (cold_text_section && sect == cold_text_section));
1322 in_text_section_p = sect == text_section;
1323
1324 if (dwarf2out_do_cfi_asm ())
1325 dwarf2out_do_cfi_startproc (true);
1326
1327 var_location_switch_text_section ();
1328
1329 if (cold_text_section != NULLnullptr)
1330 set_cur_line_info_table (sect);
1331}
1332
1333/* And now, the subset of the debugging information support code necessary
1334 for emitting location expressions. */
1335
1336/* Describe an entry into the .debug_addr section. */
1337
1338enum ate_kind {
1339 ate_kind_rtx,
1340 ate_kind_rtx_dtprel,
1341 ate_kind_label
1342};
1343
1344struct GTY((for_user)) addr_table_entry {
1345 enum ate_kind kind;
1346 unsigned int refcount;
1347 unsigned int index;
1348 union addr_table_entry_struct_union
1349 {
1350 rtx GTY ((tag ("0"))) rtl;
1351 char * GTY ((tag ("1"))) label;
1352 }
1353 GTY ((desc ("%1.kind"))) addr;
1354};
1355
1356typedef unsigned int var_loc_view;
1357
1358/* Location lists are ranges + location descriptions for that range,
1359 so you can track variables that are in different places over
1360 their entire life. */
1361typedef struct GTY(()) dw_loc_list_struct {
1362 dw_loc_list_ref dw_loc_next;
1363 const char *begin; /* Label and addr_entry for start of range */
1364 addr_table_entry *begin_entry;
1365 const char *end; /* Label for end of range */
1366 addr_table_entry *end_entry;
1367 char *ll_symbol; /* Label for beginning of location list.
1368 Only on head of list. */
1369 char *vl_symbol; /* Label for beginning of view list. Ditto. */
1370 const char *section; /* Section this loclist is relative to */
1371 dw_loc_descr_ref expr;
1372 var_loc_view vbegin, vend;
1373 hashval_t hash;
1374 /* True if all addresses in this and subsequent lists are known to be
1375 resolved. */
1376 bool resolved_addr;
1377 /* True if this list has been replaced by dw_loc_next. */
1378 bool replaced;
1379 /* True if it has been emitted into .debug_loc* / .debug_loclists*
1380 section. */
1381 unsigned char emitted : 1;
1382 /* True if hash field is index rather than hash value. */
1383 unsigned char num_assigned : 1;
1384 /* True if .debug_loclists.dwo offset has been emitted for it already. */
1385 unsigned char offset_emitted : 1;
1386 /* True if note_variable_value_in_expr has been called on it. */
1387 unsigned char noted_variable_value : 1;
1388 /* True if the range should be emitted even if begin and end
1389 are the same. */
1390 bool force;
1391} dw_loc_list_node;
1392
1393static dw_loc_descr_ref int_loc_descriptor (poly_int64);
1394static dw_loc_descr_ref uint_loc_descriptor (unsigned HOST_WIDE_INTlong);
1395
1396/* Convert a DWARF stack opcode into its string name. */
1397
1398static const char *
1399dwarf_stack_op_name (unsigned int op)
1400{
1401 const char *name = get_DW_OP_name (op);
1402
1403 if (name != NULLnullptr)
1404 return name;
1405
1406 return "OP_<unknown>";
1407}
1408
1409/* Return TRUE iff we're to output location view lists as a separate
1410 attribute next to the location lists, as an extension compatible
1411 with DWARF 2 and above. */
1412
1413static inline bool
1414dwarf2out_locviews_in_attribute ()
1415{
1416 return debug_variable_location_viewsglobal_options.x_debug_variable_location_views == 1;
1417}
1418
1419/* Return TRUE iff we're to output location view lists as part of the
1420 location lists, as proposed for standardization after DWARF 5. */
1421
1422static inline bool
1423dwarf2out_locviews_in_loclist ()
1424{
1425#ifndef DW_LLE_view_pairDW_LLE_GNU_view_pair
1426 return false;
1427#else
1428 return debug_variable_location_viewsglobal_options.x_debug_variable_location_views == -1;
1429#endif
1430}
1431
1432/* Return a pointer to a newly allocated location description. Location
1433 descriptions are simple expression terms that can be strung
1434 together to form more complicated location (address) descriptions. */
1435
1436static inline dw_loc_descr_ref
1437new_loc_descr (enum dwarf_location_atom op, unsigned HOST_WIDE_INTlong oprnd1,
1438 unsigned HOST_WIDE_INTlong oprnd2)
1439{
1440 dw_loc_descr_ref descr = ggc_cleared_alloc<dw_loc_descr_node> ();
1441
1442 descr->dw_loc_opc = op;
1443 descr->dw_loc_oprnd1.val_class = dw_val_class_unsigned_const;
1444 descr->dw_loc_oprnd1.val_entry = NULLnullptr;
1445 descr->dw_loc_oprnd1.v.val_unsigned = oprnd1;
1446 descr->dw_loc_oprnd2.val_class = dw_val_class_unsigned_const;
1447 descr->dw_loc_oprnd2.val_entry = NULLnullptr;
1448 descr->dw_loc_oprnd2.v.val_unsigned = oprnd2;
1449
1450 return descr;
1451}
1452
1453/* Add a location description term to a location description expression. */
1454
1455static inline void
1456add_loc_descr (dw_loc_descr_ref *list_head, dw_loc_descr_ref descr)
1457{
1458 dw_loc_descr_ref *d;
1459
1460 /* Find the end of the chain. */
1461 for (d = list_head; (*d) != NULLnullptr; d = &(*d)->dw_loc_next)
1462 ;
1463
1464 *d = descr;
1465}
1466
1467/* Compare two location operands for exact equality. */
1468
1469static bool
1470dw_val_equal_p (dw_val_node *a, dw_val_node *b)
1471{
1472 if (a->val_class != b->val_class)
1473 return false;
1474 switch (a->val_class)
1475 {
1476 case dw_val_class_none:
1477 return true;
1478 case dw_val_class_addr:
1479 return rtx_equal_p (a->v.val_addr, b->v.val_addr);
1480
1481 case dw_val_class_offset:
1482 case dw_val_class_unsigned_const:
1483 case dw_val_class_const:
1484 case dw_val_class_unsigned_const_implicit:
1485 case dw_val_class_const_implicit:
1486 case dw_val_class_range_list:
1487 /* These are all HOST_WIDE_INT, signed or unsigned. */
1488 return a->v.val_unsigned == b->v.val_unsigned;
1489
1490 case dw_val_class_loc:
1491 return a->v.val_loc == b->v.val_loc;
1492 case dw_val_class_loc_list:
1493 return a->v.val_loc_list == b->v.val_loc_list;
1494 case dw_val_class_view_list:
1495 return a->v.val_view_list == b->v.val_view_list;
1496 case dw_val_class_die_ref:
1497 return a->v.val_die_ref.die == b->v.val_die_ref.die;
1498 case dw_val_class_fde_ref:
1499 return a->v.val_fde_index == b->v.val_fde_index;
1500 case dw_val_class_symview:
1501 return strcmp (a->v.val_symbolic_view, b->v.val_symbolic_view) == 0;
1502 case dw_val_class_lbl_id:
1503 case dw_val_class_lineptr:
1504 case dw_val_class_macptr:
1505 case dw_val_class_loclistsptr:
1506 case dw_val_class_high_pc:
1507 return strcmp (a->v.val_lbl_id, b->v.val_lbl_id) == 0;
1508 case dw_val_class_str:
1509 return a->v.val_str == b->v.val_str;
1510 case dw_val_class_flag:
1511 return a->v.val_flag == b->v.val_flag;
1512 case dw_val_class_file:
1513 case dw_val_class_file_implicit:
1514 return a->v.val_file == b->v.val_file;
1515 case dw_val_class_decl_ref:
1516 return a->v.val_decl_ref == b->v.val_decl_ref;
1517
1518 case dw_val_class_const_double:
1519 return (a->v.val_double.high == b->v.val_double.high
1520 && a->v.val_double.low == b->v.val_double.low);
1521
1522 case dw_val_class_wide_int:
1523 return *a->v.val_wide == *b->v.val_wide;
1524
1525 case dw_val_class_vec:
1526 {
1527 size_t a_len = a->v.val_vec.elt_size * a->v.val_vec.length;
1528 size_t b_len = b->v.val_vec.elt_size * b->v.val_vec.length;
1529
1530 return (a_len == b_len
1531 && !memcmp (a->v.val_vec.array, b->v.val_vec.array, a_len));
1532 }
1533
1534 case dw_val_class_data8:
1535 return memcmp (a->v.val_data8, b->v.val_data8, 8) == 0;
1536
1537 case dw_val_class_vms_delta:
1538 return (!strcmp (a->v.val_vms_delta.lbl1, b->v.val_vms_delta.lbl1)
1539 && !strcmp (a->v.val_vms_delta.lbl2, b->v.val_vms_delta.lbl2));
1540
1541 case dw_val_class_discr_value:
1542 return (a->v.val_discr_value.pos == b->v.val_discr_value.pos
1543 && a->v.val_discr_value.v.uval == b->v.val_discr_value.v.uval);
1544 case dw_val_class_discr_list:
1545 /* It makes no sense comparing two discriminant value lists. */
1546 return false;
1547 }
1548 gcc_unreachable ()(fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 1548, __FUNCTION__))
;
1549}
1550
1551/* Compare two location atoms for exact equality. */
1552
1553static bool
1554loc_descr_equal_p_1 (dw_loc_descr_ref a, dw_loc_descr_ref b)
1555{
1556 if (a->dw_loc_opc != b->dw_loc_opc)
1557 return false;
1558
1559 /* ??? This is only ever set for DW_OP_constNu, for N equal to the
1560 address size, but since we always allocate cleared storage it
1561 should be zero for other types of locations. */
1562 if (a->dtprel != b->dtprel)
1563 return false;
1564
1565 return (dw_val_equal_p (&a->dw_loc_oprnd1, &b->dw_loc_oprnd1)
1566 && dw_val_equal_p (&a->dw_loc_oprnd2, &b->dw_loc_oprnd2));
1567}
1568
1569/* Compare two complete location expressions for exact equality. */
1570
1571bool
1572loc_descr_equal_p (dw_loc_descr_ref a, dw_loc_descr_ref b)
1573{
1574 while (1)
1575 {
1576 if (a == b)
1577 return true;
1578 if (a == NULLnullptr || b == NULLnullptr)
1579 return false;
1580 if (!loc_descr_equal_p_1 (a, b))
1581 return false;
1582
1583 a = a->dw_loc_next;
1584 b = b->dw_loc_next;
1585 }
1586}
1587
1588
1589/* Add a constant POLY_OFFSET to a location expression. */
1590
1591static void
1592loc_descr_plus_const (dw_loc_descr_ref *list_head, poly_int64 poly_offset)
1593{
1594 dw_loc_descr_ref loc;
1595 HOST_WIDE_INTlong *p;
1596
1597 gcc_assert (*list_head != NULL)((void)(!(*list_head != nullptr) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 1597, __FUNCTION__), 0 : 0))
;
1598
1599 if (known_eq (poly_offset, 0)(!maybe_ne (poly_offset, 0)))
1600 return;
1601
1602 /* Find the end of the chain. */
1603 for (loc = *list_head; loc->dw_loc_next != NULLnullptr; loc = loc->dw_loc_next)
1604 ;
1605
1606 HOST_WIDE_INTlong offset;
1607 if (!poly_offset.is_constant (&offset))
1608 {
1609 loc->dw_loc_next = int_loc_descriptor (poly_offset);
1610 add_loc_descr (&loc->dw_loc_next, new_loc_descr (DW_OP_plus, 0, 0));
1611 return;
1612 }
1613
1614 p = NULLnullptr;
1615 if (loc->dw_loc_opc == DW_OP_fbreg
1616 || (loc->dw_loc_opc >= DW_OP_breg0 && loc->dw_loc_opc <= DW_OP_breg31))
1617 p = &loc->dw_loc_oprnd1.v.val_int;
1618 else if (loc->dw_loc_opc == DW_OP_bregx)
1619 p = &loc->dw_loc_oprnd2.v.val_int;
1620
1621 /* If the last operation is fbreg, breg{0..31,x}, optimize by adjusting its
1622 offset. Don't optimize if an signed integer overflow would happen. */
1623 if (p != NULLnullptr
1624 && ((offset > 0 && *p <= INTTYPE_MAXIMUM (HOST_WIDE_INT)((long) (~ (long) 0 - ((long) ((! ((long) 0 < (long) -1)) ?
(long) 1 << (sizeof (long) * 8 - 1) : (long) 0))))
- offset)
1625 || (offset < 0 && *p >= INTTYPE_MINIMUM (HOST_WIDE_INT)((long) ((! ((long) 0 < (long) -1)) ? (long) 1 << (sizeof
(long) * 8 - 1) : (long) 0))
- offset)))
1626 *p += offset;
1627
1628 else if (offset > 0)
1629 loc->dw_loc_next = new_loc_descr (DW_OP_plus_uconst, offset, 0);
1630
1631 else
1632 {
1633 loc->dw_loc_next
1634 = uint_loc_descriptor (-(unsigned HOST_WIDE_INTlong) offset);
1635 add_loc_descr (&loc->dw_loc_next, new_loc_descr (DW_OP_minus, 0, 0));
1636 }
1637}
1638
1639/* Return a pointer to a newly allocated location description for
1640 REG and OFFSET. */
1641
1642static inline dw_loc_descr_ref
1643new_reg_loc_descr (unsigned int reg, poly_int64 offset)
1644{
1645 HOST_WIDE_INTlong const_offset;
1646 if (offset.is_constant (&const_offset))
1647 {
1648 if (reg <= 31)
1649 return new_loc_descr ((enum dwarf_location_atom) (DW_OP_breg0 + reg),
1650 const_offset, 0);
1651 else
1652 return new_loc_descr (DW_OP_bregx, reg, const_offset);
1653 }
1654 else
1655 {
1656 dw_loc_descr_ref ret = new_reg_loc_descr (reg, 0);
1657 loc_descr_plus_const (&ret, offset);
1658 return ret;
1659 }
1660}
1661
1662/* Add a constant OFFSET to a location list. */
1663
1664static void
1665loc_list_plus_const (dw_loc_list_ref list_head, poly_int64 offset)
1666{
1667 dw_loc_list_ref d;
1668 for (d = list_head; d != NULLnullptr; d = d->dw_loc_next)
1669 loc_descr_plus_const (&d->expr, offset);
1670}
1671
1672#define DWARF_REF_SIZE(global_options.x_dwarf_version == 2 ? (((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) + (
8) - 1) / (8)) : global_options.x_dwarf_offset_size)
\
1673 (dwarf_versionglobal_options.x_dwarf_version == 2 ? DWARF2_ADDR_SIZE(((((global_options.x_ix86_isa_flags & (1UL << 58))
!= 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags &
(1UL << 1)) != 0) ? 8 : 4))) + (8) - 1) / (8))
: dwarf_offset_sizeglobal_options.x_dwarf_offset_size)
1674
1675/* The number of bits that can be encoded by largest DW_FORM_dataN.
1676 In DWARF4 and earlier it is DW_FORM_data8 with 64 bits, in DWARF5
1677 DW_FORM_data16 with 128 bits. */
1678#define DWARF_LARGEST_DATA_FORM_BITS(global_options.x_dwarf_version >= 5 ? 128 : 64) \
1679 (dwarf_versionglobal_options.x_dwarf_version >= 5 ? 128 : 64)
1680
1681/* Utility inline function for construction of ops that were GNU extension
1682 before DWARF 5. */
1683static inline enum dwarf_location_atom
1684dwarf_OP (enum dwarf_location_atom op)
1685{
1686 switch (op)
1687 {
1688 case DW_OP_implicit_pointer:
1689 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1690 return DW_OP_GNU_implicit_pointer;
1691 break;
1692
1693 case DW_OP_entry_value:
1694 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1695 return DW_OP_GNU_entry_value;
1696 break;
1697
1698 case DW_OP_const_type:
1699 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1700 return DW_OP_GNU_const_type;
1701 break;
1702
1703 case DW_OP_regval_type:
1704 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1705 return DW_OP_GNU_regval_type;
1706 break;
1707
1708 case DW_OP_deref_type:
1709 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1710 return DW_OP_GNU_deref_type;
1711 break;
1712
1713 case DW_OP_convert:
1714 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1715 return DW_OP_GNU_convert;
1716 break;
1717
1718 case DW_OP_reinterpret:
1719 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1720 return DW_OP_GNU_reinterpret;
1721 break;
1722
1723 case DW_OP_addrx:
1724 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1725 return DW_OP_GNU_addr_index;
1726 break;
1727
1728 case DW_OP_constx:
1729 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1730 return DW_OP_GNU_const_index;
1731 break;
1732
1733 default:
1734 break;
1735 }
1736 return op;
1737}
1738
1739/* Similarly for attributes. */
1740static inline enum dwarf_attribute
1741dwarf_AT (enum dwarf_attribute at)
1742{
1743 switch (at)
1744 {
1745 case DW_AT_call_return_pc:
1746 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1747 return DW_AT_low_pc;
1748 break;
1749
1750 case DW_AT_call_tail_call:
1751 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1752 return DW_AT_GNU_tail_call;
1753 break;
1754
1755 case DW_AT_call_origin:
1756 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1757 return DW_AT_abstract_origin;
1758 break;
1759
1760 case DW_AT_call_target:
1761 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1762 return DW_AT_GNU_call_site_target;
1763 break;
1764
1765 case DW_AT_call_target_clobbered:
1766 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1767 return DW_AT_GNU_call_site_target_clobbered;
1768 break;
1769
1770 case DW_AT_call_parameter:
1771 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1772 return DW_AT_abstract_origin;
1773 break;
1774
1775 case DW_AT_call_value:
1776 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1777 return DW_AT_GNU_call_site_value;
1778 break;
1779
1780 case DW_AT_call_data_value:
1781 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1782 return DW_AT_GNU_call_site_data_value;
1783 break;
1784
1785 case DW_AT_call_all_calls:
1786 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1787 return DW_AT_GNU_all_call_sites;
1788 break;
1789
1790 case DW_AT_call_all_tail_calls:
1791 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1792 return DW_AT_GNU_all_tail_call_sites;
1793 break;
1794
1795 case DW_AT_dwo_name:
1796 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1797 return DW_AT_GNU_dwo_name;
1798 break;
1799
1800 case DW_AT_addr_base:
1801 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1802 return DW_AT_GNU_addr_base;
1803 break;
1804
1805 default:
1806 break;
1807 }
1808 return at;
1809}
1810
1811/* And similarly for tags. */
1812static inline enum dwarf_tag
1813dwarf_TAG (enum dwarf_tag tag)
1814{
1815 switch (tag)
1816 {
1817 case DW_TAG_call_site:
1818 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1819 return DW_TAG_GNU_call_site;
1820 break;
1821
1822 case DW_TAG_call_site_parameter:
1823 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1824 return DW_TAG_GNU_call_site_parameter;
1825 break;
1826
1827 default:
1828 break;
1829 }
1830 return tag;
1831}
1832
1833/* And similarly for forms. */
1834static inline enum dwarf_form
1835dwarf_FORM (enum dwarf_form form)
1836{
1837 switch (form)
1838 {
1839 case DW_FORM_addrx:
1840 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1841 return DW_FORM_GNU_addr_index;
1842 break;
1843
1844 case DW_FORM_strx:
1845 if (dwarf_versionglobal_options.x_dwarf_version < 5)
1846 return DW_FORM_GNU_str_index;
1847 break;
1848
1849 default:
1850 break;
1851 }
1852 return form;
1853}
1854
1855static unsigned long int get_base_type_offset (dw_die_ref);
1856
1857/* Return the size of a location descriptor. */
1858
1859static unsigned long
1860size_of_loc_descr (dw_loc_descr_ref loc)
1861{
1862 unsigned long size = 1;
1863
1864 switch (loc->dw_loc_opc)
1865 {
1866 case DW_OP_addr:
1867 size += DWARF2_ADDR_SIZE(((((global_options.x_ix86_isa_flags & (1UL << 58))
!= 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags &
(1UL << 1)) != 0) ? 8 : 4))) + (8) - 1) / (8))
;
1868 break;
1869 case DW_OP_GNU_addr_index:
1870 case DW_OP_addrx:
1871 case DW_OP_GNU_const_index:
1872 case DW_OP_constx:
1873 gcc_assert (loc->dw_loc_oprnd1.val_entry->index != NO_INDEX_ASSIGNED)((void)(!(loc->dw_loc_oprnd1.val_entry->index != (-2U))
? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 1873, __FUNCTION__), 0 : 0))
;
1874 size += size_of_uleb128 (loc->dw_loc_oprnd1.val_entry->index);
1875 break;
1876 case DW_OP_const1u:
1877 case DW_OP_const1s:
1878 size += 1;
1879 break;
1880 case DW_OP_const2u:
1881 case DW_OP_const2s:
1882 size += 2;
1883 break;
1884 case DW_OP_const4u:
1885 case DW_OP_const4s:
1886 size += 4;
1887 break;
1888 case DW_OP_const8u:
1889 case DW_OP_const8s:
1890 size += 8;
1891 break;
1892 case DW_OP_constu:
1893 size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
1894 break;
1895 case DW_OP_consts:
1896 size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
1897 break;
1898 case DW_OP_pick:
1899 size += 1;
1900 break;
1901 case DW_OP_plus_uconst:
1902 size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
1903 break;
1904 case DW_OP_skip:
1905 case DW_OP_bra:
1906 size += 2;
1907 break;
1908 case DW_OP_breg0:
1909 case DW_OP_breg1:
1910 case DW_OP_breg2:
1911 case DW_OP_breg3:
1912 case DW_OP_breg4:
1913 case DW_OP_breg5:
1914 case DW_OP_breg6:
1915 case DW_OP_breg7:
1916 case DW_OP_breg8:
1917 case DW_OP_breg9:
1918 case DW_OP_breg10:
1919 case DW_OP_breg11:
1920 case DW_OP_breg12:
1921 case DW_OP_breg13:
1922 case DW_OP_breg14:
1923 case DW_OP_breg15:
1924 case DW_OP_breg16:
1925 case DW_OP_breg17:
1926 case DW_OP_breg18:
1927 case DW_OP_breg19:
1928 case DW_OP_breg20:
1929 case DW_OP_breg21:
1930 case DW_OP_breg22:
1931 case DW_OP_breg23:
1932 case DW_OP_breg24:
1933 case DW_OP_breg25:
1934 case DW_OP_breg26:
1935 case DW_OP_breg27:
1936 case DW_OP_breg28:
1937 case DW_OP_breg29:
1938 case DW_OP_breg30:
1939 case DW_OP_breg31:
1940 size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
1941 break;
1942 case DW_OP_regx:
1943 size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
1944 break;
1945 case DW_OP_fbreg:
1946 size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int);
1947 break;
1948 case DW_OP_bregx:
1949 size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
1950 size += size_of_sleb128 (loc->dw_loc_oprnd2.v.val_int);
1951 break;
1952 case DW_OP_piece:
1953 size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
1954 break;
1955 case DW_OP_bit_piece:
1956 size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
1957 size += size_of_uleb128 (loc->dw_loc_oprnd2.v.val_unsigned);
1958 break;
1959 case DW_OP_deref_size:
1960 case DW_OP_xderef_size:
1961 size += 1;
1962 break;
1963 case DW_OP_call2:
1964 size += 2;
1965 break;
1966 case DW_OP_call4:
1967 size += 4;
1968 break;
1969 case DW_OP_call_ref:
1970 case DW_OP_GNU_variable_value:
1971 size += DWARF_REF_SIZE(global_options.x_dwarf_version == 2 ? (((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) + (
8) - 1) / (8)) : global_options.x_dwarf_offset_size)
;
1972 break;
1973 case DW_OP_implicit_value:
1974 size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned)
1975 + loc->dw_loc_oprnd1.v.val_unsigned;
1976 break;
1977 case DW_OP_implicit_pointer:
1978 case DW_OP_GNU_implicit_pointer:
1979 size += DWARF_REF_SIZE(global_options.x_dwarf_version == 2 ? (((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) + (
8) - 1) / (8)) : global_options.x_dwarf_offset_size)
+ size_of_sleb128 (loc->dw_loc_oprnd2.v.val_int);
1980 break;
1981 case DW_OP_entry_value:
1982 case DW_OP_GNU_entry_value:
1983 {
1984 unsigned long op_size = size_of_locs (loc->dw_loc_oprnd1.v.val_loc);
1985 size += size_of_uleb128 (op_size) + op_size;
1986 break;
1987 }
1988 case DW_OP_const_type:
1989 case DW_OP_GNU_const_type:
1990 {
1991 unsigned long o
1992 = get_base_type_offset (loc->dw_loc_oprnd1.v.val_die_ref.die);
1993 size += size_of_uleb128 (o) + 1;
1994 switch (loc->dw_loc_oprnd2.val_class)
1995 {
1996 case dw_val_class_vec:
1997 size += loc->dw_loc_oprnd2.v.val_vec.length
1998 * loc->dw_loc_oprnd2.v.val_vec.elt_size;
1999 break;
2000 case dw_val_class_const:
2001 size += HOST_BITS_PER_WIDE_INT64 / BITS_PER_UNIT(8);
2002 break;
2003 case dw_val_class_const_double:
2004 size += HOST_BITS_PER_DOUBLE_INT(2 * 64) / BITS_PER_UNIT(8);
2005 break;
2006 case dw_val_class_wide_int:
2007 size += (get_full_len (*loc->dw_loc_oprnd2.v.val_wide)
2008 * HOST_BITS_PER_WIDE_INT64 / BITS_PER_UNIT(8));
2009 break;
2010 default:
2011 gcc_unreachable ()(fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2011, __FUNCTION__))
;
2012 }
2013 break;
2014 }
2015 case DW_OP_regval_type:
2016 case DW_OP_GNU_regval_type:
2017 {
2018 unsigned long o
2019 = get_base_type_offset (loc->dw_loc_oprnd2.v.val_die_ref.die);
2020 size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned)
2021 + size_of_uleb128 (o);
2022 }
2023 break;
2024 case DW_OP_deref_type:
2025 case DW_OP_GNU_deref_type:
2026 {
2027 unsigned long o
2028 = get_base_type_offset (loc->dw_loc_oprnd2.v.val_die_ref.die);
2029 size += 1 + size_of_uleb128 (o);
2030 }
2031 break;
2032 case DW_OP_convert:
2033 case DW_OP_reinterpret:
2034 case DW_OP_GNU_convert:
2035 case DW_OP_GNU_reinterpret:
2036 if (loc->dw_loc_oprnd1.val_class == dw_val_class_unsigned_const)
2037 size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned);
2038 else
2039 {
2040 unsigned long o
2041 = get_base_type_offset (loc->dw_loc_oprnd1.v.val_die_ref.die);
2042 size += size_of_uleb128 (o);
2043 }
2044 break;
2045 case DW_OP_GNU_parameter_ref:
2046 size += 4;
2047 break;
2048 default:
2049 break;
2050 }
2051
2052 return size;
2053}
2054
2055/* Return the size of a series of location descriptors. */
2056
2057unsigned long
2058size_of_locs (dw_loc_descr_ref loc)
2059{
2060 dw_loc_descr_ref l;
2061 unsigned long size;
2062
2063 /* If there are no skip or bra opcodes, don't fill in the dw_loc_addr
2064 field, to avoid writing to a PCH file. */
2065 for (size = 0, l = loc; l != NULLnullptr; l = l->dw_loc_next)
2066 {
2067 if (l->dw_loc_opc == DW_OP_skip || l->dw_loc_opc == DW_OP_bra)
2068 break;
2069 size += size_of_loc_descr (l);
2070 }
2071 if (! l)
2072 return size;
2073
2074 for (size = 0, l = loc; l != NULLnullptr; l = l->dw_loc_next)
2075 {
2076 l->dw_loc_addr = size;
2077 size += size_of_loc_descr (l);
2078 }
2079
2080 return size;
2081}
2082
2083/* Return the size of the value in a DW_AT_discr_value attribute. */
2084
2085static int
2086size_of_discr_value (dw_discr_value *discr_value)
2087{
2088 if (discr_value->pos)
2089 return size_of_uleb128 (discr_value->v.uval);
2090 else
2091 return size_of_sleb128 (discr_value->v.sval);
2092}
2093
2094/* Return the size of the value in a DW_AT_discr_list attribute. */
2095
2096static int
2097size_of_discr_list (dw_discr_list_ref discr_list)
2098{
2099 int size = 0;
2100
2101 for (dw_discr_list_ref list = discr_list;
2102 list != NULLnullptr;
2103 list = list->dw_discr_next)
2104 {
2105 /* One byte for the discriminant value descriptor, and then one or two
2106 LEB128 numbers, depending on whether it's a single case label or a
2107 range label. */
2108 size += 1;
2109 size += size_of_discr_value (&list->dw_discr_lower_bound);
2110 if (list->dw_discr_range != 0)
2111 size += size_of_discr_value (&list->dw_discr_upper_bound);
2112 }
2113 return size;
2114}
2115
2116static HOST_WIDE_INTlong extract_int (const unsigned char *, unsigned);
2117static void get_ref_die_offset_label (char *, dw_die_ref);
2118static unsigned long int get_ref_die_offset (dw_die_ref);
2119
2120/* Output location description stack opcode's operands (if any).
2121 The for_eh_or_skip parameter controls whether register numbers are
2122 converted using DWARF2_FRAME_REG_OUT, which is needed in the case that
2123 hard reg numbers have been processed via DWARF_FRAME_REGNUM (i.e. for unwind
2124 info). This should be suppressed for the cases that have not been converted
2125 (i.e. symbolic debug info), by setting the parameter < 0. See PR47324. */
2126
2127static void
2128output_loc_operands (dw_loc_descr_ref loc, int for_eh_or_skip)
2129{
2130 dw_val_ref val1 = &loc->dw_loc_oprnd1;
2131 dw_val_ref val2 = &loc->dw_loc_oprnd2;
2132
2133 switch (loc->dw_loc_opc)
2134 {
2135#ifdef DWARF2_DEBUGGING_INFO1
2136 case DW_OP_const2u:
2137 case DW_OP_const2s:
2138 dw2_asm_output_data (2, val1->v.val_int, NULLnullptr);
2139 break;
2140 case DW_OP_const4u:
2141 if (loc->dtprel)
2142 {
2143 gcc_assert (targetm.asm_out.output_dwarf_dtprel)((void)(!(targetm.asm_out.output_dwarf_dtprel) ? fancy_abort (
"/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2143, __FUNCTION__), 0 : 0))
;
2144 targetm.asm_out.output_dwarf_dtprel (asm_out_file, 4,
2145 val1->v.val_addr);
2146 fputc ('\n', asm_out_file);
2147 break;
2148 }
2149 /* FALLTHRU */
2150 case DW_OP_const4s:
2151 dw2_asm_output_data (4, val1->v.val_int, NULLnullptr);
2152 break;
2153 case DW_OP_const8u:
2154 if (loc->dtprel)
2155 {
2156 gcc_assert (targetm.asm_out.output_dwarf_dtprel)((void)(!(targetm.asm_out.output_dwarf_dtprel) ? fancy_abort (
"/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2156, __FUNCTION__), 0 : 0))
;
2157 targetm.asm_out.output_dwarf_dtprel (asm_out_file, 8,
2158 val1->v.val_addr);
2159 fputc ('\n', asm_out_file);
2160 break;
2161 }
2162 /* FALLTHRU */
2163 case DW_OP_const8s:
2164 gcc_assert (HOST_BITS_PER_WIDE_INT >= 64)((void)(!(64 >= 64) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2164, __FUNCTION__), 0 : 0))
;
2165 dw2_asm_output_data (8, val1->v.val_int, NULLnullptr);
2166 break;
2167 case DW_OP_skip:
2168 case DW_OP_bra:
2169 {
2170 int offset;
2171
2172 gcc_assert (val1->val_class == dw_val_class_loc)((void)(!(val1->val_class == dw_val_class_loc) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2172, __FUNCTION__), 0 : 0))
;
2173 offset = val1->v.val_loc->dw_loc_addr - (loc->dw_loc_addr + 3);
2174
2175 dw2_asm_output_data (2, offset, NULLnullptr);
2176 }
2177 break;
2178 case DW_OP_implicit_value:
2179 dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULLnullptr);
2180 switch (val2->val_class)
2181 {
2182 case dw_val_class_const:
2183 dw2_asm_output_data (val1->v.val_unsigned, val2->v.val_int, NULLnullptr);
2184 break;
2185 case dw_val_class_vec:
2186 {
2187 unsigned int elt_size = val2->v.val_vec.elt_size;
2188 unsigned int len = val2->v.val_vec.length;
2189 unsigned int i;
2190 unsigned char *p;
2191
2192 if (elt_size > sizeof (HOST_WIDE_INTlong))
2193 {
2194 elt_size /= 2;
2195 len *= 2;
2196 }
2197 for (i = 0, p = (unsigned char *) val2->v.val_vec.array;
2198 i < len;
2199 i++, p += elt_size)
2200 dw2_asm_output_data (elt_size, extract_int (p, elt_size),
2201 "fp or vector constant word %u", i);
2202 }
2203 break;
2204 case dw_val_class_const_double:
2205 {
2206 unsigned HOST_WIDE_INTlong first, second;
2207
2208 if (WORDS_BIG_ENDIAN0)
2209 {
2210 first = val2->v.val_double.high;
2211 second = val2->v.val_double.low;
2212 }
2213 else
2214 {
2215 first = val2->v.val_double.low;
2216 second = val2->v.val_double.high;
2217 }
2218 dw2_asm_output_data (HOST_BITS_PER_WIDE_INT64 / HOST_BITS_PER_CHAR8,
2219 first, NULLnullptr);
2220 dw2_asm_output_data (HOST_BITS_PER_WIDE_INT64 / HOST_BITS_PER_CHAR8,
2221 second, NULLnullptr);
2222 }
2223 break;
2224 case dw_val_class_wide_int:
2225 {
2226 int i;
2227 int len = get_full_len (*val2->v.val_wide);
2228 if (WORDS_BIG_ENDIAN0)
2229 for (i = len - 1; i >= 0; --i)
2230 dw2_asm_output_data (HOST_BITS_PER_WIDE_INT64 / HOST_BITS_PER_CHAR8,
2231 val2->v.val_wide->elt (i), NULLnullptr);
2232 else
2233 for (i = 0; i < len; ++i)
2234 dw2_asm_output_data (HOST_BITS_PER_WIDE_INT64 / HOST_BITS_PER_CHAR8,
2235 val2->v.val_wide->elt (i), NULLnullptr);
2236 }
2237 break;
2238 case dw_val_class_addr:
2239 gcc_assert (val1->v.val_unsigned == DWARF2_ADDR_SIZE)((void)(!(val1->v.val_unsigned == (((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) + (
8) - 1) / (8))) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2239, __FUNCTION__), 0 : 0))
;
2240 dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE(((((global_options.x_ix86_isa_flags & (1UL << 58))
!= 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags &
(1UL << 1)) != 0) ? 8 : 4))) + (8) - 1) / (8))
, val2->v.val_addr, NULLnullptr);
2241 break;
2242 default:
2243 gcc_unreachable ()(fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2243, __FUNCTION__))
;
2244 }
2245 break;
2246#else
2247 case DW_OP_const2u:
2248 case DW_OP_const2s:
2249 case DW_OP_const4u:
2250 case DW_OP_const4s:
2251 case DW_OP_const8u:
2252 case DW_OP_const8s:
2253 case DW_OP_skip:
2254 case DW_OP_bra:
2255 case DW_OP_implicit_value:
2256 /* We currently don't make any attempt to make sure these are
2257 aligned properly like we do for the main unwind info, so
2258 don't support emitting things larger than a byte if we're
2259 only doing unwinding. */
2260 gcc_unreachable ()(fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2260, __FUNCTION__))
;
2261#endif
2262 case DW_OP_const1u:
2263 case DW_OP_const1s:
2264 dw2_asm_output_data (1, val1->v.val_int, NULLnullptr);
2265 break;
2266 case DW_OP_constu:
2267 dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULLnullptr);
2268 break;
2269 case DW_OP_consts:
2270 dw2_asm_output_data_sleb128 (val1->v.val_int, NULLnullptr);
2271 break;
2272 case DW_OP_pick:
2273 dw2_asm_output_data (1, val1->v.val_int, NULLnullptr);
2274 break;
2275 case DW_OP_plus_uconst:
2276 dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULLnullptr);
2277 break;
2278 case DW_OP_breg0:
2279 case DW_OP_breg1:
2280 case DW_OP_breg2:
2281 case DW_OP_breg3:
2282 case DW_OP_breg4:
2283 case DW_OP_breg5:
2284 case DW_OP_breg6:
2285 case DW_OP_breg7:
2286 case DW_OP_breg8:
2287 case DW_OP_breg9:
2288 case DW_OP_breg10:
2289 case DW_OP_breg11:
2290 case DW_OP_breg12:
2291 case DW_OP_breg13:
2292 case DW_OP_breg14:
2293 case DW_OP_breg15:
2294 case DW_OP_breg16:
2295 case DW_OP_breg17:
2296 case DW_OP_breg18:
2297 case DW_OP_breg19:
2298 case DW_OP_breg20:
2299 case DW_OP_breg21:
2300 case DW_OP_breg22:
2301 case DW_OP_breg23:
2302 case DW_OP_breg24:
2303 case DW_OP_breg25:
2304 case DW_OP_breg26:
2305 case DW_OP_breg27:
2306 case DW_OP_breg28:
2307 case DW_OP_breg29:
2308 case DW_OP_breg30:
2309 case DW_OP_breg31:
2310 dw2_asm_output_data_sleb128 (val1->v.val_int, NULLnullptr);
2311 break;
2312 case DW_OP_regx:
2313 {
2314 unsigned r = val1->v.val_unsigned;
2315 if (for_eh_or_skip >= 0)
2316 r = DWARF2_FRAME_REG_OUT (r, for_eh_or_skip)(r);
2317 gcc_assert (size_of_uleb128 (r)((void)(!(size_of_uleb128 (r) == size_of_uleb128 (val1->v.
val_unsigned)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2318, __FUNCTION__), 0 : 0))
2318 == size_of_uleb128 (val1->v.val_unsigned))((void)(!(size_of_uleb128 (r) == size_of_uleb128 (val1->v.
val_unsigned)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2318, __FUNCTION__), 0 : 0))
;
2319 dw2_asm_output_data_uleb128 (r, NULLnullptr);
2320 }
2321 break;
2322 case DW_OP_fbreg:
2323 dw2_asm_output_data_sleb128 (val1->v.val_int, NULLnullptr);
2324 break;
2325 case DW_OP_bregx:
2326 {
2327 unsigned r = val1->v.val_unsigned;
2328 if (for_eh_or_skip >= 0)
2329 r = DWARF2_FRAME_REG_OUT (r, for_eh_or_skip)(r);
2330 gcc_assert (size_of_uleb128 (r)((void)(!(size_of_uleb128 (r) == size_of_uleb128 (val1->v.
val_unsigned)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2331, __FUNCTION__), 0 : 0))
2331 == size_of_uleb128 (val1->v.val_unsigned))((void)(!(size_of_uleb128 (r) == size_of_uleb128 (val1->v.
val_unsigned)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2331, __FUNCTION__), 0 : 0))
;
2332 dw2_asm_output_data_uleb128 (r, NULLnullptr);
2333 dw2_asm_output_data_sleb128 (val2->v.val_int, NULLnullptr);
2334 }
2335 break;
2336 case DW_OP_piece:
2337 dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULLnullptr);
2338 break;
2339 case DW_OP_bit_piece:
2340 dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULLnullptr);
2341 dw2_asm_output_data_uleb128 (val2->v.val_unsigned, NULLnullptr);
2342 break;
2343 case DW_OP_deref_size:
2344 case DW_OP_xderef_size:
2345 dw2_asm_output_data (1, val1->v.val_int, NULLnullptr);
2346 break;
2347
2348 case DW_OP_addr:
2349 if (loc->dtprel)
2350 {
2351 if (targetm.asm_out.output_dwarf_dtprel)
2352 {
2353 targetm.asm_out.output_dwarf_dtprel (asm_out_file,
2354 DWARF2_ADDR_SIZE(((((global_options.x_ix86_isa_flags & (1UL << 58))
!= 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags &
(1UL << 1)) != 0) ? 8 : 4))) + (8) - 1) / (8))
,
2355 val1->v.val_addr);
2356 fputc ('\n', asm_out_file);
2357 }
2358 else
2359 gcc_unreachable ()(fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2359, __FUNCTION__))
;
2360 }
2361 else
2362 {
2363#ifdef DWARF2_DEBUGGING_INFO1
2364 dw2_asm_output_addr_rtx (DWARF2_ADDR_SIZE(((((global_options.x_ix86_isa_flags & (1UL << 58))
!= 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags &
(1UL << 1)) != 0) ? 8 : 4))) + (8) - 1) / (8))
, val1->v.val_addr, NULLnullptr);
2365#else
2366 gcc_unreachable ()(fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2366, __FUNCTION__))
;
2367#endif
2368 }
2369 break;
2370
2371 case DW_OP_GNU_addr_index:
2372 case DW_OP_addrx:
2373 case DW_OP_GNU_const_index:
2374 case DW_OP_constx:
2375 gcc_assert (loc->dw_loc_oprnd1.val_entry->index != NO_INDEX_ASSIGNED)((void)(!(loc->dw_loc_oprnd1.val_entry->index != (-2U))
? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2375, __FUNCTION__), 0 : 0))
;
2376 dw2_asm_output_data_uleb128 (loc->dw_loc_oprnd1.val_entry->index,
2377 "(index into .debug_addr)");
2378 break;
2379
2380 case DW_OP_call2:
2381 case DW_OP_call4:
2382 {
2383 unsigned long die_offset
2384 = get_ref_die_offset (val1->v.val_die_ref.die);
2385 /* Make sure the offset has been computed and that we can encode it as
2386 an operand. */
2387 gcc_assert (die_offset > 0((void)(!(die_offset > 0 && die_offset <= (loc->
dw_loc_opc == DW_OP_call2 ? 0xffff : 0xffffffff)) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2390, __FUNCTION__), 0 : 0))
2388 && die_offset <= (loc->dw_loc_opc == DW_OP_call2((void)(!(die_offset > 0 && die_offset <= (loc->
dw_loc_opc == DW_OP_call2 ? 0xffff : 0xffffffff)) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2390, __FUNCTION__), 0 : 0))
2389 ? 0xffff((void)(!(die_offset > 0 && die_offset <= (loc->
dw_loc_opc == DW_OP_call2 ? 0xffff : 0xffffffff)) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2390, __FUNCTION__), 0 : 0))
2390 : 0xffffffff))((void)(!(die_offset > 0 && die_offset <= (loc->
dw_loc_opc == DW_OP_call2 ? 0xffff : 0xffffffff)) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2390, __FUNCTION__), 0 : 0))
;
2391 dw2_asm_output_data ((loc->dw_loc_opc == DW_OP_call2) ? 2 : 4,
2392 die_offset, NULLnullptr);
2393 }
2394 break;
2395
2396 case DW_OP_call_ref:
2397 case DW_OP_GNU_variable_value:
2398 {
2399 char label[MAX_ARTIFICIAL_LABEL_BYTES40
2400 + HOST_BITS_PER_WIDE_INT64 / 2 + 2];
2401 gcc_assert (val1->val_class == dw_val_class_die_ref)((void)(!(val1->val_class == dw_val_class_die_ref) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2401, __FUNCTION__), 0 : 0))
;
2402 get_ref_die_offset_label (label, val1->v.val_die_ref.die);
2403 dw2_asm_output_offset (DWARF_REF_SIZE(global_options.x_dwarf_version == 2 ? (((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) + (
8) - 1) / (8)) : global_options.x_dwarf_offset_size)
, label, debug_info_section, NULLnullptr);
2404 }
2405 break;
2406
2407 case DW_OP_implicit_pointer:
2408 case DW_OP_GNU_implicit_pointer:
2409 {
2410 char label[MAX_ARTIFICIAL_LABEL_BYTES40
2411 + HOST_BITS_PER_WIDE_INT64 / 2 + 2];
2412 gcc_assert (val1->val_class == dw_val_class_die_ref)((void)(!(val1->val_class == dw_val_class_die_ref) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2412, __FUNCTION__), 0 : 0))
;
2413 get_ref_die_offset_label (label, val1->v.val_die_ref.die);
2414 dw2_asm_output_offset (DWARF_REF_SIZE(global_options.x_dwarf_version == 2 ? (((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) + (
8) - 1) / (8)) : global_options.x_dwarf_offset_size)
, label, debug_info_section, NULLnullptr);
2415 dw2_asm_output_data_sleb128 (val2->v.val_int, NULLnullptr);
2416 }
2417 break;
2418
2419 case DW_OP_entry_value:
2420 case DW_OP_GNU_entry_value:
2421 dw2_asm_output_data_uleb128 (size_of_locs (val1->v.val_loc), NULLnullptr);
2422 output_loc_sequence (val1->v.val_loc, for_eh_or_skip);
2423 break;
2424
2425 case DW_OP_const_type:
2426 case DW_OP_GNU_const_type:
2427 {
2428 unsigned long o = get_base_type_offset (val1->v.val_die_ref.die), l;
2429 gcc_assert (o)((void)(!(o) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2429, __FUNCTION__), 0 : 0))
;
2430 dw2_asm_output_data_uleb128 (o, NULLnullptr);
2431 switch (val2->val_class)
2432 {
2433 case dw_val_class_const:
2434 l = HOST_BITS_PER_WIDE_INT64 / HOST_BITS_PER_CHAR8;
2435 dw2_asm_output_data (1, l, NULLnullptr);
2436 dw2_asm_output_data (l, val2->v.val_int, NULLnullptr);
2437 break;
2438 case dw_val_class_vec:
2439 {
2440 unsigned int elt_size = val2->v.val_vec.elt_size;
2441 unsigned int len = val2->v.val_vec.length;
2442 unsigned int i;
2443 unsigned char *p;
2444
2445 l = len * elt_size;
2446 dw2_asm_output_data (1, l, NULLnullptr);
2447 if (elt_size > sizeof (HOST_WIDE_INTlong))
2448 {
2449 elt_size /= 2;
2450 len *= 2;
2451 }
2452 for (i = 0, p = (unsigned char *) val2->v.val_vec.array;
2453 i < len;
2454 i++, p += elt_size)
2455 dw2_asm_output_data (elt_size, extract_int (p, elt_size),
2456 "fp or vector constant word %u", i);
2457 }
2458 break;
2459 case dw_val_class_const_double:
2460 {
2461 unsigned HOST_WIDE_INTlong first, second;
2462 l = HOST_BITS_PER_WIDE_INT64 / HOST_BITS_PER_CHAR8;
2463
2464 dw2_asm_output_data (1, 2 * l, NULLnullptr);
2465 if (WORDS_BIG_ENDIAN0)
2466 {
2467 first = val2->v.val_double.high;
2468 second = val2->v.val_double.low;
2469 }
2470 else
2471 {
2472 first = val2->v.val_double.low;
2473 second = val2->v.val_double.high;
2474 }
2475 dw2_asm_output_data (l, first, NULLnullptr);
2476 dw2_asm_output_data (l, second, NULLnullptr);
2477 }
2478 break;
2479 case dw_val_class_wide_int:
2480 {
2481 int i;
2482 int len = get_full_len (*val2->v.val_wide);
2483 l = HOST_BITS_PER_WIDE_INT64 / HOST_BITS_PER_CHAR8;
2484
2485 dw2_asm_output_data (1, len * l, NULLnullptr);
2486 if (WORDS_BIG_ENDIAN0)
2487 for (i = len - 1; i >= 0; --i)
2488 dw2_asm_output_data (l, val2->v.val_wide->elt (i), NULLnullptr);
2489 else
2490 for (i = 0; i < len; ++i)
2491 dw2_asm_output_data (l, val2->v.val_wide->elt (i), NULLnullptr);
2492 }
2493 break;
2494 default:
2495 gcc_unreachable ()(fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2495, __FUNCTION__))
;
2496 }
2497 }
2498 break;
2499 case DW_OP_regval_type:
2500 case DW_OP_GNU_regval_type:
2501 {
2502 unsigned r = val1->v.val_unsigned;
2503 unsigned long o = get_base_type_offset (val2->v.val_die_ref.die);
2504 gcc_assert (o)((void)(!(o) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2504, __FUNCTION__), 0 : 0))
;
2505 if (for_eh_or_skip >= 0)
2506 {
2507 r = DWARF2_FRAME_REG_OUT (r, for_eh_or_skip)(r);
2508 gcc_assert (size_of_uleb128 (r)((void)(!(size_of_uleb128 (r) == size_of_uleb128 (val1->v.
val_unsigned)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2509, __FUNCTION__), 0 : 0))
2509 == size_of_uleb128 (val1->v.val_unsigned))((void)(!(size_of_uleb128 (r) == size_of_uleb128 (val1->v.
val_unsigned)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2509, __FUNCTION__), 0 : 0))
;
2510 }
2511 dw2_asm_output_data_uleb128 (r, NULLnullptr);
2512 dw2_asm_output_data_uleb128 (o, NULLnullptr);
2513 }
2514 break;
2515 case DW_OP_deref_type:
2516 case DW_OP_GNU_deref_type:
2517 {
2518 unsigned long o = get_base_type_offset (val2->v.val_die_ref.die);
2519 gcc_assert (o)((void)(!(o) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2519, __FUNCTION__), 0 : 0))
;
2520 dw2_asm_output_data (1, val1->v.val_int, NULLnullptr);
2521 dw2_asm_output_data_uleb128 (o, NULLnullptr);
2522 }
2523 break;
2524 case DW_OP_convert:
2525 case DW_OP_reinterpret:
2526 case DW_OP_GNU_convert:
2527 case DW_OP_GNU_reinterpret:
2528 if (loc->dw_loc_oprnd1.val_class == dw_val_class_unsigned_const)
2529 dw2_asm_output_data_uleb128 (val1->v.val_unsigned, NULLnullptr);
2530 else
2531 {
2532 unsigned long o = get_base_type_offset (val1->v.val_die_ref.die);
2533 gcc_assert (o)((void)(!(o) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2533, __FUNCTION__), 0 : 0))
;
2534 dw2_asm_output_data_uleb128 (o, NULLnullptr);
2535 }
2536 break;
2537
2538 case DW_OP_GNU_parameter_ref:
2539 {
2540 unsigned long o;
2541 gcc_assert (val1->val_class == dw_val_class_die_ref)((void)(!(val1->val_class == dw_val_class_die_ref) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2541, __FUNCTION__), 0 : 0))
;
2542 o = get_ref_die_offset (val1->v.val_die_ref.die);
2543 dw2_asm_output_data (4, o, NULLnullptr);
2544 }
2545 break;
2546
2547 default:
2548 /* Other codes have no operands. */
2549 break;
2550 }
2551}
2552
2553/* Output a sequence of location operations.
2554 The for_eh_or_skip parameter controls whether register numbers are
2555 converted using DWARF2_FRAME_REG_OUT, which is needed in the case that
2556 hard reg numbers have been processed via DWARF_FRAME_REGNUM (i.e. for unwind
2557 info). This should be suppressed for the cases that have not been converted
2558 (i.e. symbolic debug info), by setting the parameter < 0. See PR47324. */
2559
2560void
2561output_loc_sequence (dw_loc_descr_ref loc, int for_eh_or_skip)
2562{
2563 for (; loc != NULLnullptr; loc = loc->dw_loc_next)
2564 {
2565 enum dwarf_location_atom opc = loc->dw_loc_opc;
2566 /* Output the opcode. */
2567 if (for_eh_or_skip >= 0
2568 && opc >= DW_OP_breg0 && opc <= DW_OP_breg31)
2569 {
2570 unsigned r = (opc - DW_OP_breg0);
2571 r = DWARF2_FRAME_REG_OUT (r, for_eh_or_skip)(r);
2572 gcc_assert (r <= 31)((void)(!(r <= 31) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2572, __FUNCTION__), 0 : 0))
;
2573 opc = (enum dwarf_location_atom) (DW_OP_breg0 + r);
2574 }
2575 else if (for_eh_or_skip >= 0
2576 && opc >= DW_OP_reg0 && opc <= DW_OP_reg31)
2577 {
2578 unsigned r = (opc - DW_OP_reg0);
2579 r = DWARF2_FRAME_REG_OUT (r, for_eh_or_skip)(r);
2580 gcc_assert (r <= 31)((void)(!(r <= 31) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2580, __FUNCTION__), 0 : 0))
;
2581 opc = (enum dwarf_location_atom) (DW_OP_reg0 + r);
2582 }
2583
2584 dw2_asm_output_data (1, opc,
2585 "%s", dwarf_stack_op_name (opc));
2586
2587 /* Output the operand(s) (if any). */
2588 output_loc_operands (loc, for_eh_or_skip);
2589 }
2590}
2591
2592/* Output location description stack opcode's operands (if any).
2593 The output is single bytes on a line, suitable for .cfi_escape. */
2594
2595static void
2596output_loc_operands_raw (dw_loc_descr_ref loc)
2597{
2598 dw_val_ref val1 = &loc->dw_loc_oprnd1;
2599 dw_val_ref val2 = &loc->dw_loc_oprnd2;
2600
2601 switch (loc->dw_loc_opc)
2602 {
2603 case DW_OP_addr:
2604 case DW_OP_GNU_addr_index:
2605 case DW_OP_addrx:
2606 case DW_OP_GNU_const_index:
2607 case DW_OP_constx:
2608 case DW_OP_implicit_value:
2609 /* We cannot output addresses in .cfi_escape, only bytes. */
2610 gcc_unreachable ()(fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2610, __FUNCTION__))
;
2611
2612 case DW_OP_const1u:
2613 case DW_OP_const1s:
2614 case DW_OP_pick:
2615 case DW_OP_deref_size:
2616 case DW_OP_xderef_size:
2617 fputc (',', asm_out_file);
2618 dw2_asm_output_data_raw (1, val1->v.val_int);
2619 break;
2620
2621 case DW_OP_const2u:
2622 case DW_OP_const2s:
2623 fputc (',', asm_out_file);
2624 dw2_asm_output_data_raw (2, val1->v.val_int);
2625 break;
2626
2627 case DW_OP_const4u:
2628 case DW_OP_const4s:
2629 fputc (',', asm_out_file);
2630 dw2_asm_output_data_raw (4, val1->v.val_int);
2631 break;
2632
2633 case DW_OP_const8u:
2634 case DW_OP_const8s:
2635 gcc_assert (HOST_BITS_PER_WIDE_INT >= 64)((void)(!(64 >= 64) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2635, __FUNCTION__), 0 : 0))
;
2636 fputc (',', asm_out_file);
2637 dw2_asm_output_data_raw (8, val1->v.val_int);
2638 break;
2639
2640 case DW_OP_skip:
2641 case DW_OP_bra:
2642 {
2643 int offset;
2644
2645 gcc_assert (val1->val_class == dw_val_class_loc)((void)(!(val1->val_class == dw_val_class_loc) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2645, __FUNCTION__), 0 : 0))
;
2646 offset = val1->v.val_loc->dw_loc_addr - (loc->dw_loc_addr + 3);
2647
2648 fputc (',', asm_out_file);
2649 dw2_asm_output_data_raw (2, offset);
2650 }
2651 break;
2652
2653 case DW_OP_regx:
2654 {
2655 unsigned r = DWARF2_FRAME_REG_OUT (val1->v.val_unsigned, 1)(val1->v.val_unsigned);
2656 gcc_assert (size_of_uleb128 (r)((void)(!(size_of_uleb128 (r) == size_of_uleb128 (val1->v.
val_unsigned)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2657, __FUNCTION__), 0 : 0))
2657 == size_of_uleb128 (val1->v.val_unsigned))((void)(!(size_of_uleb128 (r) == size_of_uleb128 (val1->v.
val_unsigned)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2657, __FUNCTION__), 0 : 0))
;
2658 fputc (',', asm_out_file);
2659 dw2_asm_output_data_uleb128_raw (r);
2660 }
2661 break;
2662
2663 case DW_OP_constu:
2664 case DW_OP_plus_uconst:
2665 case DW_OP_piece:
2666 fputc (',', asm_out_file);
2667 dw2_asm_output_data_uleb128_raw (val1->v.val_unsigned);
2668 break;
2669
2670 case DW_OP_bit_piece:
2671 fputc (',', asm_out_file);
2672 dw2_asm_output_data_uleb128_raw (val1->v.val_unsigned);
2673 dw2_asm_output_data_uleb128_raw (val2->v.val_unsigned);
2674 break;
2675
2676 case DW_OP_consts:
2677 case DW_OP_breg0:
2678 case DW_OP_breg1:
2679 case DW_OP_breg2:
2680 case DW_OP_breg3:
2681 case DW_OP_breg4:
2682 case DW_OP_breg5:
2683 case DW_OP_breg6:
2684 case DW_OP_breg7:
2685 case DW_OP_breg8:
2686 case DW_OP_breg9:
2687 case DW_OP_breg10:
2688 case DW_OP_breg11:
2689 case DW_OP_breg12:
2690 case DW_OP_breg13:
2691 case DW_OP_breg14:
2692 case DW_OP_breg15:
2693 case DW_OP_breg16:
2694 case DW_OP_breg17:
2695 case DW_OP_breg18:
2696 case DW_OP_breg19:
2697 case DW_OP_breg20:
2698 case DW_OP_breg21:
2699 case DW_OP_breg22:
2700 case DW_OP_breg23:
2701 case DW_OP_breg24:
2702 case DW_OP_breg25:
2703 case DW_OP_breg26:
2704 case DW_OP_breg27:
2705 case DW_OP_breg28:
2706 case DW_OP_breg29:
2707 case DW_OP_breg30:
2708 case DW_OP_breg31:
2709 case DW_OP_fbreg:
2710 fputc (',', asm_out_file);
2711 dw2_asm_output_data_sleb128_raw (val1->v.val_int);
2712 break;
2713
2714 case DW_OP_bregx:
2715 {
2716 unsigned r = DWARF2_FRAME_REG_OUT (val1->v.val_unsigned, 1)(val1->v.val_unsigned);
2717 gcc_assert (size_of_uleb128 (r)((void)(!(size_of_uleb128 (r) == size_of_uleb128 (val1->v.
val_unsigned)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2718, __FUNCTION__), 0 : 0))
2718 == size_of_uleb128 (val1->v.val_unsigned))((void)(!(size_of_uleb128 (r) == size_of_uleb128 (val1->v.
val_unsigned)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2718, __FUNCTION__), 0 : 0))
;
2719 fputc (',', asm_out_file);
2720 dw2_asm_output_data_uleb128_raw (r);
2721 fputc (',', asm_out_file);
2722 dw2_asm_output_data_sleb128_raw (val2->v.val_int);
2723 }
2724 break;
2725
2726 case DW_OP_implicit_pointer:
2727 case DW_OP_entry_value:
2728 case DW_OP_const_type:
2729 case DW_OP_regval_type:
2730 case DW_OP_deref_type:
2731 case DW_OP_convert:
2732 case DW_OP_reinterpret:
2733 case DW_OP_GNU_implicit_pointer:
2734 case DW_OP_GNU_entry_value:
2735 case DW_OP_GNU_const_type:
2736 case DW_OP_GNU_regval_type:
2737 case DW_OP_GNU_deref_type:
2738 case DW_OP_GNU_convert:
2739 case DW_OP_GNU_reinterpret:
2740 case DW_OP_GNU_parameter_ref:
2741 gcc_unreachable ()(fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2741, __FUNCTION__))
;
2742 break;
2743
2744 default:
2745 /* Other codes have no operands. */
2746 break;
2747 }
2748}
2749
2750void
2751output_loc_sequence_raw (dw_loc_descr_ref loc)
2752{
2753 while (1)
2754 {
2755 enum dwarf_location_atom opc = loc->dw_loc_opc;
2756 /* Output the opcode. */
2757 if (opc >= DW_OP_breg0 && opc <= DW_OP_breg31)
2758 {
2759 unsigned r = (opc - DW_OP_breg0);
2760 r = DWARF2_FRAME_REG_OUT (r, 1)(r);
2761 gcc_assert (r <= 31)((void)(!(r <= 31) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2761, __FUNCTION__), 0 : 0))
;
2762 opc = (enum dwarf_location_atom) (DW_OP_breg0 + r);
2763 }
2764 else if (opc >= DW_OP_reg0 && opc <= DW_OP_reg31)
2765 {
2766 unsigned r = (opc - DW_OP_reg0);
2767 r = DWARF2_FRAME_REG_OUT (r, 1)(r);
2768 gcc_assert (r <= 31)((void)(!(r <= 31) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2768, __FUNCTION__), 0 : 0))
;
2769 opc = (enum dwarf_location_atom) (DW_OP_reg0 + r);
2770 }
2771 /* Output the opcode. */
2772 fprintf (asm_out_file, "%#x", opc);
2773 output_loc_operands_raw (loc);
2774
2775 if (!loc->dw_loc_next)
2776 break;
2777 loc = loc->dw_loc_next;
2778
2779 fputc (',', asm_out_file);
2780 }
2781}
2782
2783static void
2784build_breg_loc (struct dw_loc_descr_node **head, unsigned int regno)
2785{
2786 if (regno <= 31)
2787 add_loc_descr (head, new_loc_descr ((enum dwarf_location_atom)
2788 (DW_OP_breg0 + regno), 0, 0));
2789 else
2790 add_loc_descr (head, new_loc_descr (DW_OP_bregx, regno, 0));
2791}
2792
2793/* Build a dwarf location for a cfa_reg spanning multiple
2794 consecutive registers. */
2795
2796struct dw_loc_descr_node *
2797build_span_loc (struct cfa_reg reg)
2798{
2799 struct dw_loc_descr_node *head = NULLnullptr;
2800
2801 gcc_assert (reg.span_width > 0)((void)(!(reg.span_width > 0) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2801, __FUNCTION__), 0 : 0))
;
2802 gcc_assert (reg.span > 1)((void)(!(reg.span > 1) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 2802, __FUNCTION__), 0 : 0))
;
2803
2804 /* Start from the highest number register as it goes in the upper bits. */
2805 unsigned int regno = reg.reg + reg.span - 1;
2806 build_breg_loc (&head, regno);
2807
2808 /* Deal with the remaining registers in the span. */
2809 for (int i = reg.span - 2; i >= 0; i--)
2810 {
2811 add_loc_descr (&head, int_loc_descriptor (reg.span_width * 8));
2812 add_loc_descr (&head, new_loc_descr (DW_OP_shl, 0, 0));
2813 regno--;
2814 build_breg_loc (&head, regno);
2815 add_loc_descr (&head, new_loc_descr (DW_OP_plus, 0, 0));
2816 }
2817 return head;
2818}
2819
2820/* This function builds a dwarf location descriptor sequence from a
2821 dw_cfa_location, adding the given OFFSET to the result of the
2822 expression. */
2823
2824struct dw_loc_descr_node *
2825build_cfa_loc (dw_cfa_location *cfa, poly_int64 offset)
2826{
2827 struct dw_loc_descr_node *head, *tmp;
2828
2829 offset += cfa->offset;
2830
2831 if (cfa->reg.span > 1)
2832 {
2833 head = build_span_loc (cfa->reg);
2834
2835 if (maybe_ne (offset, 0))
2836 loc_descr_plus_const (&head, offset);
2837 }
2838 else if (cfa->indirect)
2839 {
2840 head = new_reg_loc_descr (cfa->reg.reg, cfa->base_offset);
2841 head->dw_loc_oprnd1.val_class = dw_val_class_const;
2842 head->dw_loc_oprnd1.val_entry = NULLnullptr;
2843 tmp = new_loc_descr (DW_OP_deref, 0, 0);
2844 add_loc_descr (&head, tmp);
2845 loc_descr_plus_const (&head, offset);
2846 }
2847 else
2848 head = new_reg_loc_descr (cfa->reg.reg, offset);
2849
2850 return head;
2851}
2852
2853/* This function builds a dwarf location descriptor sequence for
2854 the address at OFFSET from the CFA when stack is aligned to
2855 ALIGNMENT byte. */
2856
2857struct dw_loc_descr_node *
2858build_cfa_aligned_loc (dw_cfa_location *cfa,
2859 poly_int64 offset, HOST_WIDE_INTlong alignment)
2860{
2861 struct dw_loc_descr_node *head;
2862 unsigned int dwarf_fp
2863 = DWARF_FRAME_REGNUM (HARD_FRAME_POINTER_REGNUM)(((global_options.x_ix86_isa_flags & (1UL << 1)) !=
0) ? debugger64_register_map[6] : svr4_debugger_register_map
[6])
;
2864
2865 /* When CFA is defined as FP+OFFSET, emulate stack alignment. */
2866 if (cfa->reg.reg == HARD_FRAME_POINTER_REGNUM6 && cfa->indirect == 0)
2867 {
2868 head = new_reg_loc_descr (dwarf_fp, 0);
2869 add_loc_descr (&head, int_loc_descriptor (alignment));
2870 add_loc_descr (&head, new_loc_descr (DW_OP_and, 0, 0));
2871 loc_descr_plus_const (&head, offset);
2872 }
2873 else
2874 head = new_reg_loc_descr (dwarf_fp, offset);
2875 return head;
2876}
2877
2878/* And now, the support for symbolic debugging information. */
2879
2880/* .debug_str support. */
2881
2882static void dwarf2out_init (const char *);
2883static void dwarf2out_finish (const char *);
2884static void dwarf2out_early_finish (const char *);
2885static void dwarf2out_assembly_start (void);
2886static void dwarf2out_define (unsigned int, const char *);
2887static void dwarf2out_undef (unsigned int, const char *);
2888static void dwarf2out_start_source_file (unsigned, const char *);
2889static void dwarf2out_end_source_file (unsigned);
2890static void dwarf2out_function_decl (tree);
2891static void dwarf2out_begin_block (unsigned, unsigned);
2892static void dwarf2out_end_block (unsigned, unsigned);
2893static bool dwarf2out_ignore_block (const_tree);
2894static void dwarf2out_set_ignored_loc (unsigned, unsigned, const char *);
2895static void dwarf2out_early_global_decl (tree);
2896static void dwarf2out_late_global_decl (tree);
2897static void dwarf2out_type_decl (tree, int);
2898static void dwarf2out_imported_module_or_decl (tree, tree, tree, bool, bool);
2899static void dwarf2out_imported_module_or_decl_1 (tree, tree, tree,
2900 dw_die_ref);
2901static void dwarf2out_abstract_function (tree);
2902static void dwarf2out_var_location (rtx_insn *);
2903static void dwarf2out_inline_entry (tree);
2904static void dwarf2out_size_function (tree);
2905static void dwarf2out_begin_function (tree);
2906static void dwarf2out_end_function (unsigned int);
2907static void dwarf2out_register_main_translation_unit (tree unit);
2908static void dwarf2out_set_name (tree, tree);
2909static void dwarf2out_register_external_die (tree decl, const char *sym,
2910 unsigned HOST_WIDE_INTlong off);
2911static bool dwarf2out_die_ref_for_decl (tree decl, const char **sym,
2912 unsigned HOST_WIDE_INTlong *off);
2913
2914/* The debug hooks structure. */
2915
2916const struct gcc_debug_hooks dwarf2_debug_hooks =
2917{
2918 dwarf2out_init,
2919 dwarf2out_finish,
2920 dwarf2out_early_finish,
2921 dwarf2out_assembly_start,
2922 dwarf2out_define,
2923 dwarf2out_undef,
2924 dwarf2out_start_source_file,
2925 dwarf2out_end_source_file,
2926 dwarf2out_begin_block,
2927 dwarf2out_end_block,
2928 dwarf2out_ignore_block,
2929 dwarf2out_source_line,
2930 dwarf2out_set_ignored_loc,
2931 dwarf2out_begin_prologue,
2932#if VMS_DEBUGGING_INFO
2933 dwarf2out_vms_end_prologue,
2934 dwarf2out_vms_begin_epilogue,
2935#else
2936 debug_nothing_int_charstar,
2937 debug_nothing_int_charstar,
2938#endif
2939 dwarf2out_end_epilogue,
2940 dwarf2out_begin_function,
2941 dwarf2out_end_function, /* end_function */
2942 dwarf2out_register_main_translation_unit,
2943 dwarf2out_function_decl, /* function_decl */
2944 dwarf2out_early_global_decl,
2945 dwarf2out_late_global_decl,
2946 dwarf2out_type_decl, /* type_decl */
2947 dwarf2out_imported_module_or_decl,
2948 dwarf2out_die_ref_for_decl,
2949 dwarf2out_register_external_die,
2950 debug_nothing_tree, /* deferred_inline_function */
2951 /* The DWARF 2 backend tries to reduce debugging bloat by not
2952 emitting the abstract description of inline functions until
2953 something tries to reference them. */
2954 dwarf2out_abstract_function, /* outlining_inline_function */
2955 debug_nothing_rtx_code_label, /* label */
2956 debug_nothing_int, /* handle_pch */
2957 dwarf2out_var_location,
2958 dwarf2out_inline_entry, /* inline_entry */
2959 dwarf2out_size_function, /* size_function */
2960 dwarf2out_switch_text_section,
2961 dwarf2out_set_name,
2962 1, /* start_end_main_source_file */
2963 TYPE_SYMTAB_IS_DIE(1) /* tree_type_symtab_field */
2964};
2965
2966const struct gcc_debug_hooks dwarf2_lineno_debug_hooks =
2967{
2968 dwarf2out_init,
2969 debug_nothing_charstar,
2970 debug_nothing_charstar,
2971 dwarf2out_assembly_start,
2972 debug_nothing_int_charstar,
2973 debug_nothing_int_charstar,
2974 debug_nothing_int_charstar,
2975 debug_nothing_int,
2976 debug_nothing_int_int, /* begin_block */
2977 debug_nothing_int_int, /* end_block */
2978 debug_true_const_tree, /* ignore_block */
2979 dwarf2out_source_line, /* source_line */
2980 debug_nothing_int_int_charstar, /* set_ignored_loc */
2981 debug_nothing_int_int_charstar, /* begin_prologue */
2982 debug_nothing_int_charstar, /* end_prologue */
2983 debug_nothing_int_charstar, /* begin_epilogue */
2984 debug_nothing_int_charstar, /* end_epilogue */
2985 debug_nothing_tree, /* begin_function */
2986 debug_nothing_int, /* end_function */
2987 debug_nothing_tree, /* register_main_translation_unit */
2988 debug_nothing_tree, /* function_decl */
2989 debug_nothing_tree, /* early_global_decl */
2990 debug_nothing_tree, /* late_global_decl */
2991 debug_nothing_tree_int, /* type_decl */
2992 debug_nothing_tree_tree_tree_bool_bool,/* imported_module_or_decl */
2993 debug_false_tree_charstarstar_uhwistar,/* die_ref_for_decl */
2994 debug_nothing_tree_charstar_uhwi, /* register_external_die */
2995 debug_nothing_tree, /* deferred_inline_function */
2996 debug_nothing_tree, /* outlining_inline_function */
2997 debug_nothing_rtx_code_label, /* label */
2998 debug_nothing_int, /* handle_pch */
2999 debug_nothing_rtx_insn, /* var_location */
3000 debug_nothing_tree, /* inline_entry */
3001 debug_nothing_tree, /* size_function */
3002 debug_nothing_void, /* switch_text_section */
3003 debug_nothing_tree_tree, /* set_name */
3004 0, /* start_end_main_source_file */
3005 TYPE_SYMTAB_IS_ADDRESS(0) /* tree_type_symtab_field */
3006};
3007
3008/* NOTE: In the comments in this file, many references are made to
3009 "Debugging Information Entries". This term is abbreviated as `DIE'
3010 throughout the remainder of this file. */
3011
3012/* An internal representation of the DWARF output is built, and then
3013 walked to generate the DWARF debugging info. The walk of the internal
3014 representation is done after the entire program has been compiled.
3015 The types below are used to describe the internal representation. */
3016
3017/* Whether to put type DIEs into their own section .debug_types instead
3018 of making them part of the .debug_info section. Only supported for
3019 Dwarf V4 or higher and the user didn't disable them through
3020 -fno-debug-types-section. It is more efficient to put them in a
3021 separate comdat sections since the linker will then be able to
3022 remove duplicates. But not all tools support .debug_types sections
3023 yet. For Dwarf V5 or higher .debug_types doesn't exist any more,
3024 it is DW_UT_type unit type in .debug_info section. For late LTO
3025 debug there should be almost no types emitted so avoid enabling
3026 -fdebug-types-section there. */
3027
3028#define use_debug_types(global_options.x_dwarf_version >= 4 && global_options
.x_flag_debug_types_section && !global_options.x_in_lto_p
)
(dwarf_versionglobal_options.x_dwarf_version >= 4 \
3029 && flag_debug_types_sectionglobal_options.x_flag_debug_types_section \
3030 && !in_lto_pglobal_options.x_in_lto_p)
3031
3032/* Various DIE's use offsets relative to the beginning of the
3033 .debug_info section to refer to each other. */
3034
3035typedef long int dw_offset;
3036
3037struct comdat_type_node;
3038
3039/* The entries in the line_info table more-or-less mirror the opcodes
3040 that are used in the real dwarf line table. Arrays of these entries
3041 are collected per section when DWARF2_ASM_LINE_DEBUG_INFO is not
3042 supported. */
3043
3044enum dw_line_info_opcode {
3045 /* Emit DW_LNE_set_address; the operand is the label index. */
3046 LI_set_address,
3047
3048 /* Emit a row to the matrix with the given line. This may be done
3049 via any combination of DW_LNS_copy, DW_LNS_advance_line, and
3050 special opcodes. */
3051 LI_set_line,
3052
3053 /* Emit a DW_LNS_set_file. */
3054 LI_set_file,
3055
3056 /* Emit a DW_LNS_set_column. */
3057 LI_set_column,
3058
3059 /* Emit a DW_LNS_negate_stmt; the operand is ignored. */
3060 LI_negate_stmt,
3061
3062 /* Emit a DW_LNS_set_prologue_end/epilogue_begin; the operand is ignored. */
3063 LI_set_prologue_end,
3064 LI_set_epilogue_begin,
3065
3066 /* Emit a DW_LNE_set_discriminator. */
3067 LI_set_discriminator,
3068
3069 /* Output a Fixed Advance PC; the target PC is the label index; the
3070 base PC is the previous LI_adv_address or LI_set_address entry.
3071 We only use this when emitting debug views without assembler
3072 support, at explicit user request. Ideally, we should only use
3073 it when the offset might be zero but we can't tell: it's the only
3074 way to maybe change the PC without resetting the view number. */
3075 LI_adv_address
3076};
3077
3078typedef struct GTY(()) dw_line_info_struct {
3079 enum dw_line_info_opcode opcode;
3080 unsigned int val;
3081} dw_line_info_entry;
3082
3083
3084struct GTY(()) dw_line_info_table {
3085 /* The label that marks the end of this section. */
3086 const char *end_label;
3087
3088 /* The values for the last row of the matrix, as collected in the table.
3089 These are used to minimize the changes to the next row. */
3090 unsigned int file_num;
3091 unsigned int line_num;
3092 unsigned int column_num;
3093 int discrim_num;
3094 bool is_stmt;
3095 bool in_use;
3096
3097 /* This denotes the NEXT view number.
3098
3099 If it is 0, it is known that the NEXT view will be the first view
3100 at the given PC.
3101
3102 If it is -1, we're forcing the view number to be reset, e.g. at a
3103 function entry.
3104
3105 The meaning of other nonzero values depends on whether we're
3106 computing views internally or leaving it for the assembler to do
3107 so. If we're emitting them internally, view denotes the view
3108 number since the last known advance of PC. If we're leaving it
3109 for the assembler, it denotes the LVU label number that we're
3110 going to ask the assembler to assign. */
3111 var_loc_view view;
3112
3113 /* This counts the number of symbolic views emitted in this table
3114 since the latest view reset. Its max value, over all tables,
3115 sets symview_upper_bound. */
3116 var_loc_view symviews_since_reset;
3117
3118#define FORCE_RESET_NEXT_VIEW(x)((x) = (var_loc_view)-1) ((x) = (var_loc_view)-1)
3119#define RESET_NEXT_VIEW(x)((x) = (var_loc_view)0) ((x) = (var_loc_view)0)
3120#define FORCE_RESETTING_VIEW_P(x)((x) == (var_loc_view)-1) ((x) == (var_loc_view)-1)
3121#define RESETTING_VIEW_P(x)((x) == (var_loc_view)0 || ((x) == (var_loc_view)-1)) ((x) == (var_loc_view)0 || FORCE_RESETTING_VIEW_P (x)((x) == (var_loc_view)-1))
3122
3123 vec<dw_line_info_entry, va_gc> *entries;
3124};
3125
3126/* This is an upper bound for view numbers that the assembler may
3127 assign to symbolic views output in this translation. It is used to
3128 decide how big a field to use to represent view numbers in
3129 symview-classed attributes. */
3130
3131static var_loc_view symview_upper_bound;
3132
3133/* If we're keep track of location views and their reset points, and
3134 INSN is a reset point (i.e., it necessarily advances the PC), mark
3135 the next view in TABLE as reset. */
3136
3137static void
3138maybe_reset_location_view (rtx_insn *insn, dw_line_info_table *table)
3139{
3140 if (!debug_internal_reset_location_viewsglobal_options.x_debug_internal_reset_location_views)
3141 return;
3142
3143 /* Maybe turn (part of?) this test into a default target hook. */
3144 int reset = 0;
3145
3146 if (targetm.reset_location_view)
3147 reset = targetm.reset_location_view (insn);
3148
3149 if (reset)
3150 ;
3151 else if (JUMP_TABLE_DATA_P (insn)(((enum rtx_code) (insn)->code) == JUMP_TABLE_DATA))
3152 reset = 1;
3153 else if (GET_CODE (insn)((enum rtx_code) (insn)->code) == USE
3154 || GET_CODE (insn)((enum rtx_code) (insn)->code) == CLOBBER
3155 || GET_CODE (insn)((enum rtx_code) (insn)->code) == ASM_INPUT
3156 || asm_noperands (insn) >= 0)
3157 ;
3158 else if (get_attr_min_length (insn) > 0)
3159 reset = 1;
3160
3161 if (reset > 0 && !RESETTING_VIEW_P (table->view)((table->view) == (var_loc_view)0 || ((table->view) == (
var_loc_view)-1))
)
3162 RESET_NEXT_VIEW (table->view)((table->view) = (var_loc_view)0);
3163}
3164
3165/* The Debugging Information Entry (DIE) structure. DIEs form a tree.
3166 The children of each node form a circular list linked by
3167 die_sib. die_child points to the node *before* the "first" child node. */
3168
3169typedef struct GTY((chain_circular ("%h.die_sib"), for_user)) die_struct {
3170 union die_symbol_or_type_node
3171 {
3172 const char * GTY ((tag ("0"))) die_symbol;
3173 comdat_type_node *GTY ((tag ("1"))) die_type_node;
3174 }
3175 GTY ((desc ("%0.comdat_type_p"))) die_id;
3176 vec<dw_attr_node, va_gc> *die_attr;
3177 dw_die_ref die_parent;
3178 dw_die_ref die_child;
3179 dw_die_ref die_sib;
3180 dw_die_ref die_definition; /* ref from a specification to its definition */
3181 dw_offset die_offset;
3182 unsigned long die_abbrev;
3183 int die_mark;
3184 unsigned int decl_id;
3185 enum dwarf_tag die_tag;
3186 /* Die is used and must not be pruned as unused. */
3187 BOOL_BITFIELDunsigned int die_perennial_p : 1;
3188 BOOL_BITFIELDunsigned int comdat_type_p : 1; /* DIE has a type signature */
3189 /* For an external ref to die_symbol if die_offset contains an extra
3190 offset to that symbol. */
3191 BOOL_BITFIELDunsigned int with_offset : 1;
3192 /* Whether this DIE was removed from the DIE tree, for example via
3193 prune_unused_types. We don't consider those present from the
3194 DIE lookup routines. */
3195 BOOL_BITFIELDunsigned int removed : 1;
3196 /* Lots of spare bits. */
3197}
3198die_node;
3199
3200/* Set to TRUE while dwarf2out_early_global_decl is running. */
3201static bool early_dwarf;
3202static bool early_dwarf_finished;
3203class set_early_dwarf {
3204public:
3205 bool saved;
3206 set_early_dwarf () : saved(early_dwarf)
3207 {
3208 gcc_assert (! early_dwarf_finished)((void)(!(! early_dwarf_finished) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 3208, __FUNCTION__), 0 : 0))
;
3209 early_dwarf = true;
3210 }
3211 ~set_early_dwarf () { early_dwarf = saved; }
3212};
3213
3214/* Evaluate 'expr' while 'c' is set to each child of DIE in order. */
3215#define FOR_EACH_CHILD(die, c, expr)do { c = die->die_child; if (c) do { c = c->die_sib; expr
; } while (c != die->die_child); } while (0)
do { \
3216 c = die->die_child; \
3217 if (c) do { \
3218 c = c->die_sib; \
3219 expr; \
3220 } while (c != die->die_child); \
3221} while (0)
3222
3223/* The pubname structure */
3224
3225typedef struct GTY(()) pubname_struct {
3226 dw_die_ref die;
3227 const char *name;
3228}
3229pubname_entry;
3230
3231
3232struct GTY(()) dw_ranges {
3233 const char *label;
3234 /* If this is positive, it's a block number, otherwise it's a
3235 bitwise-negated index into dw_ranges_by_label. */
3236 int num;
3237 /* If idx is equal to DW_RANGES_IDX_SKELETON, it should be emitted
3238 into .debug_rnglists section rather than .debug_rnglists.dwo
3239 for -gsplit-dwarf and DWARF >= 5. */
3240#define DW_RANGES_IDX_SKELETON((1U << 31) - 1) ((1U << 31) - 1)
3241 /* Index for the range list for DW_FORM_rnglistx. */
3242 unsigned int idx : 31;
3243 /* True if this range might be possibly in a different section
3244 from previous entry. */
3245 unsigned int maybe_new_sec : 1;
3246 addr_table_entry *begin_entry;
3247 addr_table_entry *end_entry;
3248};
3249
3250/* A structure to hold a macinfo entry. */
3251
3252typedef struct GTY(()) macinfo_struct {
3253 unsigned char code;
3254 unsigned HOST_WIDE_INTlong lineno;
3255 const char *info;
3256}
3257macinfo_entry;
3258
3259
3260struct GTY(()) dw_ranges_by_label {
3261 const char *begin;
3262 const char *end;
3263};
3264
3265/* The comdat type node structure. */
3266struct GTY(()) comdat_type_node
3267{
3268 dw_die_ref root_die;
3269 dw_die_ref type_die;
3270 dw_die_ref skeleton_die;
3271 char signature[DWARF_TYPE_SIGNATURE_SIZE8];
3272 comdat_type_node *next;
3273};
3274
3275/* A list of DIEs for which we can't determine ancestry (parent_die
3276 field) just yet. Later in dwarf2out_finish we will fill in the
3277 missing bits. */
3278typedef struct GTY(()) limbo_die_struct {
3279 dw_die_ref die;
3280 /* The tree for which this DIE was created. We use this to
3281 determine ancestry later. */
3282 tree created_for;
3283 struct limbo_die_struct *next;
3284}
3285limbo_die_node;
3286
3287typedef struct skeleton_chain_struct
3288{
3289 dw_die_ref old_die;
3290 dw_die_ref new_die;
3291 struct skeleton_chain_struct *parent;
3292}
3293skeleton_chain_node;
3294
3295/* Define a macro which returns nonzero for a TYPE_DECL which was
3296 implicitly generated for a type.
3297
3298 Note that, unlike the C front-end (which generates a NULL named
3299 TYPE_DECL node for each complete tagged type, each array type,
3300 and each function type node created) the C++ front-end generates
3301 a _named_ TYPE_DECL node for each tagged type node created.
3302 These TYPE_DECLs have DECL_ARTIFICIAL set, so we know not to
3303 generate a DW_TAG_typedef DIE for them. Likewise with the Ada
3304 front-end, but for each type, tagged or not. */
3305
3306#define TYPE_DECL_IS_STUB(decl)(((contains_struct_check ((decl), (TS_DECL_MINIMAL), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 3306, __FUNCTION__))->decl_minimal.name) == (tree) nullptr
|| (((contains_struct_check ((decl), (TS_DECL_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 3306, __FUNCTION__))->decl_common.artificial_flag) &&
((decl == (((contains_struct_check (((tree_class_check ((((contains_struct_check
((decl), (TS_TYPED), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 3306, __FUNCTION__))->typed.type)), (tcc_type), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 3306, __FUNCTION__))), (TS_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 3306, __FUNCTION__))->common.chain))) || (((contains_struct_check
((decl), (TS_DECL_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 3306, __FUNCTION__))->decl_common.abstract_origin) != (tree
) nullptr && (decl_ultimate_origin (decl) == (((contains_struct_check
(((tree_class_check ((((contains_struct_check ((decl), (TS_TYPED
), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 3306, __FUNCTION__))->typed.type)), (tcc_type), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 3306, __FUNCTION__))), (TS_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 3306, __FUNCTION__))->common.chain)))))))
\
3307 (DECL_NAME (decl)((contains_struct_check ((decl), (TS_DECL_MINIMAL), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 3307, __FUNCTION__))->decl_minimal.name)
== NULL_TREE(tree) nullptr \
3308 || (DECL_ARTIFICIAL (decl)((contains_struct_check ((decl), (TS_DECL_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 3308, __FUNCTION__))->decl_common.artificial_flag)
\
3309 && ((decl == TYPE_STUB_DECL (TREE_TYPE (decl))(((contains_struct_check (((tree_class_check ((((contains_struct_check
((decl), (TS_TYPED), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 3309, __FUNCTION__))->typed.type)), (tcc_type), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 3309, __FUNCTION__))), (TS_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 3309, __FUNCTION__))->common.chain))
) \
3310 /* This is necessary for stub decls that \
3311 appear in nested inline functions. */ \
3312 || (DECL_ABSTRACT_ORIGIN (decl)((contains_struct_check ((decl), (TS_DECL_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 3312, __FUNCTION__))->decl_common.abstract_origin)
!= NULL_TREE(tree) nullptr \
3313 && (decl_ultimate_origin (decl) \
3314 == TYPE_STUB_DECL (TREE_TYPE (decl))(((contains_struct_check (((tree_class_check ((((contains_struct_check
((decl), (TS_TYPED), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 3314, __FUNCTION__))->typed.type)), (tcc_type), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 3314, __FUNCTION__))), (TS_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 3314, __FUNCTION__))->common.chain))
)))))
3315
3316/* Information concerning the compilation unit's programming
3317 language, and compiler version. */
3318
3319/* Fixed size portion of the DWARF compilation unit header. */
3320#define DWARF_COMPILE_UNIT_HEADER_SIZE((global_options.x_dwarf_offset_size == 4 ? 4 : 12) + global_options
.x_dwarf_offset_size + (global_options.x_dwarf_version >= 5
? 4 : 3))
\
3321 (DWARF_INITIAL_LENGTH_SIZE(global_options.x_dwarf_offset_size == 4 ? 4 : 12) + dwarf_offset_sizeglobal_options.x_dwarf_offset_size \
3322 + (dwarf_versionglobal_options.x_dwarf_version >= 5 ? 4 : 3))
3323
3324/* Fixed size portion of the DWARF comdat type unit header. */
3325#define DWARF_COMDAT_TYPE_UNIT_HEADER_SIZE(((global_options.x_dwarf_offset_size == 4 ? 4 : 12) + global_options
.x_dwarf_offset_size + (global_options.x_dwarf_version >= 5
? 4 : 3)) + 8 + global_options.x_dwarf_offset_size)
\
3326 (DWARF_COMPILE_UNIT_HEADER_SIZE((global_options.x_dwarf_offset_size == 4 ? 4 : 12) + global_options
.x_dwarf_offset_size + (global_options.x_dwarf_version >= 5
? 4 : 3))
\
3327 + DWARF_TYPE_SIGNATURE_SIZE8 + dwarf_offset_sizeglobal_options.x_dwarf_offset_size)
3328
3329/* Fixed size portion of the DWARF skeleton compilation unit header. */
3330#define DWARF_COMPILE_UNIT_SKELETON_HEADER_SIZE(((global_options.x_dwarf_offset_size == 4 ? 4 : 12) + global_options
.x_dwarf_offset_size + (global_options.x_dwarf_version >= 5
? 4 : 3)) + (global_options.x_dwarf_version >= 5 ? 8 : 0)
)
\
3331 (DWARF_COMPILE_UNIT_HEADER_SIZE((global_options.x_dwarf_offset_size == 4 ? 4 : 12) + global_options
.x_dwarf_offset_size + (global_options.x_dwarf_version >= 5
? 4 : 3))
+ (dwarf_versionglobal_options.x_dwarf_version >= 5 ? 8 : 0))
3332
3333/* Fixed size portion of public names info. */
3334#define DWARF_PUBNAMES_HEADER_SIZE(2 * global_options.x_dwarf_offset_size + 2) (2 * dwarf_offset_sizeglobal_options.x_dwarf_offset_size + 2)
3335
3336/* Fixed size portion of the address range info. */
3337#define DWARF_ARANGES_HEADER_SIZE((((((global_options.x_dwarf_offset_size == 4 ? 4 : 12) + global_options
.x_dwarf_offset_size + 4) + ((((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) + (
8) - 1) / (8)) * 2) - 1) / ((((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) + (
8) - 1) / (8)) * 2)) * ((((((global_options.x_ix86_isa_flags &
(1UL << 58)) != 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags
& (1UL << 1)) != 0) ? 8 : 4))) + (8) - 1) / (8)) *
2)) - (global_options.x_dwarf_offset_size == 4 ? 4 : 12))
\
3338 (DWARF_ROUND (DWARF_INITIAL_LENGTH_SIZE + dwarf_offset_size + 4, \(((((global_options.x_dwarf_offset_size == 4 ? 4 : 12) + global_options
.x_dwarf_offset_size + 4) + ((((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) + (
8) - 1) / (8)) * 2) - 1) / ((((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) + (
8) - 1) / (8)) * 2)) * ((((((global_options.x_ix86_isa_flags &
(1UL << 58)) != 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags
& (1UL << 1)) != 0) ? 8 : 4))) + (8) - 1) / (8)) *
2))
3339 DWARF2_ADDR_SIZE * 2)(((((global_options.x_dwarf_offset_size == 4 ? 4 : 12) + global_options
.x_dwarf_offset_size + 4) + ((((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) + (
8) - 1) / (8)) * 2) - 1) / ((((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) + (
8) - 1) / (8)) * 2)) * ((((((global_options.x_ix86_isa_flags &
(1UL << 58)) != 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags
& (1UL << 1)) != 0) ? 8 : 4))) + (8) - 1) / (8)) *
2))
\
3340 - DWARF_INITIAL_LENGTH_SIZE(global_options.x_dwarf_offset_size == 4 ? 4 : 12))
3341
3342/* Size of padding portion in the address range info. It must be
3343 aligned to twice the pointer size. */
3344#define DWARF_ARANGES_PAD_SIZE((((((global_options.x_dwarf_offset_size == 4 ? 4 : 12) + global_options
.x_dwarf_offset_size + 4) + ((((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) + (
8) - 1) / (8)) * 2) - 1) / ((((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) + (
8) - 1) / (8)) * 2)) * ((((((global_options.x_ix86_isa_flags &
(1UL << 58)) != 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags
& (1UL << 1)) != 0) ? 8 : 4))) + (8) - 1) / (8)) *
2)) - ((global_options.x_dwarf_offset_size == 4 ? 4 : 12) + global_options
.x_dwarf_offset_size + 4))
\
3345 (DWARF_ROUND (DWARF_INITIAL_LENGTH_SIZE + dwarf_offset_size + 4, \(((((global_options.x_dwarf_offset_size == 4 ? 4 : 12) + global_options
.x_dwarf_offset_size + 4) + ((((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) + (
8) - 1) / (8)) * 2) - 1) / ((((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) + (
8) - 1) / (8)) * 2)) * ((((((global_options.x_ix86_isa_flags &
(1UL << 58)) != 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags
& (1UL << 1)) != 0) ? 8 : 4))) + (8) - 1) / (8)) *
2))
3346 DWARF2_ADDR_SIZE * 2)(((((global_options.x_dwarf_offset_size == 4 ? 4 : 12) + global_options
.x_dwarf_offset_size + 4) + ((((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) + (
8) - 1) / (8)) * 2) - 1) / ((((((global_options.x_ix86_isa_flags
& (1UL << 58)) != 0) ? 32 : ((8) * (((global_options
.x_ix86_isa_flags & (1UL << 1)) != 0) ? 8 : 4))) + (
8) - 1) / (8)) * 2)) * ((((((global_options.x_ix86_isa_flags &
(1UL << 58)) != 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags
& (1UL << 1)) != 0) ? 8 : 4))) + (8) - 1) / (8)) *
2))
\
3347 - (DWARF_INITIAL_LENGTH_SIZE(global_options.x_dwarf_offset_size == 4 ? 4 : 12) + dwarf_offset_sizeglobal_options.x_dwarf_offset_size + 4))
3348
3349/* Use assembler line directives if available. */
3350#ifndef DWARF2_ASM_LINE_DEBUG_INFO
3351#ifdef HAVE_AS_DWARF2_DEBUG_LINE1
3352#define DWARF2_ASM_LINE_DEBUG_INFO 1
3353#else
3354#define DWARF2_ASM_LINE_DEBUG_INFO 0
3355#endif
3356#endif
3357
3358/* Use assembler views in line directives if available. */
3359#ifndef DWARF2_ASM_VIEW_DEBUG_INFO
3360#ifdef HAVE_AS_DWARF2_DEBUG_VIEW1
3361#define DWARF2_ASM_VIEW_DEBUG_INFO 1
3362#else
3363#define DWARF2_ASM_VIEW_DEBUG_INFO 0
3364#endif
3365#endif
3366
3367/* Return true if GCC configure detected assembler support for .loc. */
3368
3369bool
3370dwarf2out_default_as_loc_support (void)
3371{
3372 return DWARF2_ASM_LINE_DEBUG_INFO;
3373#if (GCC_VERSION(4 * 1000 + 2) >= 3000)
3374# undef DWARF2_ASM_LINE_DEBUG_INFO
3375# pragma GCC poison DWARF2_ASM_LINE_DEBUG_INFO
3376#endif
3377}
3378
3379/* Return true if GCC configure detected assembler support for views
3380 in .loc directives. */
3381
3382bool
3383dwarf2out_default_as_locview_support (void)
3384{
3385 return DWARF2_ASM_VIEW_DEBUG_INFO;
3386#if (GCC_VERSION(4 * 1000 + 2) >= 3000)
3387# undef DWARF2_ASM_VIEW_DEBUG_INFO
3388# pragma GCC poison DWARF2_ASM_VIEW_DEBUG_INFO
3389#endif
3390}
3391
3392/* A bit is set in ZERO_VIEW_P if we are using the assembler-supported
3393 view computation, and it refers to a view identifier for which we
3394 will not emit a label because it is known to map to a view number
3395 zero. We won't allocate the bitmap if we're not using assembler
3396 support for location views, but we have to make the variable
3397 visible for GGC and for code that will be optimized out for lack of
3398 support but that's still parsed and compiled. We could abstract it
3399 out with macros, but it's not worth it. */
3400static GTY(()) bitmap zero_view_p;
3401
3402/* Evaluate to TRUE iff N is known to identify the first location view
3403 at its PC. When not using assembler location view computation,
3404 that must be view number zero. Otherwise, ZERO_VIEW_P is allocated
3405 and views label numbers recorded in it are the ones known to be
3406 zero. */
3407#define ZERO_VIEW_P(N)((N) == (var_loc_view)0 || (N) == (var_loc_view)-1 || (zero_view_p
&& bitmap_bit_p (zero_view_p, (N))))
((N) == (var_loc_view)0 \
3408 || (N) == (var_loc_view)-1 \
3409 || (zero_view_p \
3410 && bitmap_bit_p (zero_view_p, (N))))
3411
3412/* Return true iff we're to emit .loc directives for the assembler to
3413 generate line number sections.
3414
3415 When we're not emitting views, all we need from the assembler is
3416 support for .loc directives.
3417
3418 If we are emitting views, we can only use the assembler's .loc
3419 support if it also supports views.
3420
3421 When the compiler is emitting the line number programs and
3422 computing view numbers itself, it resets view numbers at known PC
3423 changes and counts from that, and then it emits view numbers as
3424 literal constants in locviewlists. There are cases in which the
3425 compiler is not sure about PC changes, e.g. when extra alignment is
3426 requested for a label. In these cases, the compiler may not reset
3427 the view counter, and the potential PC advance in the line number
3428 program will use an opcode that does not reset the view counter
3429 even if the PC actually changes, so that compiler and debug info
3430 consumer can keep view numbers in sync.
3431
3432 When the compiler defers view computation to the assembler, it
3433 emits symbolic view numbers in locviewlists, with the exception of
3434 views known to be zero (forced resets, or reset after
3435 compiler-visible PC changes): instead of emitting symbols for
3436 these, we emit literal zero and assert the assembler agrees with
3437 the compiler's assessment. We could use symbolic views everywhere,
3438 instead of special-casing zero views, but then we'd be unable to
3439 optimize out locviewlists that contain only zeros. */
3440
3441static bool
3442output_asm_line_debug_info (void)
3443{
3444 return (dwarf2out_as_loc_supportglobal_options.x_dwarf2out_as_loc_support
3445 && (dwarf2out_as_locview_supportglobal_options.x_dwarf2out_as_locview_support
3446 || !debug_variable_location_viewsglobal_options.x_debug_variable_location_views));
3447}
3448
3449static bool asm_outputs_debug_line_str (void);
3450
3451/* Minimum line offset in a special line info. opcode.
3452 This value was chosen to give a reasonable range of values. */
3453#define DWARF_LINE_BASE-10 -10
3454
3455/* First special line opcode - leave room for the standard opcodes. */
3456#define DWARF_LINE_OPCODE_BASE((int)DW_LNS_set_isa + 1) ((int)DW_LNS_set_isa + 1)
3457
3458/* Range of line offsets in a special line info. opcode. */
3459#define DWARF_LINE_RANGE(254-((int)DW_LNS_set_isa + 1)+1) (254-DWARF_LINE_OPCODE_BASE((int)DW_LNS_set_isa + 1)+1)
3460
3461/* Flag that indicates the initial value of the is_stmt_start flag.
3462 In the present implementation, we do not mark any lines as
3463 the beginning of a source statement, because that information
3464 is not made available by the GCC front-end. */
3465#define DWARF_LINE_DEFAULT_IS_STMT_START1 1
3466
3467/* Maximum number of operations per instruction bundle. */
3468#ifndef DWARF_LINE_DEFAULT_MAX_OPS_PER_INSN1
3469#define DWARF_LINE_DEFAULT_MAX_OPS_PER_INSN1 1
3470#endif
3471
3472/* This location is used by calc_die_sizes() to keep track
3473 the offset of each DIE within the .debug_info section. */
3474static unsigned long next_die_offset;
3475
3476/* Record the root of the DIE's built for the current compilation unit. */
3477static GTY(()) dw_die_ref single_comp_unit_die;
3478
3479/* A list of type DIEs that have been separated into comdat sections. */
3480static GTY(()) comdat_type_node *comdat_type_list;
3481
3482/* A list of CU DIEs that have been separated. */
3483static GTY(()) limbo_die_node *cu_die_list;
3484
3485/* A list of DIEs with a NULL parent waiting to be relocated. */
3486static GTY(()) limbo_die_node *limbo_die_list;
3487
3488/* A list of DIEs for which we may have to generate
3489 DW_AT_{,MIPS_}linkage_name once their DECL_ASSEMBLER_NAMEs are set. */
3490static GTY(()) limbo_die_node *deferred_asm_name;
3491
3492struct dwarf_file_hasher : ggc_ptr_hash<dwarf_file_data>
3493{
3494 typedef const char *compare_type;
3495
3496 static hashval_t hash (dwarf_file_data *);
3497 static bool equal (dwarf_file_data *, const char *);
3498};
3499
3500/* Filenames referenced by this compilation unit. */
3501static GTY(()) hash_table<dwarf_file_hasher> *file_table;
3502
3503struct decl_die_hasher : ggc_ptr_hash<die_node>
3504{
3505 typedef tree compare_type;
3506
3507 static hashval_t hash (die_node *);
3508 static bool equal (die_node *, tree);
3509};
3510/* A hash table of references to DIE's that describe declarations.
3511 The key is a DECL_UID() which is a unique number identifying each decl. */
3512static GTY (()) hash_table<decl_die_hasher> *decl_die_table;
3513
3514struct GTY ((for_user)) variable_value_struct {
3515 unsigned int decl_id;
3516 vec<dw_die_ref, va_gc> *dies;
3517};
3518
3519struct variable_value_hasher : ggc_ptr_hash<variable_value_struct>
3520{
3521 typedef tree compare_type;
3522
3523 static hashval_t hash (variable_value_struct *);
3524 static bool equal (variable_value_struct *, tree);
3525};
3526/* A hash table of DIEs that contain DW_OP_GNU_variable_value with
3527 dw_val_class_decl_ref class, indexed by FUNCTION_DECLs which is
3528 DECL_CONTEXT of the referenced VAR_DECLs. */
3529static GTY (()) hash_table<variable_value_hasher> *variable_value_hash;
3530
3531struct block_die_hasher : ggc_ptr_hash<die_struct>
3532{
3533 static hashval_t hash (die_struct *);
3534 static bool equal (die_struct *, die_struct *);
3535};
3536
3537/* A hash table of references to DIE's that describe COMMON blocks.
3538 The key is DECL_UID() ^ die_parent. */
3539static GTY (()) hash_table<block_die_hasher> *common_block_die_table;
3540
3541typedef struct GTY(()) die_arg_entry_struct {
3542 dw_die_ref die;
3543 tree arg;
3544} die_arg_entry;
3545
3546
3547/* Node of the variable location list. */
3548struct GTY ((chain_next ("%h.next"))) var_loc_node {
3549 /* Either NOTE_INSN_VAR_LOCATION, or, for SRA optimized variables,
3550 EXPR_LIST chain. For small bitsizes, bitsize is encoded
3551 in mode of the EXPR_LIST node and first EXPR_LIST operand
3552 is either NOTE_INSN_VAR_LOCATION for a piece with a known
3553 location or NULL for padding. For larger bitsizes,
3554 mode is 0 and first operand is a CONCAT with bitsize
3555 as first CONCAT operand and NOTE_INSN_VAR_LOCATION resp.
3556 NULL as second operand. */
3557 rtx GTY (()) loc;
3558 const char * GTY (()) label;
3559 struct var_loc_node * GTY (()) next;
3560 var_loc_view view;
3561};
3562
3563/* Variable location list. */
3564struct GTY ((for_user)) var_loc_list_def {
3565 struct var_loc_node * GTY (()) first;
3566
3567 /* Pointer to the last but one or last element of the
3568 chained list. If the list is empty, both first and
3569 last are NULL, if the list contains just one node
3570 or the last node certainly is not redundant, it points
3571 to the last node, otherwise points to the last but one.
3572 Do not mark it for GC because it is marked through the chain. */
3573 struct var_loc_node * GTY ((skip ("%h"))) last;
3574
3575 /* Pointer to the last element before section switch,
3576 if NULL, either sections weren't switched or first
3577 is after section switch. */
3578 struct var_loc_node * GTY ((skip ("%h"))) last_before_switch;
3579
3580 /* DECL_UID of the variable decl. */
3581 unsigned int decl_id;
3582};
3583typedef struct var_loc_list_def var_loc_list;
3584
3585/* Call argument location list. */
3586struct GTY ((chain_next ("%h.next"))) call_arg_loc_node {
3587 rtx GTY (()) call_arg_loc_note;
3588 const char * GTY (()) label;
3589 tree GTY (()) block;
3590 bool tail_call_p;
3591 rtx GTY (()) symbol_ref;
3592 struct call_arg_loc_node * GTY (()) next;
3593};
3594
3595
3596struct decl_loc_hasher : ggc_ptr_hash<var_loc_list>
3597{
3598 typedef const_tree compare_type;
3599
3600 static hashval_t hash (var_loc_list *);
3601 static bool equal (var_loc_list *, const_tree);
3602};
3603
3604/* Table of decl location linked lists. */
3605static GTY (()) hash_table<decl_loc_hasher> *decl_loc_table;
3606
3607/* Head and tail of call_arg_loc chain. */
3608static GTY (()) struct call_arg_loc_node *call_arg_locations;
3609static struct call_arg_loc_node *call_arg_loc_last;
3610
3611/* Number of call sites in the current function. */
3612static int call_site_count = -1;
3613/* Number of tail call sites in the current function. */
3614static int tail_call_site_count = -1;
3615
3616/* A cached location list. */
3617struct GTY ((for_user)) cached_dw_loc_list_def {
3618 /* The DECL_UID of the decl that this entry describes. */
3619 unsigned int decl_id;
3620
3621 /* The cached location list. */
3622 dw_loc_list_ref loc_list;
3623};
3624typedef struct cached_dw_loc_list_def cached_dw_loc_list;
3625
3626struct dw_loc_list_hasher : ggc_ptr_hash<cached_dw_loc_list>
3627{
3628
3629 typedef const_tree compare_type;
3630
3631 static hashval_t hash (cached_dw_loc_list *);
3632 static bool equal (cached_dw_loc_list *, const_tree);
3633};
3634
3635/* Table of cached location lists. */
3636static GTY (()) hash_table<dw_loc_list_hasher> *cached_dw_loc_list_table;
3637
3638/* A vector of references to DIE's that are uniquely identified by their tag,
3639 presence/absence of children DIE's, and list of attribute/value pairs. */
3640static GTY(()) vec<dw_die_ref, va_gc> *abbrev_die_table;
3641
3642/* A hash map to remember the stack usage for DWARF procedures. The value
3643 stored is the stack size difference between before the DWARF procedure
3644 invokation and after it returned. In other words, for a DWARF procedure
3645 that consumes N stack slots and that pushes M ones, this stores M - N. */
3646static hash_map<dw_die_ref, int> *dwarf_proc_stack_usage_map;
3647
3648/* A global counter for generating labels for line number data. */
3649static unsigned int line_info_label_num;
3650
3651/* The current table to which we should emit line number information
3652 for the current function. This will be set up at the beginning of
3653 assembly for the function. */
3654static GTY(()) dw_line_info_table *cur_line_info_table;
3655
3656/* The two default tables of line number info. */
3657static GTY(()) dw_line_info_table *text_section_line_info;
3658static GTY(()) dw_line_info_table *cold_text_section_line_info;
3659
3660/* The set of all non-default tables of line number info. */
3661static GTY(()) vec<dw_line_info_table *, va_gc> *separate_line_info;
3662
3663/* A flag to tell pubnames/types export if there is an info section to
3664 refer to. */
3665static bool info_section_emitted;
3666
3667/* A pointer to the base of a table that contains a list of publicly
3668 accessible names. */
3669static GTY (()) vec<pubname_entry, va_gc> *pubname_table;
3670
3671/* A pointer to the base of a table that contains a list of publicly
3672 accessible types. */
3673static GTY (()) vec<pubname_entry, va_gc> *pubtype_table;
3674
3675/* A pointer to the base of a table that contains a list of macro
3676 defines/undefines (and file start/end markers). */
3677static GTY (()) vec<macinfo_entry, va_gc> *macinfo_table;
3678
3679/* True if .debug_macinfo or .debug_macros section is going to be
3680 emitted. */
3681#define have_macinfo((!0 || 0) && global_options.x_debug_info_level >=
DINFO_LEVEL_VERBOSE && !macinfo_table->is_empty (
))
\
3682 ((!XCOFF_DEBUGGING_INFO0 || HAVE_XCOFF_DWARF_EXTRAS0) \
3683 && debug_info_levelglobal_options.x_debug_info_level >= DINFO_LEVEL_VERBOSE \
3684 && !macinfo_table->is_empty ())
3685
3686/* Vector of dies for which we should generate .debug_ranges info. */
3687static GTY (()) vec<dw_ranges, va_gc> *ranges_table;
3688
3689/* Vector of pairs of labels referenced in ranges_table. */
3690static GTY (()) vec<dw_ranges_by_label, va_gc> *ranges_by_label;
3691
3692/* Whether we have location lists that need outputting */
3693static GTY(()) bool have_location_lists;
3694
3695/* Unique label counter. */
3696static GTY(()) unsigned int loclabel_num;
3697
3698/* Unique label counter for point-of-call tables. */
3699static GTY(()) unsigned int poc_label_num;
3700
3701/* The last file entry emitted by maybe_emit_file(). */
3702static GTY(()) struct dwarf_file_data * last_emitted_file;
3703
3704/* Number of internal labels generated by gen_internal_sym(). */
3705static GTY(()) int label_num;
3706
3707static GTY(()) vec<die_arg_entry, va_gc> *tmpl_value_parm_die_table;
3708
3709/* Instances of generic types for which we need to generate debug
3710 info that describe their generic parameters and arguments. That
3711 generation needs to happen once all types are properly laid out so
3712 we do it at the end of compilation. */
3713static GTY(()) vec<tree, va_gc> *generic_type_instances;
3714
3715/* Offset from the "steady-state frame pointer" to the frame base,
3716 within the current function. */
3717static poly_int64 frame_pointer_fb_offset;
3718static bool frame_pointer_fb_offset_valid;
3719
3720static vec<dw_die_ref> base_types;
3721
3722/* Flags to represent a set of attribute classes for attributes that represent
3723 a scalar value (bounds, pointers, ...). */
3724enum dw_scalar_form
3725{
3726 dw_scalar_form_constant = 0x01,
3727 dw_scalar_form_exprloc = 0x02,
3728 dw_scalar_form_reference = 0x04
3729};
3730
3731/* Forward declarations for functions defined in this file. */
3732
3733static int is_pseudo_reg (const_rtx);
3734static tree type_main_variant (tree);
3735static int is_tagged_type (const_tree);
3736static const char *dwarf_tag_name (unsigned);
3737static const char *dwarf_attr_name (unsigned);
3738static const char *dwarf_form_name (unsigned);
3739static tree decl_ultimate_origin (const_tree);
3740static tree decl_class_context (tree);
3741static void add_dwarf_attr (dw_die_ref, dw_attr_node *);
3742static inline unsigned int AT_index (dw_attr_node *);
3743static void add_AT_flag (dw_die_ref, enum dwarf_attribute, unsigned);
3744static inline unsigned AT_flag (dw_attr_node *);
3745static void add_AT_int (dw_die_ref, enum dwarf_attribute, HOST_WIDE_INTlong);
3746static void add_AT_unsigned (dw_die_ref, enum dwarf_attribute, unsigned HOST_WIDE_INTlong);
3747static void add_AT_double (dw_die_ref, enum dwarf_attribute,
3748 HOST_WIDE_INTlong, unsigned HOST_WIDE_INTlong);
3749static inline void add_AT_vec (dw_die_ref, enum dwarf_attribute, unsigned int,
3750 unsigned int, unsigned char *);
3751static void add_AT_data8 (dw_die_ref, enum dwarf_attribute, unsigned char *);
3752static void add_AT_string (dw_die_ref, enum dwarf_attribute, const char *);
3753static inline const char *AT_string (dw_attr_node *);
3754static enum dwarf_form AT_string_form (dw_attr_node *);
3755static void add_AT_die_ref (dw_die_ref, enum dwarf_attribute, dw_die_ref);
3756static void add_AT_specification (dw_die_ref, dw_die_ref);
3757static inline dw_die_ref AT_ref (dw_attr_node *);
3758static inline int AT_ref_external (dw_attr_node *);
3759static inline void set_AT_ref_external (dw_attr_node *, int);
3760static void add_AT_loc (dw_die_ref, enum dwarf_attribute, dw_loc_descr_ref);
3761static void add_AT_loc_list (dw_die_ref, enum dwarf_attribute,
3762 dw_loc_list_ref);
3763static inline dw_loc_list_ref AT_loc_list (dw_attr_node *);
3764static void add_AT_view_list (dw_die_ref, enum dwarf_attribute);
3765static inline dw_loc_list_ref AT_loc_list (dw_attr_node *);
3766static addr_table_entry *add_addr_table_entry (void *, enum ate_kind);
3767static void remove_addr_table_entry (addr_table_entry *);
3768static void add_AT_addr (dw_die_ref, enum dwarf_attribute, rtx, bool);
3769static inline rtx AT_addr (dw_attr_node *);
3770static void add_AT_symview (dw_die_ref, enum dwarf_attribute, const char *);
3771static void add_AT_lbl_id (dw_die_ref, enum dwarf_attribute, const char *);
3772static void add_AT_lineptr (dw_die_ref, enum dwarf_attribute, const char *);
3773static void add_AT_macptr (dw_die_ref, enum dwarf_attribute, const char *);
3774static void add_AT_range_list (dw_die_ref, enum dwarf_attribute,
3775 unsigned long, bool);
3776static inline const char *AT_lbl (dw_attr_node *);
3777static const char *get_AT_low_pc (dw_die_ref);
3778static bool is_c (void);
3779static bool is_cxx (void);
3780static bool is_cxx (const_tree);
3781static bool is_fortran (void);
3782static bool is_ada (void);
3783static bool remove_AT (dw_die_ref, enum dwarf_attribute);
3784static void remove_child_TAG (dw_die_ref, enum dwarf_tag);
3785static void add_child_die (dw_die_ref, dw_die_ref);
3786static dw_die_ref new_die (enum dwarf_tag, dw_die_ref, tree);
3787static dw_die_ref strip_naming_typedef (tree, dw_die_ref);
3788static dw_die_ref lookup_type_die_strip_naming_typedef (tree);
3789static void equate_type_number_to_die (tree, dw_die_ref);
3790static var_loc_list *lookup_decl_loc (const_tree);
3791static void equate_decl_number_to_die (tree, dw_die_ref);
3792static struct var_loc_node *add_var_loc_to_decl (tree, rtx, const char *, var_loc_view);
3793static void print_spaces (FILE *);
3794static void print_die (dw_die_ref, FILE *);
3795static void loc_checksum (dw_loc_descr_ref, struct md5_ctx *);
3796static void attr_checksum (dw_attr_node *, struct md5_ctx *, int *);
3797static void die_checksum (dw_die_ref, struct md5_ctx *, int *);
3798static void checksum_sleb128 (HOST_WIDE_INTlong, struct md5_ctx *);
3799static void checksum_uleb128 (unsigned HOST_WIDE_INTlong, struct md5_ctx *);
3800static void loc_checksum_ordered (dw_loc_descr_ref, struct md5_ctx *);
3801static void attr_checksum_ordered (enum dwarf_tag, dw_attr_node *,
3802 struct md5_ctx *, int *);
3803struct checksum_attributes;
3804static void collect_checksum_attributes (struct checksum_attributes *, dw_die_ref);
3805static void die_checksum_ordered (dw_die_ref, struct md5_ctx *, int *);
3806static void checksum_die_context (dw_die_ref, struct md5_ctx *);
3807static void generate_type_signature (dw_die_ref, comdat_type_node *);
3808static int same_loc_p (dw_loc_descr_ref, dw_loc_descr_ref, int *);
3809static int same_dw_val_p (const dw_val_node *, const dw_val_node *, int *);
3810static int same_attr_p (dw_attr_node *, dw_attr_node *, int *);
3811static int same_die_p (dw_die_ref, dw_die_ref, int *);
3812static int is_type_die (dw_die_ref);
3813static inline bool is_template_instantiation (dw_die_ref);
3814static int is_declaration_die (dw_die_ref);
3815static int should_move_die_to_comdat (dw_die_ref);
3816static dw_die_ref clone_as_declaration (dw_die_ref);
3817static dw_die_ref clone_die (dw_die_ref);
3818static dw_die_ref clone_tree (dw_die_ref);
3819static dw_die_ref copy_declaration_context (dw_die_ref, dw_die_ref);
3820static void generate_skeleton_ancestor_tree (skeleton_chain_node *);
3821static void generate_skeleton_bottom_up (skeleton_chain_node *);
3822static dw_die_ref generate_skeleton (dw_die_ref);
3823static dw_die_ref remove_child_or_replace_with_skeleton (dw_die_ref,
3824 dw_die_ref,
3825 dw_die_ref);
3826static void break_out_comdat_types (dw_die_ref);
3827static void copy_decls_for_unworthy_types (dw_die_ref);
3828
3829static void add_sibling_attributes (dw_die_ref);
3830static void output_location_lists (dw_die_ref);
3831static int constant_size (unsigned HOST_WIDE_INTlong);
3832static unsigned long size_of_die (dw_die_ref);
3833static void calc_die_sizes (dw_die_ref);
3834static void calc_base_type_die_sizes (void);
3835static void mark_dies (dw_die_ref);
3836static void unmark_dies (dw_die_ref);
3837static void unmark_all_dies (dw_die_ref);
3838static unsigned long size_of_pubnames (vec<pubname_entry, va_gc> *);
3839static unsigned long size_of_aranges (void);
3840static enum dwarf_form value_format (dw_attr_node *);
3841static void output_value_format (dw_attr_node *);
3842static void output_abbrev_section (void);
3843static void output_die_abbrevs (unsigned long, dw_die_ref);
3844static void output_die (dw_die_ref);
3845static void output_compilation_unit_header (enum dwarf_unit_type);
3846static void output_comp_unit (dw_die_ref, int, const unsigned char *);
3847static void output_comdat_type_unit (comdat_type_node *, bool);
3848static const char *dwarf2_name (tree, int);
3849static void add_pubname (tree, dw_die_ref);
3850static void add_enumerator_pubname (const char *, dw_die_ref);
3851static void add_pubname_string (const char *, dw_die_ref);
3852static void add_pubtype (tree, dw_die_ref);
3853static void output_pubnames (vec<pubname_entry, va_gc> *);
3854static void output_aranges (void);
3855static unsigned int add_ranges (const_tree, bool = false);
3856static void add_ranges_by_labels (dw_die_ref, const char *, const char *,
3857 bool *, bool);
3858static void output_ranges (void);
3859static dw_line_info_table *new_line_info_table (void);
3860static void output_line_info (bool);
3861static void output_file_names (void);
3862static int is_base_type (tree);
3863static dw_die_ref subrange_type_die (tree, tree, tree, tree, dw_die_ref);
3864static int decl_quals (const_tree);
3865static dw_die_ref modified_type_die (tree, int, bool, dw_die_ref);
3866static dw_die_ref generic_parameter_die (tree, tree, bool, dw_die_ref);
3867static dw_die_ref template_parameter_pack_die (tree, tree, dw_die_ref);
3868static unsigned int debugger_reg_number (const_rtx);
3869static void add_loc_descr_op_piece (dw_loc_descr_ref *, int);
3870static dw_loc_descr_ref reg_loc_descriptor (rtx, enum var_init_status);
3871static dw_loc_descr_ref one_reg_loc_descriptor (unsigned int,
3872 enum var_init_status);
3873static dw_loc_descr_ref multiple_reg_loc_descriptor (rtx, rtx,
3874 enum var_init_status);
3875static dw_loc_descr_ref based_loc_descr (rtx, poly_int64,
3876 enum var_init_status);
3877static int is_based_loc (const_rtx);
3878static bool resolve_one_addr (rtx *);
3879static dw_loc_descr_ref concat_loc_descriptor (rtx, rtx,
3880 enum var_init_status);
3881static dw_loc_descr_ref loc_descriptor (rtx, machine_mode mode,
3882 enum var_init_status);
3883struct loc_descr_context;
3884static void add_loc_descr_to_each (dw_loc_list_ref list, dw_loc_descr_ref ref);
3885static void add_loc_list (dw_loc_list_ref *ret, dw_loc_list_ref list);
3886static dw_loc_list_ref loc_list_from_tree (tree, int,
3887 struct loc_descr_context *);
3888static dw_loc_descr_ref loc_descriptor_from_tree (tree, int,
3889 struct loc_descr_context *);
3890static tree field_type (const_tree);
3891static unsigned int simple_type_align_in_bits (const_tree);
3892static unsigned int simple_decl_align_in_bits (const_tree);
3893static unsigned HOST_WIDE_INTlong simple_type_size_in_bits (const_tree);
3894struct vlr_context;
3895static dw_loc_descr_ref field_byte_offset (const_tree, struct vlr_context *,
3896 HOST_WIDE_INTlong *);
3897static void add_AT_location_description (dw_die_ref, enum dwarf_attribute,
3898 dw_loc_list_ref);
3899static void add_data_member_location_attribute (dw_die_ref, tree,
3900 struct vlr_context *);
3901static bool add_const_value_attribute (dw_die_ref, machine_mode, rtx);
3902static void insert_int (HOST_WIDE_INTlong, unsigned, unsigned char *);
3903static void insert_wide_int (const wide_int &, unsigned char *, int);
3904static unsigned insert_float (const_rtx, unsigned char *);
3905static rtx rtl_for_decl_location (tree);
3906static bool add_location_or_const_value_attribute (dw_die_ref, tree, bool);
3907static bool tree_add_const_value_attribute (dw_die_ref, tree);
3908static bool tree_add_const_value_attribute_for_decl (dw_die_ref, tree);
3909static void add_desc_attribute (dw_die_ref, tree);
3910static void add_gnat_descriptive_type_attribute (dw_die_ref, tree, dw_die_ref);
3911static void add_comp_dir_attribute (dw_die_ref);
3912static void add_scalar_info (dw_die_ref, enum dwarf_attribute, tree, int,
3913 struct loc_descr_context *);
3914static void add_bound_info (dw_die_ref, enum dwarf_attribute, tree,
3915 struct loc_descr_context *);
3916static void add_subscript_info (dw_die_ref, tree, bool);
3917static void add_byte_size_attribute (dw_die_ref, tree);
3918static void add_alignment_attribute (dw_die_ref, tree);
3919static void add_bit_offset_attribute (dw_die_ref, tree);
3920static void add_bit_size_attribute (dw_die_ref, tree);
3921static void add_prototyped_attribute (dw_die_ref, tree);
3922static void add_abstract_origin_attribute (dw_die_ref, tree);
3923static void add_pure_or_virtual_attribute (dw_die_ref, tree);
3924static void add_src_coords_attributes (dw_die_ref, tree);
3925static void add_name_and_src_coords_attributes (dw_die_ref, tree, bool = false);
3926static void add_discr_value (dw_die_ref, dw_discr_value *);
3927static void add_discr_list (dw_die_ref, dw_discr_list_ref);
3928static inline dw_discr_list_ref AT_discr_list (dw_attr_node *);
3929static dw_die_ref scope_die_for (tree, dw_die_ref);
3930static inline int local_scope_p (dw_die_ref);
3931static inline int class_scope_p (dw_die_ref);
3932static inline int class_or_namespace_scope_p (dw_die_ref);
3933static void add_type_attribute (dw_die_ref, tree, int, bool, dw_die_ref);
3934static void add_calling_convention_attribute (dw_die_ref, tree);
3935static const char *type_tag (const_tree);
3936static tree member_declared_type (const_tree);
3937#if 0
3938static const char *decl_start_label (tree);
3939#endif
3940static void gen_array_type_die (tree, dw_die_ref);
3941static void gen_descr_array_type_die (tree, struct array_descr_info *, dw_die_ref);
3942#if 0
3943static void gen_entry_point_die (tree, dw_die_ref);
3944#endif
3945static dw_die_ref gen_enumeration_type_die (tree, dw_die_ref);
3946static dw_die_ref gen_formal_parameter_die (tree, tree, bool, dw_die_ref);
3947static dw_die_ref gen_formal_parameter_pack_die (tree, tree, dw_die_ref, tree*);
3948static void gen_unspecified_parameters_die (tree, dw_die_ref);
3949static void gen_formal_types_die (tree, dw_die_ref);
3950static void gen_subprogram_die (tree, dw_die_ref);
3951static void gen_variable_die (tree, tree, dw_die_ref);
3952static void gen_const_die (tree, dw_die_ref);
3953static void gen_label_die (tree, dw_die_ref);
3954static void gen_lexical_block_die (tree, dw_die_ref);
3955static void gen_inlined_subroutine_die (tree, dw_die_ref);
3956static void gen_field_die (tree, struct vlr_context *, dw_die_ref);
3957static void gen_ptr_to_mbr_type_die (tree, dw_die_ref);
3958static dw_die_ref gen_compile_unit_die (const char *);
3959static void gen_inheritance_die (tree, tree, tree, dw_die_ref);
3960static void gen_member_die (tree, dw_die_ref);
3961static void gen_struct_or_union_type_die (tree, dw_die_ref,
3962 enum debug_info_usage);
3963static void gen_subroutine_type_die (tree, dw_die_ref);
3964static void gen_typedef_die (tree, dw_die_ref);
3965static void gen_type_die (tree, dw_die_ref);
3966static void gen_block_die (tree, dw_die_ref);
3967static void decls_for_scope (tree, dw_die_ref, bool = true);
3968static bool is_naming_typedef_decl (const_tree);
3969static inline dw_die_ref get_context_die (tree);
3970static void gen_namespace_die (tree, dw_die_ref);
3971static dw_die_ref gen_namelist_decl (tree, dw_die_ref, tree);
3972static dw_die_ref gen_decl_die (tree, tree, struct vlr_context *, dw_die_ref);
3973static dw_die_ref force_decl_die (tree);
3974static dw_die_ref force_type_die (tree);
3975static dw_die_ref setup_namespace_context (tree, dw_die_ref);
3976static dw_die_ref declare_in_namespace (tree, dw_die_ref);
3977static struct dwarf_file_data * lookup_filename (const char *);
3978static void retry_incomplete_types (void);
3979static void gen_type_die_for_member (tree, tree, dw_die_ref);
3980static void gen_generic_params_dies (tree);
3981static void gen_tagged_type_die (tree, dw_die_ref, enum debug_info_usage);
3982static void gen_type_die_with_usage (tree, dw_die_ref, enum debug_info_usage);
3983static void splice_child_die (dw_die_ref, dw_die_ref);
3984static int file_info_cmp (const void *, const void *);
3985static dw_loc_list_ref new_loc_list (dw_loc_descr_ref, const char *, var_loc_view,
3986 const char *, var_loc_view, const char *);
3987static void output_loc_list (dw_loc_list_ref);
3988static char *gen_internal_sym (const char *);
3989static bool want_pubnames (void);
3990
3991static void prune_unmark_dies (dw_die_ref);
3992static void prune_unused_types_mark_generic_parms_dies (dw_die_ref);
3993static void prune_unused_types_mark (dw_die_ref, int);
3994static void prune_unused_types_walk (dw_die_ref);
3995static void prune_unused_types_walk_attribs (dw_die_ref);
3996static void prune_unused_types_prune (dw_die_ref);
3997static void prune_unused_types (void);
3998static int maybe_emit_file (struct dwarf_file_data *fd);
3999static inline const char *AT_vms_delta1 (dw_attr_node *);
4000static inline const char *AT_vms_delta2 (dw_attr_node *);
4001#if VMS_DEBUGGING_INFO
4002static inline void add_AT_vms_delta (dw_die_ref, enum dwarf_attribute,
4003 const char *, const char *);
4004#endif
4005static void append_entry_to_tmpl_value_parm_die_table (dw_die_ref, tree);
4006static void gen_remaining_tmpl_value_param_die_attribute (void);
4007static bool generic_type_p (tree);
4008static void schedule_generic_params_dies_gen (tree t);
4009static void gen_scheduled_generic_parms_dies (void);
4010static void resolve_variable_values (void);
4011
4012static const char *comp_dir_string (void);
4013
4014static void hash_loc_operands (dw_loc_descr_ref, inchash::hash &);
4015
4016/* enum for tracking thread-local variables whose address is really an offset
4017 relative to the TLS pointer, which will need link-time relocation, but will
4018 not need relocation by the DWARF consumer. */
4019
4020enum dtprel_bool
4021{
4022 dtprel_false = 0,
4023 dtprel_true = 1
4024};
4025
4026/* Return the operator to use for an address of a variable. For dtprel_true, we
4027 use DW_OP_const*. For regular variables, which need both link-time
4028 relocation and consumer-level relocation (e.g., to account for shared objects
4029 loaded at a random address), we use DW_OP_addr*. */
4030
4031static inline enum dwarf_location_atom
4032dw_addr_op (enum dtprel_bool dtprel)
4033{
4034 if (dtprel == dtprel_true)
4035 return (dwarf_split_debug_infoglobal_options.x_dwarf_split_debug_info ? dwarf_OP (DW_OP_constx)
4036 : (DWARF2_ADDR_SIZE(((((global_options.x_ix86_isa_flags & (1UL << 58))
!= 0) ? 32 : ((8) * (((global_options.x_ix86_isa_flags &
(1UL << 1)) != 0) ? 8 : 4))) + (8) - 1) / (8))
== 4 ? DW_OP_const4u : DW_OP_const8u));
4037 else
4038 return dwarf_split_debug_infoglobal_options.x_dwarf_split_debug_info ? dwarf_OP (DW_OP_addrx) : DW_OP_addr;
4039}
4040
4041/* Return a pointer to a newly allocated address location description. If
4042 dwarf_split_debug_info is true, then record the address with the appropriate
4043 relocation. */
4044static inline dw_loc_descr_ref
4045new_addr_loc_descr (rtx addr, enum dtprel_bool dtprel)
4046{
4047 dw_loc_descr_ref ref = new_loc_descr (dw_addr_op (dtprel), 0, 0);
4048
4049 ref->dw_loc_oprnd1.val_class = dw_val_class_addr;
4050 ref->dw_loc_oprnd1.v.val_addr = addr;
4051 ref->dtprel = dtprel;
4052 if (dwarf_split_debug_infoglobal_options.x_dwarf_split_debug_info)
4053 ref->dw_loc_oprnd1.val_entry
4054 = add_addr_table_entry (addr,
4055 dtprel ? ate_kind_rtx_dtprel : ate_kind_rtx);
4056 else
4057 ref->dw_loc_oprnd1.val_entry = NULLnullptr;
4058
4059 return ref;
4060}
4061
4062/* Section names used to hold DWARF debugging information. */
4063
4064#ifndef DEBUG_INFO_SECTION".debug_info"
4065#define DEBUG_INFO_SECTION".debug_info" ".debug_info"
4066#endif
4067#ifndef DEBUG_DWO_INFO_SECTION".debug_info.dwo"
4068#define DEBUG_DWO_INFO_SECTION".debug_info.dwo" ".debug_info.dwo"
4069#endif
4070#ifndef DEBUG_LTO_INFO_SECTION".gnu.debuglto_.debug_info"
4071#define DEBUG_LTO_INFO_SECTION".gnu.debuglto_.debug_info" ".gnu.debuglto_.debug_info"
4072#endif
4073#ifndef DEBUG_LTO_DWO_INFO_SECTION".gnu.debuglto_.debug_info.dwo"
4074#define DEBUG_LTO_DWO_INFO_SECTION".gnu.debuglto_.debug_info.dwo" ".gnu.debuglto_.debug_info.dwo"
4075#endif
4076#ifndef DEBUG_ABBREV_SECTION".debug_abbrev"
4077#define DEBUG_ABBREV_SECTION".debug_abbrev" ".debug_abbrev"
4078#endif
4079#ifndef DEBUG_LTO_ABBREV_SECTION".gnu.debuglto_.debug_abbrev"
4080#define DEBUG_LTO_ABBREV_SECTION".gnu.debuglto_.debug_abbrev" ".gnu.debuglto_.debug_abbrev"
4081#endif
4082#ifndef DEBUG_DWO_ABBREV_SECTION".debug_abbrev.dwo"
4083#define DEBUG_DWO_ABBREV_SECTION".debug_abbrev.dwo" ".debug_abbrev.dwo"
4084#endif
4085#ifndef DEBUG_LTO_DWO_ABBREV_SECTION".gnu.debuglto_.debug_abbrev.dwo"
4086#define DEBUG_LTO_DWO_ABBREV_SECTION".gnu.debuglto_.debug_abbrev.dwo" ".gnu.debuglto_.debug_abbrev.dwo"
4087#endif
4088#ifndef DEBUG_ARANGES_SECTION".debug_aranges"
4089#define DEBUG_ARANGES_SECTION".debug_aranges" ".debug_aranges"
4090#endif
4091#ifndef DEBUG_ADDR_SECTION".debug_addr"
4092#define DEBUG_ADDR_SECTION".debug_addr" ".debug_addr"
4093#endif
4094#ifndef DEBUG_MACINFO_SECTION".debug_macinfo"
4095#define DEBUG_MACINFO_SECTION".debug_macinfo" ".debug_macinfo"
4096#endif
4097#ifndef DEBUG_LTO_MACINFO_SECTION".gnu.debuglto_.debug_macinfo"
4098#define DEBUG_LTO_MACINFO_SECTION".gnu.debuglto_.debug_macinfo" ".gnu.debuglto_.debug_macinfo"
4099#endif
4100#ifndef DEBUG_DWO_MACINFO_SECTION".debug_macinfo.dwo"
4101#define DEBUG_DWO_MACINFO_SECTION".debug_macinfo.dwo" ".debug_macinfo.dwo"
4102#endif
4103#ifndef DEBUG_LTO_DWO_MACINFO_SECTION".gnu.debuglto_.debug_macinfo.dwo"
4104#define DEBUG_LTO_DWO_MACINFO_SECTION".gnu.debuglto_.debug_macinfo.dwo" ".gnu.debuglto_.debug_macinfo.dwo"
4105#endif
4106#ifndef DEBUG_MACRO_SECTION".debug_macro"
4107#define DEBUG_MACRO_SECTION".debug_macro" ".debug_macro"
4108#endif
4109#ifndef DEBUG_LTO_MACRO_SECTION".gnu.debuglto_.debug_macro"
4110#define DEBUG_LTO_MACRO_SECTION".gnu.debuglto_.debug_macro" ".gnu.debuglto_.debug_macro"
4111#endif
4112#ifndef DEBUG_DWO_MACRO_SECTION".debug_macro.dwo"
4113#define DEBUG_DWO_MACRO_SECTION".debug_macro.dwo" ".debug_macro.dwo"
4114#endif
4115#ifndef DEBUG_LTO_DWO_MACRO_SECTION".gnu.debuglto_.debug_macro.dwo"
4116#define DEBUG_LTO_DWO_MACRO_SECTION".gnu.debuglto_.debug_macro.dwo" ".gnu.debuglto_.debug_macro.dwo"
4117#endif
4118#ifndef DEBUG_LINE_SECTION".debug_line"
4119#define DEBUG_LINE_SECTION".debug_line" ".debug_line"
4120#endif
4121#ifndef DEBUG_LTO_LINE_SECTION".gnu.debuglto_.debug_line"
4122#define DEBUG_LTO_LINE_SECTION".gnu.debuglto_.debug_line" ".gnu.debuglto_.debug_line"
4123#endif
4124#ifndef DEBUG_DWO_LINE_SECTION".debug_line.dwo"
4125#define DEBUG_DWO_LINE_SECTION".debug_line.dwo" ".debug_line.dwo"
4126#endif
4127#ifndef DEBUG_LTO_DWO_LINE_SECTION".gnu.debuglto_.debug_line.dwo"
4128#define DEBUG_LTO_DWO_LINE_SECTION".gnu.debuglto_.debug_line.dwo" ".gnu.debuglto_.debug_line.dwo"
4129#endif
4130#ifndef DEBUG_LOC_SECTION".debug_loc"
4131#define DEBUG_LOC_SECTION".debug_loc" ".debug_loc"
4132#endif
4133#ifndef DEBUG_DWO_LOC_SECTION".debug_loc.dwo"
4134#define DEBUG_DWO_LOC_SECTION".debug_loc.dwo" ".debug_loc.dwo"
4135#endif
4136#ifndef DEBUG_LOCLISTS_SECTION".debug_loclists"
4137#define DEBUG_LOCLISTS_SECTION".debug_loclists" ".debug_loclists"
4138#endif
4139#ifndef DEBUG_DWO_LOCLISTS_SECTION".debug_loclists.dwo"
4140#define DEBUG_DWO_LOCLISTS_SECTION".debug_loclists.dwo" ".debug_loclists.dwo"
4141#endif
4142#ifndef DEBUG_PUBNAMES_SECTION((global_options.x_debug_generate_pub_sections == 2) ? ".debug_gnu_pubnames"
: ".debug_pubnames")
4143#define DEBUG_PUBNAMES_SECTION((global_options.x_debug_generate_pub_sections == 2) ? ".debug_gnu_pubnames"
: ".debug_pubnames")
\
4144 ((debug_generate_pub_sectionsglobal_options.x_debug_generate_pub_sections == 2) \
4145 ? ".debug_gnu_pubnames" : ".debug_pubnames")
4146#endif
4147#ifndef DEBUG_PUBTYPES_SECTION((global_options.x_debug_generate_pub_sections == 2) ? ".debug_gnu_pubtypes"
: ".debug_pubtypes")
4148#define DEBUG_PUBTYPES_SECTION((global_options.x_debug_generate_pub_sections == 2) ? ".debug_gnu_pubtypes"
: ".debug_pubtypes")
\
4149 ((debug_generate_pub_sectionsglobal_options.x_debug_generate_pub_sections == 2) \
4150 ? ".debug_gnu_pubtypes" : ".debug_pubtypes")
4151#endif
4152#ifndef DEBUG_STR_OFFSETS_SECTION".debug_str_offsets"
4153#define DEBUG_STR_OFFSETS_SECTION".debug_str_offsets" ".debug_str_offsets"
4154#endif
4155#ifndef DEBUG_DWO_STR_OFFSETS_SECTION".debug_str_offsets.dwo"
4156#define DEBUG_DWO_STR_OFFSETS_SECTION".debug_str_offsets.dwo" ".debug_str_offsets.dwo"
4157#endif
4158#ifndef DEBUG_LTO_DWO_STR_OFFSETS_SECTION".gnu.debuglto_.debug_str_offsets.dwo"
4159#define DEBUG_LTO_DWO_STR_OFFSETS_SECTION".gnu.debuglto_.debug_str_offsets.dwo" ".gnu.debuglto_.debug_str_offsets.dwo"
4160#endif
4161#ifndef DEBUG_STR_SECTION".debug_str"
4162#define DEBUG_STR_SECTION".debug_str" ".debug_str"
4163#endif
4164#ifndef DEBUG_LTO_STR_SECTION".gnu.debuglto_.debug_str"
4165#define DEBUG_LTO_STR_SECTION".gnu.debuglto_.debug_str" ".gnu.debuglto_.debug_str"
4166#endif
4167#ifndef DEBUG_STR_DWO_SECTION".debug_str.dwo"
4168#define DEBUG_STR_DWO_SECTION".debug_str.dwo" ".debug_str.dwo"
4169#endif
4170#ifndef DEBUG_LTO_STR_DWO_SECTION".gnu.debuglto_.debug_str.dwo"
4171#define DEBUG_LTO_STR_DWO_SECTION".gnu.debuglto_.debug_str.dwo" ".gnu.debuglto_.debug_str.dwo"
4172#endif
4173#ifndef DEBUG_RANGES_SECTION".debug_ranges"
4174#define DEBUG_RANGES_SECTION".debug_ranges" ".debug_ranges"
4175#endif
4176#ifndef DEBUG_RNGLISTS_SECTION".debug_rnglists"
4177#define DEBUG_RNGLISTS_SECTION".debug_rnglists" ".debug_rnglists"
4178#endif
4179#ifndef DEBUG_DWO_RNGLISTS_SECTION".debug_rnglists.dwo"
4180#define DEBUG_DWO_RNGLISTS_SECTION".debug_rnglists.dwo" ".debug_rnglists.dwo"
4181#endif
4182#ifndef DEBUG_LINE_STR_SECTION".debug_line_str"
4183#define DEBUG_LINE_STR_SECTION".debug_line_str" ".debug_line_str"
4184#endif
4185#ifndef DEBUG_LTO_LINE_STR_SECTION".gnu.debuglto_.debug_line_str"
4186#define DEBUG_LTO_LINE_STR_SECTION".gnu.debuglto_.debug_line_str" ".gnu.debuglto_.debug_line_str"
4187#endif
4188
4189/* Section flags for .debug_str section. */
4190#define DEBUG_STR_SECTION_FLAGS(1 && global_options.x_flag_merge_debug_strings ? SECTION_DEBUG
| SECTION_MERGE | SECTION_STRINGS | 1 : SECTION_DEBUG)
\
4191 (HAVE_GAS_SHF_MERGE1 && flag_merge_debug_stringsglobal_options.x_flag_merge_debug_strings \
4192 ? SECTION_DEBUG | SECTION_MERGE | SECTION_STRINGS | 1 \
4193 : SECTION_DEBUG)
4194
4195/* Section flags for .debug_str.dwo section. */
4196#define DEBUG_STR_DWO_SECTION_FLAGS(SECTION_DEBUG | SECTION_EXCLUDE) (SECTION_DEBUG | SECTION_EXCLUDE)
4197
4198/* Attribute used to refer to the macro section. */
4199#define DEBUG_MACRO_ATTRIBUTE(global_options.x_dwarf_version >= 5 ? DW_AT_macros : global_options
.x_dwarf_strict ? DW_AT_macro_info : DW_AT_GNU_macros)
(dwarf_versionglobal_options.x_dwarf_version >= 5 ? DW_AT_macros \
4200 : dwarf_strictglobal_options.x_dwarf_strict ? DW_AT_macro_info : DW_AT_GNU_macros)
4201
4202/* Labels we insert at beginning sections we can reference instead of
4203 the section names themselves. */
4204
4205#ifndef TEXT_SECTION_LABEL"Ltext"
4206#define TEXT_SECTION_LABEL"Ltext" "Ltext"
4207#endif
4208#ifndef COLD_TEXT_SECTION_LABEL"Ltext_cold"
4209#define COLD_TEXT_SECTION_LABEL"Ltext_cold" "Ltext_cold"
4210#endif
4211#ifndef DEBUG_LINE_SECTION_LABEL"Ldebug_line"
4212#define DEBUG_LINE_SECTION_LABEL"Ldebug_line" "Ldebug_line"
4213#endif
4214#ifndef DEBUG_SKELETON_LINE_SECTION_LABEL"Lskeleton_debug_line"
4215#define DEBUG_SKELETON_LINE_SECTION_LABEL"Lskeleton_debug_line" "Lskeleton_debug_line"
4216#endif
4217#ifndef DEBUG_INFO_SECTION_LABEL"Ldebug_info"
4218#define DEBUG_INFO_SECTION_LABEL"Ldebug_info" "Ldebug_info"
4219#endif
4220#ifndef DEBUG_SKELETON_INFO_SECTION_LABEL"Lskeleton_debug_info"
4221#define DEBUG_SKELETON_INFO_SECTION_LABEL"Lskeleton_debug_info" "Lskeleton_debug_info"
4222#endif
4223#ifndef DEBUG_ABBREV_SECTION_LABEL"Ldebug_abbrev"
4224#define DEBUG_ABBREV_SECTION_LABEL"Ldebug_abbrev" "Ldebug_abbrev"
4225#endif
4226#ifndef DEBUG_SKELETON_ABBREV_SECTION_LABEL"Lskeleton_debug_abbrev"
4227#define DEBUG_SKELETON_ABBREV_SECTION_LABEL"Lskeleton_debug_abbrev" "Lskeleton_debug_abbrev"
4228#endif
4229#ifndef DEBUG_ADDR_SECTION_LABEL"Ldebug_addr"
4230#define DEBUG_ADDR_SECTION_LABEL"Ldebug_addr" "Ldebug_addr"
4231#endif
4232#ifndef DEBUG_LOC_SECTION_LABEL"Ldebug_loc"
4233#define DEBUG_LOC_SECTION_LABEL"Ldebug_loc" "Ldebug_loc"
4234#endif
4235#ifndef DEBUG_RANGES_SECTION_LABEL"Ldebug_ranges"
4236#define DEBUG_RANGES_SECTION_LABEL"Ldebug_ranges" "Ldebug_ranges"
4237#endif
4238#ifndef DEBUG_MACINFO_SECTION_LABEL"Ldebug_macinfo"
4239#define DEBUG_MACINFO_SECTION_LABEL"Ldebug_macinfo" "Ldebug_macinfo"
4240#endif
4241#ifndef DEBUG_MACRO_SECTION_LABEL"Ldebug_macro"
4242#define DEBUG_MACRO_SECTION_LABEL"Ldebug_macro" "Ldebug_macro"
4243#endif
4244#define SKELETON_COMP_DIE_ABBREV1 1
4245#define SKELETON_TYPE_DIE_ABBREV2 2
4246
4247/* Definitions of defaults for formats and names of various special
4248 (artificial) labels which may be generated within this file (when the -g
4249 options is used and DWARF2_DEBUGGING_INFO is in effect.
4250 If necessary, these may be overridden from within the tm.h file, but
4251 typically, overriding these defaults is unnecessary. */
4252
4253static char text_end_label[MAX_ARTIFICIAL_LABEL_BYTES40];
4254static char text_section_label[MAX_ARTIFICIAL_LABEL_BYTES40];
4255static char cold_text_section_label[MAX_ARTIFICIAL_LABEL_BYTES40];
4256static char cold_end_label[MAX_ARTIFICIAL_LABEL_BYTES40];
4257static char abbrev_section_label[MAX_ARTIFICIAL_LABEL_BYTES40];
4258static char debug_info_section_label[MAX_ARTIFICIAL_LABEL_BYTES40];
4259static char debug_skeleton_info_section_label[MAX_ARTIFICIAL_LABEL_BYTES40];
4260static char debug_skeleton_abbrev_section_label[MAX_ARTIFICIAL_LABEL_BYTES40];
4261static char debug_line_section_label[MAX_ARTIFICIAL_LABEL_BYTES40];
4262static char debug_addr_section_label[MAX_ARTIFICIAL_LABEL_BYTES40];
4263static char debug_skeleton_line_section_label[MAX_ARTIFICIAL_LABEL_BYTES40];
4264static char macinfo_section_label[MAX_ARTIFICIAL_LABEL_BYTES40];
4265static char loc_section_label[MAX_ARTIFICIAL_LABEL_BYTES40];
4266static char ranges_section_label[2 * MAX_ARTIFICIAL_LABEL_BYTES40];
4267static char ranges_base_label[2 * MAX_ARTIFICIAL_LABEL_BYTES40];
4268
4269#ifndef TEXT_END_LABEL"Letext"
4270#define TEXT_END_LABEL"Letext" "Letext"
4271#endif
4272#ifndef COLD_END_LABEL"Letext_cold"
4273#define COLD_END_LABEL"Letext_cold" "Letext_cold"
4274#endif
4275#ifndef BLOCK_BEGIN_LABEL"LBB"
4276#define BLOCK_BEGIN_LABEL"LBB" "LBB"
4277#endif
4278#ifndef BLOCK_INLINE_ENTRY_LABEL"LBI"
4279#define BLOCK_INLINE_ENTRY_LABEL"LBI" "LBI"
4280#endif
4281#ifndef BLOCK_END_LABEL"LBE"
4282#define BLOCK_END_LABEL"LBE" "LBE"
4283#endif
4284#ifndef LINE_CODE_LABEL"LM"
4285#define LINE_CODE_LABEL"LM" "LM"
4286#endif
4287
4288
4289/* Return the root of the DIE's built for the current compilation unit. */
4290static dw_die_ref
4291comp_unit_die (void)
4292{
4293 if (!single_comp_unit_die)
4294 single_comp_unit_die = gen_compile_unit_die (NULLnullptr);
4295 return single_comp_unit_die;
4296}
4297
4298/* We allow a language front-end to designate a function that is to be
4299 called to "demangle" any name before it is put into a DIE. */
4300
4301static const char *(*demangle_name_func) (const char *);
4302
4303void
4304dwarf2out_set_demangle_name_func (const char *(*func) (const char *))
4305{
4306 demangle_name_func = func;
4307}
4308
4309/* Test if rtl node points to a pseudo register. */
4310
4311static inline int
4312is_pseudo_reg (const_rtx rtl)
4313{
4314 return ((REG_P (rtl)(((enum rtx_code) (rtl)->code) == REG) && REGNO (rtl)(rhs_regno(rtl)) >= FIRST_PSEUDO_REGISTER76)
4315 || (GET_CODE (rtl)((enum rtx_code) (rtl)->code) == SUBREG
4316 && REGNO (SUBREG_REG (rtl))(rhs_regno((((rtl)->u.fld[0]).rt_rtx))) >= FIRST_PSEUDO_REGISTER76));
4317}
4318
4319/* Return a reference to a type, with its const and volatile qualifiers
4320 removed. */
4321
4322static inline tree
4323type_main_variant (tree type)
4324{
4325 type = TYPE_MAIN_VARIANT (type)((tree_class_check ((type), (tcc_type), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4325, __FUNCTION__))->type_common.main_variant)
;
4326
4327 /* ??? There really should be only one main variant among any group of
4328 variants of a given type (and all of the MAIN_VARIANT values for all
4329 members of the group should point to that one type) but sometimes the C
4330 front-end messes this up for array types, so we work around that bug
4331 here. */
4332 if (TREE_CODE (type)((enum tree_code) (type)->base.code) == ARRAY_TYPE)
4333 while (type != TYPE_MAIN_VARIANT (type)((tree_class_check ((type), (tcc_type), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4333, __FUNCTION__))->type_common.main_variant)
)
4334 type = TYPE_MAIN_VARIANT (type)((tree_class_check ((type), (tcc_type), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4334, __FUNCTION__))->type_common.main_variant)
;
4335
4336 return type;
4337}
4338
4339/* Return nonzero if the given type node represents a tagged type. */
4340
4341static inline int
4342is_tagged_type (const_tree type)
4343{
4344 enum tree_code code = TREE_CODE (type)((enum tree_code) (type)->base.code);
4345
4346 return (code == RECORD_TYPE || code == UNION_TYPE
4347 || code == QUAL_UNION_TYPE || code == ENUMERAL_TYPE);
4348}
4349
4350/* Set label to debug_info_section_label + die_offset of a DIE reference. */
4351
4352static void
4353get_ref_die_offset_label (char *label, dw_die_ref ref)
4354{
4355 sprintf (label, "%s+%ld", debug_info_section_label, ref->die_offset);
4356}
4357
4358/* Return die_offset of a DIE reference to a base type. */
4359
4360static unsigned long int
4361get_base_type_offset (dw_die_ref ref)
4362{
4363 if (ref->die_offset)
4364 return ref->die_offset;
4365 if (comp_unit_die ()->die_abbrev)
4366 {
4367 calc_base_type_die_sizes ();
4368 gcc_assert (ref->die_offset)((void)(!(ref->die_offset) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4368, __FUNCTION__), 0 : 0))
;
4369 }
4370 return ref->die_offset;
4371}
4372
4373/* Return die_offset of a DIE reference other than base type. */
4374
4375static unsigned long int
4376get_ref_die_offset (dw_die_ref ref)
4377{
4378 gcc_assert (ref->die_offset)((void)(!(ref->die_offset) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4378, __FUNCTION__), 0 : 0))
;
4379 return ref->die_offset;
4380}
4381
4382/* Convert a DIE tag into its string name. */
4383
4384static const char *
4385dwarf_tag_name (unsigned int tag)
4386{
4387 const char *name = get_DW_TAG_name (tag);
4388
4389 if (name != NULLnullptr)
4390 return name;
4391
4392 return "DW_TAG_<unknown>";
4393}
4394
4395/* Convert a DWARF attribute code into its string name. */
4396
4397static const char *
4398dwarf_attr_name (unsigned int attr)
4399{
4400 const char *name;
4401
4402 switch (attr)
4403 {
4404#if VMS_DEBUGGING_INFO
4405 case DW_AT_HP_prologue:
4406 return "DW_AT_HP_prologue";
4407#else
4408 case DW_AT_MIPS_loop_unroll_factor:
4409 return "DW_AT_MIPS_loop_unroll_factor";
4410#endif
4411
4412#if VMS_DEBUGGING_INFO
4413 case DW_AT_HP_epilogue:
4414 return "DW_AT_HP_epilogue";
4415#else
4416 case DW_AT_MIPS_stride:
4417 return "DW_AT_MIPS_stride";
4418#endif
4419 }
4420
4421 name = get_DW_AT_name (attr);
4422
4423 if (name != NULLnullptr)
4424 return name;
4425
4426 return "DW_AT_<unknown>";
4427}
4428
4429/* Convert a DWARF value form code into its string name. */
4430
4431static const char *
4432dwarf_form_name (unsigned int form)
4433{
4434 const char *name = get_DW_FORM_name (form);
4435
4436 if (name != NULLnullptr)
4437 return name;
4438
4439 return "DW_FORM_<unknown>";
4440}
4441
4442/* Determine the "ultimate origin" of a decl. The decl may be an inlined
4443 instance of an inlined instance of a decl which is local to an inline
4444 function, so we have to trace all of the way back through the origin chain
4445 to find out what sort of node actually served as the original seed for the
4446 given block. */
4447
4448static tree
4449decl_ultimate_origin (const_tree decl)
4450{
4451 if (!CODE_CONTAINS_STRUCT (TREE_CODE (decl), TS_DECL_COMMON)(tree_contains_struct[(((enum tree_code) (decl)->base.code
))][(TS_DECL_COMMON)])
)
4452 return NULL_TREE(tree) nullptr;
4453
4454 /* DECL_ABSTRACT_ORIGIN can point to itself; ignore that if
4455 we're trying to output the abstract instance of this function. */
4456 if (DECL_ABSTRACT_P (decl)((contains_struct_check ((decl), (TS_DECL_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4456, __FUNCTION__))->decl_common.abstract_flag)
&& DECL_ABSTRACT_ORIGIN (decl)((contains_struct_check ((decl), (TS_DECL_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4456, __FUNCTION__))->decl_common.abstract_origin)
== decl)
4457 return NULL_TREE(tree) nullptr;
4458
4459 /* Since the DECL_ABSTRACT_ORIGIN for a DECL is supposed to be the
4460 most distant ancestor, this should never happen. */
4461 gcc_assert (!DECL_FROM_INLINE (DECL_ORIGIN (decl)))((void)(!(!(((contains_struct_check (((((contains_struct_check
((decl), (TS_DECL_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4461, __FUNCTION__))->decl_common.abstract_origin) ? ((contains_struct_check
((decl), (TS_DECL_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4461, __FUNCTION__))->decl_common.abstract_origin) : (decl
))), (TS_DECL_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4461, __FUNCTION__))->decl_common.abstract_origin) != (tree
) nullptr && ((contains_struct_check (((((contains_struct_check
((decl), (TS_DECL_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4461, __FUNCTION__))->decl_common.abstract_origin) ? ((contains_struct_check
((decl), (TS_DECL_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4461, __FUNCTION__))->decl_common.abstract_origin) : (decl
))), (TS_DECL_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4461, __FUNCTION__))->decl_common.abstract_origin) != ((
((contains_struct_check ((decl), (TS_DECL_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4461, __FUNCTION__))->decl_common.abstract_origin) ? ((contains_struct_check
((decl), (TS_DECL_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4461, __FUNCTION__))->decl_common.abstract_origin) : (decl
))))) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4461, __FUNCTION__), 0 : 0))
;
4462
4463 return DECL_ABSTRACT_ORIGIN (decl)((contains_struct_check ((decl), (TS_DECL_COMMON), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4463, __FUNCTION__))->decl_common.abstract_origin)
;
4464}
4465
4466/* Get the class to which DECL belongs, if any. In g++, the DECL_CONTEXT
4467 of a virtual function may refer to a base class, so we check the 'this'
4468 parameter. */
4469
4470static tree
4471decl_class_context (tree decl)
4472{
4473 tree context = NULL_TREE(tree) nullptr;
4474
4475 if (TREE_CODE (decl)((enum tree_code) (decl)->base.code) != FUNCTION_DECL || ! DECL_VINDEX (decl)((tree_check ((decl), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4475, __FUNCTION__, (FUNCTION_DECL)))->function_decl.vindex
)
)
4476 context = DECL_CONTEXT (decl)((contains_struct_check ((decl), (TS_DECL_MINIMAL), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4476, __FUNCTION__))->decl_minimal.context)
;
4477 else
4478 context = TYPE_MAIN_VARIANT((tree_class_check ((((contains_struct_check ((((tree_check (
(((tree_check2 ((((contains_struct_check ((decl), (TS_TYPED),
"/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4479, __FUNCTION__))->typed.type)), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4479, __FUNCTION__, (FUNCTION_TYPE), (METHOD_TYPE)))->type_non_common
.values)), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4479, __FUNCTION__, (TREE_LIST)))->list.value)), (TS_TYPED
), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4479, __FUNCTION__))->typed.type)), (tcc_type), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4479, __FUNCTION__))->type_common.main_variant)
4479 (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)))))((tree_class_check ((((contains_struct_check ((((tree_check (
(((tree_check2 ((((contains_struct_check ((decl), (TS_TYPED),
"/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4479, __FUNCTION__))->typed.type)), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4479, __FUNCTION__, (FUNCTION_TYPE), (METHOD_TYPE)))->type_non_common
.values)), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4479, __FUNCTION__, (TREE_LIST)))->list.value)), (TS_TYPED
), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4479, __FUNCTION__))->typed.type)), (tcc_type), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4479, __FUNCTION__))->type_common.main_variant)
;
4480
4481 if (context && !TYPE_P (context)(tree_code_type_tmpl <0>::tree_code_type[(int) (((enum tree_code
) (context)->base.code))] == tcc_type)
)
4482 context = NULL_TREE(tree) nullptr;
4483
4484 return context;
4485}
4486
4487/* Add an attribute/value pair to a DIE. */
4488
4489static inline void
4490add_dwarf_attr (dw_die_ref die, dw_attr_node *attr)
4491{
4492 /* Maybe this should be an assert? */
4493 if (die == NULLnullptr)
4494 return;
4495
4496 if (flag_checkingglobal_options.x_flag_checking)
4497 {
4498 /* Check we do not add duplicate attrs. Can't use get_AT here
4499 because that recurses to the specification/abstract origin DIE. */
4500 dw_attr_node *a;
4501 unsigned ix;
4502 FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)for (ix = 0; vec_safe_iterate ((die->die_attr), (ix), &
(a)); ++(ix))
4503 gcc_assert (a->dw_attr != attr->dw_attr)((void)(!(a->dw_attr != attr->dw_attr) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4503, __FUNCTION__), 0 : 0))
;
4504 }
4505
4506 vec_safe_reserve (die->die_attr, 1);
4507 vec_safe_push (die->die_attr, *attr);
4508}
4509
4510enum dw_val_class
4511AT_class (dw_attr_node *a)
4512{
4513 return a->dw_attr_val.val_class;
4514}
4515
4516/* Return the index for any attribute that will be referenced with a
4517 DW_FORM_addrx/GNU_addr_index or DW_FORM_strx/GNU_str_index. String
4518 indices are stored in dw_attr_val.v.val_str for reference counting
4519 pruning. */
4520
4521static inline unsigned int
4522AT_index (dw_attr_node *a)
4523{
4524 if (AT_class (a) == dw_val_class_str)
4525 return a->dw_attr_val.v.val_str->index;
4526 else if (a->dw_attr_val.val_entry != NULLnullptr)
4527 return a->dw_attr_val.val_entry->index;
4528 return NOT_INDEXED(-1U);
4529}
4530
4531/* Add a flag value attribute to a DIE. */
4532
4533static inline void
4534add_AT_flag (dw_die_ref die, enum dwarf_attribute attr_kind, unsigned int flag)
4535{
4536 dw_attr_node attr;
4537
4538 attr.dw_attr = attr_kind;
4539 attr.dw_attr_val.val_class = dw_val_class_flag;
4540 attr.dw_attr_val.val_entry = NULLnullptr;
4541 attr.dw_attr_val.v.val_flag = flag;
4542 add_dwarf_attr (die, &attr);
4543}
4544
4545static inline unsigned
4546AT_flag (dw_attr_node *a)
4547{
4548 gcc_assert (a && AT_class (a) == dw_val_class_flag)((void)(!(a && AT_class (a) == dw_val_class_flag) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4548, __FUNCTION__), 0 : 0))
;
4549 return a->dw_attr_val.v.val_flag;
4550}
4551
4552/* Add a signed integer attribute value to a DIE. */
4553
4554static inline void
4555add_AT_int (dw_die_ref die, enum dwarf_attribute attr_kind, HOST_WIDE_INTlong int_val)
4556{
4557 dw_attr_node attr;
4558
4559 attr.dw_attr = attr_kind;
4560 attr.dw_attr_val.val_class = dw_val_class_const;
4561 attr.dw_attr_val.val_entry = NULLnullptr;
4562 attr.dw_attr_val.v.val_int = int_val;
4563 add_dwarf_attr (die, &attr);
4564}
4565
4566HOST_WIDE_INTlong
4567AT_int (dw_attr_node *a)
4568{
4569 gcc_assert (a && (AT_class (a) == dw_val_class_const((void)(!(a && (AT_class (a) == dw_val_class_const ||
AT_class (a) == dw_val_class_const_implicit)) ? fancy_abort (
"/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4570, __FUNCTION__), 0 : 0))
4570 || AT_class (a) == dw_val_class_const_implicit))((void)(!(a && (AT_class (a) == dw_val_class_const ||
AT_class (a) == dw_val_class_const_implicit)) ? fancy_abort (
"/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4570, __FUNCTION__), 0 : 0))
;
4571 return a->dw_attr_val.v.val_int;
4572}
4573
4574/* Add an unsigned integer attribute value to a DIE. */
4575
4576static inline void
4577add_AT_unsigned (dw_die_ref die, enum dwarf_attribute attr_kind,
4578 unsigned HOST_WIDE_INTlong unsigned_val)
4579{
4580 dw_attr_node attr;
4581
4582 attr.dw_attr = attr_kind;
4583 attr.dw_attr_val.val_class = dw_val_class_unsigned_const;
4584 attr.dw_attr_val.val_entry = NULLnullptr;
4585 attr.dw_attr_val.v.val_unsigned = unsigned_val;
4586 add_dwarf_attr (die, &attr);
4587}
4588
4589unsigned HOST_WIDE_INTlong
4590AT_unsigned (dw_attr_node *a)
4591{
4592 gcc_assert (a && (AT_class (a) == dw_val_class_unsigned_const((void)(!(a && (AT_class (a) == dw_val_class_unsigned_const
|| AT_class (a) == dw_val_class_unsigned_const_implicit)) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4593, __FUNCTION__), 0 : 0))
4593 || AT_class (a) == dw_val_class_unsigned_const_implicit))((void)(!(a && (AT_class (a) == dw_val_class_unsigned_const
|| AT_class (a) == dw_val_class_unsigned_const_implicit)) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4593, __FUNCTION__), 0 : 0))
;
4594 return a->dw_attr_val.v.val_unsigned;
4595}
4596
4597/* Add an unsigned wide integer attribute value to a DIE. */
4598
4599static inline void
4600add_AT_wide (dw_die_ref die, enum dwarf_attribute attr_kind,
4601 const wide_int& w)
4602{
4603 dw_attr_node attr;
4604
4605 attr.dw_attr = attr_kind;
4606 attr.dw_attr_val.val_class = dw_val_class_wide_int;
4607 attr.dw_attr_val.val_entry = NULLnullptr;
4608 attr.dw_attr_val.v.val_wide = ggc_alloc<wide_int> ();
4609 *attr.dw_attr_val.v.val_wide = w;
4610 add_dwarf_attr (die, &attr);
4611}
4612
4613/* Add an unsigned double integer attribute value to a DIE. */
4614
4615static inline void
4616add_AT_double (dw_die_ref die, enum dwarf_attribute attr_kind,
4617 HOST_WIDE_INTlong high, unsigned HOST_WIDE_INTlong low)
4618{
4619 dw_attr_node attr;
4620
4621 attr.dw_attr = attr_kind;
4622 attr.dw_attr_val.val_class = dw_val_class_const_double;
4623 attr.dw_attr_val.val_entry = NULLnullptr;
4624 attr.dw_attr_val.v.val_double.high = high;
4625 attr.dw_attr_val.v.val_double.low = low;
4626 add_dwarf_attr (die, &attr);
4627}
4628
4629/* Add a floating point attribute value to a DIE and return it. */
4630
4631static inline void
4632add_AT_vec (dw_die_ref die, enum dwarf_attribute attr_kind,
4633 unsigned int length, unsigned int elt_size, unsigned char *array)
4634{
4635 dw_attr_node attr;
4636
4637 attr.dw_attr = attr_kind;
4638 attr.dw_attr_val.val_class = dw_val_class_vec;
4639 attr.dw_attr_val.val_entry = NULLnullptr;
4640 attr.dw_attr_val.v.val_vec.length = length;
4641 attr.dw_attr_val.v.val_vec.elt_size = elt_size;
4642 attr.dw_attr_val.v.val_vec.array = array;
4643 add_dwarf_attr (die, &attr);
4644}
4645
4646/* Add an 8-byte data attribute value to a DIE. */
4647
4648static inline void
4649add_AT_data8 (dw_die_ref die, enum dwarf_attribute attr_kind,
4650 unsigned char data8[8])
4651{
4652 dw_attr_node attr;
4653
4654 attr.dw_attr = attr_kind;
4655 attr.dw_attr_val.val_class = dw_val_class_data8;
4656 attr.dw_attr_val.val_entry = NULLnullptr;
4657 memcpy (attr.dw_attr_val.v.val_data8, data8, 8);
4658 add_dwarf_attr (die, &attr);
4659}
4660
4661/* Add DW_AT_low_pc and DW_AT_high_pc to a DIE. When using
4662 dwarf_split_debug_info, address attributes in dies destined for the
4663 final executable have force_direct set to avoid using indexed
4664 references. */
4665
4666static inline void
4667add_AT_low_high_pc (dw_die_ref die, const char *lbl_low, const char *lbl_high,
4668 bool force_direct)
4669{
4670 dw_attr_node attr;
4671 char * lbl_id;
4672
4673 lbl_id = xstrdup (lbl_low);
4674 attr.dw_attr = DW_AT_low_pc;
4675 attr.dw_attr_val.val_class = dw_val_class_lbl_id;
4676 attr.dw_attr_val.v.val_lbl_id = lbl_id;
4677 if (dwarf_split_debug_infoglobal_options.x_dwarf_split_debug_info && !force_direct)
4678 attr.dw_attr_val.val_entry
4679 = add_addr_table_entry (lbl_id, ate_kind_label);
4680 else
4681 attr.dw_attr_val.val_entry = NULLnullptr;
4682 add_dwarf_attr (die, &attr);
4683
4684 attr.dw_attr = DW_AT_high_pc;
4685 if (dwarf_versionglobal_options.x_dwarf_version < 4)
4686 attr.dw_attr_val.val_class = dw_val_class_lbl_id;
4687 else
4688 attr.dw_attr_val.val_class = dw_val_class_high_pc;
4689 lbl_id = xstrdup (lbl_high);
4690 attr.dw_attr_val.v.val_lbl_id = lbl_id;
4691 if (attr.dw_attr_val.val_class == dw_val_class_lbl_id
4692 && dwarf_split_debug_infoglobal_options.x_dwarf_split_debug_info && !force_direct)
4693 attr.dw_attr_val.val_entry
4694 = add_addr_table_entry (lbl_id, ate_kind_label);
4695 else
4696 attr.dw_attr_val.val_entry = NULLnullptr;
4697 add_dwarf_attr (die, &attr);
4698}
4699
4700/* Hash and equality functions for debug_str_hash. */
4701
4702hashval_t
4703indirect_string_hasher::hash (indirect_string_node *x)
4704{
4705 return htab_hash_string (x->str);
4706}
4707
4708bool
4709indirect_string_hasher::equal (indirect_string_node *x1, const char *x2)
4710{
4711 return strcmp (x1->str, x2) == 0;
4712}
4713
4714/* Add STR to the given string hash table. */
4715
4716static struct indirect_string_node *
4717find_AT_string_in_table (const char *str,
4718 hash_table<indirect_string_hasher> *table,
4719 enum insert_option insert = INSERT)
4720{
4721 struct indirect_string_node *node;
4722
4723 indirect_string_node **slot
4724 = table->find_slot_with_hash (str, htab_hash_string (str), insert);
4725 if (*slot == NULLnullptr)
4726 {
4727 node = ggc_cleared_alloc<indirect_string_node> ();
4728 node->str = ggc_strdup (str)ggc_alloc_string ((str), -1 );
4729 *slot = node;
4730 }
4731 else
4732 node = *slot;
4733
4734 node->refcount++;
4735 return node;
4736}
4737
4738/* Add STR to the indirect string hash table. */
4739
4740static struct indirect_string_node *
4741find_AT_string (const char *str, enum insert_option insert = INSERT)
4742{
4743 if (! debug_str_hash)
4744 debug_str_hash = hash_table<indirect_string_hasher>::create_ggc (10);
4745
4746 return find_AT_string_in_table (str, debug_str_hash, insert);
4747}
4748
4749/* Add a string attribute value to a DIE. */
4750
4751static inline void
4752add_AT_string (dw_die_ref die, enum dwarf_attribute attr_kind, const char *str)
4753{
4754 dw_attr_node attr;
4755 struct indirect_string_node *node;
4756
4757 node = find_AT_string (str);
4758
4759 attr.dw_attr = attr_kind;
4760 attr.dw_attr_val.val_class = dw_val_class_str;
4761 attr.dw_attr_val.val_entry = NULLnullptr;
4762 attr.dw_attr_val.v.val_str = node;
4763 add_dwarf_attr (die, &attr);
4764}
4765
4766static inline const char *
4767AT_string (dw_attr_node *a)
4768{
4769 gcc_assert (a && AT_class (a) == dw_val_class_str)((void)(!(a && AT_class (a) == dw_val_class_str) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4769, __FUNCTION__), 0 : 0))
;
4770 return a->dw_attr_val.v.val_str->str;
4771}
4772
4773/* Call this function directly to bypass AT_string_form's logic to put
4774 the string inline in the die. */
4775
4776static void
4777set_indirect_string (struct indirect_string_node *node)
4778{
4779 char label[MAX_ARTIFICIAL_LABEL_BYTES40];
4780 /* Already indirect is a no op. */
4781 if (node->form == DW_FORM_strp
4782 || node->form == DW_FORM_line_strp
4783 || node->form == dwarf_FORM (DW_FORM_strx))
4784 {
4785 gcc_assert (node->label)((void)(!(node->label) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4785, __FUNCTION__), 0 : 0))
;
4786 return;
4787 }
4788 ASM_GENERATE_INTERNAL_LABEL (label, "LASF", dw2_string_counter)do { char *__p; (label)[0] = '*'; (label)[1] = '.'; __p = stpcpy
(&(label)[2], "LASF"); sprint_ul (__p, (unsigned long) (
dw2_string_counter)); } while (0)
;
4789 ++dw2_string_counter;
4790 node->label = xstrdup (label);
4791
4792 if (!dwarf_split_debug_infoglobal_options.x_dwarf_split_debug_info)
4793 {
4794 node->form = DW_FORM_strp;
4795 node->index = NOT_INDEXED(-1U);
4796 }
4797 else
4798 {
4799 node->form = dwarf_FORM (DW_FORM_strx);
4800 node->index = NO_INDEX_ASSIGNED(-2U);
4801 }
4802}
4803
4804/* A helper function for dwarf2out_finish, called to reset indirect
4805 string decisions done for early LTO dwarf output before fat object
4806 dwarf output. */
4807
4808int
4809reset_indirect_string (indirect_string_node **h, void *)
4810{
4811 struct indirect_string_node *node = *h;
4812 if (node->form == DW_FORM_strp
4813 || node->form == DW_FORM_line_strp
4814 || node->form == dwarf_FORM (DW_FORM_strx))
4815 {
4816 free (node->label);
4817 node->label = NULLnullptr;
4818 node->form = (dwarf_form) 0;
4819 node->index = 0;
4820 }
4821 return 1;
4822}
4823
4824/* Add a string representing a file or filepath attribute value to a DIE. */
4825
4826static inline void
4827add_filepath_AT_string (dw_die_ref die, enum dwarf_attribute attr_kind,
4828 const char *str)
4829{
4830 if (! asm_outputs_debug_line_str ())
4831 add_AT_string (die, attr_kind, str);
4832 else
4833 {
4834 dw_attr_node attr;
4835 struct indirect_string_node *node;
4836
4837 if (!debug_line_str_hash)
4838 debug_line_str_hash
4839 = hash_table<indirect_string_hasher>::create_ggc (10);
4840
4841 node = find_AT_string_in_table (str, debug_line_str_hash);
4842 set_indirect_string (node);
4843 node->form = DW_FORM_line_strp;
4844
4845 attr.dw_attr = attr_kind;
4846 attr.dw_attr_val.val_class = dw_val_class_str;
4847 attr.dw_attr_val.val_entry = NULLnullptr;
4848 attr.dw_attr_val.v.val_str = node;
4849 add_dwarf_attr (die, &attr);
4850 }
4851}
4852
4853/* Find out whether a string should be output inline in DIE
4854 or out-of-line in .debug_str section. */
4855
4856static enum dwarf_form
4857find_string_form (struct indirect_string_node *node)
4858{
4859 unsigned int len;
4860
4861 if (node->form)
4862 return node->form;
4863
4864 len = strlen (node->str) + 1;
4865
4866 /* If the string is shorter or equal to the size of the reference, it is
4867 always better to put it inline. */
4868 if (len <= (unsigned) dwarf_offset_sizeglobal_options.x_dwarf_offset_size || node->refcount == 0)
4869 return node->form = DW_FORM_string;
4870
4871 /* If we cannot expect the linker to merge strings in .debug_str
4872 section, only put it into .debug_str if it is worth even in this
4873 single module. */
4874 if (DWARF2_INDIRECT_STRING_SUPPORT_MISSING_ON_TARGET0
4875 || ((debug_str_section->common.flags & SECTION_MERGE) == 0
4876 && (len - dwarf_offset_sizeglobal_options.x_dwarf_offset_size) * node->refcount <= len))
4877 return node->form = DW_FORM_string;
4878
4879 set_indirect_string (node);
4880
4881 return node->form;
4882}
4883
4884/* Find out whether the string referenced from the attribute should be
4885 output inline in DIE or out-of-line in .debug_str section. */
4886
4887static enum dwarf_form
4888AT_string_form (dw_attr_node *a)
4889{
4890 gcc_assert (a && AT_class (a) == dw_val_class_str)((void)(!(a && AT_class (a) == dw_val_class_str) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4890, __FUNCTION__), 0 : 0))
;
4891 return find_string_form (a->dw_attr_val.v.val_str);
4892}
4893
4894/* Add a DIE reference attribute value to a DIE. */
4895
4896static inline void
4897add_AT_die_ref (dw_die_ref die, enum dwarf_attribute attr_kind, dw_die_ref targ_die)
4898{
4899 dw_attr_node attr;
4900 gcc_checking_assert (targ_die != NULL)((void)(!(targ_die != nullptr) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4900, __FUNCTION__), 0 : 0))
;
4901
4902 /* With LTO we can end up trying to reference something we didn't create
4903 a DIE for. Avoid crashing later on a NULL referenced DIE. */
4904 if (targ_die == NULLnullptr)
4905 return;
4906
4907 attr.dw_attr = attr_kind;
4908 attr.dw_attr_val.val_class = dw_val_class_die_ref;
4909 attr.dw_attr_val.val_entry = NULLnullptr;
4910 attr.dw_attr_val.v.val_die_ref.die = targ_die;
4911 attr.dw_attr_val.v.val_die_ref.external = 0;
4912 add_dwarf_attr (die, &attr);
4913}
4914
4915/* Change DIE reference REF to point to NEW_DIE instead. */
4916
4917static inline void
4918change_AT_die_ref (dw_attr_node *ref, dw_die_ref new_die)
4919{
4920 gcc_assert (ref->dw_attr_val.val_class == dw_val_class_die_ref)((void)(!(ref->dw_attr_val.val_class == dw_val_class_die_ref
) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4920, __FUNCTION__), 0 : 0))
;
4921 ref->dw_attr_val.v.val_die_ref.die = new_die;
4922 ref->dw_attr_val.v.val_die_ref.external = 0;
4923}
4924
4925/* Add an AT_specification attribute to a DIE, and also make the back
4926 pointer from the specification to the definition. */
4927
4928static inline void
4929add_AT_specification (dw_die_ref die, dw_die_ref targ_die)
4930{
4931 add_AT_die_ref (die, DW_AT_specification, targ_die);
4932 gcc_assert (!targ_die->die_definition)((void)(!(!targ_die->die_definition) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4932, __FUNCTION__), 0 : 0))
;
4933 targ_die->die_definition = die;
4934}
4935
4936static inline dw_die_ref
4937AT_ref (dw_attr_node *a)
4938{
4939 gcc_assert (a && AT_class (a) == dw_val_class_die_ref)((void)(!(a && AT_class (a) == dw_val_class_die_ref) ?
fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4939, __FUNCTION__), 0 : 0))
;
4940 return a->dw_attr_val.v.val_die_ref.die;
4941}
4942
4943static inline int
4944AT_ref_external (dw_attr_node *a)
4945{
4946 if (a && AT_class (a) == dw_val_class_die_ref)
4947 return a->dw_attr_val.v.val_die_ref.external;
4948
4949 return 0;
4950}
4951
4952static inline void
4953set_AT_ref_external (dw_attr_node *a, int i)
4954{
4955 gcc_assert (a && AT_class (a) == dw_val_class_die_ref)((void)(!(a && AT_class (a) == dw_val_class_die_ref) ?
fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4955, __FUNCTION__), 0 : 0))
;
4956 a->dw_attr_val.v.val_die_ref.external = i;
4957}
4958
4959/* Add a location description attribute value to a DIE. */
4960
4961static inline void
4962add_AT_loc (dw_die_ref die, enum dwarf_attribute attr_kind, dw_loc_descr_ref loc)
4963{
4964 dw_attr_node attr;
4965
4966 attr.dw_attr = attr_kind;
4967 attr.dw_attr_val.val_class = dw_val_class_loc;
4968 attr.dw_attr_val.val_entry = NULLnullptr;
4969 attr.dw_attr_val.v.val_loc = loc;
4970 add_dwarf_attr (die, &attr);
4971}
4972
4973dw_loc_descr_ref
4974AT_loc (dw_attr_node *a)
4975{
4976 gcc_assert (a && AT_class (a) == dw_val_class_loc)((void)(!(a && AT_class (a) == dw_val_class_loc) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4976, __FUNCTION__), 0 : 0))
;
4977 return a->dw_attr_val.v.val_loc;
4978}
4979
4980static inline void
4981add_AT_loc_list (dw_die_ref die, enum dwarf_attribute attr_kind, dw_loc_list_ref loc_list)
4982{
4983 dw_attr_node attr;
4984
4985 if (XCOFF_DEBUGGING_INFO0 && !HAVE_XCOFF_DWARF_EXTRAS0)
4986 return;
4987
4988 attr.dw_attr = attr_kind;
4989 attr.dw_attr_val.val_class = dw_val_class_loc_list;
4990 attr.dw_attr_val.val_entry = NULLnullptr;
4991 attr.dw_attr_val.v.val_loc_list = loc_list;
4992 add_dwarf_attr (die, &attr);
4993 have_location_lists = true;
4994}
4995
4996static inline dw_loc_list_ref
4997AT_loc_list (dw_attr_node *a)
4998{
4999 gcc_assert (a && AT_class (a) == dw_val_class_loc_list)((void)(!(a && AT_class (a) == dw_val_class_loc_list)
? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 4999, __FUNCTION__), 0 : 0))
;
5000 return a->dw_attr_val.v.val_loc_list;
5001}
5002
5003/* Add a view list attribute to DIE. It must have a DW_AT_location
5004 attribute, because the view list complements the location list. */
5005
5006static inline void
5007add_AT_view_list (dw_die_ref die, enum dwarf_attribute attr_kind)
5008{
5009 dw_attr_node attr;
5010
5011 if (XCOFF_DEBUGGING_INFO0 && !HAVE_XCOFF_DWARF_EXTRAS0)
5012 return;
5013
5014 attr.dw_attr = attr_kind;
5015 attr.dw_attr_val.val_class = dw_val_class_view_list;
5016 attr.dw_attr_val.val_entry = NULLnullptr;
5017 attr.dw_attr_val.v.val_view_list = die;
5018 add_dwarf_attr (die, &attr);
5019 gcc_checking_assert (get_AT (die, DW_AT_location))((void)(!(get_AT (die, DW_AT_location)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5019, __FUNCTION__), 0 : 0))
;
5020 gcc_assert (have_location_lists)((void)(!(have_location_lists) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5020, __FUNCTION__), 0 : 0))
;
5021}
5022
5023/* Return a pointer to the location list referenced by the attribute.
5024 If the named attribute is a view list, look up the corresponding
5025 DW_AT_location attribute and return its location list. */
5026
5027static inline dw_loc_list_ref *
5028AT_loc_list_ptr (dw_attr_node *a)
5029{
5030 gcc_assert (a)((void)(!(a) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5030, __FUNCTION__), 0 : 0))
;
5031 switch (AT_class (a))
5032 {
5033 case dw_val_class_loc_list:
5034 return &a->dw_attr_val.v.val_loc_list;
5035 case dw_val_class_view_list:
5036 {
5037 dw_attr_node *l;
5038 l = get_AT (a->dw_attr_val.v.val_view_list, DW_AT_location);
5039 if (!l)
5040 return NULLnullptr;
5041 gcc_checking_assert (l + 1 == a)((void)(!(l + 1 == a) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5041, __FUNCTION__), 0 : 0))
;
5042 return AT_loc_list_ptr (l);
5043 }
5044 default:
5045 gcc_unreachable ()(fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5045, __FUNCTION__))
;
5046 }
5047}
5048
5049/* Return the location attribute value associated with a view list
5050 attribute value. */
5051
5052static inline dw_val_node *
5053view_list_to_loc_list_val_node (dw_val_node *val)
5054{
5055 gcc_assert (val->val_class == dw_val_class_view_list)((void)(!(val->val_class == dw_val_class_view_list) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5055, __FUNCTION__), 0 : 0))
;
5056 dw_attr_node *loc = get_AT (val->v.val_view_list, DW_AT_location);
5057 if (!loc)
5058 return NULLnullptr;
5059 gcc_checking_assert (&(loc + 1)->dw_attr_val == val)((void)(!(&(loc + 1)->dw_attr_val == val) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5059, __FUNCTION__), 0 : 0))
;
5060 gcc_assert (AT_class (loc) == dw_val_class_loc_list)((void)(!(AT_class (loc) == dw_val_class_loc_list) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5060, __FUNCTION__), 0 : 0))
;
5061 return &loc->dw_attr_val;
5062}
5063
5064struct addr_hasher : ggc_ptr_hash<addr_table_entry>
5065{
5066 static hashval_t hash (addr_table_entry *);
5067 static bool equal (addr_table_entry *, addr_table_entry *);
5068};
5069
5070/* Table of entries into the .debug_addr section. */
5071
5072static GTY (()) hash_table<addr_hasher> *addr_index_table;
5073
5074/* Hash an address_table_entry. */
5075
5076hashval_t
5077addr_hasher::hash (addr_table_entry *a)
5078{
5079 inchash::hash hstate;
5080 switch (a->kind)
5081 {
5082 case ate_kind_rtx:
5083 hstate.add_int (0);
5084 break;
5085 case ate_kind_rtx_dtprel:
5086 hstate.add_int (1);
5087 break;
5088 case ate_kind_label:
5089 return htab_hash_string (a->addr.label);
5090 default:
5091 gcc_unreachable ()(fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5091, __FUNCTION__))
;
5092 }
5093 inchash::add_rtx (a->addr.rtl, hstate);
5094 return hstate.end ();
5095}
5096
5097/* Determine equality for two address_table_entries. */
5098
5099bool
5100addr_hasher::equal (addr_table_entry *a1, addr_table_entry *a2)
5101{
5102 if (a1->kind != a2->kind)
5103 return 0;
5104 switch (a1->kind)
5105 {
5106 case ate_kind_rtx:
5107 case ate_kind_rtx_dtprel:
5108 return rtx_equal_p (a1->addr.rtl, a2->addr.rtl);
5109 case ate_kind_label:
5110 return strcmp (a1->addr.label, a2->addr.label) == 0;
5111 default:
5112 gcc_unreachable ()(fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5112, __FUNCTION__))
;
5113 }
5114}
5115
5116/* Initialize an addr_table_entry. */
5117
5118void
5119init_addr_table_entry (addr_table_entry *e, enum ate_kind kind, void *addr)
5120{
5121 e->kind = kind;
5122 switch (kind)
5123 {
5124 case ate_kind_rtx:
5125 case ate_kind_rtx_dtprel:
5126 e->addr.rtl = (rtx) addr;
5127 break;
5128 case ate_kind_label:
5129 e->addr.label = (char *) addr;
5130 break;
5131 }
5132 e->refcount = 0;
5133 e->index = NO_INDEX_ASSIGNED(-2U);
5134}
5135
5136/* Add attr to the address table entry to the table. Defer setting an
5137 index until output time. */
5138
5139static addr_table_entry *
5140add_addr_table_entry (void *addr, enum ate_kind kind)
5141{
5142 addr_table_entry *node;
5143 addr_table_entry finder;
5144
5145 gcc_assert (dwarf_split_debug_info)((void)(!(global_options.x_dwarf_split_debug_info) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5145, __FUNCTION__), 0 : 0))
;
5146 if (! addr_index_table)
5147 addr_index_table = hash_table<addr_hasher>::create_ggc (10);
5148 init_addr_table_entry (&finder, kind, addr);
5149 addr_table_entry **slot = addr_index_table->find_slot (&finder, INSERT);
5150
5151 if (*slot == HTAB_EMPTY_ENTRY((void *) 0))
5152 {
5153 node = ggc_cleared_alloc<addr_table_entry> ();
5154 init_addr_table_entry (node, kind, addr);
5155 *slot = node;
5156 }
5157 else
5158 node = *slot;
5159
5160 node->refcount++;
5161 return node;
5162}
5163
5164/* Remove an entry from the addr table by decrementing its refcount.
5165 Strictly, decrementing the refcount would be enough, but the
5166 assertion that the entry is actually in the table has found
5167 bugs. */
5168
5169static void
5170remove_addr_table_entry (addr_table_entry *entry)
5171{
5172 gcc_assert (dwarf_split_debug_info && addr_index_table)((void)(!(global_options.x_dwarf_split_debug_info && addr_index_table
) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5172, __FUNCTION__), 0 : 0))
;
5173 /* After an index is assigned, the table is frozen. */
5174 gcc_assert (entry->refcount > 0 && entry->index == NO_INDEX_ASSIGNED)((void)(!(entry->refcount > 0 && entry->index
== (-2U)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5174, __FUNCTION__), 0 : 0))
;
5175 entry->refcount--;
5176}
5177
5178/* Given a location list, remove all addresses it refers to from the
5179 address_table. */
5180
5181static void
5182remove_loc_list_addr_table_entries (dw_loc_descr_ref descr)
5183{
5184 for (; descr; descr = descr->dw_loc_next)
5185 if (descr->dw_loc_oprnd1.val_entry != NULLnullptr)
5186 {
5187 gcc_assert (descr->dw_loc_oprnd1.val_entry->index == NO_INDEX_ASSIGNED)((void)(!(descr->dw_loc_oprnd1.val_entry->index == (-2U
)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5187, __FUNCTION__), 0 : 0))
;
5188 remove_addr_table_entry (descr->dw_loc_oprnd1.val_entry);
5189 }
5190}
5191
5192/* A helper function for dwarf2out_finish called through
5193 htab_traverse. Assign an addr_table_entry its index. All entries
5194 must be collected into the table when this function is called,
5195 because the indexing code relies on htab_traverse to traverse nodes
5196 in the same order for each run. */
5197
5198int
5199index_addr_table_entry (addr_table_entry **h, unsigned int *index)
5200{
5201 addr_table_entry *node = *h;
5202
5203 /* Don't index unreferenced nodes. */
5204 if (node->refcount == 0)
5205 return 1;
5206
5207 gcc_assert (node->index == NO_INDEX_ASSIGNED)((void)(!(node->index == (-2U)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5207, __FUNCTION__), 0 : 0))
;
5208 node->index = *index;
5209 *index += 1;
5210
5211 return 1;
5212}
5213
5214/* Return the tag of a given DIE. */
5215
5216enum dwarf_tag
5217dw_get_die_tag (dw_die_ref die)
5218{
5219 return die->die_tag;
5220}
5221
5222/* Return a reference to the children list of a given DIE. */
5223
5224dw_die_ref
5225dw_get_die_child (dw_die_ref die)
5226{
5227 return die->die_child;
5228}
5229
5230/* Return a reference to the sibling of a given DIE. */
5231
5232dw_die_ref
5233dw_get_die_sib (dw_die_ref die)
5234{
5235 return die->die_sib;
5236}
5237
5238/* Add an address constant attribute value to a DIE. When using
5239 dwarf_split_debug_info, address attributes in dies destined for the
5240 final executable should be direct references--setting the parameter
5241 force_direct ensures this behavior. */
5242
5243static inline void
5244add_AT_addr (dw_die_ref die, enum dwarf_attribute attr_kind, rtx addr,
5245 bool force_direct)
5246{
5247 dw_attr_node attr;
5248
5249 attr.dw_attr = attr_kind;
5250 attr.dw_attr_val.val_class = dw_val_class_addr;
5251 attr.dw_attr_val.v.val_addr = addr;
5252 if (dwarf_split_debug_infoglobal_options.x_dwarf_split_debug_info && !force_direct)
5253 attr.dw_attr_val.val_entry = add_addr_table_entry (addr, ate_kind_rtx);
5254 else
5255 attr.dw_attr_val.val_entry = NULLnullptr;
5256 add_dwarf_attr (die, &attr);
5257}
5258
5259/* Get the RTX from to an address DIE attribute. */
5260
5261static inline rtx
5262AT_addr (dw_attr_node *a)
5263{
5264 gcc_assert (a && AT_class (a) == dw_val_class_addr)((void)(!(a && AT_class (a) == dw_val_class_addr) ? fancy_abort
("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5264, __FUNCTION__), 0 : 0))
;
5265 return a->dw_attr_val.v.val_addr;
5266}
5267
5268/* Add a file attribute value to a DIE. */
5269
5270static inline void
5271add_AT_file (dw_die_ref die, enum dwarf_attribute attr_kind,
5272 struct dwarf_file_data *fd)
5273{
5274 dw_attr_node attr;
5275
5276 attr.dw_attr = attr_kind;
5277 attr.dw_attr_val.val_class = dw_val_class_file;
5278 attr.dw_attr_val.val_entry = NULLnullptr;
5279 attr.dw_attr_val.v.val_file = fd;
5280 add_dwarf_attr (die, &attr);
5281}
5282
5283/* Get the dwarf_file_data from a file DIE attribute. */
5284
5285static inline struct dwarf_file_data *
5286AT_file (dw_attr_node *a)
5287{
5288 gcc_assert (a && (AT_class (a) == dw_val_class_file((void)(!(a && (AT_class (a) == dw_val_class_file || AT_class
(a) == dw_val_class_file_implicit)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5289, __FUNCTION__), 0 : 0))
5289 || AT_class (a) == dw_val_class_file_implicit))((void)(!(a && (AT_class (a) == dw_val_class_file || AT_class
(a) == dw_val_class_file_implicit)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5289, __FUNCTION__), 0 : 0))
;
5290 return a->dw_attr_val.v.val_file;
5291}
5292
5293#if VMS_DEBUGGING_INFO
5294/* Add a vms delta attribute value to a DIE. */
5295
5296static inline void
5297add_AT_vms_delta (dw_die_ref die, enum dwarf_attribute attr_kind,
5298 const char *lbl1, const char *lbl2)
5299{
5300 dw_attr_node attr;
5301
5302 attr.dw_attr = attr_kind;
5303 attr.dw_attr_val.val_class = dw_val_class_vms_delta;
5304 attr.dw_attr_val.val_entry = NULLnullptr;
5305 attr.dw_attr_val.v.val_vms_delta.lbl1 = xstrdup (lbl1);
5306 attr.dw_attr_val.v.val_vms_delta.lbl2 = xstrdup (lbl2);
5307 add_dwarf_attr (die, &attr);
5308}
5309#endif
5310
5311/* Add a symbolic view identifier attribute value to a DIE. */
5312
5313static inline void
5314add_AT_symview (dw_die_ref die, enum dwarf_attribute attr_kind,
5315 const char *view_label)
5316{
5317 dw_attr_node attr;
5318
5319 attr.dw_attr = attr_kind;
5320 attr.dw_attr_val.val_class = dw_val_class_symview;
5321 attr.dw_attr_val.val_entry = NULLnullptr;
5322 attr.dw_attr_val.v.val_symbolic_view = xstrdup (view_label);
5323 add_dwarf_attr (die, &attr);
5324}
5325
5326/* Add a label identifier attribute value to a DIE. */
5327
5328static inline void
5329add_AT_lbl_id (dw_die_ref die, enum dwarf_attribute attr_kind,
5330 const char *lbl_id)
5331{
5332 dw_attr_node attr;
5333
5334 attr.dw_attr = attr_kind;
5335 attr.dw_attr_val.val_class = dw_val_class_lbl_id;
5336 attr.dw_attr_val.val_entry = NULLnullptr;
5337 attr.dw_attr_val.v.val_lbl_id = xstrdup (lbl_id);
5338 if (dwarf_split_debug_infoglobal_options.x_dwarf_split_debug_info)
5339 attr.dw_attr_val.val_entry
5340 = add_addr_table_entry (attr.dw_attr_val.v.val_lbl_id,
5341 ate_kind_label);
5342 add_dwarf_attr (die, &attr);
5343}
5344
5345/* Add a section offset attribute value to a DIE, an offset into the
5346 debug_line section. */
5347
5348static inline void
5349add_AT_lineptr (dw_die_ref die, enum dwarf_attribute attr_kind,
5350 const char *label)
5351{
5352 dw_attr_node attr;
5353
5354 attr.dw_attr = attr_kind;
5355 attr.dw_attr_val.val_class = dw_val_class_lineptr;
5356 attr.dw_attr_val.val_entry = NULLnullptr;
5357 attr.dw_attr_val.v.val_lbl_id = xstrdup (label);
5358 add_dwarf_attr (die, &attr);
5359}
5360
5361/* Add a section offset attribute value to a DIE, an offset into the
5362 debug_macinfo section. */
5363
5364static inline void
5365add_AT_macptr (dw_die_ref die, enum dwarf_attribute attr_kind,
5366 const char *label)
5367{
5368 dw_attr_node attr;
5369
5370 attr.dw_attr = attr_kind;
5371 attr.dw_attr_val.val_class = dw_val_class_macptr;
5372 attr.dw_attr_val.val_entry = NULLnullptr;
5373 attr.dw_attr_val.v.val_lbl_id = xstrdup (label);
5374 add_dwarf_attr (die, &attr);
5375}
5376
5377/* Add a range_list attribute value to a DIE. When using
5378 dwarf_split_debug_info, address attributes in dies destined for the
5379 final executable should be direct references--setting the parameter
5380 force_direct ensures this behavior. */
5381
5382#define UNRELOCATED_OFFSET((addr_table_entry *) 1) ((addr_table_entry *) 1)
5383#define RELOCATED_OFFSET(nullptr) (NULLnullptr)
5384
5385static void
5386add_AT_range_list (dw_die_ref die, enum dwarf_attribute attr_kind,
5387 long unsigned int offset, bool force_direct)
5388{
5389 dw_attr_node attr;
5390
5391 attr.dw_attr = attr_kind;
5392 attr.dw_attr_val.val_class = dw_val_class_range_list;
5393 /* For the range_list attribute, use val_entry to store whether the
5394 offset should follow split-debug-info or normal semantics. This
5395 value is read in output_range_list_offset. */
5396 if (dwarf_split_debug_infoglobal_options.x_dwarf_split_debug_info && !force_direct)
5397 attr.dw_attr_val.val_entry = UNRELOCATED_OFFSET((addr_table_entry *) 1);
5398 else
5399 attr.dw_attr_val.val_entry = RELOCATED_OFFSET(nullptr);
5400 attr.dw_attr_val.v.val_offset = offset;
5401 add_dwarf_attr (die, &attr);
5402}
5403
5404/* Return the start label of a delta attribute. */
5405
5406static inline const char *
5407AT_vms_delta1 (dw_attr_node *a)
5408{
5409 gcc_assert (a && (AT_class (a) == dw_val_class_vms_delta))((void)(!(a && (AT_class (a) == dw_val_class_vms_delta
)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5409, __FUNCTION__), 0 : 0))
;
5410 return a->dw_attr_val.v.val_vms_delta.lbl1;
5411}
5412
5413/* Return the end label of a delta attribute. */
5414
5415static inline const char *
5416AT_vms_delta2 (dw_attr_node *a)
5417{
5418 gcc_assert (a && (AT_class (a) == dw_val_class_vms_delta))((void)(!(a && (AT_class (a) == dw_val_class_vms_delta
)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5418, __FUNCTION__), 0 : 0))
;
5419 return a->dw_attr_val.v.val_vms_delta.lbl2;
5420}
5421
5422static inline const char *
5423AT_lbl (dw_attr_node *a)
5424{
5425 gcc_assert (a && (AT_class (a) == dw_val_class_lbl_id((void)(!(a && (AT_class (a) == dw_val_class_lbl_id ||
AT_class (a) == dw_val_class_lineptr || AT_class (a) == dw_val_class_macptr
|| AT_class (a) == dw_val_class_loclistsptr || AT_class (a) ==
dw_val_class_high_pc)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5429, __FUNCTION__), 0 : 0))
5426 || AT_class (a) == dw_val_class_lineptr((void)(!(a && (AT_class (a) == dw_val_class_lbl_id ||
AT_class (a) == dw_val_class_lineptr || AT_class (a) == dw_val_class_macptr
|| AT_class (a) == dw_val_class_loclistsptr || AT_class (a) ==
dw_val_class_high_pc)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5429, __FUNCTION__), 0 : 0))
5427 || AT_class (a) == dw_val_class_macptr((void)(!(a && (AT_class (a) == dw_val_class_lbl_id ||
AT_class (a) == dw_val_class_lineptr || AT_class (a) == dw_val_class_macptr
|| AT_class (a) == dw_val_class_loclistsptr || AT_class (a) ==
dw_val_class_high_pc)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5429, __FUNCTION__), 0 : 0))
5428 || AT_class (a) == dw_val_class_loclistsptr((void)(!(a && (AT_class (a) == dw_val_class_lbl_id ||
AT_class (a) == dw_val_class_lineptr || AT_class (a) == dw_val_class_macptr
|| AT_class (a) == dw_val_class_loclistsptr || AT_class (a) ==
dw_val_class_high_pc)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5429, __FUNCTION__), 0 : 0))
5429 || AT_class (a) == dw_val_class_high_pc))((void)(!(a && (AT_class (a) == dw_val_class_lbl_id ||
AT_class (a) == dw_val_class_lineptr || AT_class (a) == dw_val_class_macptr
|| AT_class (a) == dw_val_class_loclistsptr || AT_class (a) ==
dw_val_class_high_pc)) ? fancy_abort ("/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5429, __FUNCTION__), 0 : 0))
;
5430 return a->dw_attr_val.v.val_lbl_id;
5431}
5432
5433/* Get the attribute of type attr_kind. */
5434
5435dw_attr_node *
5436get_AT (dw_die_ref die, enum dwarf_attribute attr_kind)
5437{
5438 dw_attr_node *a;
5439 unsigned ix;
5440 dw_die_ref spec = NULLnullptr;
5441
5442 if (! die)
5443 return NULLnullptr;
5444
5445 FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)for (ix = 0; vec_safe_iterate ((die->die_attr), (ix), &
(a)); ++(ix))
5446 if (a->dw_attr == attr_kind)
5447 return a;
5448 else if (a->dw_attr == DW_AT_specification
5449 || a->dw_attr == DW_AT_abstract_origin)
5450 spec = AT_ref (a);
5451
5452 if (spec)
5453 return get_AT (spec, attr_kind);
5454
5455 return NULLnullptr;
5456}
5457
5458/* Returns the parent of the declaration of DIE. */
5459
5460static dw_die_ref
5461get_die_parent (dw_die_ref die)
5462{
5463 dw_die_ref t;
5464
5465 if (!die)
5466 return NULLnullptr;
5467
5468 if ((t = get_AT_ref (die, DW_AT_abstract_origin))
5469 || (t = get_AT_ref (die, DW_AT_specification)))
5470 die = t;
5471
5472 return die->die_parent;
5473}
5474
5475/* Return the "low pc" attribute value, typically associated with a subprogram
5476 DIE. Return null if the "low pc" attribute is either not present, or if it
5477 cannot be represented as an assembler label identifier. */
5478
5479static inline const char *
5480get_AT_low_pc (dw_die_ref die)
5481{
5482 dw_attr_node *a = get_AT (die, DW_AT_low_pc);
5483
5484 return a ? AT_lbl (a) : NULLnullptr;
5485}
5486
5487/* Return the value of the string attribute designated by ATTR_KIND, or
5488 NULL if it is not present. */
5489
5490const char *
5491get_AT_string (dw_die_ref die, enum dwarf_attribute attr_kind)
5492{
5493 dw_attr_node *a = get_AT (die, attr_kind);
5494
5495 return a ? AT_string (a) : NULLnullptr;
5496}
5497
5498/* Return the value of the flag attribute designated by ATTR_KIND, or -1
5499 if it is not present. */
5500
5501int
5502get_AT_flag (dw_die_ref die, enum dwarf_attribute attr_kind)
5503{
5504 dw_attr_node *a = get_AT (die, attr_kind);
5505
5506 return a ? AT_flag (a) : 0;
5507}
5508
5509/* Return the value of the unsigned attribute designated by ATTR_KIND, or 0
5510 if it is not present. */
5511
5512unsigned
5513get_AT_unsigned (dw_die_ref die, enum dwarf_attribute attr_kind)
5514{
5515 dw_attr_node *a = get_AT (die, attr_kind);
5516
5517 return a ? AT_unsigned (a) : 0;
5518}
5519
5520dw_die_ref
5521get_AT_ref (dw_die_ref die, enum dwarf_attribute attr_kind)
5522{
5523 dw_attr_node *a = get_AT (die, attr_kind);
5524
5525 return a ? AT_ref (a) : NULLnullptr;
5526}
5527
5528struct dwarf_file_data *
5529get_AT_file (dw_die_ref die, enum dwarf_attribute attr_kind)
5530{
5531 dw_attr_node *a = get_AT (die, attr_kind);
5532
5533 return a ? AT_file (a) : NULLnullptr;
5534}
5535
5536/* Return TRUE if the language is C. */
5537
5538static inline bool
5539is_c (void)
5540{
5541 unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language);
5542
5543 return (lang == DW_LANG_C || lang == DW_LANG_C89 || lang == DW_LANG_C99
5544 || lang == DW_LANG_C11 || lang == DW_LANG_ObjC);
5545
5546
5547}
5548
5549/* Return TRUE if the language is C++. */
5550
5551static inline bool
5552is_cxx (void)
5553{
5554 unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language);
5555
5556 return (lang == DW_LANG_C_plus_plus || lang == DW_LANG_ObjC_plus_plus
5557 || lang == DW_LANG_C_plus_plus_11 || lang == DW_LANG_C_plus_plus_14);
5558}
5559
5560/* Return TRUE if DECL was created by the C++ frontend. */
5561
5562static bool
5563is_cxx (const_tree decl)
5564{
5565 if (in_lto_pglobal_options.x_in_lto_p)
5566 {
5567 const_tree context = get_ultimate_context (decl);
5568 if (context && TRANSLATION_UNIT_LANGUAGE (context)((tree_check ((context), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5568, __FUNCTION__, (TRANSLATION_UNIT_DECL)))->translation_unit_decl
.language)
)
5569 return startswith (TRANSLATION_UNIT_LANGUAGE (context)((tree_check ((context), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5569, __FUNCTION__, (TRANSLATION_UNIT_DECL)))->translation_unit_decl
.language)
, "GNU C++");
5570 }
5571 return is_cxx ();
5572}
5573
5574/* Return TRUE if the language is Fortran. */
5575
5576static inline bool
5577is_fortran (void)
5578{
5579 unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language);
5580
5581 return (lang == DW_LANG_Fortran77
5582 || lang == DW_LANG_Fortran90
5583 || lang == DW_LANG_Fortran95
5584 || lang == DW_LANG_Fortran03
5585 || lang == DW_LANG_Fortran08);
5586}
5587
5588static inline bool
5589is_fortran (const_tree decl)
5590{
5591 if (in_lto_pglobal_options.x_in_lto_p)
5592 {
5593 const_tree context = get_ultimate_context (decl);
5594 if (context && TRANSLATION_UNIT_LANGUAGE (context)((tree_check ((context), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5594, __FUNCTION__, (TRANSLATION_UNIT_DECL)))->translation_unit_decl
.language)
)
5595 return (strncmp (TRANSLATION_UNIT_LANGUAGE (context)((tree_check ((context), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5595, __FUNCTION__, (TRANSLATION_UNIT_DECL)))->translation_unit_decl
.language)
,
5596 "GNU Fortran", 11) == 0
5597 || strcmp (TRANSLATION_UNIT_LANGUAGE (context)((tree_check ((context), "/buildworker/marxinbox-gcc-clang-static-analyzer/build/gcc/dwarf2out.cc"
, 5597, __FUNCTION__, (TRANSLATION_UNIT_DECL)))->translation_unit_decl
.language)
,
5598 "GNU F77") == 0);
5599 }
5600 return is_fortran ();
5601}
5602
5603/* Return TRUE if the language is Rust.
5604 Note, returns FALSE for dwarf_version < 5 && dwarf_strict. */
5605
5606static inline bool
5607is_rust ()
5608{
5609 unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language);
5610
5611 return lang == DW_LANG_Rust;
5612}
5613
5614/* Return TRUE if the language is Ada. */
5615
5616static inline bool
5617is_ada (void)
5618{
5619 unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language);
5620
5621 return lang == DW_LANG_Ada95 || lang == DW_LANG_Ada83;
5622}
5623
5624/* Return TRUE if the language is D. */
5625
5626static inline bool
5627is_dlang (void)
5628{
5629 unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language);
5630
5631 return lang == DW_LANG_D;
5632}
5633
5634/* Remove the specified attribute if present. Return TRUE if removal
5635 was successful. */
5636
5637static bool
5638remove_AT (dw_die_ref die, enum dwarf_attribute attr_kind)
5639{
5640 dw_attr_node *a;
5641 unsigned ix;
5642
5643 if (! die)
5644 return false;
5645
5646 FOR_EACH_VEC_SAFE_ELT (die->die_attr, ix, a)for (ix = 0; vec_safe_iterate ((die->die_attr), (ix), &
(a)); ++(ix))
5647 if (a->dw_attr == attr_kind)
5648