#include "p-lang.h"
#include "addrmap.h"
#include "cli/cli-utils.h"
-
+#include "fnmatch.h"
#include "hashtab.h"
#include "gdb_obstack.h"
&& 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.
const char *mangled)
{
char *demangled = NULL;
+ int i;
+ int recognized;
if (gsymbol->language == language_unknown)
gsymbol->language = language_auto;
- if (gsymbol->language == language_objc
- || gsymbol->language == language_auto)
- {
- demangled =
- objc_demangle (mangled, 0);
- if (demangled != NULL)
- {
- gsymbol->language = language_objc;
- return demangled;
- }
- }
- if (gsymbol->language == language_cplus
- || gsymbol->language == language_auto)
+ if (gsymbol->language != language_auto)
{
- demangled =
- gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI);
- if (demangled != NULL)
- {
- gsymbol->language = language_cplus;
- return demangled;
- }
- }
- if (gsymbol->language == language_java)
- {
- demangled =
- gdb_demangle (mangled,
- DMGL_PARAMS | DMGL_ANSI | DMGL_JAVA);
- if (demangled != NULL)
- {
- gsymbol->language = language_java;
- return demangled;
- }
- }
- if (gsymbol->language == language_d
- || gsymbol->language == language_auto)
- {
- demangled = d_demangle(mangled, 0);
- if (demangled != NULL)
- {
- gsymbol->language = language_d;
- return demangled;
- }
+ const struct language_defn *lang = language_def (gsymbol->language);
+
+ language_sniff_from_mangled_name (lang, mangled, &demangled);
+ return demangled;
}
- /* FIXME(dje): Continually adding languages here is clumsy.
- Better to just call la_demangle if !auto, and if auto then call
- a utility routine that tries successive languages in turn and reports
- which one it finds. I realize the la_demangle options may be different
- for different languages but there's already a FIXME for that. */
- if (gsymbol->language == language_go
- || gsymbol->language == language_auto)
+
+ for (i = language_unknown; i < nr_languages; ++i)
{
- demangled = go_demangle (mangled, 0);
- if (demangled != NULL)
+ enum language l = (enum language) i;
+ const struct language_defn *lang = language_def (l);
+
+ if (language_sniff_from_mangled_name (lang, mangled, &demangled))
{
- gsymbol->language = language_go;
+ gsymbol->language = l;
return demangled;
}
}
- /* We could support `gsymbol->language == language_fortran' here to provide
- module namespaces also for inferiors with only minimal symbol table (ELF
- symbols). Just the mangling standard is not standardized across compilers
- and there is no DW_AT_producer available for inferiors with only the ELF
- symbols to check the mangling kind. */
-
- /* Check for Ada symbols last. See comment below explaining why. */
-
- if (gsymbol->language == language_auto)
- {
- const char *demangled = ada_decode (mangled);
-
- if (demangled != mangled && demangled != NULL && demangled[0] != '<')
- {
- /* Set the gsymbol language to Ada, but still return NULL.
- Two reasons for that:
-
- 1. For Ada, we prefer computing the symbol's decoded name
- on the fly rather than pre-compute it, in order to save
- memory (Ada projects are typically very large).
-
- 2. There are some areas in the definition of the GNAT
- encoding where, with a bit of bad luck, we might be able
- to decode a non-Ada symbol, generating an incorrect
- demangled name (Eg: names ending with "TB" for instance
- are identified as task bodies and so stripped from
- the decoded name returned).
-
- Returning NULL, here, helps us get a little bit of
- the best of both worlds. Because we're last, we should
- not affect any of the other languages that were able to
- demangle the symbol before us; we get to correctly tag
- Ada symbols as such; and even if we incorrectly tagged
- a non-Ada symbol, which should be rare, any routing
- through the Ada language should be transparent (Ada
- tries to behave much like C/C++ with non-Ada symbols). */
- gsymbol->language = language_ada;
- return NULL;
- }
- }
-
return NULL;
}
struct symbol_cache *cache
= (struct symbol_cache *) program_space_data (pspace, symbol_cache_key);
int pass;
- size_t total_size;
if (cache == NULL)
return;
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
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);
gdb_assert (ops != NULL);
gdb_assert (ops->tracepoint_var_ref != NULL);
gdb_assert (ops->describe_location != NULL);
- gdb_assert (ops->read_needs_frame != NULL);
+ gdb_assert (ops->get_symbol_read_needs != NULL);
gdb_assert (ops->read_variable != NULL);
return result;