49 const char *result = strrchr (path,
':');
64 return std::string ();
103 error (_(
"Could not find active enum variant"));
114 return (
type->
code () == TYPE_CODE_STRUCT
129 if (
type->
code () != TYPE_CODE_STRUCT)
137 xsnprintf (buf,
sizeof (buf),
"__%d", field_number);
162 if (
type->
code () == TYPE_CODE_STRUCT
171 return ((streq (
n1,
"data_ptr") && streq (
n2,
"length"))
172 || (streq (
n2,
"data_ptr") && streq (
n1,
"length")));
184 if (
type->
code () != TYPE_CODE_STRUCT
187 || strstr (
type->
name (),
"::Range") == NULL)
216 return (strstr (
type->
name (),
"::RangeInclusive") != NULL
217 || strstr (
type->
name (),
"::RangeToInclusive") != NULL);
225 return (
type->
code () == TYPE_CODE_INT
235 return (
type->
code () == TYPE_CODE_CHAR
253 int vtable_field = 0;
254 for (
int i = 0; i < 2; ++i)
279 const gdb_byte *
string,
unsigned int length,
280 const char *user_encoding,
int force_ellipses,
285 const char *encoding = user_encoding;
286 if (user_encoding == NULL || !*user_encoding)
296 user_encoding, force_ellipses,
334 if (strcmp (
type->
name (),
"&str") == 0)
366 (
struct value *val,
struct ui_file *stream,
int recurse,
395 if (is_tuple || is_tuple_struct)
417 else if (!first_field)
422 if (!is_tuple && !is_tuple_struct)
439 if (is_tuple || is_tuple_struct)
458 gdb::array_view<const gdb_byte> view
466 gdb_printf (stream, _(
"%s {%p[<No data fields>%p]}"),
497 bool first_field =
true;
498 for (
int j = 0; j < variant_type->
num_fields (); j++)
523 (
struct value *val,
struct ui_file *stream,
int recurse,
530 opts.prettyformat = (opts.prettyformat_structs
538 LONGEST low_bound, high_bound;
551 if (opts.addressprint)
559 high_bound - low_bound + 1, stream,
576 case TYPE_CODE_STRING:
578 LONGEST low_bound, high_bound;
581 error (_(
"Could not determine the array bounds"));
589 high_bound - low_bound + 1,
"ASCII", 0, &opts);
593 case TYPE_CODE_ARRAY:
595 LONGEST low_bound, high_bound;
598 && high_bound - low_bound + 1 == 0)
605 case TYPE_CODE_UNION:
614 case TYPE_CODE_STRUCT:
636 opts.deref_ref =
true;
653 struct ui_file *stream,
int show,
int level,
660 struct ui_file *stream,
int show,
int level,
675 if (
flags->print_offsets)
684 const char *tagname =
type->
name ();
703 else if (
type->
code () == TYPE_CODE_STRUCT)
714 if (for_rust_enum && !
flags->print_offsets)
715 gdb_puts (is_tuple_struct ?
"(" :
"{", stream);
717 gdb_puts (is_tuple_struct ?
" (\n" :
" {\n", stream);
732 if (
flags->print_offsets)
736 return (type->field (a).loc_bitpos ()
737 < type->field (b).loc_bitpos ());
747 if (
flags->print_offsets)
756 if (!for_rust_enum ||
flags->print_offsets)
761 else if (!is_tuple_struct)
767 stream, (is_enum ? show : show - 1),
768 level + 2,
flags, is_enum, podata);
769 if (!for_rust_enum ||
flags->print_offsets)
778 if (
flags->print_offsets)
787 if (!for_rust_enum ||
flags->print_offsets)
789 gdb_puts (is_tuple_struct ?
")" :
"}", stream);
796 struct ui_file *stream,
int show,
int level,
806 if (
type->
code () == TYPE_CODE_VOID)
830 if (varstring != NULL)
839 -1, 0,
flags,
false, podata);
847 -1, 0,
flags,
false, podata);
851 case TYPE_CODE_ARRAY:
853 LONGEST low_bound, high_bound;
857 stream, show - 1, level,
flags,
false,
865 plongest (high_bound - low_bound + 1));
870 case TYPE_CODE_UNION:
871 case TYPE_CODE_STRUCT:
873 for_rust_enum, podata);
898 &&
name[len + 1] ==
':')
939 const char *field1,
struct type *type1,
940 const char *field2,
struct type *type2)
943 int i, nfields, bitpos;
951 result->
set_code (TYPE_CODE_STRUCT);
965 bitpos += type1->
length () * TARGET_CHAR_BIT;
980 align *= TARGET_CHAR_BIT;
981 delta = bitpos % align;
983 bitpos += align - delta;
1002 struct type *usize_type)
1008 "data_ptr", elt_type,
1009 "length", usize_type);
1023 struct value *addrval, *result;
1025 struct type *range_type;
1027 struct type *temp_type;
1037 name =
"std::ops::RangeFull";
1043 ?
"std::ops::RangeToInclusive" :
"std::ops::RangeTo");
1051 name =
"std::ops::RangeFrom";
1056 error (_(
"Range expression with different types"));
1058 name = inclusive ?
"std::ops::RangeInclusive" :
"std::ops::Range";
1109 LONGEST *low, LONGEST *high,
1147 struct value *result;
1148 struct type *rhstype;
1149 LONGEST low, high_bound;
1159 error (_(
"Can't take slice of array without '&'"));
1169 struct type *base_type =
nullptr;
1170 if (
type->
code () == TYPE_CODE_ARRAY)
1182 if (base_type ==
nullptr)
1183 error (_(
"Could not find 'data_ptr' in slice type"));
1185 else if (
type->
code () == TYPE_CODE_PTR)
1188 error (_(
"Cannot subscript non-array type"));
1214 if (
type->
code () == TYPE_CODE_ARRAY)
1218 error (_(
"Can't compute array bounds"));
1220 error (_(
"Found array with non-zero lower bound"));
1232 else if (
type->
code () == TYPE_CODE_PTR)
1239 error (_(
"Cannot subscript non-array type"));
1244 error (_(
"Index less than zero"));
1245 if (low > high_bound)
1246 error (_(
"Index greater than length"));
1255 struct type *usize, *slice;
1257 struct value *addrval, *tem;
1262 error (_(
"High index less than zero"));
1264 error (_(
"Low index greater than high index"));
1265 if (high > high_bound)
1266 error (_(
"High index greater than length"));
1271 const char *new_name = ((
type !=
nullptr
1308 if (trait_ptr != NULL)
1339 error (_(
"Array with negative number of elements"));
1344 std::vector<struct value *> eltvec (copies);
1346 for (i = 0; i < copies; ++i)
1348 return value_array (0, copies - 1, eltvec.data ());
1352 struct type *arraytype
1367 int field_number = std::get<0> (
m_storage);
1371 if (
type->
code () == TYPE_CODE_STRUCT)
1373 struct type *outer_type = NULL;
1381 error (_(
"Cannot access field %d of empty enum %s"),
1393 if (field_number >= nfields || field_number < 0)
1395 if (outer_type != NULL)
1396 error(_(
"Cannot access field %d of variant %s::%s, "
1397 "there are only %d fields"),
1398 field_number, outer_type->
name (),
1402 error(_(
"Cannot access field %d of %s, "
1403 "there are only %d fields"),
1404 field_number,
type->
name (), nfields);
1410 if (outer_type != NULL)
1411 error(_(
"Variant %s::%s is not a tuple variant"),
1412 outer_type->
name (),
1415 error(_(
"Attempting to access anonymous field %d "
1416 "of %s, which is not a tuple, tuple struct, or "
1417 "tuple-like variant"),
1424 error(_(
"Anonymous field access is only allowed on tuples, \
1425tuple structs, and tuple-like enum variants"));
1436 struct value *result;
1444 error (_(
"Cannot access field %s of empty enum %s"),
1453 error (_(
"Attempting to access named field %s of tuple "
1454 "variant %s::%s, which has only anonymous fields"),
1463 catch (
const gdb_exception_error &except)
1465 error (_(
"Could not find field %s of struct variant %s::%s"),
1484 struct value *addrval = NULL;
1496 struct value *init = std::get<1> (
m_storage)->evaluate (
nullptr, exp,
1508 for (
const auto &item : std::get<2> (
m_storage))
1510 value *val = item.second->evaluate (
nullptr, exp,
noside);
1513 const char *fieldname = item.first.c_str ();
1515 nullptr,
"structure");
1532 const std::vector<operation_up> &ops)
1534 std::vector<struct value *> args (ops.size () + 1);
1544 if ((
type->
code () != TYPE_CODE_STRUCT
1545 &&
type->
code () != TYPE_CODE_UNION
1546 &&
type->
code () != TYPE_CODE_ENUM)
1548 error (_(
"Method calls only supported on struct or enum types"));
1550 error (_(
"Method call on nameless type"));
1559 error (_(
"Could not find function named '%s'"),
name.c_str ());
1563 error (_(
"Function '%s' takes no arguments"),
name.c_str ());
1570 for (
int i = 0; i < ops.size (); ++i)
1591 auto add = [&] (
struct type * t) ->
struct type *
1597 struct type *bool_type
1601 struct type *u8_type
1612 struct type *usize_type
1630 struct ui_file *stream,
int show,
int level,
1635 flags,
false, &podata);
1642 struct ui_file *stream,
int quoter)
const
1647 else if (ch ==
'\\' || ch == quoter)
1649 else if (ch ==
'\n')
1651 else if (ch ==
'\r')
1653 else if (ch ==
'\t')
1655 else if (ch ==
'\0')
1657 else if (ch >= 32 && ch <= 127 && isprint (ch))
1670 LONGEST low_bound, high_bound;
1673 return ((
type->
code () == TYPE_CODE_STRING)
1679 || (
type->
code () == TYPE_CODE_STRUCT
1682 && strcmp (
type->
name (),
"&str") == 0));
const char * block_scope(const struct block *block)
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)
@ Val_prettyformat_default
@ 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 * resolve_dynamic_type(struct type *type, gdb::array_view< const gdb_byte > valaddr, CORE_ADDR addr)
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 * arch_boolean_type(struct gdbarch *gdbarch, int bit, int unsigned_p, const char *name)
const struct floatformat * floatformats_ieee_single[BFD_ENDIAN_UNKNOWN]
struct type * arch_float_type(struct gdbarch *gdbarch, int bit, const char *name, const struct floatformat **floatformats)
struct type * arch_character_type(struct gdbarch *gdbarch, int bit, int unsigned_p, const char *name)
bool get_array_bounds(struct type *type, LONGEST *low_bound, LONGEST *high_bound)
unsigned type_align(struct type *type)
bool types_equal(struct type *a, struct type *b)
struct type * alloc_type_copy(const struct type *type)
const struct floatformat * floatformats_ieee_double[BFD_ENDIAN_UNKNOWN]
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_ZALLOC(t, size)
#define TYPE_FIELD_ARTIFICIAL(thistype, n)
#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)
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_slice_type_p(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)
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)
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)
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
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
void set_num_fields(int num_fields)
void set_name(const char *name)
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
void set_fields(struct field *fields)
const ui_file_style * ptr() const
enum val_prettyformat prettyformat
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)
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_array(int lowbound, int highbound, struct value **elemvec)
struct value * value_allocate_space_in_inferior(int len)
struct value * value_at_lazy(struct type *type, CORE_ADDR addr)
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_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)
struct type * value_type(const struct value *value)
struct value * value_zero(struct type *type, enum lval_type lv)
struct value * allocate_value_lazy(struct type *type)
struct value * value_field(struct value *arg1, int fieldno)
struct value * allocate_value(struct type *type)
CORE_ADDR value_as_address(struct value *val)
void set_value_address(struct value *value, CORE_ADDR addr)
void value_fetch_lazy(struct value *val)
struct value * value_primitive_field(struct value *arg1, LONGEST offset, int fieldno, struct type *arg_type)
CORE_ADDR value_address(const struct value *value)
struct value * value_from_longest(struct type *type, LONGEST num)
gdb::array_view< const gdb_byte > value_contents(struct value *value)
LONGEST value_as_long(struct value *val)
gdb::array_view< const gdb_byte > value_contents_for_printing(struct value *value)