47 return startswith (
name,
"_ZTV");
119 if (result !=
nullptr)
122 struct type *void_ptr_type
124 struct type *ptr_to_void_fn_type
128 struct type *ptrdiff_type
137 field_list = XCNEWVEC (
struct field, 4);
138 field = &field_list[0];
170 gdb_assert (
field == (field_list + 4));
172 t =
arch_type (
arch, TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, NULL);
175 t->
set_name (
"gdb_gnu_v3_abi_vtable");
213 int fieldnum, fieldelem;
216 gdb_assert (
type->
code () == TYPE_CODE_STRUCT
217 ||
type->
code () == TYPE_CODE_UNION);
219 if (
type->
code () == TYPE_CODE_UNION)
258 struct type *container_type, CORE_ADDR container_addr)
261 struct type *vtable_pointer_type;
262 struct value *vtable_pointer;
263 CORE_ADDR vtable_address;
266 gdb_assert (container_type->
code () == TYPE_CODE_STRUCT);
284 vtable_pointer =
value_at (vtable_pointer_type, container_addr);
297 int *full_p, LONGEST *top_p,
int *using_enc_p)
301 struct value *vtable;
303 const char *vtable_symbol_name;
304 const char *class_name;
305 struct type *run_time_type;
306 LONGEST offset_to_top;
310 if (values_type->
code () != TYPE_CODE_STRUCT
338 if (vtable_symbol_name == NULL
339 || !startswith (vtable_symbol_name,
"vtable for "))
341 warning (_(
"can't find linker symbol for virtual table for `%s' value"),
343 if (vtable_symbol_name)
344 warning (_(
" found `%s' instead"), vtable_symbol_name);
347 class_name = vtable_symbol_name + 11;
350 atsign = strchr (class_name,
'@');
355 copy = (
char *) alloca (atsign - class_name + 1);
356 memcpy (copy, class_name, atsign - class_name);
357 copy[atsign - class_name] =
'\0';
364 if (run_time_type == NULL)
375 >= run_time_type->
length ()));
377 *top_p = - offset_to_top;
378 return run_time_type;
386 struct type *fntype,
int vtable_index)
388 struct value *vtable, *vfn;
393 gdb_assert (vtable != NULL);
425 if (values_type->
code () != TYPE_CODE_STRUCT)
426 error (_(
"Only classes can have virtual functions."));
434 if (vfn_base != values_type)
451 const bfd_byte *valaddr, LONGEST embedded_offset,
452 CORE_ADDR address,
const struct value *val)
455 struct type *ptr_type;
456 struct value *vtable;
457 struct value *vbase_array;
458 long int cur_base_offset, base_offset;
484 addr_stack.
addr = address + embedded_offset;
485 addr_stack.
next =
nullptr;
490 return (
int) (result - addr_stack.
addr);
500 error (_(
"Expected a negative vbase offset (old compiler?)"));
503 if ((- cur_base_offset) % ptr_type->
length () != 0)
504 error (_(
"Misaligned vbase offset."));
505 cur_base_offset = cur_base_offset / ((int) ptr_type->
length ());
508 gdb_assert (vtable != NULL);
530 for (i = 0; i < len; i++)
539 for (j = 0; j < len2; j++)
550 struct type *basetype;
559 if (adjustment >= pos && adjustment < pos + basetype->
length ())
570 const gdb_byte *contents,
572 LONGEST *adjustment_p)
578 LONGEST voffset, adjustment;
589 funcptr_type->
length (), byte_order);
590 contents += funcptr_type->
length ();
597 voffset = voffset ^ vbit;
601 vbit = adjustment & 1;
602 adjustment = adjustment >> 1;
605 *value_p = vbit? voffset : ptr_value;
606 *adjustment_p = adjustment;
627 if (ptr_value == 0 && vbit == 0)
637 const char *physname;
650 gdb::unique_xmalloc_ptr<char> demangled_name
654 if (demangled_name == NULL)
657 gdb_puts (demangled_name.get (), stream);
661 else if (ptr_value != 0)
673 gdb_printf (stream,
"&virtual table offset ");
703 CORE_ADDR
value,
int is_virtual)
738 struct type *self_type, *final_type, *method_type;
780 method_type, voffset);
832 return addra < addrb;
843 std::vector<value_and_voffset *> *offset_vec,
851 gdb_assert (
type->
code () == TYPE_CODE_STRUCT);
860 slot = htab_find_slot (offset_hash, &search_vo, INSERT);
869 offset_vec->push_back (current_vo);
905 struct value *vtable;
914 gdb_printf (_(
"vtable for '%s' @ %s (subobject @ %s):\n"),
920 for (i = 0; i <= max_voffset; ++i)
940 catch (
const gdb_exception_error &ex)
943 _(
"<error: %s>"), ex.what ());
960 struct value *vtable;
975 if (opts.objectprint)
984 if (
type->
code () == TYPE_CODE_STRUCT)
990 gdb_printf (_(
"This object does not have a virtual function table\n"));
997 std::vector<value_and_voffset *> result_vec;
1000 std::sort (result_vec.begin (), result_vec.end (),
1006 if (iter->max_voffset >= 0)
1028 struct type *void_ptr_type
1030 struct type *char_type
1032 struct type *char_ptr_type
1035 field_list = XCNEWVEC (
struct field, 2);
1036 field = &field_list[0];
1053 gdb_assert (
field == (field_list + 2));
1055 t =
arch_type (
arch, TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, NULL);
1058 t->
set_name (
"gdb_gnu_v3_type_info");
1070 struct type *typeinfo_type;
1074 if (typeinfo == NULL)
1077 if (typeinfo_type ==
nullptr)
1084 typeinfo_type = typeinfo->
type ();
1086 return typeinfo_type;
1091static struct value *
1094 struct type *typeinfo_type;
1097 struct value *result;
1098 std::string type_name;
1099 gdb::unique_xmalloc_ptr<char> canonical;
1111 if (
type->
code () == TYPE_CODE_REF)
1119 if (type_name.empty ())
1120 error (_(
"cannot find typeinfo for unnamed type"));
1127 const char *
name = (canonical ==
nullptr
1128 ? type_name.c_str ()
1129 : canonical.get ());
1135 if (
type->
code () == TYPE_CODE_STRUCT
1139 struct value *vtable, *typeinfo_value;
1144 error (_(
"cannot find typeinfo for object of type '%s'"),
1152 std::string sym_name = std::string (
"typeinfo for ") +
name;
1156 if (minsym.
minsym == NULL)
1157 error (_(
"could not find typeinfo symbol for '%s'"),
name);
1173 const char *symname;
1174 const char *class_name;
1179 if (typeinfo_sym.
minsym == NULL)
1180 error (_(
"could not find minimal symbol for typeinfo address %s"),
1183#define TYPEINFO_PREFIX "typeinfo for "
1184#define TYPEINFO_PREFIX_LEN (sizeof (TYPEINFO_PREFIX) - 1)
1188 error (_(
"typeinfo symbol '%s' has unexpected name"),
1193 atsign = strchr (class_name,
'@');
1195 return std::string (class_name, atsign - class_name);
1220 CORE_ADDR real_stop_pc, method_stop_pc, func_addr;
1224 const char *thunk_name, *fn_name;
1227 if (real_stop_pc == 0)
1228 real_stop_pc = stop_pc;
1233 if (thunk_sym.
minsym == NULL || section == NULL)
1240 if (thunk_name == NULL || strstr (thunk_name,
" thunk to ") == NULL)
1243 fn_name = strstr (thunk_name,
" thunk to ") + strlen (
" thunk to ");
1245 if (fn_sym.
minsym == NULL)
1257 method_stop_pc = func_addr;
1260 (
gdbarch, frame, method_stop_pc);
1261 if (real_stop_pc == 0)
1262 real_stop_pc = method_stop_pc;
1264 return real_stop_pc;
1291 case DW_DEFAULTED_no:
1293 case DW_DEFAULTED_in_class:
1295 case DW_DEFAULTED_out_of_class:
1330 struct type *method_type,
1341 if (arg_type->
code () != expected)
1351 for (
int i = 2; i < method_type->
num_fields (); i++)
1353 arg_type = method_type->
field (i).
type ();
1372 struct type *method_type)
1382 struct type *method_type)
1385 TYPE_CODE_RVALUE_REF);
1409 int fieldnum, fieldelem;
1416 bool has_cc_attr =
false;
1417 bool is_pass_by_value =
false;
1418 bool is_dynamic =
false;
1424 if (
type->
code () != TYPE_CODE_STRUCT
1425 &&
type->
code () != TYPE_CODE_UNION)
1434 is_pass_by_value =
true;
1442 is_pass_by_value =
false;
1504 bool cctor_implicitly_deleted
1508 bool cctor_explicitly_deleted = (cctor_def ==
DELETED);
1510 if (cctor_implicitly_deleted || cctor_explicitly_deleted)
1511 info.copy_constructible =
false;
1514 info.destructible =
false;
1518 info.trivially_copy_constructible
1522 info.trivially_copyable
1523 = (info.trivially_copy_constructible
1524 && info.trivially_destructible
1540 if (field_type->
code () == TYPE_CODE_ARRAY)
1547 info.copy_constructible =
false;
1549 info.destructible =
false;
1551 info.trivially_copyable =
false;
1552 if (!
field_info.trivially_copy_constructible)
1553 info.trivially_copy_constructible =
false;
1555 info.trivially_destructible =
false;
1559 if (has_cc_attr && info.trivially_copyable != is_pass_by_value)
1563 info.trivially_copyable = is_pass_by_value;
1576 (
enum dtor_kinds (*) (
const char *))is_gnu_v3_mangled_dtor;
1578 (
enum ctor_kinds (*) (
const char *))is_gnu_v3_mangled_ctor;
void * xcalloc(size_t number, size_t size)
void c_print_type(struct type *type, const char *varstring, struct ui_file *stream, int show, int level, enum language language, const struct type_print_options *flags)
ui_file_style style() const
void set(unsigned key, void *datum)
cli_style_option metadata_style
int register_cp_abi(struct cp_abi_ops *abi)
enum ctor_kinds is_constructor_name(const char *name)
void set_cp_abi_as_auto_default(const char *short_name)
gdb::unique_xmalloc_ptr< char > gdb_demangle(const char *name, int options)
struct type * cp_lookup_rtti_type(const char *name, const struct block *block)
gdb::unique_xmalloc_ptr< char > cp_canonicalize_string(const char *string)
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)
CORE_ADDR extract_typed_address(const gdb_byte *buf, struct type *type)
static LONGEST extract_signed_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
struct value * evaluate_type(struct expression *exp)
std::unique_ptr< expression > expression_up
expression_up parse_expression(const char *, innermost_block_tracker *=nullptr, bool void_context_p=false)
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
int gdbarch_vtable_function_descriptors(struct gdbarch *gdbarch)
CORE_ADDR gdbarch_skip_trampoline_code(struct gdbarch *gdbarch, frame_info_ptr frame, CORE_ADDR pc)
int gdbarch_vbit_in_delta(struct gdbarch *gdbarch)
CORE_ADDR gdbarch_convert_from_func_ptr_addr(struct gdbarch *gdbarch, CORE_ADDR addr, struct target_ops *targ)
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
struct type * make_pointer_type(struct type *type, struct type **typeptr)
enum bfd_endian type_byte_order(const struct type *type)
void check_stub_method_group(struct type *type, int method_id)
struct type * lookup_pointer_type(struct type *type)
int field_is_static(struct field *f)
struct type * lookup_array_range_type(struct type *element_type, LONGEST low_bound, LONGEST high_bound)
struct type * make_cv_type(int cnst, int voltl, struct type *type, struct type **typeptr)
struct type * make_type_with_address_space(struct type *type, type_instance_flags space_flag)
struct type * arch_type(struct gdbarch *gdbarch, enum type_code code, int bit, const char *name)
int class_types_same_p(const struct type *a, const struct type *b)
struct type * arch_integer_type(struct gdbarch *gdbarch, int bit, int unsigned_p, const char *name)
struct type * check_typedef(struct type *type)
#define TYPE_FN_FIELD_PHYSNAME(thisfn, n)
#define TYPE_NFN_FIELDS(thistype)
#define TYPE_CPLUS_DYNAMIC(thistype)
#define ALLOCATE_CPLUS_STRUCT_TYPE(type)
#define TYPE_FN_FIELD_VOFFSET(thisfn, n)
@ FIELD_LOC_KIND_DWARF_BLOCK
#define TYPE_FN_FIELDLIST1(thistype, n)
@ TYPE_INSTANCE_FLAG_CODE_SPACE
#define TYPE_SAFE_NAME(type)
#define TYPE_SELF_TYPE(thistype)
#define TYPE_FN_FIELD_TYPE(thisfn, n)
#define TYPE_FN_FIELD_VIRTUAL_P(thisfn, n)
#define TYPE_FN_FIELD_CONSTRUCTOR(thisfn, n)
#define TYPE_BASECLASS_BITPOS(thistype, index)
#define TYPE_FN_FIELDLIST_LENGTH(thistype, n)
#define INIT_CPLUS_SPECIFIC(type)
#define TYPE_CPLUS_CALLING_CONVENTION(thistype)
#define TYPE_FN_FIELD_DEFAULTED(thisfn, n)
#define TYPE_FN_FIELD_DELETED(thisfn, n)
#define BASETYPE_VIA_VIRTUAL(thistype, index)
#define TYPE_FN_FIELDLIST_NAME(thistype, n)
#define TYPE_FN_FIELD_ARTIFICIAL(thisfn, n)
#define TYPE_N_BASECLASSES(thistype)
void _initialize_gnu_v3_abi()
static const registry< gdbarch >::key< struct type > std_type_info_gdbarch_data
static struct type * vtable_ptrdiff_type(struct gdbarch *gdbarch)
static struct value * gnuv3_get_typeid(struct value *value)
static void gnuv3_make_method_ptr(struct type *type, gdb_byte *contents, CORE_ADDR value, int is_virtual)
static const registry< gdbarch >::key< struct type > vtable_type_gdbarch_data
static std::string gnuv3_get_typename_from_type_info(struct value *type_info_ptr)
static struct type * get_gdb_vtable_type(struct gdbarch *arch)
static definition_style get_def_style(struct fn_field *fn, int fieldelem)
static int gnuv3_is_vtable_name(const char *name)
static CORE_ADDR gnuv3_skip_trampoline(frame_info_ptr frame, CORE_ADDR stop_pc)
@ DOES_NOT_EXIST_IN_SOURCE
static struct cp_abi_ops gnu_v3_abi_ops
static bool is_move_constructor_type(struct type *class_type, struct type *method_type)
static struct language_pass_by_ref_info gnuv3_pass_by_reference(struct type *type)
static void init_gnuv3_ops(void)
#define TYPEINFO_PREFIX_LEN
static struct type * gnuv3_rtti_type(struct value *value, int *full_p, LONGEST *top_p, int *using_enc_p)
static bool is_copy_constructor_type(struct type *class_type, struct type *method_type)
static int vtable_address_point_offset(struct gdbarch *gdbarch)
static const char * gnuv3_find_method_in(struct type *domain, CORE_ADDR voffset, LONGEST adjustment)
static bool is_copy_or_move_constructor_type(struct type *class_type, struct type *method_type, type_code expected)
static bool is_user_provided_def(definition_style def)
static void gnuv3_print_vtable(struct value *value)
static int gnuv3_is_operator_name(const char *name)
static int gnuv3_baseclass_offset(struct type *type, int index, const bfd_byte *valaddr, LONGEST embedded_offset, CORE_ADDR address, const struct value *val)
static struct value * gnuv3_virtual_fn_field(struct value **value_p, struct fn_field *f, int j, struct type *vfn_base, int offset)
static int gnuv3_method_ptr_size(struct type *type)
static int eq_value_and_voffset(const void *a, const void *b)
static hashval_t hash_value_and_voffset(const void *p)
static void compute_vtable_size(htab_t offset_hash, std::vector< value_and_voffset * > *offset_vec, struct value *value)
static int gnuv3_decode_method_ptr(struct gdbarch *gdbarch, const gdb_byte *contents, CORE_ADDR *value_p, LONGEST *adjustment_p)
static struct type * build_std_type_info_type(struct gdbarch *arch)
static struct value * gnuv3_get_virtual_fn(struct gdbarch *gdbarch, struct value *container, struct type *fntype, int vtable_index)
static struct type * gnuv3_get_typeid_type(struct gdbarch *gdbarch)
static struct type * gnuv3_get_type_from_type_info(struct value *type_info_ptr)
static struct value * gnuv3_get_vtable(struct gdbarch *gdbarch, struct type *container_type, CORE_ADDR container_addr)
static void gnuv3_print_method_ptr(const gdb_byte *contents, struct type *type, struct ui_file *stream)
static bool is_implicit_def(definition_style def)
@ vtable_field_offset_to_top
@ vtable_field_vcall_and_vbase_offsets
@ vtable_field_virtual_functions
static bool compare_value_and_voffset(const struct value_and_voffset *va, const struct value_and_voffset *vb)
static int gnuv3_dynamic_class(struct type *type)
static void print_one_vtable(struct gdbarch *gdbarch, struct value *value, int max_voffset, struct value_print_options *opts)
static struct value * gnuv3_method_ptr_to_value(struct value **this_p, struct value *method_ptr)
struct inferior * current_inferior(void)
const struct language_defn * current_language
bool dwarf2_evaluate_property(const struct dynamic_prop *prop, frame_info_ptr frame, const struct property_addr_info *addr_stack, CORE_ADDR *value, gdb::array_view< CORE_ADDR > push_values)
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
struct bound_minimal_symbol lookup_minimal_symbol_by_pc(CORE_ADDR pc)
struct obj_section * find_pc_section(CORE_ADDR pc)
int print_address_demangle(const struct value_print_options *opts, struct gdbarch *gdbarch, CORE_ADDR addr, struct ui_file *stream, int do_demangle)
CORE_ADDR value_address() const
struct minimal_symbol * minsym
struct type * builtin_func_ptr
struct type * builtin_data_ptr
struct type * builtin_char
int(* method_ptr_size)(struct type *)
CORE_ADDR(* skip_trampoline)(frame_info_ptr, CORE_ADDR)
struct type *(* get_typeid_type)(struct gdbarch *gdbarch)
struct type *(* get_type_from_type_info)(struct value *value)
void(* make_method_ptr)(struct type *, gdb_byte *, CORE_ADDR, int)
int(* baseclass_offset)(struct type *type, int index, const bfd_byte *valaddr, LONGEST embedded_offset, CORE_ADDR address, const struct value *val)
struct value *(* method_ptr_to_value)(struct value **, struct value *)
int(* is_vtable_name)(const char *name)
enum ctor_kinds(* is_constructor_name)(const char *name)
struct value *(* virtual_fn_field)(struct value **arg1p, struct fn_field *f, int j, struct type *type, int offset)
enum dtor_kinds(* is_destructor_name)(const char *name)
void(* print_vtable)(struct value *)
int(* is_operator_name)(const char *name)
struct language_pass_by_ref_info(* pass_by_reference)(struct type *type)
std::string(* get_typename_from_type_info)(struct value *value)
struct value *(* get_typeid)(struct value *value)
void(* print_method_ptr)(const gdb_byte *contents, struct type *type, struct ui_file *stream)
struct type *(* rtti_type)(struct value *v, int *full, LONGEST *top, int *using_enc)
struct dwarf2_locexpr_baton locexpr
struct type * property_type
void set_locexpr(void *baton)
void set_type(struct type *type)
void set_loc_bitpos(LONGEST bitpos)
LONGEST loc_bitpos() const
field_loc_kind loc_kind() const
dwarf2_locexpr_baton * loc_dwarf_block() const
void set_name(const char *name)
struct type * type() const
const char * demangled_name
const char * linkage_name() const
enum language la_language
struct property_addr_info * next
struct type * type() const
struct type * target_type() const
struct field & field(int idx) const
void set_num_fields(int num_fields)
void set_name(const char *name)
void set_fields(struct field *fields)
struct block_symbol lookup_symbol(const char *name, const struct block *block, domain_enum domain, struct field_of_this_result *is_a_field_of_this)
const struct type_print_options type_print_raw_options
std::string type_to_string(struct type *type)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
void fprintf_styled(struct ui_file *stream, const ui_file_style &style, const char *format,...)
void gdb_printf(struct ui_file *stream, const char *format,...)
void gdb_puts(const char *linebuffer, struct ui_file *stream)
struct value * value_subscript(struct value *array, LONGEST index)
struct value * value_ptradd(struct value *arg1, LONGEST arg2)
struct value * value_at(struct type *type, CORE_ADDR addr)
struct value * value_at_lazy(struct type *type, CORE_ADDR addr)
struct value * value_full_object(struct value *argp, struct type *rtype, int xfull, int xtop, int xusing_enc)
struct value * value_addr(struct value *arg1)
struct value * value_cast(struct type *type, struct value *arg2)
struct value * value_ind(struct value *arg1)
void get_user_print_options(struct value_print_options *opts)
void print_longest(struct ui_file *stream, int format, int use_c_format, LONGEST val_long)
void print_function_pointer_address(const struct value_print_options *options, struct gdbarch *gdbarch, CORE_ADDR address, struct ui_file *stream)
struct type * value_type(const struct value *value)
LONGEST value_embedded_offset(const struct value *value)
struct value * value_field(struct value *arg1, int fieldno)
CORE_ADDR value_as_address(struct value *val)
CORE_ADDR value_address(const struct value *value)
struct value * coerce_ref(struct value *arg)
gdb::array_view< const gdb_byte > value_contents(struct value *value)
LONGEST value_as_long(struct value *val)
enum lval_type value_lval_const(const struct value *value)
struct value * value_from_pointer(struct type *type, CORE_ADDR addr)
struct type * value_enclosing_type(const struct value *value)