Automatic date update in version.in
[deliverable/binutils-gdb.git] / gdb / rust-lang.c
index b4a529d58a452dc09ccc84676b8a4dc77a4b9c15..817976ab33a7a40dd445bef24a26b105de8f637b 100644 (file)
@@ -35,8 +35,6 @@
 #include <string>
 #include <vector>
 
-extern initialize_file_ftype _initialize_rust_language;
-
 /* Returns the last segment of a Rust path like foo::bar::baz.  Will
    not handle cases where the last segment contains generics.  This
    will return NULL if the last segment cannot be found.  */
@@ -893,13 +891,12 @@ rust_print_type (struct type *type, const char *varstring,
        fputs_filtered ("[", stream);
        rust_print_type (TYPE_TARGET_TYPE (type), NULL,
                         stream, show - 1, level, flags);
-       fputs_filtered ("; ", stream);
 
        if (TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCEXPR
            || TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCLIST)
-         fprintf_filtered (stream, "variable length");
+         fprintf_filtered (stream, "variable length");
        else if (get_array_bounds (type, &low_bound, &high_bound))
-         fprintf_filtered (stream, "%s", 
+         fprintf_filtered (stream, "; %s",
                            plongest (high_bound - low_bound + 1));
        fputs_filtered ("]", stream);
       }
@@ -1762,7 +1759,7 @@ tuple structs, and tuple-like enum variants"));
 
     case STRUCTOP_STRUCT:
       {
-        struct valuelhs;
+        struct value *lhs;
         struct type *type;
         int tem, pc;
 
@@ -1771,16 +1768,14 @@ tuple structs, and tuple-like enum variants"));
         (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1);
         lhs = evaluate_subexp (NULL_TYPE, exp, pos, noside);
 
+       const char *field_name = &exp->elts[pc + 2].string;
         type = value_type (lhs);
         if (TYPE_CODE (type) == TYPE_CODE_UNION
             && !rust_union_is_untagged (type))
          {
            int i, start;
            struct disr_info disr;
-           struct type* variant_type;
-           char* field_name;
-
-           field_name = &exp->elts[pc + 2].string;
+           struct type *variant_type;
 
            disr = rust_get_disr_info (type, value_contents (lhs),
                                       value_embedded_offset (lhs),
@@ -1817,9 +1812,10 @@ which has only anonymous fields"),
          }
        else
          {
-           /* Field access in structs and untagged unions works like C.  */
-           *pos = pc;
-           result = evaluate_subexp_standard (expect_type, exp, pos, noside);
+           result = value_struct_elt (&lhs, NULL, field_name, NULL,
+                                      "structure");
+           if (noside == EVAL_AVOID_SIDE_EFFECTS)
+             result = value_zero (value_type (result), VALUE_LVAL (result));
          }
       }
       break;
@@ -2123,6 +2119,20 @@ rust_sniff_from_mangled_name (const char *mangled, char **demangled)
 
 \f
 
+/* la_watch_location_expression for Rust.  */
+
+static gdb::unique_xmalloc_ptr<char>
+rust_watch_location_expression (struct type *type, CORE_ADDR addr)
+{
+  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 ()));
+}
+
+\f
+
 static const struct exp_descriptor exp_descriptor_rust = 
 {
   rust_print_subexp,
@@ -2138,7 +2148,7 @@ static const char *rust_extensions[] =
   ".rs", NULL
 };
 
-static const struct language_defn rust_language_defn =
+extern const struct language_defn rust_language_defn =
 {
   "rust",
   "Rust",
@@ -2172,11 +2182,12 @@ static const struct language_defn rust_language_defn =
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
   default_word_break_characters,
-  default_make_symbol_completion_list,
+  default_collect_symbol_completion_matches,
   rust_language_arch_info,
   default_print_array_index,
   default_pass_by_reference,
   c_get_string,
+  rust_watch_location_expression,
   NULL,                                /* la_get_symbol_name_cmp */
   iterate_over_symbols,
   &default_varobj_ops,
@@ -2184,9 +2195,3 @@ static const struct language_defn rust_language_defn =
   NULL,
   LANG_MAGIC
 };
-
-void
-_initialize_rust_language (void)
-{
-  add_language (&rust_language_defn);
-}
This page took 0.026621 seconds and 4 git commands to generate.