From 5c5b5d4b0e4dd49699a6a88dd58f5816f6c14386 Mon Sep 17 00:00:00 2001 From: Per Bothner Date: Fri, 10 Jul 1992 03:56:17 +0000 Subject: [PATCH] Various fixes to improve C++ debugging. See ChangeLog. --- gdb/.Sanitize | 1 + gdb/ChangeLog | 20 ++++++++++++++++ gdb/buildsym.c | 23 ++++++++++++------ gdb/gcc.patch | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++ gdb/gdbtypes.c | 4 ++++ 5 files changed, 104 insertions(+), 7 deletions(-) create mode 100644 gdb/gcc.patch diff --git a/gdb/.Sanitize b/gdb/.Sanitize index f1d65e159db..3e252952232 100644 --- a/gdb/.Sanitize +++ b/gdb/.Sanitize @@ -84,6 +84,7 @@ expprint.c expression.h findvar.c frame.h +gcc.patch gdb-stabs.h gdb.1 gdbcmd.h diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 8cf2b7367e9..522c25faebe 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -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. diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 104df4702e8..a3a2f875954 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -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 index 00000000000..1317d1baf6a --- /dev/null +++ b/gdb/gcc.patch @@ -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; diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 1965cd83b70..7559ed2d244 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -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) { -- 2.30.2