aboutsummaryrefslogtreecommitdiff
path: root/gcc/opts.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/opts.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/opts.c')
-rw-r--r--gcc/opts.c137
1 files changed, 108 insertions, 29 deletions
diff --git a/gcc/opts.c b/gcc/opts.c
index 52e9e3a..66262c5 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -42,7 +42,7 @@ static void set_Wstrict_aliasing (struct gcc_options *opts, int onoff);
const char *const debug_type_names[] =
{
- "none", "stabs", "dwarf-2", "xcoff", "vms"
+ "none", "stabs", "dwarf-2", "xcoff", "vms", "ctf", "btf"
};
/* Bitmasks of fundamental debug info formats indexed by enum
@@ -50,13 +50,14 @@ const char *const debug_type_names[] =
static uint32_t debug_type_masks[] =
{
- NO_DEBUG, DBX_DEBUG, DWARF2_DEBUG, XCOFF_DEBUG, VMS_DEBUG
+ NO_DEBUG, DBX_DEBUG, DWARF2_DEBUG, XCOFF_DEBUG, VMS_DEBUG,
+ CTF_DEBUG, BTF_DEBUG
};
/* Names of the set of debug formats requested by user. Updated and accessed
via debug_set_names. */
-static char df_set_names[sizeof "none stabs dwarf-2 xcoff vms"];
+static char df_set_names[sizeof "none stabs dwarf-2 xcoff vms ctf btf"];
/* Get enum debug_info_type of the specified debug format, for error messages.
Can be used only for individual debug format types. */
@@ -126,6 +127,14 @@ debug_set_names (uint32_t w_symbols)
return df_set_names;
}
+/* Return TRUE iff BTF debug info is enabled. */
+
+bool
+btf_debuginfo_p ()
+{
+ return (write_symbols & BTF_DEBUG);
+}
+
/* Return TRUE iff dwarf2 debug info is enabled. */
bool
@@ -134,6 +143,15 @@ dwarf_debuginfo_p ()
return (write_symbols & DWARF2_DEBUG);
}
+/* Return true iff the debug info format is to be generated based on DWARF
+ DIEs (like CTF and BTF debug info formats). */
+
+bool dwarf_based_debuginfo_p ()
+{
+ return ((write_symbols & CTF_DEBUG)
+ || (write_symbols & BTF_DEBUG));
+}
+
/* Parse the -femit-struct-debug-detailed option value
and set the flag variables. */
@@ -2868,6 +2886,24 @@ common_handle_option (struct gcc_options *opts,
loc);
break;
+ case OPT_gbtf:
+ set_debug_level (BTF_DEBUG, false, arg, opts, opts_set, loc);
+ /* set the debug level to level 2, but if already at level 3,
+ don't lower it. */
+ if (opts->x_debug_info_level < DINFO_LEVEL_NORMAL)
+ opts->x_debug_info_level = DINFO_LEVEL_NORMAL;
+ break;
+
+ case OPT_gctf:
+ set_debug_level (CTF_DEBUG, false, arg, opts, opts_set, loc);
+ /* CTF generation feeds off DWARF dies. For optimal CTF, switch debug
+ info level to 2. If off or at level 1, set it to level 2, but if
+ already at level 3, don't lower it. */
+ if (opts->x_debug_info_level < DINFO_LEVEL_NORMAL
+ && opts->x_ctf_debug_info_level > CTFINFO_LEVEL_NONE)
+ opts->x_debug_info_level = DINFO_LEVEL_NORMAL;
+ break;
+
case OPT_gdwarf:
if (arg && strlen (arg) != 0)
{
@@ -3116,7 +3152,10 @@ set_debug_level (uint32_t dinfo, int extended, const char *arg,
if (extended == 2)
{
#if defined DWARF2_DEBUGGING_INFO || defined DWARF2_LINENO_DEBUGGING_INFO
- opts->x_write_symbols = DWARF2_DEBUG;
+ if (opts->x_write_symbols & CTF_DEBUG)
+ opts->x_write_symbols |= DWARF2_DEBUG;
+ else
+ opts->x_write_symbols = DWARF2_DEBUG;
#elif defined DBX_DEBUGGING_INFO
opts->x_write_symbols = DBX_DEBUG;
#endif
@@ -3125,41 +3164,81 @@ set_debug_level (uint32_t dinfo, int extended, const char *arg,
if (opts->x_write_symbols == NO_DEBUG)
warning_at (loc, 0, "target system does not support debug output");
}
+ else if ((opts->x_write_symbols & CTF_DEBUG)
+ || (opts->x_write_symbols & BTF_DEBUG))
+ {
+ opts->x_write_symbols |= DWARF2_DEBUG;
+ opts_set->x_write_symbols |= DWARF2_DEBUG;
+ }
}
else
{
- /* Does it conflict with an already selected debug format? */
- if (opts_set->x_write_symbols != NO_DEBUG
- && opts->x_write_symbols != NO_DEBUG
- && dinfo != opts->x_write_symbols)
+ /* Make and retain the choice if both CTF and DWARF debug info are to
+ be generated. */
+ if (((dinfo == DWARF2_DEBUG) || (dinfo == CTF_DEBUG))
+ && ((opts->x_write_symbols == (DWARF2_DEBUG|CTF_DEBUG))
+ || (opts->x_write_symbols == DWARF2_DEBUG)
+ || (opts->x_write_symbols == CTF_DEBUG)))
{
- gcc_assert (debug_set_count (dinfo) <= 1);
- error_at (loc, "debug format %qs conflicts with prior selection",
- debug_type_names[debug_set_to_format (dinfo)]);
+ opts->x_write_symbols |= dinfo;
+ opts_set->x_write_symbols |= dinfo;
+ }
+ /* However, CTF and BTF are not allowed together at this time. */
+ else if (((dinfo == DWARF2_DEBUG) || (dinfo == BTF_DEBUG))
+ && ((opts->x_write_symbols == (DWARF2_DEBUG|BTF_DEBUG))
+ || (opts->x_write_symbols == DWARF2_DEBUG)
+ || (opts->x_write_symbols == BTF_DEBUG)))
+ {
+ opts->x_write_symbols |= dinfo;
+ opts_set->x_write_symbols |= dinfo;
+ }
+ else
+ {
+ /* Does it conflict with an already selected debug format? */
+ if (opts_set->x_write_symbols != NO_DEBUG
+ && opts->x_write_symbols != NO_DEBUG
+ && dinfo != opts->x_write_symbols)
+ {
+ gcc_assert (debug_set_count (dinfo) <= 1);
+ error_at (loc, "debug format %qs conflicts with prior selection",
+ debug_type_names[debug_set_to_format (dinfo)]);
+ }
+ opts->x_write_symbols = dinfo;
+ opts_set->x_write_symbols = dinfo;
}
-
- opts->x_write_symbols = dinfo;
- opts_set->x_write_symbols = dinfo;
}
- /* A debug flag without a level defaults to level 2.
- If off or at level 1, set it to level 2, but if already
- at level 3, don't lower it. */
- if (*arg == '\0')
- {
- if (opts->x_debug_info_level < DINFO_LEVEL_NORMAL)
- opts->x_debug_info_level = DINFO_LEVEL_NORMAL;
- }
- else
+ if (dinfo != BTF_DEBUG)
{
- int argval = integral_argument (arg);
- if (argval == -1)
- error_at (loc, "unrecognized debug output level %qs", arg);
- else if (argval > 3)
- error_at (loc, "debug output level %qs is too high", arg);
+ /* A debug flag without a level defaults to level 2.
+ If off or at level 1, set it to level 2, but if already
+ at level 3, don't lower it. */
+ if (*arg == '\0')
+ {
+ if (dinfo == CTF_DEBUG)
+ opts->x_ctf_debug_info_level = CTFINFO_LEVEL_NORMAL;
+ else if (opts->x_debug_info_level < DINFO_LEVEL_NORMAL)
+ opts->x_debug_info_level = DINFO_LEVEL_NORMAL;
+ }
else
- opts->x_debug_info_level = (enum debug_info_levels) argval;
+ {
+ int argval = integral_argument (arg);
+ if (argval == -1)
+ error_at (loc, "unrecognized debug output level %qs", arg);
+ else if (argval > 3)
+ error_at (loc, "debug output level %qs is too high", arg);
+ else
+ {
+ if (dinfo == CTF_DEBUG)
+ opts->x_ctf_debug_info_level
+ = (enum ctf_debug_info_levels) argval;
+ else
+ opts->x_debug_info_level = (enum debug_info_levels) argval;
+ }
+ }
}
+ else if (*arg != '\0')
+ error_at (loc, "unrecognized btf debug output level %qs", arg);
}
/* Arrange to dump core on error for diagnostic context DC. (The