* dwarf2read.c (read_subroutine_type): If the compilation unit
authorKeith Seitz <keiths@redhat.com>
Thu, 25 Mar 2010 22:13:15 +0000 (22:13 +0000)
committerKeith Seitz <keiths@redhat.com>
Thu, 25 Mar 2010 22:13:15 +0000 (22:13 +0000)
  language is Java, mark any formal parameter named "this" as
  artificial (GCC/43521).
  (dwarf2_name): Add special handling for Java constructors.

gdb/ChangeLog
gdb/dwarf2read.c

index d2c44c0df8cbed7865f565c3ae017b0b587e10ab..3bf68362309975b51074083eaaf88de2b8d13fab 100644 (file)
@@ -1,3 +1,10 @@
+2010-03-25  Keith Seitz  <keiths@redhat.com>
+
+       * dwarf2read.c (read_subroutine_type): If the compilation unit
+       language is Java, mark any formal parameter named "this" as
+       artificial (GCC/43521).
+       (dwarf2_name): Add special handling for Java constructors.
+
 2010-03-25  Tom Tromey  <tromey@redhat.com>
 
        PR gdb/11327, PR gdb/11328, PR breakpoints/11368:
index 40f8cdeb2cb7d71287fde356a39a5eda245d88c2..4de07976f73a90005f2ca65def3eb6909c4b7c93 100644 (file)
@@ -5949,7 +5949,18 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
              if (attr)
                TYPE_FIELD_ARTIFICIAL (ftype, iparams) = DW_UNSND (attr);
              else
-               TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 0;
+               {
+                 TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 0;
+
+                 /* GCC/43521: In java, the formal parameter
+                    "this" is sometimes not marked with DW_AT_artificial.  */
+                 if (cu->language == language_java)
+                   {
+                     const char *name = dwarf2_name (child_die, cu);
+                     if (name && !strcmp (name, "this"))
+                       TYPE_FIELD_ARTIFICIAL (ftype, iparams) = 1;
+                   }
+               }
              TYPE_FIELD_TYPE (ftype, iparams) = die_type (child_die, cu);
              iparams++;
            }
@@ -9176,6 +9187,34 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
       /* These tags always have simple identifiers already; no need
         to canonicalize them.  */
       return DW_STRING (attr);
+    case DW_TAG_subprogram:
+      /* Java constructors will all be named "<init>", so return
+        the class name when we see this special case.  */
+      if (cu->language == language_java
+         && DW_STRING (attr) != NULL
+         && strcmp (DW_STRING (attr), "<init>") == 0)
+       {
+         struct dwarf2_cu *spec_cu = cu;
+         struct die_info *spec_die;
+
+         /* GCJ will output '<init>' for Java constructor names.
+            For this special case, return the name of the parent class.  */
+
+         /* GCJ may output suprogram DIEs with AT_specification set.
+            If so, use the name of the specified DIE.  */
+         spec_die = die_specification (die, &spec_cu);
+         if (spec_die != NULL)
+           return dwarf2_name (spec_die, spec_cu);
+
+         do
+           {
+             die = die->parent;
+             if (die->tag == DW_TAG_class_type)
+               return dwarf2_name (die, cu);
+           }
+         while (die->tag != DW_TAG_compile_unit);
+       }
+      /* fall through */
     default:
       if (!DW_STRING_IS_CANONICAL (attr))
        {
This page took 0.037231 seconds and 4 git commands to generate.