#include "objc-lang.h"
#include "d-lang.h"
#include "ada-lang.h"
+#include "go-lang.h"
#include "p-lang.h"
#include "addrmap.h"
/* Prototypes for local functions */
-static void completion_list_add_name (char *, char *, int, char *, char *);
-
static void rbreak_command (char *, int);
static void types_info (char *, int);
const char multiple_symbols_ask[] = "ask";
const char multiple_symbols_all[] = "all";
const char multiple_symbols_cancel[] = "cancel";
-static const char *multiple_symbols_modes[] =
+static const char *const multiple_symbols_modes[] =
{
multiple_symbols_ask,
multiple_symbols_all,
char *mangled_name;
struct fn_field *f = TYPE_FN_FIELDLIST1 (type, method_id);
struct fn_field *method = &f[signature_id];
- char *field_name = TYPE_FN_FIELDLIST_NAME (type, method_id);
+ const char *field_name = TYPE_FN_FIELDLIST_NAME (type, method_id);
const char *physname = TYPE_FN_FIELD_PHYSNAME (f, signature_id);
- char *newname = type_name_no_tag (type);
+ const char *newname = type_name_no_tag (type);
/* Does the form of physname indicate that it is the full mangled name
of a constructor (not just the args)? */
correctly allocated. For C++ symbols a cplus_specific struct is
allocated so OBJFILE must not be NULL. If this is a non C++ symbol
OBJFILE can be NULL. */
+
void
symbol_set_demangled_name (struct general_symbol_info *gsymbol,
char *name,
}
/* Return the demangled name of GSYMBOL. */
-char *
+
+const char *
symbol_get_demangled_name (const struct general_symbol_info *gsymbol)
{
if (gsymbol->language == language_cplus)
\f
/* Initialize the language dependent portion of a symbol
depending upon the language for the symbol. */
+
void
symbol_set_language (struct general_symbol_info *gsymbol,
enum language language)
{
gsymbol->language = language;
if (gsymbol->language == language_d
+ || gsymbol->language == language_go
|| gsymbol->language == language_java
|| gsymbol->language == language_objc
|| gsymbol->language == language_fortran)
};
/* Hash function for the demangled name hash. */
+
static hashval_t
hash_demangled_name_entry (const void *data)
{
}
/* Equality function for the demangled name hash. */
+
static int
eq_demangled_name_entry (const void *a, const void *b)
{
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)
+ {
+ demangled = go_demangle (mangled, 0);
+ if (demangled != NULL)
+ {
+ gsymbol->language = language_go;
+ 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
name with the symbol, we don't need to use the same trick
as Java. */
if (!copy_name)
- gsymbol->name = (char *) linkage_name;
+ gsymbol->name = linkage_name;
else
{
- gsymbol->name = obstack_alloc (&objfile->objfile_obstack, len + 1);
- memcpy (gsymbol->name, linkage_name, len);
- gsymbol->name[len] = '\0';
+ char *name = obstack_alloc (&objfile->objfile_obstack, len + 1);
+
+ memcpy (name, linkage_name, len);
+ name[len] = '\0';
+ gsymbol->name = name;
}
symbol_set_demangled_name (gsymbol, NULL, NULL);
&entry, INSERT));
/* If this name is not in the hash table, add it. */
- if (*slot == NULL)
+ if (*slot == NULL
+ /* A C version of the symbol may have already snuck into the table.
+ This happens to, e.g., main.init (__go_init_main). Cope. */
+ || (gsymbol->language == language_go
+ && (*slot)->demangled[0] == '\0'))
{
char *demangled_name = symbol_find_demangled_name (gsymbol,
linkage_name_copy);
/* Return the source code name of a symbol. In languages where
demangling is necessary, this is the demangled name. */
-char *
+const char *
symbol_natural_name (const struct general_symbol_info *gsymbol)
{
switch (gsymbol->language)
{
case language_cplus:
case language_d:
+ case language_go:
case language_java:
case language_objc:
case language_fortran:
/* Return the demangled name for a symbol based on the language for
that symbol. If no demangled name exists, return NULL. */
-char *
+
+const char *
symbol_demangled_name (const struct general_symbol_info *gsymbol)
{
switch (gsymbol->language)
{
case language_cplus:
case language_d:
+ case language_go:
case language_java:
case language_objc:
case language_fortran:
linkage name of the symbol, depending on how it will be searched for.
If there is no distinct demangled name, then returns the same value
(same pointer) as SYMBOL_LINKAGE_NAME. */
-char *
+
+const char *
symbol_search_name (const struct general_symbol_info *gsymbol)
{
if (gsymbol->language == language_ada)
}
/* Initialize the structure fields to zero values. */
+
void
init_sal (struct symtab_and_line *sal)
{
sal->end = 0;
sal->explicit_pc = 0;
sal->explicit_line = 0;
+ sal->probe = NULL;
}
\f
modified_name = name;
- /* If we are using C++, D, or Java, demangle the name before doing a
+ /* If we are using C++, D, Go, or Java, demangle the name before doing a
lookup, so we can always binary search. */
if (lang == language_cplus)
{
make_cleanup (xfree, demangled_name);
}
}
+ else if (lang == language_go)
+ {
+ demangled_name = go_demangle (name, 0);
+ if (demangled_name)
+ {
+ modified_name = demangled_name;
+ make_cleanup (xfree, demangled_name);
+ }
+ }
*result_name = modified_name;
return cleanup;
BLOCK_FOUND is set to the block in which NAME is found (in the case of
a field of `this', value_of_this sets BLOCK_FOUND to the proper value.) */
-/* This function has a bunch of loops in it and it would seem to be
- attractive to put in some QUIT's (though I'm not really sure
- whether it can run long enough to be really important). But there
+/* This function (or rather its subordinates) have a bunch of loops and
+ it would seem to be attractive to put in some QUIT's (though I'm not really
+ sure whether it can run long enough to be really important). But there
are a few calls for which it would appear to be bad news to quit
- out of here: find_proc_desc in alpha-tdep.c and mips-tdep.c. (Note
+ out of here: e.g., find_proc_desc in alpha-mdebug-tdep.c. (Note
that there is C++ code below which can error(), but that probably
doesn't affect these calls since they are looking for a known
variable and thus can probably assume it will never hit the C++
sym = lookup_block_symbol (block, lang->la_name_of_this, VAR_DOMAIN);
if (sym != NULL)
- return sym;
+ {
+ block_found = block;
+ return sym;
+ }
if (BLOCK_FUNCTION (block))
break;
block = BLOCK_SUPERBLOCK (block);
}
/* Behave like lookup_symbol except that NAME is the natural name
- of the symbol that we're looking for and, if LINKAGE_NAME is
- non-NULL, ensure that the symbol's linkage name matches as
- well. */
+ (e.g., demangled name) of the symbol that we're looking for. */
static struct symbol *
lookup_symbol_aux (const char *name, const struct block *block,
return (struct type *) 0;
}
-
/* Find the name of the file containing main(). */
/* FIXME: What about languages without main() or specially linked
executables that have no main() ? */
void
iterate_over_symbols (const struct block *block, const char *name,
const domain_enum domain,
- int (*callback) (struct symbol *, void *),
+ symbol_found_callback_ftype *callback,
void *data)
{
while (block)
address for that function that has an entry in SYMTAB's line info
table. If such an entry cannot be found, return FUNC_ADDR
unaltered. */
-CORE_ADDR
+
+static CORE_ADDR
skip_prologue_using_lineinfo (CORE_ADDR func_addr, struct symtab *symtab)
{
CORE_ADDR func_start, func_end;
If the PC was explicitly specified, the SAL is not changed.
If the line number was explicitly specified, at most the SAL's PC
is updated. If SAL is already past the prologue, then do nothing. */
+
void
skip_prologue_sal (struct symtab_and_line *sal)
{
to `__main' in `main' between the prologue and before user
code. */
if (gdbarch_skip_main_prologue_p (gdbarch)
- && name && strcmp (name, "main") == 0)
+ && name && strcmp_iw (name, "main") == 0)
{
pc = gdbarch_skip_main_prologue (gdbarch, pc);
/* Recalculate the line number (might not be N+1). */
some legitimate operator text, return a pointer to the
beginning of the substring of the operator text.
Otherwise, return "". */
+
static char *
operator_chars (char *p, char **end)
{
otherwise return non-zero. Optionally add FILE to the table if ADD
is non-zero. If *FIRST is non-zero, forget the old table
contents. */
+
static int
filename_seen (const char *file, int add, int *first)
{
/* Slave routine for sources_info. Force line breaks at ,'s.
NAME is the name to print and *FIRST is nonzero if this is the first
name printed. Set *FIRST to zero. */
+
static void
output_source_filename (const char *name, int *first)
{
}
/* A callback for map_partial_symbol_filenames. */
+
static void
output_partial_symbol_filename (const char *filename, const char *fullname,
void *data)
}
/* Free any memory associated with a search. */
+
void
free_search_symbols (struct symbol_search *symbols)
{
/* Helper function for sort_search_symbols and qsort. Can only
sort symbols, not minimal symbols. */
+
static int
compare_search_syms (const void *sa, const void *sb)
{
/* Sort the ``nfound'' symbols in the list after prevtail. Leave
prevtail where it is, but update its next pointer to point to
the first of the sorted symbols. */
+
static struct symbol_search *
sort_search_symbols (struct symbol_search *prevtail, int nfound)
{
};
/* A callback for expand_symtabs_matching. */
+
static int
search_symbols_file_matches (const char *filename, void *user_data)
{
}
/* A callback for expand_symtabs_matching. */
+
static int
search_symbols_name_matches (const char *symname, void *user_data)
{
characters. If so, add it to the current completion list. */
static void
-completion_list_add_name (char *symname, char *sym_text, int sym_text_len,
- char *text, char *word)
+completion_list_add_name (const char *symname,
+ const char *sym_text, int sym_text_len,
+ const char *text, const char *word)
{
int newsize;
again and feed all the selectors into the mill. */
static void
-completion_list_objc_symbol (struct minimal_symbol *msymbol, char *sym_text,
- int sym_text_len, char *text, char *word)
+completion_list_objc_symbol (struct minimal_symbol *msymbol,
+ const char *sym_text, int sym_text_len,
+ const char *text, const char *word)
{
static char *tmp = NULL;
static unsigned int tmplen = 0;
- char *method, *category, *selector;
+ const char *method, *category, *selector;
char *tmp2 = NULL;
method = SYMBOL_NATURAL_NAME (msymbol);
/* A callback used with macro_for_each and macro_for_each_in_scope.
This adds a macro's name to the current completion list. */
+
static void
add_macro_name (const char *name, const struct macro_definition *ignore,
struct macro_source_file *ignore2, int ignore3,
}
/* A callback for expand_partial_symbol_names. */
+
static int
expand_partial_symbol_name (const char *name, void *user_data)
{
};
/* A callback for map_partial_symbol_filenames. */
+
static void
maybe_add_partial_symtab_filename (const char *filename, const char *fullname,
void *user_data)
return;
}
+ new_main_name = go_main_name ();
+ if (new_main_name != NULL)
+ {
+ set_main_name (new_main_name);
+ return;
+ }
+
new_main_name = pascal_main_name ();
if (new_main_name != NULL)
{