/* Support for printing C++ values for GDB, the GNU debugger.
- Copyright (C) 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
- 2000, 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011
- Free Software Foundation, Inc.
+ Copyright (C) 1986, 1988-1989, 1991-1997, 2000-2003, 2005-2012 Free
+ Software Foundation, Inc.
This file is part of GDB.
#include "language.h"
#include "python/python.h"
#include "exceptions.h"
+#include "typeprint.h"
/* Controls printing of vtbl's. */
static void
int
cp_is_vtbl_ptr_type (struct type *type)
{
- char *typename = type_name_no_tag (type);
+ const char *typename = type_name_no_tag (type);
return (typename != NULL && !strcmp (typename, vtbl_ptr_name));
}
{
int statmem_obstack_initial_size = 0;
int stat_array_obstack_initial_size = 0;
-
+ struct type *vptr_basetype = NULL;
+ int vptr_fieldno;
+
if (dont_print_statmem == 0)
{
statmem_obstack_initial_size =
}
}
+ vptr_fieldno = get_vptr_fieldno (type, &vptr_basetype);
for (i = n_baseclasses; i < len; i++)
{
/* If requested, skip printing of static fields. */
}
else if (field_is_static (&TYPE_FIELD (type, i)))
{
- struct value *v = value_static_field (type, i);
-
- if (v == NULL)
+ volatile struct gdb_exception ex;
+ struct value *v = NULL;
+
+ TRY_CATCH (ex, RETURN_MASK_ERROR)
+ {
+ v = value_static_field (type, i);
+ }
+
+ if (ex.reason < 0)
+ fprintf_filtered (stream,
+ _("<error reading variable: %s>"),
+ ex.message);
+ else if (v == NULL)
val_print_optimized_out (stream);
else
cp_print_static_field (TYPE_FIELD_TYPE (type, i),
v, stream, recurse + 1,
options);
}
+ else if (i == vptr_fieldno && type == vptr_basetype)
+ {
+ int i_offset = offset + TYPE_FIELD_BITPOS (type, i) / 8;
+ struct type *i_type = TYPE_FIELD_TYPE (type, i);
+
+ if (valprint_check_validity (stream, i_type, i_offset, val))
+ {
+ CORE_ADDR addr;
+
+ addr = extract_typed_address (valaddr + i_offset, i_type);
+ print_function_pointer_address (options,
+ get_type_arch (type),
+ addr, stream);
+ }
+ }
else
{
struct value_print_options opts = *options;
int boffset = 0;
int skip;
struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
- char *basename = TYPE_NAME (baseclass);
+ const char *basename = TYPE_NAME (baseclass);
const gdb_byte *base_valaddr = NULL;
const struct value *base_val = NULL;
volatile struct gdb_exception ex;
if ((boffset + offset) < 0
|| (boffset + offset) >= TYPE_LENGTH (real_type))
{
- /* FIXME (alloca): unsafe if baseclass is really
- really large. */
- gdb_byte *buf = alloca (TYPE_LENGTH (baseclass));
+ gdb_byte *buf;
+ struct cleanup *back_to;
+
+ buf = xmalloc (TYPE_LENGTH (baseclass));
+ back_to = make_cleanup (xfree, buf);
if (target_read_memory (address + boffset, buf,
TYPE_LENGTH (baseclass)) != 0)
boffset = 0;
thistype = baseclass;
base_valaddr = value_contents_for_printing_const (base_val);
+ do_cleanups (back_to);
}
else
{
if (domain != NULL)
{
- char *name;
+ const char *name;
fputs_filtered (prefix, stream);
name = type_name_no_tag (domain);
if (name)
fputs_filtered (name, stream);
else
- c_type_print_base (domain, stream, 0, 0);
+ c_type_print_base (domain, stream, 0, 0, &type_print_raw_options);
fprintf_filtered (stream, "::");
fputs_filtered (TYPE_FIELD_NAME (domain, fieldno), stream);
}