48 const char *result = strrchr (path,
':');
63 return std::string ();
102 error (_(
"Could not find active enum variant"));
113 return (
type->
code () == TYPE_CODE_STRUCT
128 if (
type->
code () != TYPE_CODE_STRUCT)
136 xsnprintf (buf,
sizeof (buf),
"__%d", field_number);
161 if (
type->
code () == TYPE_CODE_STRUCT
170 return ((streq (
n1,
"data_ptr") && streq (
n2,
"length"))
171 || (streq (
n2,
"data_ptr") && streq (
n1,
"length")));
183 if (
type->
code () != TYPE_CODE_STRUCT
186 || strstr (
type->
name (),
"::Range") == NULL)
215 return (strstr (
type->
name (),
"::RangeInclusive") != NULL
216 || strstr (
type->
name (),
"::RangeToInclusive") != NULL);
224 return (
type->
code () == TYPE_CODE_INT
234 return (
type->
code () == TYPE_CODE_CHAR
252 int vtable_field = 0;
253 for (
int i = 0; i < 2; ++i)
278 const gdb_byte *
string,
unsigned int length,
279 const char *user_encoding,
int force_ellipses,
284 const char *encoding = user_encoding;
285 if (user_encoding == NULL || !*user_encoding)
295 user_encoding, force_ellipses,
357 if (strcmp (
type->
name (),
"&str") == 0)
384 (
struct value *val,
struct ui_file *stream,
int recurse,
413 if (is_tuple || is_tuple_struct)
419 opts.deref_ref =
false;
435 else if (!first_field)
440 if (!is_tuple && !is_tuple_struct)
457 if (is_tuple || is_tuple_struct)
473 opts.deref_ref =
false;
476 gdb::array_view<const gdb_byte> view
484 gdb_printf (stream, _(
"%s {%p[<No data fields>%p]}"),
515 bool first_field =
true;
516 for (
int j = 0; j < nfields; j++)
541 (
struct value *val,
struct ui_file *stream,
int recurse,
545 opts.deref_ref =
true;
548 opts.prettyformat = (opts.prettyformat_structs
556 LONGEST low_bound, high_bound;
569 if (opts.addressprint)
577 high_bound - low_bound + 1, stream,
594 case TYPE_CODE_STRING:
596 LONGEST low_bound, high_bound;
599 error (_(
"Could not determine the array bounds"));
607 high_bound - low_bound + 1,
"ASCII", 0, &opts);
611 case TYPE_CODE_ARRAY:
613 LONGEST low_bound, high_bound;
616 && high_bound - low_bound + 1 == 0)
623 case TYPE_CODE_UNION:
632 case TYPE_CODE_STRUCT:
654 opts.deref_ref =
true;
671 struct ui_file *stream,
int show,
int level,
678 struct ui_file *stream,
int show,
int level,
693 if (
flags->print_offsets)
702 const char *tagname =
type->
name ();
721 else if (
type->
code () == TYPE_CODE_STRUCT)
732 if (for_rust_enum && !
flags->print_offsets)
733 gdb_puts (is_tuple_struct ?
"(" :
"{", stream);
735 gdb_puts (is_tuple_struct ?
" (\n" :
" {\n", stream);
750 if (
flags->print_offsets)
754 return (type->field (a).loc_bitpos ()
755 < type->field (b).loc_bitpos ());
765 if (
flags->print_offsets)
774 if (!for_rust_enum ||
flags->print_offsets)
779 else if (!is_tuple_struct)
785 stream, (is_enum ? show : show - 1),
786 level + 2,
flags, is_enum, podata);
787 if (!for_rust_enum ||
flags->print_offsets)
796 if (
flags->print_offsets)
805 if (!for_rust_enum ||
flags->print_offsets)
807 gdb_puts (is_tuple_struct ?
")" :
"}", stream);
814 struct ui_file *stream,
int show,
int level,
824 if (
type->
code () == TYPE_CODE_VOID)
848 if (varstring != NULL)
857 -1, 0,
flags,
false, podata);
865 -1, 0,
flags,
false, podata);
869 case TYPE_CODE_ARRAY:
871 LONGEST low_bound, high_bound;
875 stream, show - 1, level,
flags,
false,
883 plongest (high_bound - low_bound + 1));
888 case TYPE_CODE_UNION:
889 case TYPE_CODE_STRUCT:
891 for_rust_enum, podata);
916 &&
name[len + 1] ==
':')
957 const char *field1,
struct type *type1,
958 const char *field2,
struct type *type2)
961 int i, nfields, bitpos;
969 result->
set_code (TYPE_CODE_STRUCT);
981 bitpos += type1->
length () * TARGET_CHAR_BIT;
996 align *= TARGET_CHAR_BIT;
997 delta = bitpos % align;
999 bitpos += align - delta;
1018 struct type *usize_type)
1024 "data_ptr", elt_type,
1025 "length", usize_type);
1039 struct value *addrval, *result;
1041 struct type *range_type;
1043 struct type *temp_type;
1053 name =
"std::ops::RangeFull";
1059 ?
"std::ops::RangeToInclusive" :
"std::ops::RangeTo");
1067 name =
"std::ops::RangeFrom";
1072 error (_(
"Range expression with different types"));
1074 name = inclusive ?
"std::ops::RangeInclusive" :
"std::ops::Range";
1125 LONGEST *low, LONGEST *high,
1163 struct value *result;
1164 struct type *rhstype;
1165 LONGEST low, high_bound;
1175 error (_(
"Can't take slice of array without '&'"));
1185 struct type *base_type =
nullptr;
1186 if (
type->
code () == TYPE_CODE_ARRAY)
1198 if (base_type ==
nullptr)
1199 error (_(
"Could not find 'data_ptr' in slice type"));
1201 else if (
type->
code () == TYPE_CODE_PTR)
1204 error (_(
"Cannot subscript non-array type"));
1230 if (
type->
code () == TYPE_CODE_ARRAY)
1234 error (_(
"Can't compute array bounds"));
1236 error (_(
"Found array with non-zero lower bound"));
1248 else if (
type->
code () == TYPE_CODE_PTR)
1252 high_bound = LONGEST_MAX;
1255 error (_(
"Cannot subscript non-array type"));
1260 error (_(
"Index less than zero"));
1261 if (low > high_bound)
1262 error (_(
"Index greater than length"));
1271 struct type *usize, *slice;
1273 struct value *addrval, *tem;
1278 error (_(
"High index less than zero"));
1280 error (_(
"Low index greater than high index"));
1281 if (high > high_bound)
1282 error (_(
"High index greater than length"));
1287 const char *new_name = ((
type !=
nullptr
1324 if (trait_ptr != NULL)
1355 error (_(
"Array with negative number of elements"));
1358 return value_array (0, std::vector<value *> (copies, elt));
1361 struct type *arraytype
1376 int field_number = std::get<0> (
m_storage);
1380 if (
type->
code () == TYPE_CODE_STRUCT)
1382 struct type *outer_type = NULL;
1390 error (_(
"Cannot access field %d of empty enum %s"),
1402 if (field_number >= nfields || field_number < 0)
1404 if (outer_type != NULL)
1405 error(_(
"Cannot access field %d of variant %s::%s, "
1406 "there are only %d fields"),
1407 field_number, outer_type->
name (),
1411 error(_(
"Cannot access field %d of %s, "
1412 "there are only %d fields"),
1413 field_number,
type->
name (), nfields);
1419 if (outer_type != NULL)
1420 error(_(
"Variant %s::%s is not a tuple variant"),
1421 outer_type->
name (),
1424 error(_(
"Attempting to access anonymous field %d "
1425 "of %s, which is not a tuple, tuple struct, or "
1426 "tuple-like variant"),
1433 error(_(
"Anonymous field access is only allowed on tuples, \
1434tuple structs, and tuple-like enum variants"));
1445 struct value *result;
1453 error (_(
"Cannot access field %s of empty enum %s"),
1462 error (_(
"Attempting to access named field %s of tuple "
1463 "variant %s::%s, which has only anonymous fields"),
1472 catch (
const gdb_exception_error &except)
1474 error (_(
"Could not find field %s of struct variant %s::%s"),
1493 struct value *addrval = NULL;
1505 struct value *init = std::get<1> (
m_storage)->evaluate (
nullptr, exp,
1517 for (
const auto &item : std::get<2> (
m_storage))
1519 value *val = item.second->evaluate (
nullptr, exp,
noside);
1522 const char *fieldname = item.first.c_str ();
1524 nullptr,
"structure");
1541 const std::vector<operation_up> &ops)
1543 std::vector<struct value *> args (ops.size () + 1);
1549 while (args[0]->
type ()->
code () == TYPE_CODE_PTR)
1552 struct type *
type = args[0]->type ();
1553 if ((
type->
code () != TYPE_CODE_STRUCT
1554 &&
type->
code () != TYPE_CODE_UNION
1555 &&
type->
code () != TYPE_CODE_ENUM)
1557 error (_(
"Method calls only supported on struct or enum types"));
1559 error (_(
"Method call on nameless type"));
1568 error (_(
"Could not find function named '%s'"),
name.c_str ());
1572 error (_(
"Function '%s' takes no arguments"),
name.c_str ());
1579 for (
int i = 0; i < ops.size (); ++i)
1580 args[i + 1] = ops[i]->evaluate (
nullptr, exp,
noside);
1600 auto add = [&] (
struct type * t) ->
struct type *
1607 struct type *bool_type
1611 struct type *u8_type
1624 struct type *usize_type
1642 struct ui_file *stream,
int show,
int level,
1647 flags,
false, &podata);
1654 struct ui_file *stream,
int quoter)
const
1659 else if (ch ==
'\\' || ch == quoter)
1661 else if (ch ==
'\n')
1663 else if (ch ==
'\r')
1665 else if (ch ==
'\t')
1667 else if (ch ==
'\0')
1669 else if (ch >= 32 && ch <= 127 && isprint (ch))
1682 LONGEST low_bound, high_bound;
1685 return ((
type->
code () == TYPE_CODE_STRING)
1691 || (
type->
code () == TYPE_CODE_STRUCT
1694 && strcmp (
type->
name (),
"&str") == 0));
1701 (const char *name, const struct block *block,
1702 const domain_enum domain) const
1708 (
"rust_lookup_symbol_non_local (%s, %s (scope %s), %s)",
1709 name, host_address_to_string (
block), scope,
1713 std::string scopedname;
1716 if (scope[0] !=
'\0')
1718 scopedname = std::string (scope) +
"::" +
name;
1719 name = scopedname.c_str ();
1728 if (result.
symbol == NULL)
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)
const char * target_charset(struct gdbarch *gdbarch)
ui_file_style style() const
value * evaluate(struct type *expect_type, struct expression *exp, enum noside noside) override
value * evaluate(struct type *expect_type, struct expression *exp, enum noside noside) override
value * evaluate_funcall(struct type *expect_type, struct expression *exp, enum noside noside, const std::vector< operation_up > &args) override
value * evaluate(struct type *expect_type, struct expression *exp, enum noside noside) override
value * evaluate(struct type *expect_type, struct expression *exp, enum noside noside) override
std::tuple< Arg... > m_storage
value * evaluate(struct type *expect_type, struct expression *exp, enum noside noside) override
void language_arch_info(struct gdbarch *gdbarch, struct language_arch_info *lai) const override
void print_enum(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options) const
void value_print(struct value *val, struct ui_file *stream, const struct value_print_options *options) const override
void printstr(struct ui_file *stream, struct type *elttype, const gdb_byte *string, unsigned int length, const char *encoding, int force_ellipses, const struct value_print_options *options) const override
void value_print_inner(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options) const override
void print_type(struct type *type, const char *varstring, struct ui_file *stream, int show, int level, const struct type_print_options *flags) const override
bool is_string_type_p(struct type *type) const override
void emitchar(int ch, struct type *chtype, struct ui_file *stream, int quoter) const override
void val_print_struct(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options) const
cli_style_option variable_name_style
cli_style_option metadata_style
unsigned int cp_find_first_component(const char *name)
@ EVAL_AVOID_SIDE_EFFECTS
@ RANGE_LOW_BOUND_DEFAULT
@ RANGE_HIGH_BOUND_EXCLUSIVE
@ RANGE_HIGH_BOUND_DEFAULT
const struct block * get_selected_block(CORE_ADDR *addr_in_block)
struct type * lookup_pointer_type(struct type *type)
struct type * init_character_type(type_allocator &alloc, int bit, int unsigned_p, const char *name)
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 * resolve_dynamic_type(struct type *type, gdb::array_view< const gdb_byte > valaddr, CORE_ADDR addr, const frame_info_ptr *in_frame)
const struct floatformat * floatformats_ieee_single[BFD_ENDIAN_UNKNOWN]
struct type * init_float_type(type_allocator &alloc, int bit, const char *name, const struct floatformat **floatformats, enum bfd_endian byte_order)
bool get_array_bounds(struct type *type, LONGEST *low_bound, LONGEST *high_bound)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
unsigned type_align(struct type *type)
bool types_equal(struct type *a, struct type *b)
const struct floatformat * floatformats_ieee_double[BFD_ENDIAN_UNKNOWN]
struct type * init_boolean_type(type_allocator &alloc, int bit, int unsigned_p, const char *name)
struct type * check_typedef(struct type *type)
#define TYPE_HAS_VARIANT_PARTS(t)
#define TYPE_N_BASECLASSES(thistype)
mach_port_t kern_return_t mach_port_t mach_msg_type_name_t msgportsPoly mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
struct value * call_function_by_hand(struct value *function, type *default_return_type, gdb::array_view< value * > args)
struct type * language_lookup_primitive_type(const struct language_defn *la, struct gdbarch *gdbarch, const char *name)
struct type * language_bool_type(const struct language_defn *la, struct gdbarch *gdbarch)
static struct type * new_type(char *)
static gdbpy_ref field_name(struct type *type, int field)
struct value * rust_range(struct type *expect_type, struct expression *exp, enum noside noside, enum range_flag kind, struct value *low, struct value *high)
bool rust_slice_type_p(const struct type *type)
static bool rust_chartype_p(struct type *type)
static void rust_internal_print_type(struct type *type, const char *varstring, struct ui_file *stream, int show, int level, const struct type_print_options *flags, bool for_rust_enum, print_offset_data *podata)
static bool rust_range_type_p(struct type *type)
std::string rust_crate_for_block(const struct block *block)
static const struct generic_val_print_decorations rust_decorations
static bool rust_empty_enum_p(const struct type *type)
static bool rust_u8_type_p(struct type *type)
static void rust_compute_range(struct type *type, struct value *range, LONGEST *low, LONGEST *high, range_flags *kind)
struct value * rust_subscript(struct type *expect_type, struct expression *exp, enum noside noside, bool for_addr, struct value *lhs, struct value *rhs)
struct value * eval_op_rust_complement(struct type *expect_type, struct expression *exp, enum noside noside, enum exp_opcode opcode, struct value *value)
static int rust_enum_variant(struct type *type)
static bool rust_underscore_fields(struct type *type)
static bool rust_enum_p(struct type *type)
const char * rust_last_path_segment(const char *path)
struct type * rust_slice_type(const char *name, struct type *elt_type, struct type *usize_type)
static void rust_print_struct_def(struct type *type, const char *varstring, struct ui_file *stream, int show, int level, const struct type_print_options *flags, bool for_rust_enum, print_offset_data *podata)
static void rust_val_print_slice(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options)
static struct type * rust_composite_type(struct type *original, const char *name, const char *field1, struct type *type1, const char *field2, struct type *type2)
bool rust_tuple_struct_type_p(struct type *type)
struct value * rust_slice_to_array(struct value *val)
static rust_language rust_language_defn
struct value * eval_op_rust_array(struct type *expect_type, struct expression *exp, enum noside noside, enum exp_opcode opcode, struct value *elt, struct value *ncopies)
static struct value * rust_get_trait_object_pointer(struct value *value)
bool rust_tuple_type_p(struct type *type)
static bool rust_inclusive_range_type_p(struct type *type)
bool rust_slice_type_p(const struct type *type)
struct type * rust_slice_type(const char *name, struct type *elt_type, struct type *usize_type)
bool rust_tuple_struct_type_p(struct type *type)
bool rust_tuple_type_p(struct type *type)
const char * scope() const
struct type * builtin_data_ptr
dynamic_prop_kind kind() const
struct type * original_type() const
const struct language_defn * language_defn
void set_type(struct type *type)
void set_loc_bitpos(LONGEST bitpos)
LONGEST loc_bitpos() const
bool is_artificial() const
void set_name(const char *name)
const char * name() const
struct type * type() const
void set_string_char_type(struct type *type)
void add_primitive_type(struct type *type)
void set_bool_type(struct type *type, const char *name=nullptr)
virtual void printstr(struct ui_file *stream, struct type *elttype, const gdb_byte *string, unsigned int length, const char *encoding, int force_ellipses, const struct value_print_options *options) const
void update(struct type *type, unsigned int field_idx, struct ui_file *stream)
static const int indentation
void finish(struct type *type, int level, struct ui_file *stream)
struct type * concrete_type
struct type * type() const
__extension__ enum symbol_subclass_kind subclass
struct type * target_type() const
dynamic_prop * dyn_prop(dynamic_prop_node_kind kind) const
void set_code(type_code code)
struct field & field(int idx) const
struct type * pointer_type
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 field * fields() const
bool is_pointer_or_reference() const
range_bounds * bounds() const
const char * name() const
type * index_type() const
const ui_file_style * ptr() const
enum val_prettyformat prettyformat
static struct value * zero(struct type *type, enum lval_type lv)
struct value * primitive_field(LONGEST offset, int fieldno, struct type *arg_type)
static struct value * allocate(struct type *type)
void set_lval(lval_type val)
gdb::array_view< const gdb_byte > contents()
void set_address(CORE_ADDR)
struct type * type() const
enum lval_type lval() const
static struct value * allocate_lazy(struct type *type)
gdb::array_view< const gdb_byte > contents_for_printing()
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)
struct symbol * find_symbol_at_address(CORE_ADDR address)
struct block_symbol lookup_global_symbol(const char *name, const struct block *block, const domain_enum domain)
#define symbol_lookup_debug_printf(fmt,...)
const char * domain_name(domain_enum)
struct block_symbol lookup_symbol_in_static_block(const char *name, const struct block *block, const domain_enum domain)
void type_print(struct type *type, const char *varstring, struct ui_file *stream, int show)
static styled_string_s * styled_string(const ui_file_style &style, const char *str, styled_string_s &&tmp={})
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
void print_spaces(int n, struct ui_file *stream)
void gdb_printf(struct ui_file *stream, const char *format,...)
void fputs_styled(const char *linebuffer, const ui_file_style &style, struct ui_file *stream)
void gdb_puts(const char *linebuffer, struct ui_file *stream)
bool value_logical_not(struct value *arg1)
struct value * value_subscript(struct value *array, LONGEST index)
struct value * value_complement(struct value *arg1)
struct value * value_at_lazy(struct type *type, CORE_ADDR addr, frame_info_ptr frame)
struct value * value_allocate_space_in_inferior(int len)
struct value * value_struct_elt(struct value **argp, gdb::optional< gdb::array_view< value * > > args, const char *name, int *static_memfuncp, const char *err)
struct value * value_addr(struct value *arg1)
struct value * value_array(int lowbound, gdb::array_view< struct value * > elemvec)
struct value * value_cast(struct type *type, struct value *arg2)
struct value * value_assign(struct value *toval, struct value *fromval)
struct value * value_ind(struct value *arg1)
struct value * address_of_variable(struct symbol *var, const struct block *b)
void generic_value_print(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct generic_val_print_decorations *decorations)
void generic_emit_char(int c, struct type *type, struct ui_file *stream, int quoter, const char *encoding)
int val_print_string(struct type *elttype, const char *encoding, CORE_ADDR addr, int len, struct ui_file *stream, const struct value_print_options *options)
void common_val_print(struct value *value, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
void generic_printstr(struct ui_file *stream, struct type *type, const gdb_byte *string, unsigned int length, const char *encoding, int force_ellipses, int quote_char, int c_style_terminator, const struct value_print_options *options)
@ Val_prettyformat_default
struct value * value_field(struct value *arg1, int fieldno)
CORE_ADDR value_as_address(struct value *val)
struct value * value_from_longest(struct type *type, LONGEST num)
LONGEST value_as_long(struct value *val)