]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
ChangeLog:
authorUlrich Weigand <uweigand@de.ibm.com>
Fri, 26 Mar 2010 18:05:46 +0000 (18:05 +0000)
committerUlrich Weigand <uweigand@de.ibm.com>
Fri, 26 Mar 2010 18:05:46 +0000 (18:05 +0000)
* dwarf2read.c (dwarf2_name): Work around GCC bugzilla debug/41828 by
ignoring spurious DW_AT_name attributes for unnamed structs or unions.
* completer.c (add_struct_fields): Fix inverted logic.

testsuite/ChangeLog:

* gdb.cp/inherit.exp (test_ptype_si): XFAIL test for GCC versions
that do not provide the tagless_struct type name at all.
(test_print_anon_union): Do not check value of uninitialized
union member.  Do not use cp_test_ptype_class, so we can accept
"long" as well as "long int".

gdb/ChangeLog
gdb/completer.c
gdb/dwarf2read.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.cp/inherit.exp

index 7cfac07ae6612476a5ec26f61c7605c8a3a5dc74..5effdf3672985a2833a29c7ccb49f7e79975f3f9 100644 (file)
@@ -1,3 +1,9 @@
+2010-03-26  Ulrich Weigand  <uweigand@de.ibm.com>
+
+       * dwarf2read.c (dwarf2_name): Work around GCC bugzilla debug/41828 by
+       ignoring spurious DW_AT_name attributes for unnamed structs or unions.
+       * completer.c (add_struct_fields): Fix inverted logic.
+
 2010-03-26  Ulrich Weigand  <uweigand@de.ibm.com>
 
        * breakpoint.c (bpstat_clear_actions): Reset bs->commands_left.
index 53275c0e73a3a5189fa40cf190fd1a50327f9938..e678fb1b20cdef487ffcd100d3ff190e5c1ed80b 100644 (file)
@@ -401,7 +401,7 @@ add_struct_fields (struct type *type, int *nextp, char **output,
              computed_type_name = 1;
            }
          /* Omit constructors from the completion list.  */
-         if (type_name && strcmp (type_name, name))
+         if (!type_name || strcmp (type_name, name))
            {
              output[*nextp] = xstrdup (name);
              ++*nextp;
index 4de07976f73a90005f2ca65def3eb6909c4b7c93..298703912fa34da85b2d3e3947bcfe3ff5180b7d 100644 (file)
@@ -9187,6 +9187,7 @@ 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.  */
@@ -9214,17 +9215,33 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
            }
          while (die->tag != DW_TAG_compile_unit);
        }
-      /* fall through */
+      break;
+
+    case DW_TAG_class_type:
+    case DW_TAG_interface_type:
+    case DW_TAG_structure_type:
+    case DW_TAG_union_type:
+      /* Some GCC versions emit spurious DW_AT_name attributes for unnamed
+        structures or unions.  These were of the form "._%d" in GCC 4.1,
+        or simply "<anonymous struct>" or "<anonymous union>" in GCC 4.3
+        and GCC 4.4.  We work around this problem by ignoring these.  */
+      if (strncmp (DW_STRING (attr), "._", 2) == 0
+         || strncmp (DW_STRING (attr), "<anonymous", 10) == 0)
+       return NULL;
+      break;
+
     default:
-      if (!DW_STRING_IS_CANONICAL (attr))
-       {
-         DW_STRING (attr)
-           = dwarf2_canonicalize_name (DW_STRING (attr), cu,
-                                       &cu->objfile->objfile_obstack);
-         DW_STRING_IS_CANONICAL (attr) = 1;
-       }
-      return DW_STRING (attr);
+      break;
+    }
+
+  if (!DW_STRING_IS_CANONICAL (attr))
+    {
+      DW_STRING (attr)
+       = dwarf2_canonicalize_name (DW_STRING (attr), cu,
+                                   &cu->objfile->objfile_obstack);
+      DW_STRING_IS_CANONICAL (attr) = 1;
     }
+  return DW_STRING (attr);
 }
 
 /* Return the die that this die in an extension of, or NULL if there
index 08946f3f2dbb04a691d05858821fd2abf66a6d0c..d506e1ac21267cd5806300ddb4f4e96fdb3eb862 100644 (file)
@@ -1,3 +1,11 @@
+2010-03-26  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
+
+       * gdb.cp/inherit.exp (test_ptype_si): XFAIL test for GCC versions
+       that do not provide the tagless_struct type name at all.
+       (test_print_anon_union): Do not check value of uninitialized
+       union member.  Do not use cp_test_ptype_class, so we can accept
+       "long" as well as "long int".
+
 2010-03-26  Pedro Alves  <pedro@codesourcery.com>
 
        * gdb.trace/tfile.c (tohex, bin2hex): New.
index b3bfea28a17b2d0b723aaa970239642cb146451a..a593bc6b984d2c70ef921171afd66fc8ca416b5b 100644 (file)
@@ -114,6 +114,11 @@ proc test_ptype_si { } {
            # gcc 3.4.1 -gstabs+
            pass "$name"
        }
+       -re "No symbol \"tagless_struct\" in current context.$nl$gdb_prompt $" {
+           # Several GCC 4.x versions provide neither a DW_TAG_typedef DIE
+           # nor use the typedef name as struct tag name.
+           xfail "$name"
+       }
     }
 
     set name "ptype variable of type tagless struct"
@@ -490,25 +495,20 @@ proc test_print_anon_union {} {
 
     set name "print variable of type anonymous union"
     gdb_test_multiple "print g_anon_union" $name {
-       -re "$vhn = \{one = 1, \{a = 2, b = 2\}\}$nl$gdb_prompt $" {
+       -re "$vhn = \{one = 1, \{a = 2, b = \[0-9\]+\}\}$nl$gdb_prompt $" {
            pass $name
        }
     }
 
-    # The nested union prints as a multi-line field, but the class body
-    # scanner is inherently line-oriented.  This is ugly but it works.
-
-    cp_test_ptype_class \
-       "ptype g_anon_union" "print type of anonymous union" \
-       "class" "class_with_anon_union" \
-       {
-           { field public "int one;" }
-           { field public "union \{" }
-           { field public "int a;" }
-           { field public "long int b;" }
-           { field public "\};" }
+    set name "print type of anonymous union"
+    set re_tag "class_with_anon_union"
+    set re_class "(class $re_tag \{${ws}public:|struct $re_tag\{)"
+    set re_fields "int one;${ws}union \{${ws}int a;${ws}long( int)? b;${ws}\};"
+    gdb_test_multiple "ptype g_anon_union" $name {
+       -re "type = $re_class${ws}$re_fields$nl\}$nl$gdb_prompt $" {
+           pass $name
        }
-
+    }
 }