binutils-gdb/gdb/cp-abi.h

132 lines
4.3 KiB
C
Raw Normal View History

(Changes from Daniel Berlin, with revisions by Jim Blandy.) Abstract out operations specific to particular C++ ABI's, and invoke them through a function table. This removes the C++ ABI dependencies scattered throughout the code, and allows us to cleanly add support for new C++ ABI's. * cp-abi.h, cp-abi.h, gnu-v2-abi.c, hpacc-abi.c: New files. * c-typeprint.c, c-valprint.c, dbxread.c, eval.c, gdbtypes.c, jv-typeprint.c, linespec.c, symtab.c, typeprint.c, valops.c: #include "cp-abi.h". These files all use functions now declared there. * symtab.h (OPNAME_PREFIX_P, VTBL_PREFIX_P, DESTRUCTOR_PREFIX_P): Deleted. These services are now provided by functions declared in cp-abi.h. * value.h (value_rtti_type, value_virtual_fn_field): Same. * values.c (value_virtual_fn_field): Same, for this definition. * valops.c (value_rtti_type): Same. * c-typeprint.c (c_type_print_base): Use the functions from "cp-abi.h", instead of the old macros, or hard-coded ABI-specific tests. * dbxread.c (record_minimal_symbol): Same. * gdbtypes.c (get_destructor_fn_field, virtual_base_index, virtual_base_index_skip_primaries): Same. * jv-typeprint.c (java_type_print_base): Same. * linespec.c (find_methods, decode_line_1): Same. * symtab.c (gdb_mangle_name): Same. * Makefile.in (SFILES): Add the new .c files mentioned above. (cp_abi_h): New variable. (COMMON_OBS): Add gnu-v2-abi.o, hpacc-abi.o, and cp-abi.o. (cp-abi.o, gnu-v2-abi.o, hpacc-abi.o): New targets. (c-typeprint.o, c-valprint.o, dbxread.o, eval.o, gdbtypes.o, jv-typeprint.o, symtab.o, linespec.o, typeprint.o, valops.o): Add dependency on $(cp_abi_h).
2001-04-27 02:19:09 +02:00
/* Abstraction of various C++ ABI's we support, and the info we need
to get from them.
Contributed by Daniel Berlin <dberlin@redhat.com>
Copyright 2001 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or
modify
it under the terms of the GNU General Public License as published
by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef CP_ABI_H_
#define CP_ABI_H_ 1
/* Kinds of constructors. All these values are guaranteed to be
non-zero. */
enum ctor_kinds {
/* Initialize a complete object, including virtual bases, using
memory provided by caller. */
complete_object_ctor = 1,
/* Initialize a base object of some larger object. */
base_object_ctor,
/* An allocating complete-object constructor. */
complete_object_allocating_ctor
};
/* Kinds of destructors. All these values are guaranteed to be
non-zero. */
enum dtor_kinds {
/* A destructor which finalizes the entire object, and then calls
`delete' on its storage. */
deleting_dtor = 1,
/* A destructor which finalizes the entire object, but does not call
`delete'. */
complete_object_dtor,
/* A destructor which finalizes a subobject of some larger object. */
base_object_dtor
};
struct cp_abi_ops
{
const char *shortname;
const char *longname;
const char *doc;
/* The functions here that attempt to determine what sort of thing a
mangled name refers to may well be revised in the future. It
would certainly be cleaner to carry this information explicitly
in GDB's data structures than to derive it from the mangled name. */
/* Return non-zero iff NAME is the mangled name of a constructor.
Actually, return an `enum ctor_kind' value describing what *kind*
of constructor it is. */
enum ctor_kinds (*is_constructor_name) (const char *name);
/* Return non-zero iff NAME is the mangled name of a destructor.
Actually, return an `enum dtor_kind' value describing what *kind*
of destructor it is. */
enum dtor_kinds (*is_destructor_name) (const char *name);
/* Return non-zero iff NAME is the mangled name of a vtable. */
int (*is_vtable_name) (const char *name);
/* Return non-zero iff NAME is the un-mangled name of an operator,
perhaps scoped within some class. */
int (*is_operator_name) (const char *name);
value_ptr (*virtual_fn_field) (value_ptr * arg1p, struct fn_field * f,
int j, struct type * type, int offset);
/* Find the real run-time type of a value using RTTI.
* V is a pointer to the value.
* A pointer to the struct type entry of the run-time type
* is returneed.
* FULL is a flag that is set only if the value V includes
* the entire contents of an object of the RTTI type.
* TOP is the offset to the top of the enclosing object of
* the real run-time type. This offset may be for the embedded
* object, or for the enclosing object of V.
* USING_ENC is the flag that distinguishes the two cases.
* If it is 1, then the offset is for the enclosing object,
* otherwise for the embedded object.
*
*/
struct type *(*rtti_type) (value_ptr v, int *full, int *top,
int *using_enc);
};
extern struct cp_abi_ops *cp_abis;
extern int num_cp_abis;
extern struct cp_abi_ops current_cp_abi;
extern enum ctor_kinds is_constructor_name (const char *name);
extern enum dtor_kinds is_destructor_name (const char *name);
extern int is_vtable_name (const char *name);
extern int is_operator_name (const char *name);
extern value_ptr value_virtual_fn_field (value_ptr * arg1p,
struct fn_field *f, int j,
struct type *type, int offset);
extern struct type *value_rtti_type (value_ptr v, int *full, int *top,
int *using_enc);
extern int register_cp_abi (struct cp_abi_ops abi);
extern int switch_to_cp_abi (const char *short_name);
#endif