Introduce lookup_name_info and generalize Ada's FULL/WILD name matching
[deliverable/binutils-gdb.git] / gdb / c-lang.c
index ecc1e795a9c6df0cbecdc865e634367d6bf39150..49077c7171e1fa7dc6def382485823f924be6fce 100644 (file)
@@ -1,6 +1,6 @@
 /* C language support routines for GDB, the GNU debugger.
 
-   Copyright (C) 1992-2016 Free Software Foundation, Inc.
+   Copyright (C) 1992-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -35,8 +35,6 @@
 #include <ctype.h>
 #include "gdbcore.h"
 
-extern void _initialize_c_language (void);
-
 /* Given a C string type, STR_TYPE, return the corresponding target
    character set name.  */
 
@@ -570,15 +568,12 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
       {
        int oplen, limit;
        struct type *type;
-       struct obstack output;
-       struct cleanup *cleanup;
        struct value *result;
        c_string_type dest_type;
        const char *dest_charset;
        int satisfy_expected = 0;
 
-       obstack_init (&output);
-       cleanup = make_cleanup_obstack_free (&output);
+       auto_obstack output;
 
        ++*pos;
        oplen = longest_to_int (exp->elts[*pos].longconst);
@@ -656,7 +651,6 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
              result = allocate_value (type);
            else
              result = value_cstring ("", 0, type);
-           do_cleanups (cleanup);
            return result;
          }
 
@@ -702,7 +696,6 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
                                      obstack_object_size (&output),
                                      type);
          }
-       do_cleanups (cleanup);
        return result;
       }
       break;
@@ -712,7 +705,17 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
     }
   return evaluate_subexp_standard (expect_type, exp, pos, noside);
 }
+\f
+/* la_watch_location_expression for C.  */
 
+gdb::unique_xmalloc_ptr<char>
+c_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 *) %s", name.c_str (), core_addr_to_string (addr)));
+}
 
 \f
 /* Table mapping opcodes into strings for printing operators
@@ -826,7 +829,7 @@ static const char *c_extensions[] =
   ".c", NULL
 };
 
-const struct language_defn c_language_defn =
+extern const struct language_defn c_language_defn =
 {
   "c",                         /* Language name */
   "C",
@@ -860,13 +863,15 @@ const struct language_defn c_language_defn =
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
   default_word_break_characters,
-  default_make_symbol_completion_list,
+  default_collect_symbol_completion_matches,
   c_language_arch_info,
   default_print_array_index,
   default_pass_by_reference,
   c_get_string,
-  NULL,                                /* la_get_symbol_name_cmp */
+  c_watch_location_expression,
+  NULL,                                /* la_get_symbol_name_matcher */
   iterate_over_symbols,
+  default_search_name_hash,
   &c_varobj_ops,
   c_get_compile_context,
   c_compute_program,
@@ -895,6 +900,9 @@ enum cplus_primitive_types {
   cplus_primitive_type_decfloat,
   cplus_primitive_type_decdouble,
   cplus_primitive_type_declong,
+  cplus_primitive_type_char16_t,
+  cplus_primitive_type_char32_t,
+  cplus_primitive_type_wchar_t,
   nr_cplus_primitive_types
 };
 
@@ -950,6 +958,12 @@ cplus_language_arch_info (struct gdbarch *gdbarch,
     = builtin->builtin_decdouble;
   lai->primitive_type_vector [cplus_primitive_type_declong]
     = builtin->builtin_declong;
+  lai->primitive_type_vector [cplus_primitive_type_char16_t]
+    = builtin->builtin_char16;
+  lai->primitive_type_vector [cplus_primitive_type_char32_t]
+    = builtin->builtin_char32;
+  lai->primitive_type_vector [cplus_primitive_type_wchar_t]
+    = builtin->builtin_wchar;
 
   lai->bool_type_symbol = "bool";
   lai->bool_type_default = builtin->builtin_bool;
@@ -960,7 +974,7 @@ static const char *cplus_extensions[] =
   ".C", ".cc", ".cp", ".cpp", ".cxx", ".c++", NULL
 };
 
-const struct language_defn cplus_language_defn =
+extern const struct language_defn cplus_language_defn =
 {
   "c++",                       /* Language name */
   "C++",
@@ -994,13 +1008,15 @@ const struct language_defn cplus_language_defn =
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
   default_word_break_characters,
-  default_make_symbol_completion_list,
+  default_collect_symbol_completion_matches,
   cplus_language_arch_info,
   default_print_array_index,
   cp_pass_by_reference,
   c_get_string,
-  NULL,                                /* la_get_symbol_name_cmp */
+  c_watch_location_expression,
+  cp_get_symbol_name_matcher,
   iterate_over_symbols,
+  default_search_name_hash,
   &cplus_varobj_ops,
   NULL,
   NULL,
@@ -1012,7 +1028,7 @@ static const char *asm_extensions[] =
   ".s", ".sx", ".S", NULL
 };
 
-const struct language_defn asm_language_defn =
+extern const struct language_defn asm_language_defn =
 {
   "asm",                       /* Language name */
   "assembly",
@@ -1046,13 +1062,15 @@ const struct language_defn asm_language_defn =
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
   default_word_break_characters,
-  default_make_symbol_completion_list,
+  default_collect_symbol_completion_matches,
   c_language_arch_info,        /* FIXME: la_language_arch_info.  */
   default_print_array_index,
   default_pass_by_reference,
   c_get_string,
-  NULL,                                /* la_get_symbol_name_cmp */
+  c_watch_location_expression,
+  NULL,                                /* la_get_symbol_name_matcher */
   iterate_over_symbols,
+  default_search_name_hash,
   &default_varobj_ops,
   NULL,
   NULL,
@@ -1064,7 +1082,7 @@ const struct language_defn asm_language_defn =
    to do some simple operations when debugging applications that use
    a language currently not supported by GDB.  */
 
-const struct language_defn minimal_language_defn =
+extern const struct language_defn minimal_language_defn =
 {
   "minimal",                   /* Language name */
   "Minimal",
@@ -1098,24 +1116,17 @@ const struct language_defn minimal_language_defn =
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
   default_word_break_characters,
-  default_make_symbol_completion_list,
+  default_collect_symbol_completion_matches,
   c_language_arch_info,
   default_print_array_index,
   default_pass_by_reference,
   c_get_string,
-  NULL,                                /* la_get_symbol_name_cmp */
+  c_watch_location_expression,
+  NULL,                                /* la_get_symbol_name_matcher */
   iterate_over_symbols,
+  default_search_name_hash,
   &default_varobj_ops,
   NULL,
   NULL,
   LANG_MAGIC
 };
-
-void
-_initialize_c_language (void)
-{
-  add_language (&c_language_defn);
-  add_language (&cplus_language_defn);
-  add_language (&asm_language_defn);
-  add_language (&minimal_language_defn);
-}
This page took 0.028663 seconds and 4 git commands to generate.