Message ID | 20240530213222.440435-7-david.faust@oracle.com |
---|---|
State | New |
Headers | show |
Series | btf: refactor and add pruning option | expand |
On 5/30/24 14:32, David Faust wrote: > Previously it was not supported to generate both CTF and BTF debug info > in the same compiler run, as both formats made incompatible changes to > the same internal data structures. > > With the structural change in the prior patches, in particular the > guarantee that CTF will always be fully emitted before any BTF > translation occurs, there is no longer anything preventing generation > of both CTF and BTF at the same time. This patch changes option parsing > to allow any combination of -gdwarf, -gctf, and -gbtf at the same time. > I am not an approver for this change, but I have a comment below. > gcc/ > * opts.cc (set_debug_level): Allow any combination of -gdwarf, > -gctf and -gbtf at the same time. > --- > gcc/opts.cc | 20 +++++++------------- > 1 file changed, 7 insertions(+), 13 deletions(-) > > diff --git a/gcc/opts.cc b/gcc/opts.cc > index f80d5d4ba8f9..d58bea096a5f 100644 > --- a/gcc/opts.cc > +++ b/gcc/opts.cc > @@ -3505,21 +3505,15 @@ set_debug_level (uint32_t dinfo, int extended, const char *arg, > } > else > { > - /* Make and retain the choice if both CTF and DWARF debug info are to > - be generated. */ > - if (((dinfo == DWARF2_DEBUG) || (dinfo == CTF_DEBUG)) > + /* Any combination of DWARF, CTF and BTF is allowed together. */ > + if (((dinfo == DWARF2_DEBUG) || (dinfo == CTF_DEBUG) > + || (dinfo == BTF_DEBUG)) > && ((opts->x_write_symbols == (DWARF2_DEBUG|CTF_DEBUG)) > + || (opts->x_write_symbols == (DWARF2_DEBUG|BTF_DEBUG)) > + || (opts->x_write_symbols == (CTF_DEBUG|BTF_DEBUG)) > || (opts->x_write_symbols == DWARF2_DEBUG) > - || (opts->x_write_symbols == CTF_DEBUG))) > - { > - 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 == CTF_DEBUG) > + || (opts->x_write_symbols == BTF_DEBUG))) I realised that this check will cause failures on double occurrences of the command line flags: $ gcc -c sort.c -g3 -gctf -flto -gbtf -gctf gcc: error: debug format ‘ctf’ conflicts with prior selection What do you think about the following check instead ? if ((dinfo == DWARF2_DEBUG || dinfo == CTF_DEBUG || dinfo == BTF_DEBUG) && ((opts->x_write_symbols | (DWARF2_DEBUG|CTF_DEBUG|BTF_DEBUG)) == (DWARF2_DEBUG|CTF_DEBUG|BTF_DEBUG))) { We have some testcases for checking -gctf -gdwarf (in debug/ctf/ctf-debug*), adding something for -gctf -gbtf will be great. > { > opts->x_write_symbols |= dinfo; > opts_set->x_write_symbols |= dinfo;
diff --git a/gcc/opts.cc b/gcc/opts.cc index f80d5d4ba8f9..d58bea096a5f 100644 --- a/gcc/opts.cc +++ b/gcc/opts.cc @@ -3505,21 +3505,15 @@ set_debug_level (uint32_t dinfo, int extended, const char *arg, } else { - /* Make and retain the choice if both CTF and DWARF debug info are to - be generated. */ - if (((dinfo == DWARF2_DEBUG) || (dinfo == CTF_DEBUG)) + /* Any combination of DWARF, CTF and BTF is allowed together. */ + if (((dinfo == DWARF2_DEBUG) || (dinfo == CTF_DEBUG) + || (dinfo == BTF_DEBUG)) && ((opts->x_write_symbols == (DWARF2_DEBUG|CTF_DEBUG)) + || (opts->x_write_symbols == (DWARF2_DEBUG|BTF_DEBUG)) + || (opts->x_write_symbols == (CTF_DEBUG|BTF_DEBUG)) || (opts->x_write_symbols == DWARF2_DEBUG) - || (opts->x_write_symbols == CTF_DEBUG))) - { - 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 == CTF_DEBUG) + || (opts->x_write_symbols == BTF_DEBUG))) { opts->x_write_symbols |= dinfo; opts_set->x_write_symbols |= dinfo;