aboutsummaryrefslogtreecommitdiff
path: root/gcc/dwarf2out.c
diff options
context:
space:
mode:
authorIndu Bhagat <indu.bhagat@oracle.com>2021-05-20 11:15:52 -0700
committerJose E. Marchesi <jose.marchesi@oracle.com>2021-06-28 18:47:20 +0200
commitb7e215a8ee81d44281d9e0a2a25eceb47b6911dd (patch)
tree121afbbec2428c85a68b6119ac8c0f25f6cd9fab /gcc/dwarf2out.c
parent532617d6367c29803d5909f2432b1ebfb9ee1886 (diff)
downloadgcc-b7e215a8ee81d44281d9e0a2a25eceb47b6911dd.zip
gcc-b7e215a8ee81d44281d9e0a2a25eceb47b6911dd.tar.gz
gcc-b7e215a8ee81d44281d9e0a2a25eceb47b6911dd.tar.bz2
CTF/BTF debug formats
This commit introduces support for generating CTF debugging information and BTF debugging information from GCC. 2021-06-28 Indu Bhagat <indu.bhagat@oracle.com> David Faust <david.faust@oracle.com> Jose E. Marchesi <jose.marchesi@oracle.com> Weimin Pan <weimin.pan@oracle.com> gcc/ * Makefile.in: Add ctfc.*, ctfout.c and btfout.c files to GTFILES. Add new object files. * common.opt: Add CTF and BTF debug info options. * btfout.c: New file. * ctfc.c: Likewise. * ctfc.h: Likewise. * ctfout.c: Likewise. * dwarf2ctf.c: Likewise. * dwarf2ctf.h: Likewise. * dwarf2cfi.c (dwarf2out_do_frame): Acknowledge CTF_DEBUG and BTF_DEBUG. * dwarf2out.c (dwarf2out_source_line): Likewise. (dwarf2out_finish): Skip emitting DWARF if CTF or BTF are to be generated. (debug_format_do_cu): New function. (dwarf2out_early_finish): Traverse DIEs and emit CTF/BTF for them if requested. Include dwarf2ctf.c. * final.c (dwarf2_debug_info_emitted_p): Acknowledge DWARF-based debug formats. * flag-types.h (enum debug_info_type): Add CTF_DEBUG and BTF_DEBUG. (CTF_DEBUG): New bitmask. (BTF_DEBUG): Likewise. (enum ctf_debug_info_levels): New enum. * gengtype.c (open_base_files): Handle ctfc.h. (main): Handle uint32_t type. * flags.h (btf_debuginfo_p): New definition. (dwarf_based_debuginfo_p): Likewise. * opts.c (debug_type_names): Add entries for CTF and BTF. (btf_debuginfo_p): New function. (dwarf_based_debuginfo_p): Likewise. (common_handle_option): Handle -gctfN and -gbtf options. (set_debug_level): Set CTF_DEBUG, BTF_DEBUG whenever appropriate. * toplev.c (process_options): Inform the user and ignore -gctfLEVEL if frontend is not C. include/ * ctf.h: New file. * btf.h: Likewise. libiberty/ * simple-object.c (handle_lto_debug_sections): Copy over .ctf sections.
Diffstat (limited to 'gcc/dwarf2out.c')
-rw-r--r--gcc/dwarf2out.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index e10006c..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"
@@ -28332,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;
@@ -31876,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 ();
@@ -32631,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. */
@@ -32753,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