diff options
-rw-r--r-- | gdb/ChangeLog | 36 | ||||
-rw-r--r-- | gdb/c-exp.y | 9 | ||||
-rw-r--r-- | gdb/c-lang.h | 9 | ||||
-rw-r--r-- | gdb/c-typeprint.c | 104 | ||||
-rw-r--r-- | gdb/cp-valprint.c | 24 | ||||
-rw-r--r-- | gdb/gdbtypes.c | 31 | ||||
-rw-r--r-- | gdb/gdbtypes.h | 30 | ||||
-rw-r--r-- | gdb/symtab.c | 69 | ||||
-rw-r--r-- | gdb/valops.c | 30 |
9 files changed, 186 insertions, 156 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 258b078..9877e16 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,39 @@ +Sat Dec 14 00:43:57 1996 Peter Schauer (pes@regent.e-technik.tu-muenchen.de) + + * c-exp.y (qualified_name): Replace explicit check for valid + destructor name with call to destructor_name_p. + + * c-lang.h, c-typeprint.c (cp_type_print_method_args): Removed, + no longer needed. + + * c-typeprint.c (c_type_print_varspec_prefix, c_type_print_base): + Replace remaining fprintf_unfiltered calls with their filtered variant. + (c_type_print_base): Do not print return type for destructors from + template classes. + Replace cp_type_print_method_args with cplus_demangle call to get + consistent type output for stubbed and unstubbed methods. + + * cp-valprint.c (cp_print_class_method): Replace + cp_type_print_method_args with cplus_demangle call to get consistent + type output for stubbed and unstubbed methods. + + * gdbtypes.c, gdbtypes.h (get_destructor_fn_field): New function + to find the destructor field indices for a type. + + * gdbtypes.h (struct type): Clarify comments for vptr_basetype + and arg_types fields. + (struct fn_field): Remove args field, no longer used. + + * symtab.c (decode_line_1), valops.c (value_struct_elt, + check_field_in): Use get_destructor_fn_field to find the destructor + field indices instead of assuming that the compiler passes the member + function fields in a specific order. + + * symtab.c (find_methods): Pass NULL instead of SYMBOL_BLOCK_VALUE + to lookup_symbol. + (list_symbol): Replace cp_type_print_method_args with cplus_demangle + call in zapped out code and explain why this code is zapped out. + Thu Dec 12 13:29:14 1996 Michael Meissner <meissner@tiktok.cygnus.com> * config/powerpc/ppc{,le}-sim.mt (SIM): Add the simulator common diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 0572e12..d7d4235 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -1,5 +1,5 @@ /* YACC parser for C expressions, for GDB. - Copyright (C) 1986, 1989, 1990, 1991, 1993, 1994 + Copyright (C) 1986, 1989, 1990, 1991, 1993, 1994, 1996 Free Software Foundation, Inc. This file is part of GDB. @@ -604,15 +604,14 @@ qualified_name: typebase COLONCOLON name error ("`%s' is not defined as an aggregate type.", TYPE_NAME (type)); - if (!STREQ (type_name_no_tag (type), $4.ptr)) - error ("invalid destructor `%s::~%s'", - type_name_no_tag (type), $4.ptr); - tmp_token.ptr = (char*) alloca ($4.length + 2); tmp_token.length = $4.length + 1; tmp_token.ptr[0] = '~'; memcpy (tmp_token.ptr+1, $4.ptr, $4.length); tmp_token.ptr[tmp_token.length] = 0; + + /* Check for valid destructor name. */ + destructor_name_p (tmp_token.ptr, type); write_exp_elt_opcode (OP_SCOPE); write_exp_elt_type (type); write_exp_string (tmp_token); diff --git a/gdb/c-lang.h b/gdb/c-lang.h index c8f8aa3..c7b2f55 100644 --- a/gdb/c-lang.h +++ b/gdb/c-lang.h @@ -1,5 +1,5 @@ /* C language support definitions for GDB, the GNU debugger. - Copyright 1992 Free Software Foundation, Inc. + Copyright 1992, 1996 Free Software Foundation, Inc. This file is part of GDB. @@ -55,15 +55,8 @@ c_type_print_base PARAMS ((struct type *, GDB_FILE *, int, int)); extern void c_type_print_varspec_prefix PARAMS ((struct type *, GDB_FILE *, int, int)); -extern void -cp_type_print_method_args PARAMS ((struct type **, char *, char *, int, - GDB_FILE *)); /* These are in cp-valprint.c */ -extern void -cp_type_print_method_args PARAMS ((struct type **, char *, char *, int, - GDB_FILE *)); - extern int vtblprint; /* Controls printing of vtbl's */ extern void diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 03665a2..3347050 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -144,42 +144,6 @@ c_print_type (type, varstring, stream, show, level) c_type_print_varspec_suffix (type, stream, show, 0, demangled_args); } - -/* Print the C++ method arguments ARGS to the file STREAM. */ - -void -cp_type_print_method_args (args, prefix, varstring, staticp, stream) - struct type **args; - char *prefix; - char *varstring; - int staticp; - GDB_FILE *stream; -{ - int i; - - fprintf_symbol_filtered (stream, prefix, language_cplus, DMGL_ANSI); - fprintf_symbol_filtered (stream, varstring, language_cplus, DMGL_ANSI); - fputs_filtered (" (", stream); - if (args && args[!staticp] && args[!staticp]->code != TYPE_CODE_VOID) - { - i = !staticp; /* skip the class variable */ - while (1) - { - type_print (args[i++], "", stream, -1); - if (!args[i]) - { - fprintf_filtered (stream, " ..."); - break; - } - else if (args[i]->code != TYPE_CODE_VOID) - { - fprintf_filtered (stream, ", "); - } - else break; - } - } - fprintf_filtered (stream, ")"); -} /* If TYPE is a derived type, then print out derivation information. Print only the actual base classes of this type, not the base classes @@ -274,7 +238,7 @@ c_type_print_varspec_prefix (type, stream, show, passed_a_ptr) case TYPE_CODE_METHOD: if (passed_a_ptr) - fprintf_unfiltered (stream, "("); + fprintf_filtered (stream, "("); c_type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 0); if (passed_a_ptr) { @@ -658,11 +622,11 @@ c_type_print_base (type, stream, show, level) { char *physname = TYPE_FN_FIELD_PHYSNAME (f, j); int is_full_physname_constructor = - ((physname[0]=='_' && physname[1]=='_' && - (isdigit(physname[2]) - || physname[2]=='Q' - || physname[2]=='t')) - || (strncmp(physname, "__ct__", 6) == 0)); + ((physname[0] == '_' && physname[1] == '_' + && strchr ("0123456789Qt", physname[2])) + || STREQN (physname, "__ct__", 6) + || DESTRUCTOR_PREFIX_P (physname) + || STREQN (physname, "__dt__", 6)); QUIT; if (TYPE_FN_FIELD_PROTECTED (f, j)) @@ -699,7 +663,7 @@ c_type_print_base (type, stream, show, level) if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) == 0) { /* Keep GDB from crashing here. */ - fprintf_unfiltered (stream, "<undefined type> %s;\n", + fprintf_filtered (stream, "<undefined type> %s;\n", TYPE_FN_FIELD_PHYSNAME (f, j)); break; } @@ -710,41 +674,35 @@ c_type_print_base (type, stream, show, level) fputs_filtered (" ", stream); } if (TYPE_FN_FIELD_STUB (f, j)) + /* Build something we can demangle. */ + mangled_name = gdb_mangle_name (type, i, j); + else + mangled_name = TYPE_FN_FIELD_PHYSNAME (f, j); + + demangled_name = + cplus_demangle (mangled_name, + DMGL_ANSI | DMGL_PARAMS); + if (demangled_name == NULL) + fprintf_filtered (stream, "<badly mangled name '%s'>", + mangled_name); + else { - /* Build something we can demangle. */ - mangled_name = gdb_mangle_name (type, i, j); - demangled_name = - cplus_demangle (mangled_name, - DMGL_ANSI | DMGL_PARAMS); - if (demangled_name == NULL) - fprintf_filtered (stream, "<badly mangled name %s>", - mangled_name); + char *demangled_no_class = + strchr (demangled_name, ':'); + + if (demangled_no_class == NULL) + demangled_no_class = demangled_name; else { - char *demangled_no_class = - strchr (demangled_name, ':'); - - if (demangled_no_class == NULL) - demangled_no_class = demangled_name; - else - { - if (*++demangled_no_class == ':') - ++demangled_no_class; - } - fputs_filtered (demangled_no_class, stream); - free (demangled_name); + if (*++demangled_no_class == ':') + ++demangled_no_class; } - free (mangled_name); + fputs_filtered (demangled_no_class, stream); + free (demangled_name); } - else if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_' - && is_cplus_marker (TYPE_FN_FIELD_PHYSNAME (f, j)[1])) - cp_type_print_method_args (TYPE_FN_FIELD_ARGS (f, j) + 1, - "~", method_name, 0, stream); - else - cp_type_print_method_args (TYPE_FN_FIELD_ARGS (f, j), "", - method_name, - TYPE_FN_FIELD_STATIC_P (f, j), - stream); + + if (TYPE_FN_FIELD_STUB (f, j)) + free (mangled_name); fprintf_filtered (stream, ";\n"); } diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index dc689c9..5cac8d5 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -87,6 +87,8 @@ cp_print_class_method (valaddr, type, stream) QUIT; if (TYPE_FN_FIELD_VOFFSET (f, j) == offset) { + if (TYPE_FN_FIELD_STUB (f, j)) + check_stub_method (domain, i, j); kind = "virtual "; goto common; } @@ -121,21 +123,19 @@ cp_print_class_method (valaddr, type, stream) common: if (i < len) { + char *demangled_name; + fprintf_filtered (stream, "&"); - c_type_print_varspec_prefix (TYPE_FN_FIELD_TYPE (f, j), stream, 0, 0); - fprintf_unfiltered (stream, kind); - if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_' - && is_cplus_marker (TYPE_FN_FIELD_PHYSNAME (f, j)[1])) - { - cp_type_print_method_args (TYPE_FN_FIELD_ARGS (f, j) + 1, "~", - TYPE_FN_FIELDLIST_NAME (domain, i), - 0, stream); - } + fprintf_filtered (stream, kind); + demangled_name = cplus_demangle (TYPE_FN_FIELD_PHYSNAME (f, j), + DMGL_ANSI | DMGL_PARAMS); + if (demangled_name == NULL) + fprintf_filtered (stream, "<badly mangled name %s>", + TYPE_FN_FIELD_PHYSNAME (f, j)); else { - cp_type_print_method_args (TYPE_FN_FIELD_ARGS (f, j), "", - TYPE_FN_FIELDLIST_NAME (domain, i), - 0, stream); + fputs_filtered (demangled_name, stream); + free (demangled_name); } } else diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index e9f6f8a..2f4e411 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1,5 +1,5 @@ /* Support routines for manipulating internal types for GDB. - Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc. + Copyright (C) 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. Contributed by Cygnus Support, using pieces from other GDB modules. This file is part of GDB. @@ -879,6 +879,35 @@ fill_in_vptr_fieldno (type) } } +/* Find the method and field indices for the destructor in class type T. + Return 1 if the destructor was found, otherwise, return 0. */ + +int +get_destructor_fn_field (t, method_indexp, field_indexp) + struct type *t; + int *method_indexp; + int *field_indexp; +{ + int i; + + for (i = 0; i < TYPE_NFN_FIELDS (t); i++) + { + int j; + struct fn_field *f = TYPE_FN_FIELDLIST1 (t, i); + + for (j = 0; j < TYPE_FN_FIELDLIST_LENGTH (t, i); j++) + { + if (DESTRUCTOR_PREFIX_P (TYPE_FN_FIELD_PHYSNAME (f, j))) + { + *method_indexp = i; + *field_indexp = j; + return 1; + } + } + } + return 0; +} + /* Added by Bryan Boreham, Kewill, Sun Sep 17 18:07:17 1989. If this is a stubbed struct (i.e. declared as struct foo *), see if diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index a7d8c39..02e762d 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1,5 +1,5 @@ /* Internal type definitions for GDB. - Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. + Copyright (C) 1992, 1993, 1994, 1996 Free Software Foundation, Inc. Contributed by Cygnus Support, using pieces from other GDB modules. This file is part of GDB. @@ -303,11 +303,14 @@ struct type } *fields; - /* For types with virtual functions, VPTR_BASETYPE is the base class which - defined the virtual function table pointer. + /* For types with virtual functions (TYPE_CODE_STRUCT), VPTR_BASETYPE + is the base class which defined the virtual function table pointer. - For types that are pointer to member types, VPTR_BASETYPE - is the type that this pointer is a member of. + For types that are pointer to member types (TYPE_CODE_MEMBER), + VPTR_BASETYPE is the type that this pointer is a member of. + + For method types (TYPE_CODE_METHOD), VPTR_BASETYPE is the aggregate + type that contains the method. Unused otherwise. */ @@ -327,7 +330,11 @@ struct type union type_specific { - /* ARG_TYPES is for TYPE_CODE_METHOD and TYPE_CODE_FUNC. */ + /* ARG_TYPES is for TYPE_CODE_METHOD. + Contains the type of each argument, ending with a void type + after the last argument for normal member functions or a NULL + pointer after the last argument for functions with variable + arguments. */ struct type **arg_types; @@ -433,17 +440,10 @@ struct cplus_struct_type char *physname; - /* The return value of the method */ + /* The type of the method. */ struct type *type; - /* The argument list. Only valid if is_stub is clear. Contains - the type of each argument, including `this', and ending with - a NULL pointer after the last argument. Should not contain - a `this' pointer for static member functions. */ - - struct type **args; - /* For virtual functions. First baseclass that defines this virtual function. */ @@ -775,6 +775,8 @@ lookup_fundamental_type PARAMS ((struct objfile *, int)); extern void fill_in_vptr_fieldno PARAMS ((struct type *)); +extern int get_destructor_fn_field PARAMS ((struct type *, int *, int *)); + extern int get_discrete_bounds PARAMS ((struct type*, LONGEST*, LONGEST*)); #if MAINTENANCE_CMDS diff --git a/gdb/symtab.c b/gdb/symtab.c index 92bff76..ccfdf67 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1,5 +1,5 @@ /* Symbol table lookup for the GNU debugger, GDB. - Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995 + Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. This file is part of GDB. @@ -77,7 +77,7 @@ list_symbols PARAMS ((char *, int, int, int)); static void output_source_filename PARAMS ((char *, int *)); -static char * +char * operator_chars PARAMS ((char *, char **)); static int find_line_common PARAMS ((struct linetable *, int, int *)); @@ -1551,7 +1551,7 @@ find_function_start_sal (sym, funfirstline) some legitimate operator text, return a pointer to the beginning of the substring of the operator text. Otherwise, return "". */ -static char * +char * operator_chars (p, end) char *p; char **end; @@ -1717,19 +1717,12 @@ find_methods (t, name, sym_arr) if (DESTRUCTOR_PREFIX_P (phys_name)) continue; - /* FIXME: Why are we looking this up in the - SYMBOL_BLOCK_VALUE (sym_class)? It is intended as a hook - for nested types? If so, it should probably hook to the - type, not the symbol. mipsread.c is the only symbol - reader which sets the SYMBOL_BLOCK_VALUE for types, and - this is not documented in symtab.h. -26Aug93. */ - sym_arr[i1] = lookup_symbol (phys_name, - SYMBOL_BLOCK_VALUE (sym_class), - VAR_NAMESPACE, + NULL, VAR_NAMESPACE, (int *) NULL, (struct symtab **) NULL); - if (sym_arr[i1]) i1++; + if (sym_arr[i1]) + i1++; else { fputs_filtered("(Cannot find method ", gdb_stdout); @@ -2029,25 +2022,22 @@ decode_line_1 (argptr, funfirstline, default_symtab, default_line, canonical) sym_arr = (struct symbol **) alloca(total_number_of_methods (t) * sizeof(struct symbol *)); - /* Cfront objects don't have fieldlists. */ - if (destructor_name_p (copy, t) && TYPE_FN_FIELDLISTS (t) != NULL) + if (destructor_name_p (copy, t)) { - /* destructors are a special case. */ - struct fn_field *f = TYPE_FN_FIELDLIST1 (t, 0); - int len = TYPE_FN_FIELDLIST_LENGTH (t, 0) - 1; - /* gcc 1.x puts destructor in last field, - gcc 2.x puts destructor in first field. */ - char *phys_name = TYPE_FN_FIELD_PHYSNAME (f, len); - if (!DESTRUCTOR_PREFIX_P (phys_name)) + /* Destructors are a special case. */ + int m_index, f_index; + + if (get_destructor_fn_field (t, &m_index, &f_index)) { - phys_name = TYPE_FN_FIELD_PHYSNAME (f, 0); - if (!DESTRUCTOR_PREFIX_P (phys_name)) - phys_name = ""; + struct fn_field *f = TYPE_FN_FIELDLIST1 (t, m_index); + + sym_arr[i1] = + lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, f_index), + NULL, VAR_NAMESPACE, (int *) NULL, + (struct symtab **)NULL); + if (sym_arr[i1]) + i1++; } - sym_arr[i1] = - lookup_symbol (phys_name, SYMBOL_BLOCK_VALUE (sym_class), - VAR_NAMESPACE, 0, (struct symtab **)NULL); - if (sym_arr[i1]) i1++; } else i1 = find_methods (t, copy, sym_arr); @@ -2848,15 +2838,26 @@ list_symbols (regexp, class, bpt, from_tty) } else { -# if 0 /* FIXME, why is this zapped out? */ - char buf[1024]; +# if 0 +/* Tiemann says: "info methods was never implemented." */ + char *demangled_name; c_type_print_base (TYPE_FN_FIELD_TYPE(t, i), gdb_stdout, 0, 0); c_type_print_varspec_prefix (TYPE_FN_FIELD_TYPE(t, i), gdb_stdout, 0); - sprintf (buf, " %s::", type_name_no_tag (t)); - cp_type_print_method_args (TYPE_FN_FIELD_ARGS (t, i), - buf, name, gdb_stdout); + if (TYPE_FN_FIELD_STUB (t, i)) + check_stub_method (TYPE_DOMAIN_TYPE (type), j, i); + demangled_name = + cplus_demangle (TYPE_FN_FIELD_PHYSNAME (t, i), + DMGL_ANSI | DMGL_PARAMS); + if (demangled_name == NULL) + fprintf_filtered (stream, "<badly mangled name %s>", + TYPE_FN_FIELD_PHYSNAME (t, i)); + else + { + fputs_filtered (demangled_name, stream); + free (demangled_name); + } # endif } } diff --git a/gdb/valops.c b/gdb/valops.c index b23d08b..fc98c95 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1,5 +1,5 @@ /* Perform non-arithmetic operations on values, for GDB. - Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995 + Copyright 1986, 1987, 1989, 1991, 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc. This file is part of GDB. @@ -1648,7 +1648,7 @@ search_struct_field (name, arg1, offset, type, looking_for_baseclass) error ("Internal error: could not find physical static variable named %s", phys_name); v = value_at (TYPE_FIELD_TYPE (type, i), - (CORE_ADDR)SYMBOL_BLOCK_VALUE (sym)); + SYMBOL_VALUE_ADDRESS (sym)); } else v = value_primitive_field (arg1, offset, i, type); @@ -1922,11 +1922,19 @@ value_struct_elt (argp, args, name, static_memfuncp, err) { if (!args[1]) { - /* destructors are a special case. */ - v = value_fn_field (NULL, TYPE_FN_FIELDLIST1 (t, 0), - TYPE_FN_FIELDLIST_LENGTH (t, 0), 0, 0); - if (!v) error("could not find destructor function named %s.", name); - else return v; + /* Destructors are a special case. */ + int m_index, f_index; + + v = NULL; + if (get_destructor_fn_field (t, &m_index, &f_index)) + { + v = value_fn_field (NULL, TYPE_FN_FIELDLIST1 (t, m_index), + f_index, NULL, 0); + } + if (v == NULL) + error ("could not find destructor function named %s.", name); + else + return v; } else { @@ -2005,7 +2013,11 @@ check_field_in (type, name) /* Destructors are a special case. */ if (destructor_name_p (name, type)) - return 1; + { + int m_index, f_index; + + return get_destructor_fn_field (type, &m_index, &f_index); + } for (i = TYPE_NFN_FIELDS (type) - 1; i >= 0; --i) { @@ -2092,7 +2104,7 @@ value_struct_elt_for_reference (domain, offset, curtype, name, intype) error ("Internal error: could not find physical static variable named %s", phys_name); return value_at (SYMBOL_TYPE (sym), - (CORE_ADDR)SYMBOL_BLOCK_VALUE (sym)); + SYMBOL_VALUE_ADDRESS (sym)); } if (TYPE_FIELD_PACKED (t, i)) error ("pointers to bitfield members not allowed"); |