Message ID | 20240611190145.115887-7-david.faust@oracle.com |
---|---|
State | New |
Headers | show |
Series | btf: refactor and add pruning option | expand |
Ping. archive: https://gcc.gnu.org/pipermail/gcc-patches/2024-June/654253.html On 6/11/24 12:01, 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. > > gcc/ > * opts.cc (set_debug_level): Allow any combination of -gdwarf, > -gctf and -gbtf to be enabled at the same time. > > gcc/testsuite/ > * gcc.dg/debug/btf/btf-3.c: New test. > * gcc.dg/debug/btf/btf-4.c: Likewise. > * gcc.dg/debug/btf/btf-5.c: Likewise. > --- > gcc/opts.cc | 20 +++++--------------- > gcc/testsuite/gcc.dg/debug/btf/btf-3.c | 8 ++++++++ > gcc/testsuite/gcc.dg/debug/btf/btf-4.c | 8 ++++++++ > gcc/testsuite/gcc.dg/debug/btf/btf-5.c | 9 +++++++++ > 4 files changed, 30 insertions(+), 15 deletions(-) > create mode 100644 gcc/testsuite/gcc.dg/debug/btf/btf-3.c > create mode 100644 gcc/testsuite/gcc.dg/debug/btf/btf-4.c > create mode 100644 gcc/testsuite/gcc.dg/debug/btf/btf-5.c > > diff --git a/gcc/opts.cc b/gcc/opts.cc > index 1b1b46455af6..7e9f2d91172b 100644 > --- a/gcc/opts.cc > +++ b/gcc/opts.cc > @@ -3506,21 +3506,11 @@ 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)) > - && ((opts->x_write_symbols == (DWARF2_DEBUG|CTF_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))) > + /* Any combination of DWARF, CTF and BTF is allowed. */ > + 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))) > { > opts->x_write_symbols |= dinfo; > opts_set->x_write_symbols |= dinfo; > diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-3.c b/gcc/testsuite/gcc.dg/debug/btf/btf-3.c > new file mode 100644 > index 000000000000..93c8164a2a54 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-3.c > @@ -0,0 +1,8 @@ > +/* Verify that BTF debug info can co-exist with DWARF. */ > +/* { dg-do compile } */ > +/* { dg-options "-gdwarf -gbtf -dA" } */ > +/* { dg-final { scan-assembler "0xeb9f.*btf_magic" } } */ > +/* { dg-final { scan-assembler "DWARF version number" } } */ > + > +void func (void) > +{ } > diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-4.c b/gcc/testsuite/gcc.dg/debug/btf/btf-4.c > new file mode 100644 > index 000000000000..b087917188bb > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-4.c > @@ -0,0 +1,8 @@ > +/* Verify that BTF debug info can co-exist with CTF. */ > +/* { dg-do compile } */ > +/* { dg-options "-gctf -gbtf -dA" } */ > +/* { dg-final { scan-assembler "0xeb9f.*btf_magic" } } */ > +/* { dg-final { scan-assembler "0xdff2.*CTF preamble magic number" } } */ > + > +void func (void) > +{ } > diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-5.c b/gcc/testsuite/gcc.dg/debug/btf/btf-5.c > new file mode 100644 > index 000000000000..45267b5fc422 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-5.c > @@ -0,0 +1,9 @@ > +/* Verify that BTF, CTF and DWARF can all co-exist happily. */ > +/* { dg-do compile } */ > +/* { dg-options "-gctf -gbtf -gdwarf -dA" } */ > +/* { dg-final { scan-assembler "0xeb9f.*btf_magic" } } */ > +/* { dg-final { scan-assembler "0xdff2.*CTF preamble magic number" } } */ > +/* { dg-final { scan-assembler "DWARF version number" } } */ > + > +void func (void) > +{ }
diff --git a/gcc/opts.cc b/gcc/opts.cc index 1b1b46455af6..7e9f2d91172b 100644 --- a/gcc/opts.cc +++ b/gcc/opts.cc @@ -3506,21 +3506,11 @@ 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)) - && ((opts->x_write_symbols == (DWARF2_DEBUG|CTF_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))) + /* Any combination of DWARF, CTF and BTF is allowed. */ + 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))) { opts->x_write_symbols |= dinfo; opts_set->x_write_symbols |= dinfo; diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-3.c b/gcc/testsuite/gcc.dg/debug/btf/btf-3.c new file mode 100644 index 000000000000..93c8164a2a54 --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-3.c @@ -0,0 +1,8 @@ +/* Verify that BTF debug info can co-exist with DWARF. */ +/* { dg-do compile } */ +/* { dg-options "-gdwarf -gbtf -dA" } */ +/* { dg-final { scan-assembler "0xeb9f.*btf_magic" } } */ +/* { dg-final { scan-assembler "DWARF version number" } } */ + +void func (void) +{ } diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-4.c b/gcc/testsuite/gcc.dg/debug/btf/btf-4.c new file mode 100644 index 000000000000..b087917188bb --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-4.c @@ -0,0 +1,8 @@ +/* Verify that BTF debug info can co-exist with CTF. */ +/* { dg-do compile } */ +/* { dg-options "-gctf -gbtf -dA" } */ +/* { dg-final { scan-assembler "0xeb9f.*btf_magic" } } */ +/* { dg-final { scan-assembler "0xdff2.*CTF preamble magic number" } } */ + +void func (void) +{ } diff --git a/gcc/testsuite/gcc.dg/debug/btf/btf-5.c b/gcc/testsuite/gcc.dg/debug/btf/btf-5.c new file mode 100644 index 000000000000..45267b5fc422 --- /dev/null +++ b/gcc/testsuite/gcc.dg/debug/btf/btf-5.c @@ -0,0 +1,9 @@ +/* Verify that BTF, CTF and DWARF can all co-exist happily. */ +/* { dg-do compile } */ +/* { dg-options "-gctf -gbtf -gdwarf -dA" } */ +/* { dg-final { scan-assembler "0xeb9f.*btf_magic" } } */ +/* { dg-final { scan-assembler "0xdff2.*CTF preamble magic number" } } */ +/* { dg-final { scan-assembler "DWARF version number" } } */ + +void func (void) +{ }