+ rust_is_string_type_p,
+ "{...}" /* la_struct_too_deep_ellipsis */
+};
+
+/* Class representing the Rust language. */
+
+class rust_language : public language_defn
+{
+public:
+ rust_language ()
+ : language_defn (language_rust, rust_language_data)
+ { /* Nothing. */ }
+
+ /* See language.h. */
+ void language_arch_info (struct gdbarch *gdbarch,
+ struct language_arch_info *lai) const override
+ {
+ const struct builtin_type *builtin = builtin_type (gdbarch);
+
+ struct type **types
+ = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_rust_primitive_types + 1,
+ struct type *);
+
+ types[rust_primitive_bool] = arch_boolean_type (gdbarch, 8, 1, "bool");
+ types[rust_primitive_char] = arch_character_type (gdbarch, 32, 1, "char");
+ types[rust_primitive_i8] = arch_integer_type (gdbarch, 8, 0, "i8");
+ types[rust_primitive_u8] = arch_integer_type (gdbarch, 8, 1, "u8");
+ types[rust_primitive_i16] = arch_integer_type (gdbarch, 16, 0, "i16");
+ types[rust_primitive_u16] = arch_integer_type (gdbarch, 16, 1, "u16");
+ types[rust_primitive_i32] = arch_integer_type (gdbarch, 32, 0, "i32");
+ types[rust_primitive_u32] = arch_integer_type (gdbarch, 32, 1, "u32");
+ types[rust_primitive_i64] = arch_integer_type (gdbarch, 64, 0, "i64");
+ types[rust_primitive_u64] = arch_integer_type (gdbarch, 64, 1, "u64");
+
+ unsigned int length = 8 * TYPE_LENGTH (builtin->builtin_data_ptr);
+ types[rust_primitive_isize] = arch_integer_type (gdbarch, length, 0, "isize");
+ types[rust_primitive_usize] = arch_integer_type (gdbarch, length, 1, "usize");
+
+ types[rust_primitive_f32] = arch_float_type (gdbarch, 32, "f32",
+ floatformats_ieee_single);
+ types[rust_primitive_f64] = arch_float_type (gdbarch, 64, "f64",
+ floatformats_ieee_double);
+
+ types[rust_primitive_unit] = arch_integer_type (gdbarch, 0, 1, "()");
+
+ struct type *tem = make_cv_type (1, 0, types[rust_primitive_u8], NULL);
+ types[rust_primitive_str] = rust_slice_type ("&str", tem,
+ types[rust_primitive_usize]);
+
+ lai->primitive_type_vector = types;
+ lai->bool_type_default = types[rust_primitive_bool];
+ lai->string_char_type = types[rust_primitive_u8];
+ }
+
+ /* See language.h. */
+ bool sniff_from_mangled_name (const char *mangled,
+ char **demangled) const override
+ {
+ *demangled = gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI);
+ return *demangled != NULL;
+ }
+
+ /* See language.h. */
+
+ char *demangle (const char *mangled, int options) const override
+ {
+ return gdb_demangle (mangled, options);
+ }
+
+ /* See language.h. */
+
+ 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
+ {
+ print_offset_data podata;
+ rust_internal_print_type (type, varstring, stream, show, level,
+ flags, false, &podata);
+ }
+
+ /* See language.h. */
+
+ gdb::unique_xmalloc_ptr<char> watch_location_expression
+ (struct type *type, CORE_ADDR addr) const override
+ {
+ type = check_typedef (TYPE_TARGET_TYPE (check_typedef (type)));
+ std::string name = type_to_string (type);
+ return gdb::unique_xmalloc_ptr<char>
+ (xstrprintf ("*(%s as *mut %s)", core_addr_to_string (addr),
+ name.c_str ()));
+ }
+
+ /* See language.h. */
+
+ void value_print_inner
+ (struct value *val, struct ui_file *stream, int recurse,
+ const struct value_print_options *options) const override
+ {
+ return rust_value_print_inner (val, stream, recurse, options);
+ }
+
+ /* See language.h. */
+
+ struct block_symbol lookup_symbol_nonlocal
+ (const char *name, const struct block *block,
+ const domain_enum domain) const override
+ {
+ struct block_symbol result = {};
+
+ if (symbol_lookup_debug)
+ {
+ fprintf_unfiltered (gdb_stdlog,
+ "rust_lookup_symbol_non_local"
+ " (%s, %s (scope %s), %s)\n",
+ name, host_address_to_string (block),
+ block_scope (block), domain_name (domain));
+ }
+
+ /* Look up bare names in the block's scope. */
+ std::string scopedname;
+ if (name[cp_find_first_component (name)] == '\0')
+ {
+ const char *scope = block_scope (block);
+
+ if (scope[0] != '\0')
+ {
+ scopedname = std::string (scope) + "::" + name;
+ name = scopedname.c_str ();
+ }
+ else
+ name = NULL;
+ }
+
+ if (name != NULL)
+ {
+ result = lookup_symbol_in_static_block (name, block, domain);
+ if (result.symbol == NULL)
+ result = lookup_global_symbol (name, block, domain);
+ }
+ return result;
+ }