On Wed, Sep 3, 2025 at 9:29 PM Sam James <[email protected]> wrote:
>
> Back in GCC 8, with r8-5241-g8697bf9f46f361 (-gstatement-frontiers),
> r8-6658-g58006663903200, r8-6657-gbd2b9f1e2d67ec (-gvariable-location-views),
> some advanced GNU extensions to DWARF were introduced and enabled by default
> with the aim of improving debugging optimized code.
>
> Unfortunately, as of yet, consumer support has't materialised in neither
> GDB nor LLDB and there's no sign of any progress on those fronts. On the
> GCC side, there's a large number of -fcompare-debug issues involving
> -gstatement-frontiers, and some others involving -gvariable-location-views,
> and there's nobody working on those at present.
>
> (For arm the other day, bootstrap w/ compare-debug failed as well for
> the same reason.)
>
> The format even seems to confuse LLDB. It'd be easier to lobby for that
> being fixed if GDB itself had support, but it doesn't. I've only made the
> change for DWARF as I'm only certain about the ecosystem there.
>
> Alexandre Oliva was the architct of the work and has recommended they
> be turned off by default for the foreseeable future. Implement that.
>
> (In researching afterwards, I found Jakub submitted a similar change
> in the past:
> https://inbox.sourceware.org/gcc-patches/YmA%2Fbyg8CdYQAG6u@tucnak/)
>
> In terms of the testsuite:
> * inline{2,6}.c simply relied on features we're now disabling, so re-enable
> them. We already pass a bunch of flags there for similar reasons;
>
> * deallocator.C loses a reference to a source line which was only being
> added for a LV, but there's already one right below it. The testcase has
> had a lot of tweaks in the past and given what the comment describing it
> says, this doesn't seem to be a problem;
>
> * guality churn (a wash);
>
> * A bunch of improvements for -fcompare-debug issues that appeared after
> r16-2197-g385d9937f0e23c too which is expected because we're disabling
> statement frontiers.
>
> * c-c++-common/goacc/kernels-decompose-pr100400-1-2.c now has many XPASS
> and some XFAIL. Looking at PR103836, it's not immediately obvious what
> tweak to make here.
>
> gdb's testsuite shows no changes.
>
> Bug: https://sourceware.org/PR25507
> Bug: https://github.com/llvm/llvm-project/issues/102433
> Link: https://inbox.sourceware.org/gcc-patches/[email protected]/
> Link: https://inbox.sourceware.org/gcc-patches/[email protected]/
>
> gcc/ChangeLog:
> PR debug/99654
> PR debug/104277
> PR middle-end/103836
> PR debug/121045
>
> * common.opt (gvariable-location-views): Default to 0, not 1.
> (gvariable-location-views=incompat5): Default to 0, not 2.
> * opts.cc (finish_options): Don't default-enable
> opts->x_debug_nonbind_markers_p for DWARF.
> * toplev.cc (process_options): Don't default-enable
> debug_variable_location_views.
>
> gcc/testsuite/ChangeLog:
>
> * g++.dg/debug/dwarf2/deallocator.C: Adjust test.
> * gcc.dg/debug/dwarf2/inline2.c: Pass -gstatement-frontiers
> -gvariable-location-views.
> * gcc.dg/debug/dwarf2/inline6.c: Ditto.
> ---
> Bootstrapped and tested on x86_64-pc-linux-gnu. OK?
>
> gcc/common.opt | 4 ++--
> gcc/opts.cc | 2 +-
> gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C | 1 -
> gcc/testsuite/gcc.dg/debug/dwarf2/inline2.c | 2 +-
> gcc/testsuite/gcc.dg/debug/dwarf2/inline6.c | 2 +-
> gcc/toplev.cc | 12 +++---------
> 6 files changed, 8 insertions(+), 15 deletions(-)
>
> diff --git a/gcc/common.opt b/gcc/common.opt
> index cd6a224c9a9a..a16329bfef9b 100644
> --- a/gcc/common.opt
> +++ b/gcc/common.opt
> @@ -3758,11 +3758,11 @@ Common Driver Var(flag_gtoggle)
> Toggle debug information generation.
>
> gvariable-location-views
> -Common Driver Var(debug_variable_location_views, 1)
> +Common Driver Var(debug_variable_location_views) Init(0)
> Augment variable location lists with progressive views.
>
> gvariable-location-views=incompat5
> -Common Driver RejectNegative Var(debug_variable_location_views, -1) Init(2)
> +Common Driver RejectNegative Var(debug_variable_location_views, -1) Init(0)
>
> gvms
> Common Driver JoinedOrMissing RejectNegative
> diff --git a/gcc/opts.cc b/gcc/opts.cc
> index 3ab993aea573..ba1e2a0c1852 100644
> --- a/gcc/opts.cc
> +++ b/gcc/opts.cc
> @@ -1424,7 +1424,7 @@ finish_options (struct gcc_options *opts, struct
> gcc_options *opts_set,
> opts->x_debug_nonbind_markers_p
> = (opts->x_optimize
> && ((opts->x_debug_info_level >= DINFO_LEVEL_NORMAL
> - && (dwarf_debuginfo_p (opts) || codeview_debuginfo_p ()))
> + && codeview_debuginfo_p ())
We only really have DWARF, everything else derives from it, so I
suggest to simply change this to = false.
> || opts->x_flag_auto_profile)
> && !(opts->x_flag_selective_scheduling
> || opts->x_flag_selective_scheduling2));
> diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C
> b/gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C
> index c1d387922ba2..8cab6ccb0277 100644
> --- a/gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C
> +++ b/gcc/testsuite/g++.dg/debug/dwarf2/deallocator.C
> @@ -40,6 +40,5 @@ void foo(int i)
> test_outside.foo();
> return;
> }
> -// { dg-final { scan-assembler "deallocator.C:29" } }
> // { dg-final { scan-assembler "deallocator.C:24" } }
> // { dg-final { scan-assembler "deallocator.C:21" } }
> diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/inline2.c
> b/gcc/testsuite/gcc.dg/debug/dwarf2/inline2.c
> index f5d7e4efd161..b55a9d5600eb 100644
> --- a/gcc/testsuite/gcc.dg/debug/dwarf2/inline2.c
> +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/inline2.c
> @@ -16,7 +16,7 @@
>
> /* Explicitly use dwarf-2 because dwarf-5 might use DW_FORM_implicit_const
> which is hard to scan for. */
> -/* { dg-options "-O -g3 -gdwarf-2 -gno-strict-dwarf -dA -fgnu89-inline" } */
> +/* { dg-options "-O -g3 -gdwarf-2 -gstatement-frontiers
> -gvariable-location-views -gno-strict-dwarf -dA -fgnu89-inline" } */
> /* { dg-do compile } */
>
> /* There are 6 inlined subroutines:
> diff --git a/gcc/testsuite/gcc.dg/debug/dwarf2/inline6.c
> b/gcc/testsuite/gcc.dg/debug/dwarf2/inline6.c
> index f271ebbcc803..4ca830ee4495 100644
> --- a/gcc/testsuite/gcc.dg/debug/dwarf2/inline6.c
> +++ b/gcc/testsuite/gcc.dg/debug/dwarf2/inline6.c
> @@ -16,7 +16,7 @@
>
> /* Explicitly use dwarf-5 which uses DW_FORM_implicit_const. */
> /* { dg-do compile } */
> -/* { dg-options "-O -g3 -gdwarf-5 -gno-strict-dwarf -dA -fgnu89-inline
> -gno-as-loc-support" } */
> +/* { dg-options "-O -g3 -gdwarf-5 -gstatement-frontiers
> -gvariable-location-views -gno-strict-dwarf -dA -fgnu89-inline
> -gno-as-loc-support" } */
>
> /* There are 6 inlined subroutines:
> - One for each subroutine inlined into main, that's 3.
> diff --git a/gcc/toplev.cc b/gcc/toplev.cc
> index d26467450e37..5a7656647651 100644
> --- a/gcc/toplev.cc
> +++ b/gcc/toplev.cc
> @@ -1523,15 +1523,9 @@ process_options ()
> dwarf2out_as_locview_support = false;
> }
>
> - if (!OPTION_SET_P (debug_variable_location_views))
> - {
> - debug_variable_location_views
> - = (flag_var_tracking
> - && debug_info_level >= DINFO_LEVEL_NORMAL
> - && dwarf_debuginfo_p ()
> - && !dwarf_strict);
> - }
> - else if (debug_variable_location_views == -1 && dwarf_version != 5)
> + if (OPTION_SET_P (debug_variable_location_views)
> + && debug_variable_location_views == -1
> + && dwarf_version != 5)
> {
> warning_at (UNKNOWN_LOCATION, 0,
> "without %<-gdwarf-5%>, "
> --
> 2.51.0
>