/* Support for printing C++ values for GDB, the GNU debugger.
Copyright 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
- 2000
+ 2000, 2001, 2002
Free Software Foundation, Inc.
This file is part of GDB.
Boston, MA 02111-1307, USA. */
#include "defs.h"
-#include "obstack.h"
+#include "gdb_obstack.h"
#include "symtab.h"
#include "gdbtypes.h"
#include "expression.h"
#include "gdb_string.h"
#include "c-lang.h"
#include "target.h"
+#include "cp-abi.h"
/* Indication of presence of HP-compiled object files */
extern int hp_som_som_object_present; /* defined in symtab.c */
extern void _initialize_cp_valprint (void);
-static void cp_print_static_field (struct type *, value_ptr,
+static void cp_print_static_field (struct type *, struct value *,
struct ui_file *, int, int,
enum val_prettyprint);
enum val_prettyprint, struct type **);
static void cp_print_hpacc_virtual_table_entries (struct type *, int *,
- value_ptr,
+ struct value *,
struct ui_file *, int,
int,
enum val_prettyprint);
f = TYPE_FN_FIELDLIST1 (domain, i);
len2 = TYPE_FN_FIELDLIST_LENGTH (domain, i);
+ check_stub_method_group (domain, i);
for (j = 0; j < len2; j++)
{
- 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;
}
f = TYPE_FN_FIELDLIST1 (domain, i);
len2 = TYPE_FN_FIELDLIST_LENGTH (domain, i);
+ check_stub_method_group (domain, i);
for (j = 0; j < len2; j++)
{
- QUIT;
- if (TYPE_FN_FIELD_STUB (f, j))
- check_stub_method (domain, i, j);
if (STREQ (SYMBOL_NAME (sym), TYPE_FN_FIELD_PHYSNAME (f, j)))
- {
- goto common;
- }
+ goto common;
}
}
}
int
cp_is_vtbl_member (struct type *type)
{
+ /* With older versions of g++, the vtbl field pointed to an array
+ of structures. Nowadays it points directly to the structure. */
if (TYPE_CODE (type) == TYPE_CODE_PTR)
{
type = TYPE_TARGET_TYPE (type);
return cp_is_vtbl_ptr_type (type);
}
}
+ else if (TYPE_CODE (type) == TYPE_CODE_STRUCT) /* if not using thunks */
+ {
+ return cp_is_vtbl_ptr_type (type);
+ }
+ else if (TYPE_CODE (type) == TYPE_CODE_PTR) /* if using thunks */
+ {
+ /* The type name of the thunk pointer is NULL when using dwarf2.
+ We could test for a pointer to a function, but there is
+ no type info for the virtual table either, so it wont help. */
+ return cp_is_vtbl_ptr_type (type);
+ }
}
return 0;
}
if (!TYPE_FIELD_STATIC (type, i) && TYPE_FIELD_PACKED (type, i))
{
- value_ptr v;
+ struct value *v;
/* Bitfields require special handling, especially due to byte
order problems. */
}
else if (TYPE_FIELD_STATIC (type, i))
{
- value_ptr v = value_static_field (type, i);
+ struct value *v = value_static_field (type, i);
if (v == NULL)
fputs_filtered ("<optimized out>", stream);
else
hpacc_vtbl_ptr_name,
5))
{
- value_ptr v;
+ struct value *v;
/* First get the virtual table pointer and print it out */
#if 0
struct type **last_dont_print
= (struct type **) obstack_next_free (&dont_print_vb_obstack);
int i, n_baseclasses = TYPE_N_BASECLASSES (type);
+ int thisoffset;
+ struct type *thistype;
if (dont_print_vb == 0)
{
obstack_ptr_grow (&dont_print_vb_obstack, baseclass);
}
+ thisoffset = offset;
+ thistype = real_type;
if (TYPE_HAS_VTABLE (type) && BASETYPE_VIA_VIRTUAL (type, i))
{
/* Assume HP/Taligent runtime convention */
&& ((boffset + offset) < 0
|| (boffset + offset) >= TYPE_LENGTH (type)))
{
+ /* FIXME (alloca): unsafe if baseclass is really really large. */
base_valaddr = (char *) alloca (TYPE_LENGTH (baseclass));
- if (target_read_memory (address + boffset, base_valaddr,
+ if (target_read_memory (address + offset + boffset, base_valaddr,
TYPE_LENGTH (baseclass)) != 0)
skip = 1;
+ thisoffset = 0;
+ boffset = 0;
+ thistype = baseclass;
}
else
base_valaddr = valaddr;
if (skip >= 1)
fprintf_filtered (stream, "<invalid address>");
else
- cp_print_value_fields (baseclass, real_type, base_valaddr,
- offset + boffset, address, stream, format,
+ cp_print_value_fields (baseclass, thistype, base_valaddr,
+ thisoffset + boffset, address, stream, format,
recurse, pretty,
((struct type **)
obstack_base (&dont_print_vb_obstack)),
static void
cp_print_static_field (struct type *type,
- value_ptr val,
+ struct value *val,
struct ui_file *stream,
int format,
int recurse,
static void
cp_print_hpacc_virtual_table_entries (struct type *type, int *vfuncs,
- value_ptr v, struct ui_file *stream,
+ struct value *v, struct ui_file *stream,
int format, int recurse,
enum val_prettyprint pretty)
{
- 1);
/* Get the address of the vfunction entry */
- value_ptr vf = value_copy (v);
+ struct value *vf = value_copy (v);
if (VALUE_LAZY (vf))
(void) value_fetch_lazy (vf);
/* adjust by offset */