aboutsummaryrefslogtreecommitdiff
path: root/gcc/dwarf2out.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r--gcc/dwarf2out.c118
1 files changed, 74 insertions, 44 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 9a91981..13998b2 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -79,6 +79,7 @@ along with GCC; see the file COPYING3. If not see
#include "output.h"
#include "expr.h"
#include "dwarf2out.h"
+#include "dwarf2ctf.h"
#include "dwarf2asm.h"
#include "toplev.h"
#include "md5.h"
@@ -1332,12 +1333,6 @@ dwarf2out_switch_text_section (void)
/* And now, the subset of the debugging information support code necessary
for emitting location expressions. */
-/* Data about a single source file. */
-struct GTY((for_user)) dwarf_file_data {
- const char * filename;
- int emitted_number;
-};
-
/* Describe an entry into the .debug_addr section. */
enum ate_kind {
@@ -3123,17 +3118,6 @@ maybe_reset_location_view (rtx_insn *insn, dw_line_info_table *table)
RESET_NEXT_VIEW (table->view);
}
-/* Each DIE attribute has a field specifying the attribute kind,
- a link to the next attribute in the chain, and an attribute value.
- Attributes are typically linked below the DIE they modify. */
-
-typedef struct GTY(()) dw_attr_struct {
- enum dwarf_attribute dw_attr;
- dw_val_node dw_attr_val;
-}
-dw_attr_node;
-
-
/* The Debugging Information Entry (DIE) structure. DIEs form a tree.
The children of each node form a circular list linked by
die_sib. die_child points to the node *before* the "first" child node. */
@@ -3711,14 +3695,11 @@ static const char *dwarf_form_name (unsigned);
static tree decl_ultimate_origin (const_tree);
static tree decl_class_context (tree);
static void add_dwarf_attr (dw_die_ref, dw_attr_node *);
-static inline enum dw_val_class AT_class (dw_attr_node *);
static inline unsigned int AT_index (dw_attr_node *);
static void add_AT_flag (dw_die_ref, enum dwarf_attribute, unsigned);
static inline unsigned AT_flag (dw_attr_node *);
static void add_AT_int (dw_die_ref, enum dwarf_attribute, HOST_WIDE_INT);
-static inline HOST_WIDE_INT AT_int (dw_attr_node *);
static void add_AT_unsigned (dw_die_ref, enum dwarf_attribute, unsigned HOST_WIDE_INT);
-static inline unsigned HOST_WIDE_INT AT_unsigned (dw_attr_node *);
static void add_AT_double (dw_die_ref, enum dwarf_attribute,
HOST_WIDE_INT, unsigned HOST_WIDE_INT);
static inline void add_AT_vec (dw_die_ref, enum dwarf_attribute, unsigned int,
@@ -3733,7 +3714,6 @@ static inline dw_die_ref AT_ref (dw_attr_node *);
static inline int AT_ref_external (dw_attr_node *);
static inline void set_AT_ref_external (dw_attr_node *, int);
static void add_AT_loc (dw_die_ref, enum dwarf_attribute, dw_loc_descr_ref);
-static inline dw_loc_descr_ref AT_loc (dw_attr_node *);
static void add_AT_loc_list (dw_die_ref, enum dwarf_attribute,
dw_loc_list_ref);
static inline dw_loc_list_ref AT_loc_list (dw_attr_node *);
@@ -3750,12 +3730,7 @@ static void add_AT_macptr (dw_die_ref, enum dwarf_attribute, const char *);
static void add_AT_range_list (dw_die_ref, enum dwarf_attribute,
unsigned long, bool);
static inline const char *AT_lbl (dw_attr_node *);
-static dw_attr_node *get_AT (dw_die_ref, enum dwarf_attribute);
static const char *get_AT_low_pc (dw_die_ref);
-static const char *get_AT_string (dw_die_ref, enum dwarf_attribute);
-static int get_AT_flag (dw_die_ref, enum dwarf_attribute);
-static unsigned get_AT_unsigned (dw_die_ref, enum dwarf_attribute);
-static inline dw_die_ref get_AT_ref (dw_die_ref, enum dwarf_attribute);
static bool is_c (void);
static bool is_cxx (void);
static bool is_cxx (const_tree);
@@ -3769,7 +3744,6 @@ static dw_die_ref lookup_type_die (tree);
static dw_die_ref strip_naming_typedef (tree, dw_die_ref);
static dw_die_ref lookup_type_die_strip_naming_typedef (tree);
static void equate_type_number_to_die (tree, dw_die_ref);
-static dw_die_ref lookup_decl_die (tree);
static var_loc_list *lookup_decl_loc (const_tree);
static void equate_decl_number_to_die (tree, dw_die_ref);
static struct var_loc_node *add_var_loc_to_decl (tree, rtx, const char *, var_loc_view);
@@ -3842,7 +3816,6 @@ static void output_ranges (void);
static dw_line_info_table *new_line_info_table (void);
static void output_line_info (bool);
static void output_file_names (void);
-static dw_die_ref base_type_die (tree, bool);
static int is_base_type (tree);
static dw_die_ref subrange_type_die (tree, tree, tree, tree, dw_die_ref);
static int decl_quals (const_tree);
@@ -3890,7 +3863,6 @@ static rtx rtl_for_decl_location (tree);
static bool add_location_or_const_value_attribute (dw_die_ref, tree, bool);
static bool tree_add_const_value_attribute (dw_die_ref, tree);
static bool tree_add_const_value_attribute_for_decl (dw_die_ref, tree);
-static void add_name_attribute (dw_die_ref, const char *);
static void add_desc_attribute (dw_die_ref, tree);
static void add_gnat_descriptive_type_attribute (dw_die_ref, tree, dw_die_ref);
static void add_comp_dir_attribute (dw_die_ref);
@@ -4497,7 +4469,7 @@ add_dwarf_attr (dw_die_ref die, dw_attr_node *attr)
vec_safe_push (die->die_attr, *attr);
}
-static inline enum dw_val_class
+enum dw_val_class
AT_class (dw_attr_node *a)
{
return a->dw_attr_val.val_class;
@@ -4553,7 +4525,7 @@ add_AT_int (dw_die_ref die, enum dwarf_attribute attr_kind, HOST_WIDE_INT int_va
add_dwarf_attr (die, &attr);
}
-static inline HOST_WIDE_INT
+HOST_WIDE_INT
AT_int (dw_attr_node *a)
{
gcc_assert (a && (AT_class (a) == dw_val_class_const
@@ -4576,7 +4548,7 @@ add_AT_unsigned (dw_die_ref die, enum dwarf_attribute attr_kind,
add_dwarf_attr (die, &attr);
}
-static inline unsigned HOST_WIDE_INT
+unsigned HOST_WIDE_INT
AT_unsigned (dw_attr_node *a)
{
gcc_assert (a && (AT_class (a) == dw_val_class_unsigned_const
@@ -4960,7 +4932,7 @@ add_AT_loc (dw_die_ref die, enum dwarf_attribute attr_kind, dw_loc_descr_ref loc
add_dwarf_attr (die, &attr);
}
-static inline dw_loc_descr_ref
+dw_loc_descr_ref
AT_loc (dw_attr_node *a)
{
gcc_assert (a && AT_class (a) == dw_val_class_loc);
@@ -5201,6 +5173,30 @@ index_addr_table_entry (addr_table_entry **h, unsigned int *index)
return 1;
}
+/* Return the tag of a given DIE. */
+
+enum dwarf_tag
+dw_get_die_tag (dw_die_ref die)
+{
+ return die->die_tag;
+}
+
+/* Return a reference to the children list of a given DIE. */
+
+dw_die_ref
+dw_get_die_child (dw_die_ref die)
+{
+ return die->die_child;
+}
+
+/* Return a reference to the sibling of a given DIE. */
+
+dw_die_ref
+dw_get_die_sib (dw_die_ref die)
+{
+ return die->die_sib;
+}
+
/* Add an address constant attribute value to a DIE. When using
dwarf_split_debug_info, address attributes in dies destined for the
final executable should be direct references--setting the parameter
@@ -5398,7 +5394,7 @@ AT_lbl (dw_attr_node *a)
/* Get the attribute of type attr_kind. */
-static dw_attr_node *
+dw_attr_node *
get_AT (dw_die_ref die, enum dwarf_attribute attr_kind)
{
dw_attr_node *a;
@@ -5453,7 +5449,7 @@ get_AT_low_pc (dw_die_ref die)
/* Return the value of the string attribute designated by ATTR_KIND, or
NULL if it is not present. */
-static inline const char *
+const char *
get_AT_string (dw_die_ref die, enum dwarf_attribute attr_kind)
{
dw_attr_node *a = get_AT (die, attr_kind);
@@ -5464,7 +5460,7 @@ get_AT_string (dw_die_ref die, enum dwarf_attribute attr_kind)
/* Return the value of the flag attribute designated by ATTR_KIND, or -1
if it is not present. */
-static inline int
+int
get_AT_flag (dw_die_ref die, enum dwarf_attribute attr_kind)
{
dw_attr_node *a = get_AT (die, attr_kind);
@@ -5475,7 +5471,7 @@ get_AT_flag (dw_die_ref die, enum dwarf_attribute attr_kind)
/* Return the value of the unsigned attribute designated by ATTR_KIND, or 0
if it is not present. */
-static inline unsigned
+unsigned
get_AT_unsigned (dw_die_ref die, enum dwarf_attribute attr_kind)
{
dw_attr_node *a = get_AT (die, attr_kind);
@@ -5483,7 +5479,7 @@ get_AT_unsigned (dw_die_ref die, enum dwarf_attribute attr_kind)
return a ? AT_unsigned (a) : 0;
}
-static inline dw_die_ref
+dw_die_ref
get_AT_ref (dw_die_ref die, enum dwarf_attribute attr_kind)
{
dw_attr_node *a = get_AT (die, attr_kind);
@@ -5491,7 +5487,7 @@ get_AT_ref (dw_die_ref die, enum dwarf_attribute attr_kind)
return a ? AT_ref (a) : NULL;
}
-static inline struct dwarf_file_data *
+struct dwarf_file_data *
get_AT_file (dw_die_ref die, enum dwarf_attribute attr_kind)
{
dw_attr_node *a = get_AT (die, attr_kind);
@@ -5776,7 +5772,7 @@ splice_child_die (dw_die_ref parent, dw_die_ref child)
/* Create and return a new die with TAG_VALUE as tag. */
-static inline dw_die_ref
+dw_die_ref
new_die_raw (enum dwarf_tag tag_value)
{
dw_die_ref die = ggc_cleared_alloc<die_node> ();
@@ -5921,7 +5917,7 @@ decl_die_hasher::equal (die_node *x, tree y)
/* Return the DIE associated with a given declaration. */
-static inline dw_die_ref
+dw_die_ref
lookup_decl_die (tree decl)
{
dw_die_ref *die = decl_die_table->find_slot_with_hash (decl, DECL_UID (decl),
@@ -13150,7 +13146,7 @@ need_endianity_attribute_p (bool reverse)
This routine must only be called for GCC type nodes that correspond to
Dwarf base (fundamental) types. */
-static dw_die_ref
+dw_die_ref
base_type_die (tree type, bool reverse)
{
dw_die_ref base_type_result;
@@ -20994,7 +20990,7 @@ compute_frame_pointer_to_fb_displacement (poly_int64 offset)
/* Generate a DW_AT_name attribute given some string value to be included as
the value of the attribute. */
-static void
+void
add_name_attribute (dw_die_ref die, const char *name_string)
{
if (name_string != NULL && *name_string != 0)
@@ -28337,7 +28333,10 @@ dwarf2out_source_line (unsigned int line, unsigned int column,
dw_line_info_table *table;
static var_loc_view lvugid;
- if (debug_info_level < DINFO_LEVEL_TERSE)
+ /* 'line_info_table' information gathering is not needed when the debug
+ info level is set to the lowest value. Also, the current DWARF-based
+ debug formats do not use this info. */
+ if (debug_info_level < DINFO_LEVEL_TERSE || !dwarf_debuginfo_p ())
return;
table = cur_line_info_table;
@@ -31881,6 +31880,10 @@ dwarf2out_finish (const char *filename)
unsigned char checksum[16];
char dl_section_ref[MAX_ARTIFICIAL_LABEL_BYTES];
+ /* Skip emitting DWARF if not required. */
+ if (!dwarf_debuginfo_p ())
+ return;
+
/* Flush out any latecomers to the limbo party. */
flush_limbo_die_list ();
@@ -32636,6 +32639,19 @@ note_variable_value (dw_die_ref die)
FOR_EACH_CHILD (die, c, note_variable_value (c));
}
+/* Process DWARF dies for CTF generation. */
+
+static void
+ctf_debug_do_cu (dw_die_ref die)
+{
+ dw_die_ref c;
+
+ if (!ctf_do_die (die))
+ return;
+
+ FOR_EACH_CHILD (die, c, ctf_do_die (c));
+}
+
/* Perform any cleanups needed after the early debug generation pass
has run. */
@@ -32758,6 +32774,20 @@ dwarf2out_early_finish (const char *filename)
print_die (comp_unit_die (), dump_file);
}
+ /* Generate CTF/BTF debug info. */
+ if ((ctf_debug_info_level > CTFINFO_LEVEL_NONE
+ || btf_debuginfo_p ()) && lang_GNU_C ())
+ {
+ ctf_debug_init ();
+ ctf_debug_do_cu (comp_unit_die ());
+ for (limbo_die_node *node = limbo_die_list; node; node = node->next)
+ ctf_debug_do_cu (node->die);
+ /* Post process the debug data in the CTF container if necessary. */
+ ctf_debug_init_postprocess (btf_debuginfo_p ());
+ /* Emit CTF/BTF debug info. */
+ ctf_debug_finalize (filename, btf_debuginfo_p ());
+ }
+
/* Do not generate DWARF assembler now when not producing LTO bytecode. */
if ((!flag_generate_lto && !flag_generate_offload)
/* FIXME: Disable debug info generation for (PE-)COFF targets since the