Add search_flags to expand_symtabs_matching
[binutils-gdb.git] / gdb / ada-lang.c
index 07958e7934e153634f56304c563cd48ad7f62fc6..589fbf1a0c49f3dac17b5956c69177d0374d66dd 100644 (file)
@@ -3690,6 +3690,7 @@ numeric_type_p (struct type *type)
        {
        case TYPE_CODE_INT:
        case TYPE_CODE_FLT:
+       case TYPE_CODE_FIXED_POINT:
          return 1;
        case TYPE_CODE_RANGE:
          return (type == TYPE_TARGET_TYPE (type)
@@ -3737,6 +3738,7 @@ scalar_type_p (struct type *type)
        case TYPE_CODE_RANGE:
        case TYPE_CODE_ENUM:
        case TYPE_CODE_FLT:
+       case TYPE_CODE_FIXED_POINT:
          return 1;
        default:
          return 0;
@@ -4968,7 +4970,7 @@ ada_add_local_symbols (std::vector<struct block_symbol> &result,
     add_symbols_from_enclosing_procs (result, lookup_name, domain);
 }
 
-/* An object of this type is used as the user_data argument when
+/* An object of this type is used as the callback argument when
    calling the map_matching_symbols method.  */
 
 struct match_data
@@ -4979,48 +4981,43 @@ struct match_data
   }
   DISABLE_COPY_AND_ASSIGN (match_data);
 
+  bool operator() (struct block_symbol *bsym);
+
   struct objfile *objfile = nullptr;
   std::vector<struct block_symbol> *resultp;
   struct symbol *arg_sym = nullptr;
   bool found_sym = false;
 };
 
-/* A callback for add_nonlocal_symbols that adds symbol, found in BSYM,
-   to a list of symbols.  DATA is a pointer to a struct match_data *
-   containing the vector that collects the symbol list, the file that SYM
-   must come from, a flag indicating whether a non-argument symbol has
-   been found in the current block, and the last argument symbol
-   passed in SYM within the current block (if any).  When SYM is null,
-   marking the end of a block, the argument symbol is added if no
-   other has been found.  */
+/* A callback for add_nonlocal_symbols that adds symbol, found in
+   BSYM, to a list of symbols.  */
 
-static bool
-aux_add_nonlocal_symbols (struct block_symbol *bsym,
-                         struct match_data *data)
+bool
+match_data::operator() (struct block_symbol *bsym)
 {
   const struct block *block = bsym->block;
   struct symbol *sym = bsym->symbol;
 
   if (sym == NULL)
     {
-      if (!data->found_sym && data->arg_sym != NULL) 
-       add_defn_to_vec (*data->resultp,
-                        fixup_symbol_section (data->arg_sym, data->objfile),
+      if (!found_sym && arg_sym != NULL)
+       add_defn_to_vec (*resultp,
+                        fixup_symbol_section (arg_sym, objfile),
                         block);
-      data->found_sym = false;
-      data->arg_sym = NULL;
+      found_sym = false;
+      arg_sym = NULL;
     }
   else 
     {
       if (SYMBOL_CLASS (sym) == LOC_UNRESOLVED)
        return true;
       else if (SYMBOL_IS_ARGUMENT (sym))
-       data->arg_sym = sym;
+       arg_sym = sym;
       else
        {
-         data->found_sym = true;
-         add_defn_to_vec (*data->resultp,
-                          fixup_symbol_section (sym, data->objfile),
+         found_sym = true;
+         add_defn_to_vec (*resultp,
+                          fixup_symbol_section (sym, objfile),
                           block);
        }
     }
@@ -5192,20 +5189,12 @@ add_nonlocal_symbols (std::vector<struct block_symbol> &result,
 
   bool is_wild_match = lookup_name.ada ().wild_match_p ();
 
-  auto callback = [&] (struct block_symbol *bsym)
-    {
-      return aux_add_nonlocal_symbols (bsym, &data);
-    };
-
   for (objfile *objfile : current_program_space->objfiles ())
     {
       data.objfile = objfile;
 
-      if (objfile->sf != nullptr)
-       objfile->sf->qf->map_matching_symbols (objfile, lookup_name,
-                                              domain, global, callback,
-                                              (is_wild_match
-                                               ? NULL : compare_names));
+      objfile->map_matching_symbols (lookup_name, domain, global, data,
+                                    is_wild_match ? NULL : compare_names);
 
       for (compunit_symtab *cu : objfile->compunits ())
        {
@@ -5227,10 +5216,8 @@ add_nonlocal_symbols (std::vector<struct block_symbol> &result,
       for (objfile *objfile : current_program_space->objfiles ())
        {
          data.objfile = objfile;
-         if (objfile->sf != nullptr)
-           objfile->sf->qf->map_matching_symbols (objfile, name1,
-                                                  domain, global, callback,
-                                                  compare_names);
+         objfile->map_matching_symbols (name1, domain, global, data,
+                                        compare_names);
        }
     }          
 }
@@ -10261,8 +10248,8 @@ ada_var_value_operation::evaluate_for_cast (struct type *expect_type,
                                            enum noside noside)
 {
   value *val = evaluate_var_value (noside,
-                                  std::get<1> (m_storage),
-                                  std::get<0> (m_storage));
+                                  std::get<0> (m_storage).block,
+                                  std::get<0> (m_storage).symbol);
 
   val = ada_value_cast (expect_type, val);
 
@@ -10282,7 +10269,7 @@ ada_var_value_operation::evaluate (struct type *expect_type,
                                   struct expression *exp,
                                   enum noside noside)
 {
-  symbol *sym = std::get<0> (m_storage);
+  symbol *sym = std::get<0> (m_storage).symbol;
 
   if (SYMBOL_DOMAIN (sym) == UNDEF_DOMAIN)
     /* Only encountered when an unresolved symbol occurs in a
@@ -10373,19 +10360,19 @@ ada_var_value_operation::resolve (struct expression *exp,
                                  innermost_block_tracker *tracker,
                                  struct type *context_type)
 {
-  symbol *sym = std::get<0> (m_storage);
+  symbol *sym = std::get<0> (m_storage).symbol;
   if (SYMBOL_DOMAIN (sym) == UNDEF_DOMAIN)
     {
       block_symbol resolved
-       = ada_resolve_variable (sym, std::get<1> (m_storage),
+       = ada_resolve_variable (sym, std::get<0> (m_storage).block,
                                context_type, parse_completion,
                                deprocedure_p, tracker);
-      std::get<0> (m_storage) = resolved.symbol;
-      std::get<1> (m_storage) = resolved.block;
+      std::get<0> (m_storage) = resolved;
     }
 
   if (deprocedure_p
-      && SYMBOL_TYPE (std::get<0> (m_storage))->code () == TYPE_CODE_FUNC)
+      && (SYMBOL_TYPE (std::get<0> (m_storage).symbol)->code ()
+         == TYPE_CODE_FUNC))
     return true;
 
   return false;
@@ -10478,6 +10465,11 @@ ada_unop_ind_operation::evaluate (struct type *expect_type,
                              (CORE_ADDR) value_as_address (arg1));
     }
 
+  struct type *target_type = (to_static_fixed_type
+                             (ada_aligned_type
+                              (ada_check_typedef (TYPE_TARGET_TYPE (type)))));
+  ada_ensure_varsize_limit (target_type);
+
   if (ada_is_array_descriptor_type (type))
     /* GDB allows dereferencing GNAT array descriptors.  */
     return ada_coerce_to_simple_array (arg1);
@@ -10702,8 +10694,7 @@ ada_funcall_operation::resolve (struct expression *exp,
                           tracker);
 
   std::get<0> (m_storage)
-    = make_operation<ada_var_value_operation> (resolved.symbol,
-                                              resolved.block);
+    = make_operation<ada_var_value_operation> (resolved);
   return false;
 }
 
@@ -12525,6 +12516,7 @@ ada_add_global_exceptions (compiled_regex *preg,
                             return name_matches_regex (decoded.c_str (), preg);
                           },
                           NULL,
+                          SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
                           VARIABLES_DOMAIN);
 
   for (objfile *objfile : current_program_space->objfiles ())
@@ -13041,6 +13033,7 @@ public:
                             lookup_name,
                             NULL,
                             NULL,
+                            SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
                             ALL_DOMAIN);
 
     /* At this point scan through the misc symbol vectors and add each