diff mbox

[1/2] DWARFv5 Emit DW_TAG_atomic_type.

Message ID 1407857735-18515-1-git-send-email-mjw@redhat.com
State New
Headers show

Commit Message

Mark Wielaard Aug. 12, 2014, 3:35 p.m. UTC
Ping. This patch is based on the proposed patches to support the
restrict type. But isn't meant to be integrated at this time. DWARFv5
is still only a collection of proposals and hasn't seen any draft
yet. But feedback is highly appreciated. Also if there are tips on how
(and where) to maintain an experimental patch set for a future standard
that would be welcome.

There is a corresponding patch for GDB:
https://sourceware.org/ml/gdb-patches/2014-06/msg00795.html

gcc/ChangeLog

	PR debug/60782
	* dwarf2out.c (modified_type_die): Handle TYPE_QUAL_ATOMIC.
	* opts.c (common_handle_option): Accept -gdwarf-5.

gcc/testsuite/ChangeLog

	PR debug/60782
	* gcc.dg/guality/atomic.c: New test.

include/ChangeLog

	PR debug/60782
	* dwarf2.def: Add DWARFv5 DW_TAG_atomic_type.
---
 gcc/ChangeLog                         |  6 ++++++
 gcc/dwarf2out.c                       | 22 +++++++++++++++++++---
 gcc/opts.c                            |  2 +-
 gcc/testsuite/ChangeLog               |  5 +++++
 gcc/testsuite/gcc.dg/guality/atomic.c | 13 +++++++++++++
 include/ChangeLog                     |  5 +++++
 include/dwarf2.def                    |  2 ++
 7 files changed, 51 insertions(+), 4 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/guality/atomic.c

Comments

Jason Merrill Aug. 12, 2014, 7:32 p.m. UTC | #1
On 08/12/2014 11:35 AM, Mark Wielaard wrote:
> Ping. This patch is based on the proposed patches to support the
> restrict type. But isn't meant to be integrated at this time. DWARFv5
> is still only a collection of proposals and hasn't seen any draft
> yet. But feedback is highly appreciated. Also if there are tips on how
> (and where) to maintain an experimental patch set for a future standard
> that would be welcome.

The patch looks fine.

As for where to maintain it, I'd suggest a branch in the git repository, 
mark/dwarf5 or some such.

Jason
diff mbox

Patch

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 428a1e1..1adf6a6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@ 
+2014-07-09  Mark Wielaard  <mjw@redhat.com>
+
+	PR debug/60782
+	* dwarf2out.c (modified_type_die): Handle TYPE_QUAL_ATOMIC.
+	* opts.c (common_handle_option): Accept -gdwarf-5.
+
 2014-07-08  Mark Wielaard  <mjw@redhat.com>
 
 	PR debug/59051
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 51e379e..7792604 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -10478,7 +10478,8 @@  modified_type_die (tree type, int cv_quals, dw_die_ref context_die)
     return NULL;
 
   /* Only these cv-qualifiers are currently handled.  */
-  cv_quals &= (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT);
+  cv_quals &= (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT
+	       | TYPE_QUAL_ATOMIC);
 
   /* Don't emit DW_TAG_restrict_type for DWARFv2, since it is a type
      tag modifier (and not an attribute) old consumers won't be able
@@ -10486,6 +10487,10 @@  modified_type_die (tree type, int cv_quals, dw_die_ref context_die)
   if (dwarf_version < 3)
     cv_quals &= ~TYPE_QUAL_RESTRICT;
 
+  /* Likewise for DW_TAG_atomic_type for DWARFv5.  */
+  if (dwarf_version < 5)
+    cv_quals &= ~TYPE_QUAL_ATOMIC;
+
   /* See if we already have the appropriately qualified variant of
      this type.  */
   qualified_type = get_qualified_type (type, cv_quals);
@@ -10529,7 +10534,8 @@  modified_type_die (tree type, int cv_quals, dw_die_ref context_die)
       else
 	{
 	  int dquals = TYPE_QUALS_NO_ADDR_SPACE (dtype);
-	  dquals &= (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT);
+	  dquals &= (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT
+		     | TYPE_QUAL_ATOMIC);
 	  if ((dquals & ~cv_quals) != TYPE_UNQUALIFIED
 	      || (cv_quals == dquals && DECL_ORIGINAL_TYPE (name) != type))
 	    /* cv-unqualified version of named type.  Just use
@@ -10564,12 +10570,22 @@  modified_type_die (tree type, int cv_quals, dw_die_ref context_die)
       sub_die = modified_type_die (type, cv_quals & ~TYPE_QUAL_VOLATILE,
 				   context_die);
     }
-  else if (cv_quals & TYPE_QUAL_RESTRICT)
+  else if ((cv_quals & TYPE_QUAL_RESTRICT)
+	   && (((cv_quals & ~TYPE_QUAL_RESTRICT) == TYPE_UNQUALIFIED)
+	       || get_qualified_type (type, cv_quals) == NULL_TREE
+	       || (get_qualified_type (type, cv_quals & ~TYPE_QUAL_RESTRICT)
+		   != NULL_TREE)))
     {
       mod_type_die = new_die (DW_TAG_restrict_type, mod_scope, type);
       sub_die = modified_type_die (type, cv_quals & ~TYPE_QUAL_RESTRICT,
 				   context_die);
     }
+  else if (cv_quals & TYPE_QUAL_ATOMIC)
+    {
+      mod_type_die = new_die (DW_TAG_atomic_type, mod_scope, type);
+      sub_die = modified_type_die (type, cv_quals & ~TYPE_QUAL_ATOMIC,
+				   context_die);
+    }
   else if (code == POINTER_TYPE)
     {
       mod_type_die = new_die (DW_TAG_pointer_type, mod_scope, type);
diff --git a/gcc/opts.c b/gcc/opts.c
index be1867c..f3f2817 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -1884,7 +1884,7 @@  common_handle_option (struct gcc_options *opts,
       
       /* FALLTHRU */
     case OPT_gdwarf_:
-      if (value < 2 || value > 4)
+      if (value < 2 || value > 5)
 	error_at (loc, "dwarf version %d is not supported", value);
       else
 	opts->x_dwarf_version = value;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3f9e53f..4c8ce92 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@ 
+2014-07-09  Mark Wielaard  <mjw@redhat.com>
+
+	PR debug/60782
+	* gcc.dg/guality/atomic.c: New test.
+
 2014-07-08  Mark Wielaard  <mjw@redhat.com>
 
 	PR debug/59051
diff --git a/gcc/testsuite/gcc.dg/guality/atomic.c b/gcc/testsuite/gcc.dg/guality/atomic.c
new file mode 100644
index 0000000..c76cfa4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/guality/atomic.c
@@ -0,0 +1,13 @@ 
+/* debuginfo tests for the _Atomic type qualifier.  */
+/* { dg-do run } */
+/* { dg-options "-std=c11 -gdwarf-5" } */
+
+volatile _Atomic int * const _Atomic hwaddr = (void *) 0x1234;
+
+int
+main (int argc, char **argv)
+{
+  return hwaddr == (void *) argv[0];
+}
+
+/* { dg-final { gdb-test 10 "type:hwaddr" "volatile _Atomic int * const _Atomic" } } */
diff --git a/include/ChangeLog b/include/ChangeLog
index 1cda0dc..2609e70 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,8 @@ 
+2014-07-09  Mark Wielaard  <mjw@redhat.com>
+
+	PR debug/60782
+	* dwarf2.def: Add DWARFv5 DW_TAG_atomic_type.
+
 2014-06-10  Thomas Schwinge  <thomas@codesourcery.com>
 
 	PR lto/61334
diff --git a/include/dwarf2.def b/include/dwarf2.def
index 71a37b3..6490391 100644
--- a/include/dwarf2.def
+++ b/include/dwarf2.def
@@ -133,6 +133,8 @@  DW_TAG (DW_TAG_shared_type, 0x40)
 DW_TAG (DW_TAG_type_unit, 0x41)
 DW_TAG (DW_TAG_rvalue_reference_type, 0x42)
 DW_TAG (DW_TAG_template_alias, 0x43)
+/* DWARF 5.  */
+DW_TAG (DW_TAG_atomic_type, 0x47) /* NOT AN OFFICIAL NUMBER. DWARF5 131112.1 */
 
 DW_TAG_DUP (DW_TAG_lo_user, 0x4080)
 DW_TAG_DUP (DW_TAG_hi_user, 0xffff)