Don't print symbol on address 0x0
[deliverable/binutils-gdb.git] / gdb / ada-lang.c
index 0acc1b527f5de9683ae3231cd9001852aa1feed7..6956909badf766c72955002dff9f1706f3841308 100644 (file)
@@ -357,7 +357,8 @@ static struct cmd_list_element *maint_show_ada_cmdlist;
 static void
 maint_set_ada_cmd (char *args, int from_tty)
 {
-  help_list (maint_set_ada_cmdlist, "maintenance set ada ", -1, gdb_stdout);
+  help_list (maint_set_ada_cmdlist, "maintenance set ada ", all_commands,
+            gdb_stdout);
 }
 
 /* Implement the "maintenance show ada" (prefix) command.  */
@@ -793,6 +794,7 @@ min_of_type (struct type *t)
 LONGEST
 ada_discrete_type_high_bound (struct type *type)
 {
+  type = resolve_dynamic_type (type, 0);
   switch (TYPE_CODE (type))
     {
     case TYPE_CODE_RANGE:
@@ -813,6 +815,7 @@ ada_discrete_type_high_bound (struct type *type)
 LONGEST
 ada_discrete_type_low_bound (struct type *type)
 {
+  type = resolve_dynamic_type (type, 0);
   switch (TYPE_CODE (type))
     {
     case TYPE_CODE_RANGE:
@@ -4165,7 +4168,7 @@ parse_old_style_renaming (struct type *type,
 
 static struct value *
 ada_read_renaming_var_value (struct symbol *renaming_sym,
-                            struct block *block)
+                            const struct block *block)
 {
   const char *sym_name;
   struct expression *expr;
@@ -4391,20 +4394,6 @@ ada_clear_symbol_cache (void)
   ada_init_symbol_cache (sym_cache);
 }
 
-/* STRUCT_DOMAIN symbols are also typedefs for the type.  This function tests
-   the equivalency of two Ada symbol domain types.  */
-
-static int
-ada_symbol_matches_domain (domain_enum symbol_domain, domain_enum domain)
-{
-  if (symbol_domain == domain
-      || ((domain == VAR_DOMAIN || domain == STRUCT_DOMAIN)
-         && symbol_domain == STRUCT_DOMAIN))
-    return 1;
-
-  return 0;
-}
-
 /* Search our cache for an entry matching NAME and NAMESPACE.
    Return it if found, or NULL otherwise.  */
 
@@ -4506,13 +4495,6 @@ standard_lookup (const char *name, const struct block *block,
   if (lookup_cached_symbol (name, domain, &sym, NULL))
     return sym;
   sym = lookup_symbol_in_language (name, block, domain, language_c, 0);
-
-  /* STRUCT_DOMAIN symbols also define a typedef for the type.  Lookup
-     a STRUCT_DOMAIN symbol if one is requested for VAR_DOMAIN and not
-     found.  */
-  if (sym == NULL && domain == VAR_DOMAIN)
-    sym = lookup_symbol_in_language (name, block, STRUCT_DOMAIN, language_c, 0);
-
   cache_symbol (name, domain, sym, block_found);
   return sym;
 }
@@ -5338,29 +5320,13 @@ add_nonlocal_symbols (struct obstack *obstackp, const char *name,
       data.objfile = objfile;
 
       if (is_wild_match)
-       {
-         objfile->sf->qf->map_matching_symbols (objfile, name, domain, global,
-                                                aux_add_nonlocal_symbols,
-                                                &data, wild_match, NULL);
-         if (domain == VAR_DOMAIN)
-           objfile->sf->qf->map_matching_symbols (objfile, name,
-                                                  STRUCT_DOMAIN, global,
-                                                  aux_add_nonlocal_symbols,
-                                                  &data, wild_match, NULL);
-       }
+       objfile->sf->qf->map_matching_symbols (objfile, name, domain, global,
+                                              aux_add_nonlocal_symbols, &data,
+                                              wild_match, NULL);
       else
-       {
-         objfile->sf->qf->map_matching_symbols (objfile, name, domain, global,
-                                                aux_add_nonlocal_symbols,
-                                                &data, full_match,
-                                                compare_names);
-         if (domain == VAR_DOMAIN)
-           objfile->sf->qf->map_matching_symbols (objfile, name,
-                                                  STRUCT_DOMAIN, global,
-                                                  aux_add_nonlocal_symbols,
-                                                  &data, full_match,
-                                                  compare_names);
-       }
+       objfile->sf->qf->map_matching_symbols (objfile, name, domain, global,
+                                              aux_add_nonlocal_symbols, &data,
+                                              full_match, compare_names);
     }
 
   if (num_defns_collected (obstackp) == 0 && global && !is_wild_match)
@@ -5884,7 +5850,8 @@ ada_add_block_symbols (struct obstack *obstackp,
       for (sym = block_iter_match_first (block, name, wild_match, &iter);
           sym != NULL; sym = block_iter_match_next (name, wild_match, &iter))
       {
-        if (ada_symbol_matches_domain (SYMBOL_DOMAIN (sym), domain)
+        if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
+                                   SYMBOL_DOMAIN (sym), domain)
             && wild_match (SYMBOL_LINKAGE_NAME (sym), name) == 0)
           {
            if (SYMBOL_CLASS (sym) == LOC_UNRESOLVED)
@@ -5906,7 +5873,8 @@ ada_add_block_symbols (struct obstack *obstackp,
      for (sym = block_iter_match_first (block, name, full_match, &iter);
          sym != NULL; sym = block_iter_match_next (name, full_match, &iter))
       {
-        if (ada_symbol_matches_domain (SYMBOL_DOMAIN (sym), domain))
+        if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
+                                   SYMBOL_DOMAIN (sym), domain))
           {
            if (SYMBOL_CLASS (sym) != LOC_UNRESOLVED)
              {
@@ -5938,7 +5906,8 @@ ada_add_block_symbols (struct obstack *obstackp,
 
       ALL_BLOCK_SYMBOLS (block, iter, sym)
       {
-        if (ada_symbol_matches_domain (SYMBOL_DOMAIN (sym), domain))
+        if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
+                                   SYMBOL_DOMAIN (sym), domain))
           {
             int cmp;
 
@@ -6164,7 +6133,7 @@ ada_make_symbol_completion_list (const char *text0, const char *word,
   struct symtab *s;
   struct minimal_symbol *msymbol;
   struct objfile *objfile;
-  struct block *b, *surrounding_static_block = 0;
+  const struct block *b, *surrounding_static_block = 0;
   int i;
   struct block_iterator iter;
   struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
@@ -7383,7 +7352,11 @@ ada_which_variant_applies (struct type *var_type, struct type *outer_type,
   struct value *discrim;
   LONGEST discrim_val;
 
-  outer = value_from_contents_and_address (outer_type, outer_valaddr, 0);
+  /* Using plain value_from_contents_and_address here causes problems
+     because we will end up trying to resolve a type that is currently
+     being constructed.  */
+  outer = value_from_contents_and_address_unresolved (outer_type,
+                                                     outer_valaddr, 0);
   discrim = ada_value_struct_elt (outer, discrim_name, 1);
   if (discrim == NULL)
     return -1;
@@ -7522,12 +7495,11 @@ ada_find_any_type_symbol (const char *name)
   struct symbol *sym;
 
   sym = standard_lookup (name, get_selected_block (NULL), VAR_DOMAIN);
-  if (sym != NULL
-      && (SYMBOL_DOMAIN (sym) != VAR_DOMAIN
-         || SYMBOL_CLASS (sym) == LOC_TYPEDEF))
+  if (sym != NULL && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
     return sym;
 
-  return NULL;
+  sym = standard_lookup (name, NULL, STRUCT_DOMAIN);
+  return sym;
 }
 
 /* Find a type named NAME.  Ignores ambiguity.  This routine will look
@@ -7923,7 +7895,13 @@ ada_template_to_fixed_record_type_1 (struct type *type,
                 GDB may fail to allocate a value for it.  So check the
                 size first before creating the value.  */
              check_size (rtype);
-             dval = value_from_contents_and_address (rtype, valaddr, address);
+             /* Using plain value_from_contents_and_address here
+                causes problems because we will end up trying to
+                resolve a type that is currently being
+                constructed.  */
+             dval = value_from_contents_and_address_unresolved (rtype,
+                                                                valaddr,
+                                                                address);
              rtype = value_type (dval);
            }
           else
@@ -8028,7 +8006,11 @@ ada_template_to_fixed_record_type_1 (struct type *type,
 
       if (dval0 == NULL)
        {
-         dval = value_from_contents_and_address (rtype, valaddr, address);
+         /* Using plain value_from_contents_and_address here causes
+            problems because we will end up trying to resolve a type
+            that is currently being constructed.  */
+         dval = value_from_contents_and_address_unresolved (rtype, valaddr,
+                                                            address);
          rtype = value_type (dval);
        }
       else
@@ -12776,7 +12758,7 @@ static void
 ada_add_exceptions_from_frame (regex_t *preg, struct frame_info *frame,
                               VEC(ada_exc_info) **exceptions)
 {
-  struct block *block = get_frame_block (frame, 0);
+  const struct block *block = get_frame_block (frame, 0);
 
   while (block != 0)
     {
@@ -12837,7 +12819,7 @@ ada_add_global_exceptions (regex_t *preg, VEC(ada_exc_info) **exceptions)
 
   ALL_PRIMARY_SYMTABS (objfile, s)
     {
-      struct blockvector *bv = BLOCKVECTOR (s);
+      const struct blockvector *bv = BLOCKVECTOR (s);
       int i;
 
       for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
@@ -13462,7 +13444,7 @@ ada_get_symbol_name_cmp (const char *lookup_name)
 static struct value *
 ada_read_var_value (struct symbol *var, struct frame_info *frame)
 {
-  struct block *frame_block = NULL;
+  const struct block *frame_block = NULL;
   struct symbol *renaming_sym = NULL;
 
   /* The only case where default_read_var_value is not sufficient
@@ -13536,7 +13518,7 @@ set_ada_command (char *arg, int from_tty)
 {
   printf_unfiltered (_(\
 "\"set ada\" must be followed by the name of a setting.\n"));
-  help_list (set_ada_list, "set ada ", -1, gdb_stdout);
+  help_list (set_ada_list, "set ada ", all_commands, gdb_stdout);
 }
 
 /* Implement the "show ada" prefix command.  */
This page took 0.03158 seconds and 4 git commands to generate.