Build unavailable-stack frames for tracepoint.
[deliverable/binutils-gdb.git] / gdb / symtab.c
index f65e809cb28c7d48b163d4c0ea52e2ea9fd7ec48..e06104b38f042504b6ab58a09ec8f9de577a8aaf 100644 (file)
@@ -1,6 +1,6 @@
 /* Symbol table lookup for the GNU debugger, GDB.
 
-   Copyright (C) 1986-2015 Free Software Foundation, Inc.
+   Copyright (C) 1986-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -41,7 +41,7 @@
 #include "p-lang.h"
 #include "addrmap.h"
 #include "cli/cli-utils.h"
-
+#include "fnmatch.h"
 #include "hashtab.h"
 
 #include "gdb_obstack.h"
@@ -85,6 +85,9 @@ static struct block_symbol
   lookup_symbol_in_objfile (struct objfile *objfile, int block_index,
                            const char *name, const domain_enum domain);
 
+/* See symtab.h.  */
+const struct block_symbol null_block_symbol = { NULL, NULL };
+
 extern initialize_file_ftype _initialize_symtab;
 
 /* Program space key for finding name and language of "main".  */
@@ -339,6 +342,40 @@ compare_filenames_for_search (const char *filename, const char *search_name)
              && STRIP_DRIVE_SPEC (filename) == &filename[len - search_len]));
 }
 
+/* Same as compare_filenames_for_search, but for glob-style patterns.
+   Heads up on the order of the arguments.  They match the order of
+   compare_filenames_for_search, but it's the opposite of the order of
+   arguments to gdb_filename_fnmatch.  */
+
+int
+compare_glob_filenames_for_search (const char *filename,
+                                  const char *search_name)
+{
+  /* We rely on the property of glob-style patterns with FNM_FILE_NAME that
+     all /s have to be explicitly specified.  */
+  int file_path_elements = count_path_elements (filename);
+  int search_path_elements = count_path_elements (search_name);
+
+  if (search_path_elements > file_path_elements)
+    return 0;
+
+  if (IS_ABSOLUTE_PATH (search_name))
+    {
+      return (search_path_elements == file_path_elements
+             && gdb_filename_fnmatch (search_name, filename,
+                                      FNM_FILE_NAME | FNM_NOESCAPE) == 0);
+    }
+
+  {
+    const char *file_to_compare
+      = strip_leading_path_elements (filename,
+                                    file_path_elements - search_path_elements);
+
+    return gdb_filename_fnmatch (search_name, file_to_compare,
+                                FNM_FILE_NAME | FNM_NOESCAPE) == 0;
+  }
+}
+
 /* Check for a symtab of a specific name by searching some symtabs.
    This is a helper function for callbacks of iterate_over_symtabs.
 
@@ -473,7 +510,7 @@ iterate_over_symtabs (const char *name,
 static int
 lookup_symtab_callback (struct symtab *symtab, void *data)
 {
-  struct symtab **result_ptr = data;
+  struct symtab **result_ptr = (struct symtab **) data;
 
   *result_ptr = symtab;
   return 1;
@@ -515,8 +552,8 @@ gdb_mangle_name (struct type *type, int method_id, int signature_id)
   int is_constructor;
   int is_destructor = is_destructor_name (physname);
   /* Need a new type prefix.  */
-  char *const_prefix = method->is_const ? "C" : "";
-  char *volatile_prefix = method->is_volatile ? "V" : "";
+  const char *const_prefix = method->is_const ? "C" : "";
+  const char *volatile_prefix = method->is_volatile ? "V" : "";
   char buf[20];
   int len = (newname == NULL ? 0 : strlen (newname));
 
@@ -596,11 +633,11 @@ symbol_set_demangled_name (struct general_symbol_info *gsymbol,
       else
        {
          gsymbol->ada_mangled = 1;
-         gsymbol->language_specific.mangled_lang.demangled_name = name;
+         gsymbol->language_specific.demangled_name = name;
        }
     }
   else
-    gsymbol->language_specific.mangled_lang.demangled_name = name;
+    gsymbol->language_specific.demangled_name = name;
 }
 
 /* Return the demangled name of GSYMBOL.  */
@@ -615,7 +652,7 @@ symbol_get_demangled_name (const struct general_symbol_info *gsymbol)
       /* Fall through.  */
     }
 
-  return gsymbol->language_specific.mangled_lang.demangled_name;
+  return gsymbol->language_specific.demangled_name;
 }
 
 \f
@@ -663,7 +700,8 @@ struct demangled_name_entry
 static hashval_t
 hash_demangled_name_entry (const void *data)
 {
-  const struct demangled_name_entry *e = data;
+  const struct demangled_name_entry *e
+    = (const struct demangled_name_entry *) data;
 
   return htab_hash_string (e->mangled);
 }
@@ -673,8 +711,10 @@ hash_demangled_name_entry (const void *data)
 static int
 eq_demangled_name_entry (const void *a, const void *b)
 {
-  const struct demangled_name_entry *da = a;
-  const struct demangled_name_entry *db = b;
+  const struct demangled_name_entry *da
+    = (const struct demangled_name_entry *) a;
+  const struct demangled_name_entry *db
+    = (const struct demangled_name_entry *) b;
 
   return strcmp (da->mangled, db->mangled) == 0;
 }
@@ -874,7 +914,8 @@ symbol_set_names (struct general_symbol_info *gsymbol,
        gsymbol->name = linkage_name;
       else
        {
-         char *name = obstack_alloc (&per_bfd->storage_obstack, len + 1);
+         char *name = (char *) obstack_alloc (&per_bfd->storage_obstack,
+                                              len + 1);
 
          memcpy (name, linkage_name, len);
          name[len] = '\0';
@@ -896,7 +937,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
       char *alloc_name;
 
       lookup_len = len + JAVA_PREFIX_LEN;
-      alloc_name = alloca (lookup_len + 1);
+      alloc_name = (char *) alloca (lookup_len + 1);
       memcpy (alloc_name, JAVA_PREFIX, JAVA_PREFIX_LEN);
       memcpy (alloc_name + JAVA_PREFIX_LEN, linkage_name, len);
       alloc_name[lookup_len] = '\0';
@@ -909,7 +950,7 @@ symbol_set_names (struct general_symbol_info *gsymbol,
       char *alloc_name;
 
       lookup_len = len;
-      alloc_name = alloca (lookup_len + 1);
+      alloc_name = (char *) alloca (lookup_len + 1);
       memcpy (alloc_name, linkage_name, len);
       alloc_name[lookup_len] = '\0';
 
@@ -950,10 +991,11 @@ symbol_set_names (struct general_symbol_info *gsymbol,
         us better bcache hit rates for partial symbols.  */
       if (!copy_name && lookup_name == linkage_name)
        {
-         *slot = obstack_alloc (&per_bfd->storage_obstack,
-                                offsetof (struct demangled_name_entry,
-                                          demangled)
-                                + demangled_len + 1);
+         *slot
+           = ((struct demangled_name_entry *)
+              obstack_alloc (&per_bfd->storage_obstack,
+                             offsetof (struct demangled_name_entry, demangled)
+                             + demangled_len + 1));
          (*slot)->mangled = lookup_name;
        }
       else
@@ -963,10 +1005,11 @@ symbol_set_names (struct general_symbol_info *gsymbol,
          /* If we must copy the mangled name, put it directly after
             the demangled name so we can have a single
             allocation.  */
-         *slot = obstack_alloc (&per_bfd->storage_obstack,
-                                offsetof (struct demangled_name_entry,
-                                          demangled)
-                                + lookup_len + demangled_len + 2);
+         *slot
+           = ((struct demangled_name_entry *)
+              obstack_alloc (&per_bfd->storage_obstack,
+                             offsetof (struct demangled_name_entry, demangled)
+                             + lookup_len + demangled_len + 2));
          mangled_ptr = &((*slot)->demangled[demangled_len + 1]);
          strcpy (mangled_ptr, lookup_name);
          (*slot)->mangled = mangled_ptr;
@@ -1291,8 +1334,10 @@ resize_symbol_cache (struct symbol_cache *cache, unsigned int new_size)
     {
       size_t total_size = symbol_cache_byte_size (new_size);
 
-      cache->global_symbols = xcalloc (1, total_size);
-      cache->static_symbols = xcalloc (1, total_size);
+      cache->global_symbols
+       = (struct block_symbol_cache *) xcalloc (1, total_size);
+      cache->static_symbols
+       = (struct block_symbol_cache *) xcalloc (1, total_size);
       cache->global_symbols->size = new_size;
       cache->static_symbols->size = new_size;
     }
@@ -1326,7 +1371,8 @@ free_symbol_cache (struct symbol_cache *cache)
 static struct symbol_cache *
 get_symbol_cache (struct program_space *pspace)
 {
-  struct symbol_cache *cache = program_space_data (pspace, symbol_cache_key);
+  struct symbol_cache *cache
+    = (struct symbol_cache *) program_space_data (pspace, symbol_cache_key);
 
   if (cache == NULL)
     {
@@ -1343,7 +1389,7 @@ get_symbol_cache (struct program_space *pspace)
 static void
 symbol_cache_cleanup (struct program_space *pspace, void *data)
 {
-  struct symbol_cache *cache = data;
+  struct symbol_cache *cache = (struct symbol_cache *) data;
 
   free_symbol_cache (cache);
 }
@@ -1358,7 +1404,7 @@ set_symbol_cache_size (unsigned int new_size)
   ALL_PSPACES (pspace)
     {
       struct symbol_cache *cache
-       = program_space_data (pspace, symbol_cache_key);
+       = (struct symbol_cache *) program_space_data (pspace, symbol_cache_key);
 
       /* The pspace could have been created but not have a cache yet.  */
       if (cache != NULL)
@@ -1514,7 +1560,8 @@ symbol_cache_mark_not_found (struct block_symbol_cache *bsc,
 static void
 symbol_cache_flush (struct program_space *pspace)
 {
-  struct symbol_cache *cache = program_space_data (pspace, symbol_cache_key);
+  struct symbol_cache *cache
+    = (struct symbol_cache *) program_space_data (pspace, symbol_cache_key);
   int pass;
   size_t total_size;
 
@@ -1629,7 +1676,8 @@ maintenance_print_symbol_cache (char *args, int from_tty)
                       : "(no object file)");
 
       /* If the cache hasn't been created yet, avoid creating one.  */
-      cache = program_space_data (pspace, symbol_cache_key);
+      cache
+       = (struct symbol_cache *) program_space_data (pspace, symbol_cache_key);
       if (cache == NULL)
        printf_filtered ("  <empty>\n");
       else
@@ -1700,7 +1748,8 @@ maintenance_print_symbol_cache_statistics (char *args, int from_tty)
                       : "(no object file)");
 
       /* If the cache hasn't been created yet, avoid creating one.  */
-      cache = program_space_data (pspace, symbol_cache_key);
+      cache
+       = (struct symbol_cache *) program_space_data (pspace, symbol_cache_key);
       if (cache == NULL)
        printf_filtered ("  empty, no stats available\n");
       else
@@ -4162,7 +4211,7 @@ clear_filename_seen_cache (struct filename_seen_cache *cache)
 static void
 delete_filename_seen_cache (void *ptr)
 {
-  struct filename_seen_cache *cache = ptr;
+  struct filename_seen_cache *cache = (struct filename_seen_cache *) ptr;
 
   htab_delete (cache->tab);
   xfree (cache);
@@ -4242,7 +4291,8 @@ static void
 output_partial_symbol_filename (const char *filename, const char *fullname,
                                void *data)
 {
-  output_source_filename (fullname ? fullname : filename, data);
+  output_source_filename (fullname ? fullname : filename,
+                         (struct output_source_filename_data *) data);
 }
 
 static void
@@ -4429,7 +4479,7 @@ static int
 search_symbols_file_matches (const char *filename, void *user_data,
                             int basenames)
 {
-  struct search_symbols_data *data = user_data;
+  struct search_symbols_data *data = (struct search_symbols_data *) user_data;
 
   return file_matches (filename, data->files, data->nfiles, basenames);
 }
@@ -4439,7 +4489,7 @@ search_symbols_file_matches (const char *filename, void *user_data,
 static int
 search_symbols_name_matches (const char *symname, void *user_data)
 {
-  struct search_symbols_data *data = user_data;
+  struct search_symbols_data *data = (struct search_symbols_data *) user_data;
 
   return !data->preg_p || regexec (&data->preg, symname, 0, NULL, 0) == 0;
 }
@@ -4911,7 +4961,7 @@ rbreak_command (char *regexp, int from_tty)
          char *local_name;
 
          colon_index = colon - regexp;
-         local_name = alloca (colon_index + 1);
+         local_name = (char *) alloca (colon_index + 1);
          memcpy (local_name, regexp, colon_index);
          local_name[colon_index--] = 0;
          while (isspace (local_name[colon_index]))
@@ -4942,7 +4992,7 @@ rbreak_command (char *regexp, int from_tty)
 
          if (newlen > len)
            {
-             string = xrealloc (string, newlen);
+             string = (char *) xrealloc (string, newlen);
              len = newlen;
            }
          strcpy (string, fullname);
@@ -4961,7 +5011,7 @@ rbreak_command (char *regexp, int from_tty)
 
          if (newlen > len)
            {
-             string = xrealloc (string, newlen);
+             string = (char *) xrealloc (string, newlen);
              len = newlen;
            }
          strcpy (string, "'");
@@ -5030,7 +5080,7 @@ free_completion_list (VEC (char_ptr) **list_ptr)
 static void
 do_free_completion_list (void *list)
 {
-  free_completion_list (list);
+  free_completion_list ((VEC (char_ptr) **) list);
 }
 
 /* Helper routine for make_symbol_completion_list.  */
@@ -5076,19 +5126,19 @@ completion_list_add_name (const char *symname,
 
     if (word == sym_text)
       {
-       newobj = xmalloc (strlen (symname) + 5);
+       newobj = (char *) xmalloc (strlen (symname) + 5);
        strcpy (newobj, symname);
       }
     else if (word > sym_text)
       {
        /* Return some portion of symname.  */
-       newobj = xmalloc (strlen (symname) + 5);
+       newobj = (char *) xmalloc (strlen (symname) + 5);
        strcpy (newobj, symname + (word - sym_text));
       }
     else
       {
        /* Return some of SYM_TEXT plus symname.  */
-       newobj = xmalloc (strlen (symname) + (sym_text - word) + 5);
+       newobj = (char *) xmalloc (strlen (symname) + (sym_text - word) + 5);
        strncpy (newobj, word, sym_text - word);
        newobj[sym_text - word] = '\0';
        strcat (newobj, symname);
@@ -5144,7 +5194,7 @@ completion_list_objc_symbol (struct minimal_symbol *msymbol,
        tmplen = 1024;
       else
        tmplen *= 2;
-      tmp = xrealloc (tmp, tmplen);
+      tmp = (char *) xrealloc (tmp, tmplen);
     }
   selector = strchr (method, ' ');
   if (selector != NULL)
@@ -5409,7 +5459,7 @@ default_make_symbol_completion_list_break_on_1 (const char *text,
       /* These languages may have parameters entered by user but they are never
         present in the partial symbol tables.  */
 
-      const char *cs = memchr (sym_text, '(', sym_text_len);
+      const char *cs = (const char *) memchr (sym_text, '(', sym_text_len);
 
       if (cs)
        sym_text_len = cs - sym_text;
@@ -5742,19 +5792,19 @@ add_filename_to_list (const char *fname, const char *text, const char *word,
   if (word == text)
     {
       /* Return exactly fname.  */
-      newobj = xmalloc (fnlen + 5);
+      newobj = (char *) xmalloc (fnlen + 5);
       strcpy (newobj, fname);
     }
   else if (word > text)
     {
       /* Return some portion of fname.  */
-      newobj = xmalloc (fnlen + 5);
+      newobj = (char *) xmalloc (fnlen + 5);
       strcpy (newobj, fname + (word - text));
     }
   else
     {
       /* Return some of TEXT plus fname.  */
-      newobj = xmalloc (fnlen + (text - word) + 5);
+      newobj = (char *) xmalloc (fnlen + (text - word) + 5);
       strncpy (newobj, word, text - word);
       newobj[text - word] = '\0';
       strcat (newobj, fname);
@@ -5796,7 +5846,8 @@ static void
 maybe_add_partial_symtab_filename (const char *filename, const char *fullname,
                                   void *user_data)
 {
-  struct add_partial_filename_data *data = user_data;
+  struct add_partial_filename_data *data
+    = (struct add_partial_filename_data *) user_data;
 
   if (not_interesting_fname (filename))
     return;
@@ -5893,7 +5944,8 @@ make_source_files_completion_list (const char *text, const char *word)
 static struct main_info *
 get_main_info (void)
 {
-  struct main_info *info = program_space_data (current_program_space,
+  struct main_info *info
+    = (struct main_info *) program_space_data (current_program_space,
                                               main_progspace_key);
 
   if (info == NULL)
@@ -5919,7 +5971,7 @@ get_main_info (void)
 static void
 main_info_cleanup (struct program_space *pspace, void *data)
 {
-  struct main_info *info = data;
+  struct main_info *info = (struct main_info *) data;
 
   if (info != NULL)
     xfree (info->name_of_main);
This page took 0.032259 seconds and 4 git commands to generate.