* [PATCH] DWARF: add DW_AT_location for global decls with DECL_VALUE_EXPR
@ 2017-06-01 9:28 Pierre-Marie de Rodat
2017-06-01 13:53 ` Richard Biener
0 siblings, 1 reply; 3+ messages in thread
From: Pierre-Marie de Rodat @ 2017-06-01 9:28 UTC (permalink / raw)
To: gcc-patches; +Cc: Pierre-Marie de Rodat
Hi,
In GNAT, we materialize renamings that cannot be described in standard
DWARF as synthetic variables that describe how to fetch the renamed
object. Look for "___XR" in gcc/ada/exp_dbug.ads for more details about
this convention.
In order to have a location for these variables in the debug info (GDB
requires it not to discard the variable) but also to avoid allocating
runtime space for them, we make these variable hold a DECL_VALUE_EXPR
tree. However, since GCC 7, the DWARF back-end no longer generates a
DW_AT_location attribute for those. This patch is an attempt to restore
this attribute.
Bootstrapped and reg-tested on x86_64-linux. Also, I have a ~150 bytes
increase in the size of cc1, cc1plus and gnat1 (each of these is ~200MB
large). Ok to commit? Thank you in advance!
gcc/
* dwarf2out.c (dwarf2out_late_global_decl): Add locations for
symbols that hold a DECL_VALUE_EXPR.
gcc/testsuite/
* debug12.adb, debug12.ads: New testcase.
---
gcc/dwarf2out.c | 5 +++--
gcc/testsuite/gnat.dg/debug12.adb | 9 +++++++++
gcc/testsuite/gnat.dg/debug12.ads | 8 ++++++++
3 files changed, 20 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gnat.dg/debug12.adb
create mode 100644 gcc/testsuite/gnat.dg/debug12.ads
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 5ff45eb4efd..013c902bc89 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -25526,9 +25526,10 @@ dwarf2out_late_global_decl (tree decl)
{
/* We get called via the symtab code invoking late_global_decl
for symbols that are optimized out. Do not add locations
- for those. */
+ for those, except if they have a DECL_VALUE_EXPR, in which case
+ they are relevant for debuggers. */
varpool_node *node = varpool_node::get (decl);
- if (! node || ! node->definition)
+ if ((! node || ! node->definition) && ! DECL_HAS_VALUE_EXPR_P (decl))
tree_add_const_value_attribute_for_decl (die, decl);
else
add_location_or_const_value_attribute (die, decl, false);
diff --git a/gcc/testsuite/gnat.dg/debug12.adb b/gcc/testsuite/gnat.dg/debug12.adb
new file mode 100644
index 00000000000..07175968703
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/debug12.adb
@@ -0,0 +1,9 @@
+-- { dg-options "-cargs -gdwarf-4 -fdebug-types-section -dA -margs" }
+-- { dg-final { scan-assembler-times "DW_AT_location" 4 } }
+
+package body Debug12 is
+ function Get_A2 return Boolean is
+ begin
+ return A2;
+ end Get_A2;
+end Debug12;
diff --git a/gcc/testsuite/gnat.dg/debug12.ads b/gcc/testsuite/gnat.dg/debug12.ads
new file mode 100644
index 00000000000..dbc5896cc73
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/debug12.ads
@@ -0,0 +1,8 @@
+package Debug12 is
+ type Bit_Array is array (Positive range <>) of Boolean
+ with Pack;
+ A : Bit_Array := (1 .. 10 => False);
+ A2 : Boolean renames A (2);
+
+ function Get_A2 return Boolean;
+end Debug12;
--
2.13.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] DWARF: add DW_AT_location for global decls with DECL_VALUE_EXPR
2017-06-01 9:28 [PATCH] DWARF: add DW_AT_location for global decls with DECL_VALUE_EXPR Pierre-Marie de Rodat
@ 2017-06-01 13:53 ` Richard Biener
2017-06-01 14:06 ` Pierre-Marie de Rodat
0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2017-06-01 13:53 UTC (permalink / raw)
To: Pierre-Marie de Rodat; +Cc: GCC Patches
On Thu, Jun 1, 2017 at 11:28 AM, Pierre-Marie de Rodat
<derodat@adacore.com> wrote:
> Hi,
>
> In GNAT, we materialize renamings that cannot be described in standard
> DWARF as synthetic variables that describe how to fetch the renamed
> object. Look for "___XR" in gcc/ada/exp_dbug.ads for more details about
> this convention.
>
> In order to have a location for these variables in the debug info (GDB
> requires it not to discard the variable) but also to avoid allocating
> runtime space for them, we make these variable hold a DECL_VALUE_EXPR
> tree. However, since GCC 7, the DWARF back-end no longer generates a
> DW_AT_location attribute for those. This patch is an attempt to restore
> this attribute.
>
> Bootstrapped and reg-tested on x86_64-linux. Also, I have a ~150 bytes
> increase in the size of cc1, cc1plus and gnat1 (each of these is ~200MB
> large). Ok to commit? Thank you in advance!
Ok.
Richard.
> gcc/
>
> * dwarf2out.c (dwarf2out_late_global_decl): Add locations for
> symbols that hold a DECL_VALUE_EXPR.
>
> gcc/testsuite/
>
> * debug12.adb, debug12.ads: New testcase.
> ---
> gcc/dwarf2out.c | 5 +++--
> gcc/testsuite/gnat.dg/debug12.adb | 9 +++++++++
> gcc/testsuite/gnat.dg/debug12.ads | 8 ++++++++
> 3 files changed, 20 insertions(+), 2 deletions(-)
> create mode 100644 gcc/testsuite/gnat.dg/debug12.adb
> create mode 100644 gcc/testsuite/gnat.dg/debug12.ads
>
> diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
> index 5ff45eb4efd..013c902bc89 100644
> --- a/gcc/dwarf2out.c
> +++ b/gcc/dwarf2out.c
> @@ -25526,9 +25526,10 @@ dwarf2out_late_global_decl (tree decl)
> {
> /* We get called via the symtab code invoking late_global_decl
> for symbols that are optimized out. Do not add locations
> - for those. */
> + for those, except if they have a DECL_VALUE_EXPR, in which case
> + they are relevant for debuggers. */
> varpool_node *node = varpool_node::get (decl);
> - if (! node || ! node->definition)
> + if ((! node || ! node->definition) && ! DECL_HAS_VALUE_EXPR_P (decl))
> tree_add_const_value_attribute_for_decl (die, decl);
> else
> add_location_or_const_value_attribute (die, decl, false);
> diff --git a/gcc/testsuite/gnat.dg/debug12.adb b/gcc/testsuite/gnat.dg/debug12.adb
> new file mode 100644
> index 00000000000..07175968703
> --- /dev/null
> +++ b/gcc/testsuite/gnat.dg/debug12.adb
> @@ -0,0 +1,9 @@
> +-- { dg-options "-cargs -gdwarf-4 -fdebug-types-section -dA -margs" }
> +-- { dg-final { scan-assembler-times "DW_AT_location" 4 } }
> +
> +package body Debug12 is
> + function Get_A2 return Boolean is
> + begin
> + return A2;
> + end Get_A2;
> +end Debug12;
> diff --git a/gcc/testsuite/gnat.dg/debug12.ads b/gcc/testsuite/gnat.dg/debug12.ads
> new file mode 100644
> index 00000000000..dbc5896cc73
> --- /dev/null
> +++ b/gcc/testsuite/gnat.dg/debug12.ads
> @@ -0,0 +1,8 @@
> +package Debug12 is
> + type Bit_Array is array (Positive range <>) of Boolean
> + with Pack;
> + A : Bit_Array := (1 .. 10 => False);
> + A2 : Boolean renames A (2);
> +
> + function Get_A2 return Boolean;
> +end Debug12;
> --
> 2.13.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] DWARF: add DW_AT_location for global decls with DECL_VALUE_EXPR
2017-06-01 13:53 ` Richard Biener
@ 2017-06-01 14:06 ` Pierre-Marie de Rodat
0 siblings, 0 replies; 3+ messages in thread
From: Pierre-Marie de Rodat @ 2017-06-01 14:06 UTC (permalink / raw)
To: Richard Biener; +Cc: GCC Patches
On 06/01/2017 03:53 PM, Richard Biener wrote:
> Ok.
>
> Richard.
Committed. Thank you, Richard!
--
Pierre-Marie de Rodat
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-06-01 14:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-01 9:28 [PATCH] DWARF: add DW_AT_location for global decls with DECL_VALUE_EXPR Pierre-Marie de Rodat
2017-06-01 13:53 ` Richard Biener
2017-06-01 14:06 ` Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).