From 671199e8a7da326e54e081b5c368f93428455e98 Mon Sep 17 00:00:00 2001
From: Pierre-Marie de Rodat <derodat@adacore.com>
Date: Thu, 25 Feb 2016 11:37:22 +0100
Subject: [PATCH] DWARF: fix debug info for implicit pointers to string
constants
2016-02-25 Pierre-Marie de Rodat <derodat@adacore.com>
PR debug/69947
* dwarf2out.c (prune_unused_types_walk_loc_descr): Recurse on
all dw_val_class_die_ref operands, not just the ones for
DW_OP_call* operations.
2016-02-25 Jakub Jelinek <jakub@redhat.com>
PR debug/69947
* gcc.dg/guality/pr69947.c: New test.
---
gcc/dwarf2out.c | 16 +++++++---------
gcc/testsuite/gcc.dg/guality/pr69947.c | 22 ++++++++++++++++++++++
2 files changed, 29 insertions(+), 9 deletions(-)
create mode 100644 gcc/testsuite/gcc.dg/guality/pr69947.c
@@ -25639,16 +25639,14 @@ static void
prune_unused_types_walk_loc_descr (dw_loc_descr_ref loc)
{
for (; loc != NULL; loc = loc->dw_loc_next)
- switch (loc->dw_loc_opc)
- {
- case DW_OP_call2:
- case DW_OP_call4:
- case DW_OP_call_ref:
+ {
+ if (loc->dw_loc_oprnd1.val_class == dw_val_class_die_ref
+ && !loc->dw_loc_oprnd1.v.val_die_ref.external)
prune_unused_types_mark (loc->dw_loc_oprnd1.v.val_die_ref.die, 1);
- break;
- default:
- break;
- }
+ if (loc->dw_loc_oprnd2.val_class == dw_val_class_die_ref
+ && !loc->dw_loc_oprnd2.v.val_die_ref.external)
+ prune_unused_types_mark (loc->dw_loc_oprnd2.v.val_die_ref.die, 1);
+ }
}
/* Given DIE that we're marking as used, find any other dies
new file mode 100644
@@ -0,0 +1,22 @@
+/* PR debug/69947 */
+/* { dg-do run } */
+/* { dg-options "-g" } */
+
+#include "../nop.h"
+
+static const char *c = "foobar";
+
+__attribute__((noinline, noclone)) void
+foo (void)
+{
+ static const char a[] = "abcdefg";
+ const char *b = a; /* { dg-final { gdb-test 14 "c\[2\]" "'o'" } } */
+ asm (NOP : : : "memory"); /* { dg-final { gdb-test 14 "b\[4\]" "'e'" } } */
+}
+
+int
+main ()
+{
+ foo ();
+ return 0;
+}
--
2.3.3.199.g52cae64