X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Fsymtab.c;h=f7a207a30b4c396d6c3253526ed808cad0abdb92;hb=56618e20bc50e55b49ed224df2a2a7e0840056fe;hp=1ba691e2a35cc4e7b01572a43ea48b5597637046;hpb=8d7493201cf01c9836403695f67f7e157341bfd5;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/symtab.c b/gdb/symtab.c index 1ba691e2a3..f7a207a30b 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -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; } @@ -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; } @@ -723,6 +763,7 @@ symbol_find_demangled_name (struct general_symbol_info *gsymbol, } } if (gsymbol->language == language_cplus + || gsymbol->language == language_rust || gsymbol->language == language_auto) { demangled = @@ -874,7 +915,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 +938,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 +951,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 +992,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 +1006,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 +1335,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 +1372,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 +1390,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 +1405,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,9 +1561,9 @@ 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; if (cache == NULL) return; @@ -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 (" \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 @@ -2856,11 +2905,7 @@ basic_lookup_transparent_type_1 (struct objfile *objfile, int block_index, struct type * basic_lookup_transparent_type (const char *name) { - struct symbol *sym; - struct compunit_symtab *cust; - const struct blockvector *bv; struct objfile *objfile; - struct block *block; struct type *t; /* Now search all the global symbols. Do the symtab's first, then @@ -3629,7 +3674,11 @@ find_function_start_sal (struct symbol *sym, int funfirstline) && (COMPUNIT_LOCATIONS_VALID (SYMTAB_COMPUNIT (sal.symtab)) || SYMTAB_LANGUAGE (sal.symtab) == language_asm)) { + struct gdbarch *gdbarch = symbol_arch (sym); + sal.pc = BLOCK_START (SYMBOL_BLOCK_VALUE (sym)); + if (gdbarch_skip_entrypoint_p (gdbarch)) + sal.pc = gdbarch_skip_entrypoint (gdbarch, sal.pc); return sal; } @@ -4158,7 +4207,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); @@ -4238,7 +4287,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 @@ -4365,7 +4415,7 @@ sort_search_symbols_remove_dups (struct symbol_search *found, int nfound, struct symbol_search **new_head, struct symbol_search **new_tail) { - struct symbol_search **symbols, *symp, *old_next; + struct symbol_search **symbols, *symp; int i, j, nunique; gdb_assert (found != NULL && nfound > 0); @@ -4425,7 +4475,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); } @@ -4435,7 +4485,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; } @@ -4907,7 +4957,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])) @@ -4938,7 +4988,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); @@ -4957,7 +5007,7 @@ rbreak_command (char *regexp, int from_tty) if (newlen > len) { - string = xrealloc (string, newlen); + string = (char *) xrealloc (string, newlen); len = newlen; } strcpy (string, "'"); @@ -5026,7 +5076,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. */ @@ -5072,19 +5122,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); @@ -5140,7 +5190,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) @@ -5405,7 +5455,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; @@ -5738,19 +5788,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); @@ -5792,7 +5842,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; @@ -5889,7 +5940,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) @@ -5915,7 +5967,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);