gdb: Introduce new language field la_is_string_type_p
[deliverable/binutils-gdb.git] / gdb / language.c
index 21eda576b0cb309a8703cb89ba30a1b25ea73edf..9d0eb03b4209848b4541efdc4f7c1a45eb4b5312 100644 (file)
@@ -1,6 +1,6 @@
 /* Multiple source language support for GDB.
 
-   Copyright (C) 1991-2018 Free Software Foundation, Inc.
+   Copyright (C) 1991-2019 Free Software Foundation, Inc.
 
    Contributed by the Department of Computer Science at the State University
    of New York at Buffalo.
@@ -105,10 +105,9 @@ static const struct language_defn *languages[] = {
   &ada_language_defn,
 };
 
-/* The current values of the "set language/type/range" enum
+/* The current values of the "set language/range/case-sensitive" enum
    commands.  */
 static const char *language;
-static const char *type;
 static const char *range;
 static const char *case_sensitive;
 
@@ -173,18 +172,17 @@ set_language_command (const char *ignore,
              /* Enter auto mode.  Set to the current frame's language, if
                  known, or fallback to the initial language.  */
              language_mode = language_mode_auto;
-             TRY
+             try
                {
                  struct frame_info *frame;
 
                  frame = get_selected_frame (NULL);
                  flang = get_frame_language (frame);
                }
-             CATCH (ex, RETURN_MASK_ERROR)
+             catch (const gdb_exception_error &ex)
                {
                  flang = language_unknown;
                }
-             END_CATCH
 
              if (flang != language_unknown)
                set_language (flang);
@@ -725,6 +723,20 @@ default_symbol_name_matcher (const char *symbol_search_name,
 
 /* See language.h.  */
 
+bool
+default_is_string_type_p (struct type *type)
+{
+  type = check_typedef (type);
+  while (TYPE_CODE (type) == TYPE_CODE_REF)
+    {
+      type = TYPE_TARGET_TYPE (type);
+      type = check_typedef (type);
+    }
+  return (TYPE_CODE (type)  == TYPE_CODE_STRING);
+}
+
+/* See language.h.  */
+
 symbol_name_matcher_ftype *
 get_symbol_name_matcher (const language_defn *lang,
                         const lookup_name_info &lookup_name)
@@ -879,7 +891,8 @@ const struct language_defn unknown_language_defn =
   &default_varobj_ops,
   NULL,
   NULL,
-  LANG_MAGIC
+  default_is_string_type_p,
+  "{...}"                      /* la_struct_too_deep_ellipsis */
 };
 
 /* These two structs define fake entries for the "local" and "auto"
@@ -930,7 +943,8 @@ const struct language_defn auto_language_defn =
   &default_varobj_ops,
   NULL,
   NULL,
-  LANG_MAGIC
+  default_is_string_type_p,
+  "{...}"                      /* la_struct_too_deep_ellipsis */
 };
 
 \f
@@ -1173,10 +1187,9 @@ For Fortran the default is off; for other languages the default is on."),
 
   add_set_language_command ();
 
-  language = xstrdup ("auto");
-  type = xstrdup ("auto");
-  range = xstrdup ("auto");
-  case_sensitive = xstrdup ("auto");
+  language = "auto";
+  range = "auto";
+  case_sensitive = "auto";
 
   /* Have the above take effect.  */
   set_language (language_auto);
This page took 0.03079 seconds and 4 git commands to generate.