Various fixes to improve C++ debugging. See ChangeLog.
authorPer Bothner <per@bothner.com>
Fri, 10 Jul 1992 03:56:17 +0000 (03:56 +0000)
committerPer Bothner <per@bothner.com>
Fri, 10 Jul 1992 03:56:17 +0000 (03:56 +0000)
gdb/.Sanitize
gdb/ChangeLog
gdb/buildsym.c
gdb/gcc.patch [new file with mode: 0644]
gdb/gdbtypes.c

index f1d65e159db590978c305afda991c00a5d129ac2..3e252952232b0ded8f5beb31592b5dcfe23970be 100644 (file)
@@ -84,6 +84,7 @@ expprint.c
 expression.h
 findvar.c
 frame.h
+gcc.patch
 gdb-stabs.h
 gdb.1
 gdbcmd.h
index 8cf2b7367e94c6b3c759eda105b6ba5d3e4bb6c5..522c25faebe7422764dd56becc3b0b19b48d86bc 100644 (file)
@@ -1,3 +1,23 @@
+Thu Jul  9 19:05:27 1992  Per Bothner  (bothner@rtl.cygnus.com)
+
+       * gdbtypes.c (lookup_struct_elt_type):  If the input type is
+       TYPE_CODE_PTR or TYPE_CODE_REF, dereference it to get the
+       target type.  Otherwise, 'whatis this.field' wouldn't work,
+       which would be inconsistent, since 'print this.field' works.
+       * buildsym.c (read_struct_type, read_enum_type):  Clear
+       TYPE_FLAG_STUB flag.
+       * buildsym.c (cleanup_undefined_types):  Don't rely on a
+       flawed "Reasonable test to see if" a type has been defined
+       since it was referred to; now we can just see if the
+       TYPE_FLAG_STUB flag has been cleared.
+       * valprint.c (print_type_base):  Emit public/protected/private
+       labels for methods as well as fields.  Also, indent these labels
+       2 spaces instead of 4, for a more conventional "look".
+       * symtab.c (gdb_mangle_name):  Undo Fred's change, unless
+       GCC_MANGLE_BUG is defined.  Also, handle destructors specially.
+       * gcc.patch:  New file.  Contains patch for gcc (so people
+       with gdb-2.2.x won't have to wait for a new gcc release).
+
 Thu Jul  9 18:44:26 1992  Ken Raeburn  (raeburn@cygnus.com)
 
        * i960-pinsn.c (mem): Variables reg[123] should point to CONST.
index 104df4702e8e50ae7fb290d383c94fc2cf70895c..a3a2f875954059d34c9f723798521966ac600fbb 100644 (file)
@@ -1622,8 +1622,8 @@ cleanup_undefined_types ()
       case TYPE_CODE_UNION:
       case TYPE_CODE_ENUM:
        {
-         /* Reasonable test to see if it's been defined since.  */
-         if (TYPE_NFIELDS (*type) == 0)
+         /* Check if it has been defined since.  */
+         if (TYPE_FLAGS (*type) & TYPE_FLAG_STUB)
            {
              struct pending *ppt;
              int i;
@@ -1650,9 +1650,6 @@ cleanup_undefined_types ()
                      memcpy (*type, SYMBOL_TYPE (sym), sizeof (struct type));
                  }
            }
-         else
-           /* It has been defined; don't mark it as a stub.  */
-           TYPE_FLAGS (*type) &= ~TYPE_FLAG_STUB;
        }
        break;
 
@@ -2129,6 +2126,7 @@ read_struct_type (pp, type, objfile)
 
   TYPE_CODE (type) = TYPE_CODE_STRUCT;
   INIT_CPLUS_SPECIFIC(type);
+  TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
 
   /* First comes the total size in bytes.  */
 
@@ -2339,9 +2337,19 @@ read_struct_type (pp, type, objfile)
       list->field.type = read_type (pp, objfile);
       if (**pp == ':')
        {
-         /* Static class member.  */
-         list->field.bitpos = (long)-1;
          p = ++(*pp);
+#if 0
+         /* Possible future hook for nested types. */
+         if (**pp == '!')
+           {
+             list->field.bitpos = (long)-2; /* nested type */
+             p = ++(*pp);
+           }
+         else
+#endif
+           { /* Static class member.  */
+             list->field.bitpos = (long)-1;
+           }
          while (*p != ';') p++;
          list->field.bitsize = (long) savestring (*pp, p - *pp);
          *pp = p + 1;
@@ -2943,6 +2951,7 @@ read_enum_type (pp, type, objfile)
 
   TYPE_LENGTH (type) = sizeof (int);
   TYPE_CODE (type) = TYPE_CODE_ENUM;
+  TYPE_FLAGS (type) &= ~TYPE_FLAG_STUB;
   TYPE_NFIELDS (type) = nsyms;
   TYPE_FIELDS (type) = (struct field *)
     obstack_alloc (&objfile -> type_obstack,
diff --git a/gdb/gcc.patch b/gdb/gcc.patch
new file mode 100644 (file)
index 0000000..1317d1b
--- /dev/null
@@ -0,0 +1,63 @@
+Recent versions of gcc have had a bug in how they emit debugging
+information for C++ methods (when using dbx-style stabs).
+This patch should fix the problem.  Fix you can't fix gcc,
+you can alternatively define GCC_MANGLE_BUG when compling gdb/symtab.c.
+
+===================================================================
+RCS file: /rel/cvsfiles/devo/gcc/dbxout.c,v
+retrieving revision 1.53
+diff -c -r1.53 dbxout.c
+*** 1.53       1992/07/05 09:50:22
+--- dbxout.c   1992/07/09 07:00:33
+***************
+*** 683,688 ****
+--- 683,689 ----
+    tree type_encoding;
+    register tree fndecl;
+    register tree last;
++   char formatted_type_identifier_length[16];
+    register int type_identifier_length;
+  
+    if (methods == NULL_TREE)
+***************
+*** 711,716 ****
+--- 712,719 ----
+  
+    type_identifier_length = IDENTIFIER_LENGTH (type_encoding);
+  
++   sprintf(formatted_type_identifier_length, "%d", type_identifier_length);
++ 
+    if (TREE_CODE (methods) == FUNCTION_DECL)
+      fndecl = methods;
+    else if (TREE_VEC_ELT (methods, 0) != NULL_TREE)
+***************
+*** 754,762 ****
+--- 757,769 ----
+                 if (debug_name[0] == '_' && debug_name[1] == '_')
+                   {
+                     char *method_name = debug_name + 2;
++                    char *length_ptr = formatted_type_identifier_length;
+                     /* Get past const and volatile qualifiers.  */
+                     while (*method_name == 'C' || *method_name == 'V')
+                       method_name++;
++                    /* Skip digits for length of type_encoding. */
++                    while (*method_name == *length_ptr && *length_ptr)
++                        length_ptr++, method_name++;
+                     if (! strncmp (method_name,
+                                    IDENTIFIER_POINTER (type_encoding),
+                                    type_identifier_length))
+***************
+*** 768,775 ****
+--- 775,786 ----
+             else if (debug_name[0] == '_' && debug_name[1] == '_')
+               {
+                 char *ctor_name = debug_name + 2;
++                char *length_ptr = formatted_type_identifier_length;
+                 while (*ctor_name == 'C' || *ctor_name == 'V')
+                   ctor_name++;
++                /* Skip digits for length of type_encoding. */
++                while (*ctor_name == *length_ptr && *length_ptr)
++                    length_ptr++, ctor_name++;
+                 if (!strncmp (IDENTIFIER_POINTER (type_encoding), ctor_name,
+                               type_identifier_length))
+                   debug_name = ctor_name + type_identifier_length;
index 1965cd83b7095346a727b0c9fa0ab74c37674738..7559ed2d2440e4db43ba1433ce2a4f38f2a42f5b 100644 (file)
@@ -611,6 +611,10 @@ lookup_struct_elt_type (type, name, noerr)
 {
   int i;
 
+  if (TYPE_CODE (type) == TYPE_CODE_PTR ||
+      TYPE_CODE (type) == TYPE_CODE_REF)
+      type = TYPE_TARGET_TYPE (type);
+
   if (TYPE_CODE (type) != TYPE_CODE_STRUCT &&
       TYPE_CODE (type) != TYPE_CODE_UNION)
     {