46 const char *result = strrchr (path,
':');
83 #define RUST_ENUM_PREFIX "RUST$ENCODED$ENUM$" 87 #define RUST_ENCODED_ENUM_REAL 0 91 #define RUST_ENCODED_ENUM_HIDDEN 1 124 struct type *disr_type;
126 const char *name_segment;
134 error (
_(
"Encountered void enum value"));
143 char *tail, *
token, *saveptr = NULL;
144 unsigned long fieldno;
145 struct type *member_type;
166 for (
token = strtok_r (tail,
"$", &saveptr);
168 token = strtok_r (NULL,
"$", &saveptr))
170 if (sscanf (
token,
"%lu", &fieldno) != 1)
177 error (
_(
"%s refers to field after end of member type"),
209 error (
_(
"Could not find enum discriminant field"));
225 error (
_(
"Rust debug format has changed"));
238 if (name_segment != NULL)
251 if (field_type != NULL
252 && strcmp (name_segment,
264 error (
_(
"Could not find variant of %s with discriminant %s"),
307 xsnprintf (buf,
sizeof (buf),
"__%d", field_number);
404 static struct value *
413 int vtable_field = 0;
414 for (
int i = 0; i < 2; ++i)
443 else if (c ==
'\\' || c == quoter)
453 else if (c >= 32 && c <= 127 && isprint (c))
476 const char *user_encoding,
int force_ellipses,
481 const char *encoding = user_encoding;
482 if (user_encoding == NULL || !*user_encoding)
492 force_ellipses, options);
524 int recurse,
struct value *val,
552 if (is_tuple || is_tuple_struct)
574 else if (!first_field)
579 if (!is_tuple && !is_tuple_struct)
588 stream, recurse + 1, val, &opts,
598 if (is_tuple || is_tuple_struct)
655 high_bound - low_bound + 1, stream,
665 recurse, val, options);
685 error (
_(
"Could not determine the array bounds"));
692 valaddr + embedded_offset * unit_size,
693 high_bound - low_bound + 1,
"ASCII", 0, options);
702 && high_bound - low_bound + 1 == 0)
711 int j, nfields, first_field, is_tuple, start;
712 struct type *variant_type;
724 recurse, val, options);
783 stream, recurse + 1, val, &opts,
796 recurse, val, options);
811 struct ui_file *stream,
int show,
int level,
817 struct ui_file *stream,
int show,
int level,
820 bool is_tuple_struct;
862 if (!is_tuple_struct)
866 stream, show - 1, level + 2,
891 struct ui_file *stream,
int show,
int level,
922 if (varstring != NULL)
948 stream, show - 1, level,
flags);
955 plongest (high_bound - low_bound + 1));
986 &&
name[len + 1] ==
':')
1024 if (zero_field != NULL && strlen (zero_field) > 1)
1051 for (j = skip_to; j <
TYPE_NFIELDS (variant_type); j++)
1063 stream, show - 1, level + 2,
1093 error (
_(
"Could not compute alignment of type"));
1128 static struct type *
1131 const char *field1,
struct type *type1,
1132 const char *field2,
struct type *type2)
1135 int i, nfields, bitpos;
1174 delta = bitpos % align;
1176 bitpos += align - delta;
1196 struct type *usize_type)
1202 "data_ptr", elt_type,
1203 "length", usize_type);
1237 struct type **types;
1278 static struct value *
1284 struct value *
function, *result, *arg0;
1291 if (exp->
elts[*pos + 3].
opcode != STRUCTOP_STRUCT)
1305 for (i = 0; i < num_args; ++i)
1310 std::vector<struct value *> args (num_args + 1);
1322 error (
_(
"Method calls only supported on struct or enum types"));
1324 error (
_(
"Method call on nameless type"));
1331 error (
_(
"Could not find function named '%s'"),
name.c_str ());
1335 error (
_(
"Function '%s' takes no arguments"),
name.c_str ());
1342 for (i = 0; i < num_args; ++i)
1354 static struct value *
1358 struct value *low = NULL, *high = NULL;
1359 struct value *addrval, *result;
1362 struct type *index_type;
1363 struct type *temp_type;
1382 name =
"std::ops::RangeFull";
1387 name =
"std::ops::RangeTo";
1395 name =
"std::ops::RangeFrom";
1400 error (
_(
"Range expression with different types"));
1402 name =
"std::ops::Range";
1408 temp_type = (index_type == NULL
1413 low == NULL ? NULL :
"start", index_type,
1414 high == NULL ? NULL :
"end", index_type);
1483 static struct value *
1487 struct value *lhs, *rhs, *result;
1488 struct type *rhstype;
1506 error (
_(
"Can't take slice of array without '&'"));
1516 struct type *base_type =
nullptr;
1529 if (base_type ==
nullptr)
1530 error (
_(
"Could not find 'data_ptr' in slice type"));
1535 error (
_(
"Cannot subscript non-array type"));
1565 error (
_(
"Can't compute array bounds"));
1567 error (
_(
"Found array with non-zero lower bound"));
1586 error (
_(
"Cannot subscript non-array type"));
1592 error (
_(
"Index less than zero"));
1593 if (low > high_bound)
1594 error (
_(
"Index greater than length"));
1603 struct type *usize, *slice;
1605 struct value *addrval, *tem;
1610 error (
_(
"High index less than zero"));
1612 error (
_(
"Low index greater than high index"));
1613 if (high > high_bound)
1614 error (
_(
"High index greater than length"));
1619 const char *new_name = ((
type !=
nullptr 1644 static struct value *
1648 struct value *result;
1663 if (trait_ptr != NULL)
1671 case UNOP_COMPLEMENT:
1690 case BINOP_SUBSCRIPT:
1705 struct value *addrval = NULL;
1716 if (arglen > 0 && exp->
elts[*pos].
opcode == OP_OTHERS)
1734 for (i = 0; i < arglen; i += 2)
1737 const char *fieldname;
1771 struct value *ncopies;
1777 error (
_(
"Array with negative number of elements"));
1782 std::vector<struct value *> eltvec (copies);
1784 for (i = 0; i < copies; ++i)
1786 result =
value_array (0, copies - 1, eltvec.data ());
1790 struct type *arraytype
1797 case STRUCTOP_ANONYMOUS:
1801 int pc, field_number, nfields;
1822 variant_type = NULL;
1834 if (field_number >= nfields || field_number < 0)
1835 error(
_(
"Cannot access field %d of variant %s, \ 1836 there are only %d fields"),
1837 disr.
is_encoded ? field_number : field_number - 1,
1844 error(
_(
"Variant %s is not a tuple variant"), disr.
name.c_str ());
1854 if (field_number >= nfields || field_number < 0)
1855 error(
_(
"Cannot access field %d of %s, there are only %d fields"),
1860 error(
_(
"Attempting to access anonymous field %d of %s, which is \ 1861 not a tuple, tuple struct, or tuple-like variant"),
1867 error(
_(
"Anonymous field access is only allowed on tuples, \ 1868 tuple structs, and tuple-like enum variants"));
1872 case STRUCTOP_STRUCT:
1890 struct type *variant_type;
1897 error(
_(
"Could not find field %s of struct variant %s"),
1902 if (variant_type == NULL
1906 error(
_(
"Attempting to access named field %s of tuple variant %s, \ 1907 which has only anonymous fields"),
1922 error(
_(
"Could not find field %s of struct variant %s"),
1942 if (exp->
elts[*pos + 1].
opcode == BINOP_SUBSCRIPT)
1981 case STRUCTOP_ANONYMOUS:
2008 return "OP_AGGREGATE";
2036 for (i = 0; i <
length; ++i)
2048 ?
"string" :
"name"),
2058 case STRUCTOP_ANONYMOUS:
2098 for (i = 0; i <
length; ++i)
2125 case STRUCTOP_ANONYMOUS:
2197 "rust_lookup_symbol_non_local" 2198 " (%s, %s (scope %s), %s)\n",
2208 if (scope[0] !=
'\0')
2214 if (result.
symbol == NULL)
2228 *demangled =
gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI);
2229 return *demangled != NULL;
#define TYPE_HIGH_BOUND_KIND(range_type)
struct value * value_zero(struct type *type, enum lval_type lv)
static const char * rust_op_name(enum exp_opcode opcode)
union exp_element elts[1]
const struct op_print c_op_print_tab[]
struct value * value_array(int lowbound, int highbound, struct value **elemvec)
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 rust_tuple_type_p(struct type *type)
const char * target_charset(struct gdbarch *gdbarch)
struct type * lookup_array_range_type(struct type *element_type, LONGEST low_bound, LONGEST high_bound)
struct value * value_addr(struct value *arg1)
#define RUST_ENCODED_ENUM_HIDDEN
#define SYMBOL_PRINT_NAME(symbol)
static void rust_val_print_str(struct ui_file *stream, struct value *val, const struct value_print_options *options)
struct value * value_subscript(struct value *array, LONGEST index)
int rust_parse(struct parser_state *state)
#define TYPE_FIELD_NAME(thistype, n)
#define TYPE_N_BASECLASSES(thistype)
unsigned int default_search_name_hash(const char *string0)
const struct floatformat * floatformats_ieee_double[BFD_ENDIAN_UNKNOWN]
static struct value * rust_evaluate_subexp(struct type *expect_type, struct expression *exp, int *pos, enum noside noside)
int pointer_type(struct type *type)
#define GDBARCH_OBSTACK_CALLOC(GDBARCH, NR, TYPE)
CORE_ADDR unpack_pointer(struct type *type, const gdb_byte *valaddr)
LONGEST value_as_long(struct value *val)
const char * default_word_break_characters(void)
int fputc_filtered(int c, struct ui_file *stream)
LONGEST value_embedded_offset(const struct value *value)
#define TYPE_NAME(thistype)
struct value * address_of_variable(struct symbol *var, const struct block *b)
static gdb::unique_xmalloc_ptr< char > rust_watch_location_expression(struct type *type, CORE_ADDR addr)
static const struct exp_descriptor exp_descriptor_rust
char * plongest(LONGEST l)
enum domain_enum_tag domain_enum
struct type * arch_character_type(struct gdbarch *gdbarch, int bit, int unsigned_p, const char *name)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
const struct language_defn * language_defn
static bool rust_underscore_fields(struct type *type, int offset)
static void rust_printchar(int c, struct type *type, struct ui_file *stream)
static void rust_val_print(struct type *type, int embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, struct value *val, const struct value_print_options *options)
int operator_check_standard(struct expression *exp, int pos, int(*objfile_func)(struct objfile *objfile, void *data), void *data)
unsigned int symbol_lookup_debug
struct value * default_read_var_value(struct symbol *var, const struct block *var_block, struct frame_info *frame)
static const char * rust_last_path_segment(const char *path)
void type_print(struct type *type, const char *varstring, struct ui_file *stream, int show)
static struct value * rust_range(struct expression *exp, int *pos, enum noside noside)
struct value * value_ind(struct value *arg1)
static void val_print_struct(struct type *type, int embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, struct value *val, const struct value_print_options *options)
std::string rust_crate_for_block(const struct block *block)
void get_no_prettyformat_print_options(struct value_print_options *opts)
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)
static int rust_type_alignment(struct type *t)
const gdb_byte * value_contents_for_printing(struct value *value)
struct type * string_char_type
#define SET_FIELD_BITPOS(thisfld, bitpos)
#define TYPE_FIELD(thistype, n)
#define BYTES_TO_EXP_ELEM(bytes)
struct type * arch_boolean_type(struct gdbarch *gdbarch, int bit, int unsigned_p, const char *name)
#define TYPE_FIELD_TYPE(thistype, n)
enum val_prettyformat prettyformat
struct value * allocate_value(struct type *type)
void c_get_string(struct value *value, gdb_byte **buffer, int *length, struct type **char_type, const char **charset)
int longest_to_int(LONGEST)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
static bool rust_chartype_p(struct type *type)
static struct type * new_type(char *)
static const char * rust_extensions[]
#define host_address_to_string(ADDR)
struct type * arch_integer_type(struct gdbarch *gdbarch, int bit, int unsigned_p, const char *name)
int dump_subexp(struct expression *exp, struct ui_file *stream, int elt)
static int rust_dump_subexp_body(struct expression *exp, struct ui_file *stream, int elt)
__extension__ enum symbol_subclass_kind subclass
int gdbarch_addressable_memory_unit_size(struct gdbarch *gdbarch)
static void rust_language_arch_info(struct gdbarch *gdbarch, struct language_arch_info *lai)
mach_port_t kern_return_t mach_port_t msgports 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
char * gdb_demangle(const char *name, int options)
static struct value * rust_subscript(struct expression *exp, int *pos, enum noside noside, int for_addr)
struct value * value_struct_elt(struct value **argp, struct value **args, const char *name, int *static_memfuncp, const char *err)
#define LA_EMIT_CHAR(ch, type, stream, quoter)
struct type * check_typedef(struct type *type)
const gdb_byte * value_contents(struct value *value)
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 value * value_field(struct value *arg1, int fieldno)
static void rust_operator_length(const struct expression *exp, int pc, int *oplenp, int *argsp)
static bool rust_slice_type_p(struct type *type)
struct type * bool_type_default
std::unique_ptr< T, xfree_deleter< T > > unique_xmalloc_ptr
int field_is_static(struct field *f)
struct type * alloc_type_copy(const struct type *type)
static struct type * rust_composite_type(struct type *original, const char *name, const char *field1, struct type *type1, const char *field2, struct type *type2)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
unsigned int cp_find_first_component(const char *name)
struct type * arch_float_type(struct gdbarch *gdbarch, int bit, const char *name, const struct floatformat **floatformats)
const struct block * block
struct symbol * find_symbol_at_address(CORE_ADDR address)
void fprintf_unfiltered(struct ui_file *stream, const char *format,...)
void fputs_filtered(const char *linebuffer, struct ui_file *stream)
const struct language_defn rust_language_defn
int default_pass_by_reference(struct type *type)
struct type * basic_lookup_transparent_type(const char *name)
bool rust_tuple_struct_type_p(struct type *type)
void rustyyerror(const char *msg)
struct gdbarch * get_type_arch(const struct type *type)
struct value * value_assign(struct value *toval, struct value *fromval)
int dump_subexp_body_standard(struct expression *exp, struct ui_file *stream, int elt)
struct type * language_bool_type(const struct language_defn *la, struct gdbarch *gdbarch)
static bool rust_u8_type_p(struct type *type)
static struct disr_info rust_get_disr_info(struct type *type, const gdb_byte *valaddr, int embedded_offset, CORE_ADDR address, struct value *val)
void null_post_parser(expression_up *exp, int void_context_p)
struct value * value_from_longest(struct type *type, LONGEST num)
static struct value * rust_evaluate_funcall(struct expression *exp, int *pos, enum noside noside)
struct value * value_at_lazy(struct type *type, CORE_ADDR addr)
struct value * value_cast(struct type *type, struct value *arg2)
static struct symbol * new_symbol(struct die_info *, struct type *, struct dwarf2_cu *)
void default_print_array_index(struct value *index_value, struct ui_file *stream, const struct value_print_options *options)
static void rust_printstr(struct ui_file *stream, struct type *type, const gdb_byte *string, unsigned int length, const char *user_encoding, int force_ellipses, const struct value_print_options *options)
const char * domain_name(domain_enum e)
char * xstrprintf(const char *format,...)
static void rust_print_subexp(struct expression *exp, int *pos, struct ui_file *stream, enum precedence prec)
#define TYPE_FIELDS(thistype)
struct block_symbol lookup_global_symbol(const char *name, const struct block *block, const domain_enum domain)
void c_val_print(struct type *, int, CORE_ADDR, struct ui_file *, int, struct value *, const struct value_print_options *)
#define gdb_print_host_address(ADDR, STREAM)
struct type * rust_slice_type(const char *name, struct type *elt_type, struct type *usize_type)
static bool rust_union_is_untagged(struct type *type)
static int rust_sniff_from_mangled_name(const char *mangled, char **demangled)
LONGEST unpack_long(struct type *type, const gdb_byte *valaddr)
#define TYPE_FIELD_BITPOS(thistype, n)
void c_printstr(struct ui_file *stream, struct type *type, const gdb_byte *string, unsigned int length, const char *user_encoding, int force_ellipses, const struct value_print_options *options)
const struct floatformat * floatformats_ieee_single[BFD_ENDIAN_UNKNOWN]
void default_collect_symbol_completion_matches(completion_tracker &tracker, complete_symbol_mode mode, symbol_name_match_type name_match_type, const char *text, const char *word, enum type_code code)
void fprintfi_filtered(int spaces, struct ui_file *stream, const char *format,...)
void print_spaces_filtered(int n, struct ui_file *stream)
int types_equal(struct type *a, struct type *b)
static struct block_symbol rust_lookup_symbol_nonlocal(const struct language_defn *langdef, const char *name, const struct block *block, const domain_enum domain)
struct type * concrete_type
struct type * make_cv_type(int cnst, int voltl, struct type *type, struct type **typeptr)
const struct language_defn * current_language
#define TYPE_TARGET_TYPE(thistype)
static void rust_print_type(struct type *type, const char *varstring, struct ui_file *stream, int show, int level, const struct type_print_options *flags)
void print_subexp_standard(struct expression *exp, int *pos, struct ui_file *stream, enum precedence prec)
static const struct generic_val_print_decorations rust_decorations
void print_subexp(struct expression *exp, int *pos, struct ui_file *stream, enum precedence prec)
void generic_val_print(struct type *type, int embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, struct value *original_value, const struct value_print_options *options, const struct generic_val_print_decorations *decorations)
int xsnprintf(char *str, size_t size, const char *format,...)
#define TYPE_CODE(thistype)
#define TYPE_INDEX_TYPE(type)
#define default_varobj_ops
struct type * builtin_data_ptr
void c_print_type(struct type *, const char *, struct ui_file *, int, int, const struct type_print_options *)
static void rust_print_typedef(struct type *type, struct symbol *new_symbol, struct ui_file *stream)
static bool rust_range_type_p(struct type *type)
#define TYPE_NFIELDS(thistype)
void generic_emit_char(int c, struct type *type, struct ui_file *stream, int quoter, const char *encoding)
struct value * value_complement(struct value *arg1)
struct value * evaluate_subexp(struct type *expect_type, struct expression *exp, int *pos, enum noside noside)
int value_logical_not(struct value *arg1)
struct value * evaluate_subexp_standard(struct type *expect_type, struct expression *exp, int *pos, enum noside noside)
#define TYPE_TAG_NAME(type)
void operator_length_standard(const struct expression *expr, int endpos, int *oplenp, int *argsp)
const char * op_name_standard(enum exp_opcode opcode)
void val_print(struct type *type, LONGEST embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, struct value *val, const struct value_print_options *options, const struct language_defn *language)
const struct block * get_selected_block(CORE_ADDR *addr_in_block)
#define FIELD_NAME(thisfld)
static PyObject * field_name(struct type *type, int field)
struct value * call_function_by_hand(struct value *function, type *default_return_type, int nargs, struct value **args)
struct value * value_allocate_space_in_inferior(int len)
struct value * value_primitive_field(struct value *arg1, LONGEST offset, int fieldno, struct type *arg_type)
struct type * value_type(const struct value *value)
#define SYMBOL_TYPE(symbol)
const char * core_addr_to_string(const CORE_ADDR addr)
CORE_ADDR value_as_address(struct value *val)
#define TYPE_LENGTH(thistype)
void iterate_over_symbols(const struct block *block, const lookup_name_info &name, const domain_enum domain, gdb::function_view< symbol_found_callback_ftype > callback)
struct block_symbol lookup_symbol_in_static_block(const char *name, const struct block *block, const domain_enum domain)
struct type * language_lookup_primitive_type(const struct language_defn *la, struct gdbarch *gdbarch, const char *name)
#define TYPE_ZALLOC(t, size)
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)
static void rust_compute_range(struct type *type, struct value *range, LONGEST *low, LONGEST *high, enum range_type *kind)
std::string type_to_string(struct type *type)
#define RUST_ENCODED_ENUM_REAL
CORE_ADDR value_address(const struct value *value)
struct type ** primitive_type_vector
int get_array_bounds(struct type *type, LONGEST *low_bound, LONGEST *high_bound)
void c_value_print(struct value *, struct ui_file *, const struct value_print_options *)
static int rust_operator_check(struct expression *exp, int pos, int(*objfile_func)(struct objfile *objfile, void *data), void *data)
static bool rust_tuple_variant_type_p(struct type *type)
void error(const char *fmt,...)
const char * block_scope(const struct block *block)
struct type * lookup_pointer_type(struct type *type)
#define FIELD_TYPE(thisfld)
static struct value * rust_get_trait_object_pointer(struct value *value)
struct type * builtin_int
static void rust_emitchar(int c, struct type *type, struct ui_file *stream, int quoter)