48 return startswith (
name,
"_ZTV");
119 if (result !=
nullptr)
122 struct type *void_ptr_type
124 struct type *ptr_to_void_fn_type
130 struct type *ptrdiff_type
133 t = alloc.
new_type (TYPE_CODE_STRUCT, 0,
nullptr);
148 field0.
set_name (
"vcall_and_vbase_offsets");
175 field3.
set_name (
"virtual_functions");
183 t->
set_name (
"gdb_gnu_v3_abi_vtable");
221 int fieldnum, fieldelem;
224 gdb_assert (
type->
code () == TYPE_CODE_STRUCT
225 ||
type->
code () == TYPE_CODE_UNION);
227 if (
type->
code () == TYPE_CODE_UNION)
266 struct type *container_type, CORE_ADDR container_addr)
269 struct type *vtable_pointer_type;
270 struct value *vtable_pointer;
271 CORE_ADDR vtable_address;
274 gdb_assert (container_type->
code () == TYPE_CODE_STRUCT);
292 vtable_pointer =
value_at (vtable_pointer_type, container_addr);
305 int *full_p, LONGEST *top_p,
int *using_enc_p)
309 struct value *vtable;
311 const char *vtable_symbol_name;
312 const char *class_name;
313 struct type *run_time_type;
314 LONGEST offset_to_top;
318 if (values_type->
code () != TYPE_CODE_STRUCT
346 if (vtable_symbol_name == NULL
347 || !startswith (vtable_symbol_name,
"vtable for "))
349 warning (_(
"can't find linker symbol for virtual table for `%s' value"),
351 if (vtable_symbol_name)
352 warning (_(
" found `%s' instead"), vtable_symbol_name);
355 class_name = vtable_symbol_name + 11;
358 atsign = strchr (class_name,
'@');
363 copy = (
char *) alloca (atsign - class_name + 1);
364 memcpy (copy, class_name, atsign - class_name);
365 copy[atsign - class_name] =
'\0';
372 if (run_time_type == NULL)
383 >= run_time_type->
length ()));
385 *top_p = - offset_to_top;
386 return run_time_type;
394 struct type *fntype,
int vtable_index)
396 struct value *vtable, *vfn;
401 gdb_assert (vtable != NULL);
433 if (values_type->
code () != TYPE_CODE_STRUCT)
434 error (_(
"Only classes can have virtual functions."));
442 if (vfn_base != values_type)
459 const bfd_byte *valaddr, LONGEST embedded_offset,
460 CORE_ADDR address,
const struct value *val)
463 struct type *ptr_type;
464 struct value *vtable;
465 struct value *vbase_array;
466 long int cur_base_offset, base_offset;
492 addr_stack.
addr = address + embedded_offset;
493 addr_stack.
next =
nullptr;
498 return (
int) (result - addr_stack.
addr);
508 error (_(
"Expected a negative vbase offset (old compiler?)"));
511 if ((- cur_base_offset) % ptr_type->
length () != 0)
512 error (_(
"Misaligned vbase offset."));
513 cur_base_offset = cur_base_offset / ((int) ptr_type->
length ());
516 gdb_assert (vtable != NULL);
538 for (i = 0; i < len; i++)
547 for (j = 0; j < len2; j++)
558 struct type *basetype;
567 if (adjustment >= pos && adjustment < pos + basetype->
length ())
578 const gdb_byte *contents,
580 LONGEST *adjustment_p)
586 LONGEST voffset, adjustment;
597 funcptr_type->
length (), byte_order);
598 contents += funcptr_type->
length ();
605 voffset = voffset ^ vbit;
609 vbit = adjustment & 1;
610 adjustment = adjustment >> 1;
613 *value_p = vbit? voffset : ptr_value;
614 *adjustment_p = adjustment;
635 if (ptr_value == 0 && vbit == 0)
645 const char *physname;
658 gdb::unique_xmalloc_ptr<char> demangled_name
662 if (demangled_name == NULL)
665 gdb_puts (demangled_name.get (), stream);
669 else if (ptr_value != 0)
681 gdb_printf (stream,
"&virtual table offset ");
711 CORE_ADDR
value,
int is_virtual)
744 const gdb_byte *contents = method_ptr->
contents ().data ();
746 struct type *self_type, *final_type, *method_type;
788 method_type, voffset);
840 return addra < addrb;
851 std::vector<value_and_voffset *> *offset_vec,
859 gdb_assert (
type->
code () == TYPE_CODE_STRUCT);
868 slot = htab_find_slot (offset_hash, &search_vo, INSERT);
877 offset_vec->push_back (current_vo);
913 struct value *vtable;
922 gdb_printf (_(
"vtable for '%s' @ %s (subobject @ %s):\n"),
928 for (i = 0; i <= max_voffset; ++i)
948 catch (
const gdb_exception_error &ex)
951 _(
"<error: %s>"), ex.what ());
968 struct value *vtable;
983 if (opts.objectprint)
992 if (
type->
code () == TYPE_CODE_STRUCT)
998 gdb_printf (_(
"This object does not have a virtual function table\n"));
1005 std::vector<value_and_voffset *> result_vec;
1008 std::sort (result_vec.begin (), result_vec.end (),
1014 if (iter->max_voffset >= 0)
1035 struct type *void_ptr_type
1037 struct type *char_type
1039 struct type *char_ptr_type
1051 field0.
set_name (
"_vptr.type_info");
1068 t->
set_name (
"gdb_gnu_v3_type_info");
1080 struct type *typeinfo_type;
1084 if (typeinfo == NULL)
1087 if (typeinfo_type ==
nullptr)
1094 typeinfo_type = typeinfo->
type ();
1096 return typeinfo_type;
1101static struct value *
1104 struct type *typeinfo_type;
1107 struct value *result;
1108 std::string type_name;
1109 gdb::unique_xmalloc_ptr<char> canonical;
1121 if (
type->
code () == TYPE_CODE_REF)
1129 if (type_name.empty ())
1130 error (_(
"cannot find typeinfo for unnamed type"));
1137 const char *
name = (canonical ==
nullptr
1138 ? type_name.c_str ()
1139 : canonical.get ());
1145 if (
type->
code () == TYPE_CODE_STRUCT
1149 struct value *vtable, *typeinfo_value;
1154 error (_(
"cannot find typeinfo for object of type '%s'"),
1162 std::string sym_name = std::string (
"typeinfo for ") +
name;
1166 if (minsym.
minsym == NULL)
1167 error (_(
"could not find typeinfo symbol for '%s'"),
name);
1183 const char *symname;
1184 const char *class_name;
1189 if (typeinfo_sym.
minsym == NULL)
1190 error (_(
"could not find minimal symbol for typeinfo address %s"),
1193#define TYPEINFO_PREFIX "typeinfo for "
1194#define TYPEINFO_PREFIX_LEN (sizeof (TYPEINFO_PREFIX) - 1)
1198 error (_(
"typeinfo symbol '%s' has unexpected name"),
1203 atsign = strchr (class_name,
'@');
1205 return std::string (class_name, atsign - class_name);
1220 struct value *type_val =
expr->evaluate_type ();
1221 return type_val->
type ();
1230 CORE_ADDR real_stop_pc, method_stop_pc, func_addr;
1234 const char *thunk_name, *fn_name;
1237 if (real_stop_pc == 0)
1238 real_stop_pc = stop_pc;
1243 if (thunk_sym.
minsym == NULL || section == NULL)
1250 if (thunk_name == NULL || strstr (thunk_name,
" thunk to ") == NULL)
1253 fn_name = strstr (thunk_name,
" thunk to ") + strlen (
" thunk to ");
1255 if (fn_sym.
minsym == NULL)
1267 method_stop_pc = func_addr;
1270 (
gdbarch, frame, method_stop_pc);
1271 if (real_stop_pc == 0)
1272 real_stop_pc = method_stop_pc;
1274 return real_stop_pc;
1301 case DW_DEFAULTED_no:
1303 case DW_DEFAULTED_in_class:
1305 case DW_DEFAULTED_out_of_class:
1340 struct type *method_type,
1351 if (arg_type->
code () != expected)
1361 for (
int i = 2; i < method_type->
num_fields (); i++)
1363 arg_type = method_type->
field (i).
type ();
1382 struct type *method_type)
1392 struct type *method_type)
1395 TYPE_CODE_RVALUE_REF);
1419 int fieldnum, fieldelem;
1426 bool has_cc_attr =
false;
1427 bool is_pass_by_value =
false;
1428 bool is_dynamic =
false;
1434 if (
type->
code () != TYPE_CODE_STRUCT
1435 &&
type->
code () != TYPE_CODE_UNION)
1444 is_pass_by_value =
true;
1452 is_pass_by_value =
false;
1514 bool cctor_implicitly_deleted
1518 bool cctor_explicitly_deleted = (cctor_def ==
DELETED);
1520 if (cctor_implicitly_deleted || cctor_explicitly_deleted)
1521 info.copy_constructible =
false;
1524 info.destructible =
false;
1528 info.trivially_copy_constructible
1532 info.trivially_copyable
1533 = (info.trivially_copy_constructible
1534 && info.trivially_destructible
1550 if (field_type->
code () == TYPE_CODE_ARRAY)
1557 info.copy_constructible =
false;
1559 info.destructible =
false;
1561 info.trivially_copyable =
false;
1562 if (!
field_info.trivially_copy_constructible)
1563 info.trivially_copy_constructible =
false;
1565 info.trivially_destructible =
false;
1569 if (has_cc_attr && info.trivially_copyable != is_pass_by_value)
1573 info.trivially_copyable = is_pass_by_value;
1586 (
enum dtor_kinds (*) (
const char *))is_gnu_v3_mangled_dtor;
1588 (
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)
std::unique_ptr< expression > expression_up
expression_up parse_expression(const char *, innermost_block_tracker *=nullptr, parser_flags flags=0)
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)
struct type * init_integer_type(type_allocator &alloc, int bit, int unsigned_p, const char *name)
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)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
int class_types_same_p(const struct type *a, const struct type *b)
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()
@ vtable_field_offset_to_top
@ vtable_field_vcall_and_vbase_offsets
@ vtable_field_virtual_functions
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)
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
const dwarf2_property_baton * baton() const
void set_locexpr(const dwarf2_property_baton *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
unsigned int num_fields() const
void set_name(const char *name)
void alloc_fields(unsigned int nfields, bool init=true)
void set_length(ULONGEST length)
struct type * enclosing_type() const
LONGEST embedded_offset() const
gdb::array_view< const gdb_byte > contents()
struct type * type() const
enum lval_type lval() const
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_lazy(struct type *type, CORE_ADDR addr, frame_info_ptr frame)
struct value * value_at(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 value * value_field(struct value *arg1, int fieldno)
CORE_ADDR value_as_address(struct value *val)
struct value * coerce_ref(struct value *arg)
LONGEST value_as_long(struct value *val)
struct value * value_from_pointer(struct type *type, CORE_ADDR addr)