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.
+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
/* 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.
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);
/* 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.
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
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
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)
{
{
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))
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;
}
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");
}
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;
}
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
/* 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.
}
}
+/* 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
/* 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.
} *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. */
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;
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. */
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
/* 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.
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 *));
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;
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);
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);
}
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
}
}
/* 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.
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);
{
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
{
/* 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)
{
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");