/* Symbol table lookup for the GNU debugger, GDB.
- Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
+ Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992
+ Free Software Foundation, Inc.
This file is part of GDB.
#include "target.h"
#include "value.h"
#include "symfile.h"
+#include "objfiles.h"
#include "gdbcmd.h"
+#include "call-cmds.h"
#include "regex.h"
#include "expression.h"
#include "language.h"
+#include "demangle.h"
#include <obstack.h>
#include <assert.h>
/* Prototypes for local functions */
+static char *
+expensive_mangler PARAMS ((const char *));
+
extern int
find_methods PARAMS ((struct type *, char *, char **, struct symbol **));
static void
-completion_list_add_symbol PARAMS ((char *));
+completion_list_add_symbol PARAMS ((char *, char *, int));
static struct symtabs_and_lines
decode_line_2 PARAMS ((struct symbol *[], int, int));
static void
-rbreak_command PARAMS ((char *));
+rbreak_command PARAMS ((char *, int));
static void
-types_info PARAMS ((char *));
+types_info PARAMS ((char *, int));
static void
-functions_info PARAMS ((char *));
+functions_info PARAMS ((char *, int));
static void
-variables_info PARAMS ((char *));
+variables_info PARAMS ((char *, int));
static void
-list_symbols PARAMS ((char *, int, int));
+sources_info PARAMS ((char *, int));
static void
-sources_info PARAMS ((void));
+list_symbols PARAMS ((char *, int, int));
static void
output_source_filename PARAMS ((char *, int *));
char no_symtab_msg[] = "No symbol table is loaded. Use the \"file\" command.";
+/* While the C++ support is still in flux, issue a possibly helpful hint on
+ using the new command completion feature on single quoted demangled C++
+ symbols. Remove when loose ends are cleaned up. FIXME -fnf */
+
+void
+cplusplus_hint (name)
+ char *name;
+{
+ printf ("Hint: try '%s<TAB> or '%s<ESC-?>\n", name, name);
+ printf ("(Note leading single quote.)\n");
+}
+
/* Check for a symtab of a specific name; first in symtabs, then in
psymtabs. *If* there is no '/' in the name, a match after a '/'
in the symtab filename will also work. */
{
register struct symtab *s;
register struct partial_symtab *ps;
- register char *slash = strchr (name, '/');
- register int len = strlen (name);
+ register char *slash;
register struct objfile *objfile;
+ got_symtab:
+
+ /* First, search for an exact match */
+
+ ALL_SYMTABS (objfile, s)
+ if (strcmp (name, s->filename) == 0)
+ return s;
+
+ slash = strchr (name, '/');
+
+ /* Now, search for a matching tail (only if name doesn't have any dirs) */
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
- {
- for (s = objfile -> symtabs; s != NULL; s = s -> next)
- {
- if (strcmp (name, s->filename) == 0)
- {
- return (s);
- }
- }
- }
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
- {
- for (ps = objfile -> psymtabs; ps != NULL; ps = ps->next)
- {
- if (strcmp (name, ps -> filename) == 0)
- {
- if (ps -> readin)
- {
- error ("Internal: readin pst for `%s' found when no symtab found.", name);
- }
- return (PSYMTAB_TO_SYMTAB (ps));
- }
- }
- }
if (!slash)
- {
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
- {
- for (s = objfile -> symtabs; s != NULL; s = s -> next)
- {
- int l = strlen (s->filename);
-
- if (s->filename[l - len -1] == '/'
- && (strcmp (s->filename + l - len, name) == 0))
- {
- return (s);
- }
- }
- }
+ ALL_SYMTABS (objfile, s)
+ {
+ char *p = s -> filename;
+ char *tail = strrchr (p, '/');
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
- {
- for (ps = objfile -> psymtabs; ps != NULL; ps = ps -> next)
- {
- int l = strlen (ps -> filename);
+ if (tail)
+ p = tail + 1;
+
+ if (strcmp (p, name) == 0)
+ return s;
+ }
+
+ /* Same search rules as above apply here, but now we look thru the
+ psymtabs. */
+
+ ALL_PSYMTABS (objfile, ps)
+ if (strcmp (name, ps -> filename) == 0)
+ goto got_psymtab;
+
+ if (!slash)
+ ALL_PSYMTABS (objfile, ps)
+ {
+ char *p = ps -> filename;
+ char *tail = strrchr (p, '/');
+
+ if (tail)
+ p = tail + 1;
+
+ if (strcmp (p, name) == 0)
+ goto got_psymtab;
+ }
- if (ps -> filename[l - len - 1] == '/'
- && (strcmp (ps->filename + l - len, name) == 0))
- {
- if (ps -> readin)
- {
- error ("Internal: readin pst for `%s' found when no symtab found.", name);
- }
- return (PSYMTAB_TO_SYMTAB (ps));
- }
- }
- }
- }
return (NULL);
+
+ got_psymtab:
+
+ if (ps -> readin)
+ error ("Internal: readin pst for `%s' found when no symtab found.", name);
+
+ s = PSYMTAB_TO_SYMTAB (ps);
+
+ if (s)
+ return s;
+
+ /* At this point, we have located the psymtab for this file, but
+ the conversion to a symtab has failed. This usually happens
+ when we are looking up an include file. In this case,
+ PSYMTAB_TO_SYMTAB doesn't return a symtab, even though one has
+ been created. So, we need to run through the symtabs again in
+ order to find the file.
+ XXX - This is a crock, and should be fixed inside of the the
+ symbol parsing routines. */
+ goto got_symtab;
}
/* Lookup the symbol table of a source file named NAME. Try a couple
register struct partial_symtab *pst;
register struct objfile *objfile;
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
+ ALL_PSYMTABS (objfile, pst)
{
- for (pst = objfile -> psymtabs; pst != NULL; pst = pst -> next)
+ if (strcmp (name, pst -> filename) == 0)
{
- if (strcmp (name, pst -> filename) == 0)
- {
- return (pst);
- }
+ return (pst);
}
- }
+ }
return (NULL);
}
\f
struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
struct fn_field *method = &f[j];
char *field_name = TYPE_FN_FIELDLIST_NAME (type, i);
- int is_constructor = strcmp(field_name, TYPE_NAME (type)) == 0;
+ char *physname = TYPE_FN_FIELD_PHYSNAME (f, j);
+ char *opname;
+ int is_constructor = strcmp (field_name, type_name_no_tag (type)) == 0;
/* Need a new type prefix. */
char *const_prefix = method->is_const ? "C" : "";
char *volatile_prefix = method->is_volatile ? "V" : "";
- char *newname = type_name_no_tag (type);
char buf[20];
- int len = strlen (newname);
- sprintf (buf, "__%s%s%d", const_prefix, volatile_prefix, len);
+ if (is_constructor)
+ {
+ buf[0] = '\0';
+ }
+ else
+ {
+ sprintf (buf, "__%s%s", const_prefix, volatile_prefix);
+ }
+
mangled_name_len = ((is_constructor ? 0 : strlen (field_name))
- + strlen (buf) + len
- + strlen (TYPE_FN_FIELD_PHYSNAME (f, j))
- + 1);
+ + strlen (buf) + strlen (physname) + 1);
/* Only needed for GNU-mangled names. ANSI-mangled names
work with the normal mechanisms. */
if (OPNAME_PREFIX_P (field_name))
{
- char *opname = cplus_mangle_opname (field_name + 3, 0);
+ opname = cplus_mangle_opname (field_name + 3, 0);
if (opname == NULL)
- error ("No mangling for \"%s\"", field_name);
+ {
+ error ("No mangling for \"%s\"", field_name);
+ }
mangled_name_len += strlen (opname);
- mangled_name = (char *)xmalloc (mangled_name_len);
+ mangled_name = (char *) xmalloc (mangled_name_len);
strncpy (mangled_name, field_name, 3);
- mangled_name[3] = '\0';
- strcat (mangled_name, opname);
+ strcpy (mangled_name + 3, opname);
}
else
{
- mangled_name = (char *)xmalloc (mangled_name_len);
+ mangled_name = (char *) xmalloc (mangled_name_len);
if (is_constructor)
- mangled_name[0] = '\0';
+ {
+ mangled_name[0] = '\0';
+ }
else
- strcpy (mangled_name, field_name);
+ {
+ strcpy (mangled_name, field_name);
+ }
}
strcat (mangled_name, buf);
- strcat (mangled_name, newname);
- strcat (mangled_name, TYPE_FN_FIELD_PHYSNAME (f, j));
+ strcat (mangled_name, physname);
- return mangled_name;
+ return (mangled_name);
}
\f
register struct partial_symtab *pst;
register struct objfile *objfile;
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
+ ALL_PSYMTABS (objfile, pst)
{
- for (pst = objfile -> psymtabs; pst != NULL; pst = pst -> next)
+ if (pc >= pst -> textlow && pc < pst -> texthigh)
{
- if (pc >= pst -> textlow && pc < pst -> texthigh)
- {
- return (pst);
- }
+ return (pst);
}
}
return (NULL);
}
\f
-/* Function called via iterate_over_msymbols() that tests a minimal symbol
- to see if the minimal symbol's name is a C++ mangled name that matches
- a user visible name. The user visible name (pname) is passed as arg1
- and the number of leading characters that must match in both the mangled
- name and the user name (matchcount) is passed as arg2. Returns a pointer
- to the minimal symbol if it matches, NULL otherwise. */
-
-static PTR
-cplus_mangled_symbol (objfile, msymbol, arg1, arg2, arg3)
- struct objfile *objfile;
- struct minimal_symbol *msymbol;
- PTR arg1;
- PTR arg2;
- PTR arg3;
-{
- char *pname = (char *) arg1;
- int matchcount = (int) arg2;
- char *demangled;
- struct minimal_symbol *foundit = NULL;
-
- if (strncmp (msymbol -> name, pname, matchcount) == 0)
- {
- if ((demangled = cplus_demangle (msymbol -> name, -1)) != NULL)
- {
- if (strcmp (demangled, pname) == 0)
- {
- foundit = msymbol;
- }
- free (demangled);
- }
- }
- return ((PTR) foundit);
-}
-
/* Find the definition for a specified symbol name NAME
in namespace NAMESPACE, visible from lexical block BLOCK.
Returns the struct symbol pointer, or zero if no symbol is found.
struct blockvector *bv;
register struct objfile *objfile;
register struct block *b;
- register int found;
register struct minimal_symbol *msymbol;
+ char *temp;
+ extern char *gdb_completer_word_break_characters;
+
+ /* If NAME contains any characters from gdb_completer_word_break_characters
+ then it is probably from a quoted name string. So check to see if it
+ has a C++ mangled equivalent, and if so, use the mangled equivalent. */
+
+ if (strpbrk (name, gdb_completer_word_break_characters) != NULL)
+ {
+ if ((temp = expensive_mangler (name)) != NULL)
+ {
+ name = temp;
+ }
+ }
/* Search specified block and its superiors. */
{
/* Search the list of symtabs for one which contains the
address of the start of this block. */
- for (found = 0, objfile = object_files;
- !found && objfile != NULL;
- objfile = objfile -> next)
+ ALL_SYMTABS (objfile, s)
{
- for (s = objfile -> symtabs; s != NULL; s = s -> next)
- {
- bv = BLOCKVECTOR (s);
- b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- if (BLOCK_START (b) <= BLOCK_START (block)
- && BLOCK_END (b) > BLOCK_START (block))
- {
- found++;
- break;
- }
- }
+ bv = BLOCKVECTOR (s);
+ b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ if (BLOCK_START (b) <= BLOCK_START (block)
+ && BLOCK_END (b) > BLOCK_START (block))
+ goto found;
}
+found:
*symtab = s;
}
{
struct block *b;
/* Find the right symtab. */
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
+ ALL_SYMTABS (objfile, s)
{
- for (s = objfile -> symtabs; s != NULL; s = s -> next)
+ bv = BLOCKVECTOR (s);
+ b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
+ if (BLOCK_START (b) <= BLOCK_START (block)
+ && BLOCK_END (b) > BLOCK_START (block))
{
- bv = BLOCKVECTOR (s);
- b = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- if (BLOCK_START (b) <= BLOCK_START (block)
- && BLOCK_END (b) > BLOCK_START (block))
+ sym = lookup_demangled_block_symbol (b, name);
+ if (sym)
{
- sym = lookup_demangled_block_symbol (b, name);
- if (sym)
- {
- block_found = b;
- if (symtab != NULL)
- *symtab = s;
- return sym;
- }
+ block_found = b;
+ if (symtab != NULL)
+ *symtab = s;
+ return sym;
}
}
}
/* Now search all global blocks. Do the symtab's first, then
check the psymtab's */
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
+ ALL_SYMTABS (objfile, s)
{
- for (s = objfile -> symtabs; s != NULL; s = s -> next)
+ bv = BLOCKVECTOR (s);
+ block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ sym = lookup_block_symbol (block, name, namespace);
+ if (sym)
{
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, name, namespace);
- if (sym)
- {
- block_found = block;
- if (symtab != NULL)
- *symtab = s;
- return sym;
- }
+ block_found = block;
+ if (symtab != NULL)
+ *symtab = s;
+ return sym;
}
}
if (namespace == VAR_NAMESPACE)
{
msymbol = lookup_minimal_symbol (name, (struct objfile *) NULL);
+
if (msymbol == NULL)
{
- /* Look for a mangled C++ name for NAME. */
- msymbol = (struct minimal_symbol *)
- iterate_over_msymbols (cplus_mangled_symbol, (PTR) name,
- (PTR) strlen (name), (PTR) NULL);
+ /* Test each minimal symbol to see if the minimal symbol's name
+ is a C++ mangled name that matches a user visible name. */
+
+ char *demangled;
+
+ ALL_MSYMBOLS (objfile, msymbol)
+ {
+ demangled = demangle_and_match (msymbol -> name, name, 0);
+ if (demangled != NULL)
+ {
+ free (demangled);
+ goto found_msym;
+ }
+ }
+ msymbol = NULL; /* Not found */
}
+
+found_msym:
if (msymbol != NULL)
{
s = find_pc_symtab (msymbol -> address);
}
}
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
+ ALL_PSYMTABS (objfile, ps)
{
- for (ps = objfile -> psymtabs; ps != NULL; ps = ps->next)
+ if (!ps->readin && lookup_partial_symbol (ps, name, 1, namespace))
{
- if (!ps->readin && lookup_partial_symbol (ps, name, 1, namespace))
- {
- s = PSYMTAB_TO_SYMTAB(ps);
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- sym = lookup_block_symbol (block, name, namespace);
- if (!sym)
- error ("Internal: global symbol `%s' found in psymtab but not in symtab", name);
- if (symtab != NULL)
- *symtab = s;
- return sym;
- }
+ s = PSYMTAB_TO_SYMTAB(ps);
+ bv = BLOCKVECTOR (s);
+ block = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ sym = lookup_block_symbol (block, name, namespace);
+ if (!sym)
+ error ("Internal: global symbol `%s' found in psymtab but not in symtab", name);
+ if (symtab != NULL)
+ *symtab = s;
+ return sym;
}
}
Not strictly correct, but more useful than an error.
Do the symtabs first, then check the psymtabs */
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
+ ALL_SYMTABS (objfile, s)
{
- for (s = objfile -> symtabs; s != NULL; s = s -> next)
+ bv = BLOCKVECTOR (s);
+ block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
+ sym = lookup_block_symbol (block, name, namespace);
+ if (sym)
{
+ block_found = block;
+ if (symtab != NULL)
+ *symtab = s;
+ return sym;
+ }
+ }
+
+ ALL_PSYMTABS (objfile, ps)
+ {
+ if (!ps->readin && lookup_partial_symbol (ps, name, 0, namespace))
+ {
+ s = PSYMTAB_TO_SYMTAB(ps);
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
sym = lookup_block_symbol (block, name, namespace);
+ if (!sym)
+ error ("Internal: static symbol `%s' found in psymtab but not in symtab", name);
+ if (symtab != NULL)
+ *symtab = s;
+ return sym;
+ }
+ }
+
+ /* Now search all per-file blocks for static mangled symbols.
+ Do the symtabs first, then check the psymtabs. */
+
+ if (namespace == VAR_NAMESPACE)
+ {
+ ALL_SYMTABS (objfile, s)
+ {
+ bv = BLOCKVECTOR (s);
+ block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
+ sym = lookup_demangled_block_symbol (block, name);
if (sym)
{
block_found = block;
return sym;
}
}
- }
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
- {
- for (ps = objfile -> psymtabs; ps != NULL; ps = ps -> next)
+ ALL_PSYMTABS (objfile, ps)
{
- if (!ps->readin && lookup_partial_symbol (ps, name, 0, namespace))
+ if (!ps->readin && lookup_demangled_partial_symbol (ps, name))
{
s = PSYMTAB_TO_SYMTAB(ps);
bv = BLOCKVECTOR (s);
block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- sym = lookup_block_symbol (block, name, namespace);
+ sym = lookup_demangled_block_symbol (block, name);
if (!sym)
- error ("Internal: static symbol `%s' found in psymtab but not in symtab", name);
+ error ("Internal: mangled static symbol `%s' found in psymtab but not in symtab", name);
if (symtab != NULL)
*symtab = s;
return sym;
}
}
- /* Now search all per-file blocks for static mangled symbols.
- Do the symtabs first, then check the psymtabs. */
-
- if (namespace == VAR_NAMESPACE)
- {
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
- {
- for (s = objfile -> symtabs; s != NULL; s = s -> next)
- {
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- sym = lookup_demangled_block_symbol (block, name);
- if (sym)
- {
- block_found = block;
- if (symtab != NULL)
- *symtab = s;
- return sym;
- }
- }
- }
-
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
- {
- for (ps = objfile -> psymtabs; ps != NULL; ps = ps -> next)
- {
- if (!ps->readin && lookup_demangled_partial_symbol (ps, name))
- {
- s = PSYMTAB_TO_SYMTAB(ps);
- bv = BLOCKVECTOR (s);
- block = BLOCKVECTOR_BLOCK (bv, STATIC_BLOCK);
- sym = lookup_demangled_block_symbol (block, name);
- if (!sym)
- error ("Internal: mangled static symbol `%s' found in psymtab but not in symtab", name);
- if (symtab != NULL)
- *symtab = s;
- return sym;
- }
- }
- }
- }
-
if (symtab != NULL)
*symtab = NULL;
return 0;
register const struct block *block;
const char *name;
{
- register int bot, top, inc;
+ register int bot, top;
register struct symbol *sym;
+ char *demangled;
bot = 0;
top = BLOCK_NSYMS (block);
- inc = name[0];
while (bot < top)
{
sym = BLOCK_SYM (block, bot);
- if (SYMBOL_NAME (sym)[0] == inc
- && SYMBOL_NAMESPACE (sym) == VAR_NAMESPACE)
+ if (SYMBOL_NAMESPACE (sym) == VAR_NAMESPACE)
{
- char *demangled = cplus_demangle(SYMBOL_NAME (sym), -1);
+ demangled = demangle_and_match (SYMBOL_NAME (sym), name, 0);
if (demangled != NULL)
{
- int cond = strcmp (demangled, name);
free (demangled);
- if (!cond)
- return sym;
+ return (sym);
}
}
bot++;
}
- return 0;
+ return (NULL);
}
/* Look, in partial_symtab PST, for static mangled symbol NAME. */
{
struct partial_symbol *start, *psym;
int length = pst->n_static_syms;
- register int inc = name[0];
+ char *demangled;
if (!length)
return (struct partial_symbol *) 0;
start = pst->objfile->static_psymbols.list + pst->statics_offset;
for (psym = start; psym < start + length; psym++)
{
- if (SYMBOL_NAME (psym)[0] == inc
- && SYMBOL_NAMESPACE (psym) == VAR_NAMESPACE)
+ if (SYMBOL_NAMESPACE (psym) == VAR_NAMESPACE)
{
- char *demangled = cplus_demangle(SYMBOL_NAME (psym), -1);
+ demangled = demangle_and_match (SYMBOL_NAME (psym), name, 0);
if (demangled != NULL)
{
- int cond = strcmp (demangled, name);
free (demangled);
- if (!cond)
- return psym;
+ return (psym);
}
}
}
- return (struct partial_symbol *) 0;
+ return (NULL);
}
/* Look, in partial_symtab PST, for symbol NAME. Check the global
register struct partial_symtab *pst;
register struct objfile *objfile;
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
+ ALL_PSYMTABS (objfile, pst)
{
- for (pst = objfile -> psymtabs; pst; pst = pst->next)
+ if (lookup_partial_symbol (pst, "main", 1, VAR_NAMESPACE))
{
- if (lookup_partial_symbol (pst, "main", 1, VAR_NAMESPACE))
- {
- return (pst);
- }
+ return (pst);
}
}
return (NULL);
register struct symtab *s = 0;
register struct partial_symtab *ps;
register struct objfile *objfile;
- register int found;
/* Search all symtabs for one whose file contains our pc */
- for (found = 0, objfile = object_files;
- !found && objfile != NULL;
- objfile = objfile -> next)
+ ALL_SYMTABS (objfile, s)
{
- for (s = objfile -> symtabs; s != NULL; s = s -> next)
- {
- bv = BLOCKVECTOR (s);
- b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
- if (BLOCK_START (b) <= pc
- && BLOCK_END (b) > pc)
- {
- found++;
- break;
- }
- }
+ bv = BLOCKVECTOR (s);
+ b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
+ if (BLOCK_START (b) <= pc
+ && BLOCK_END (b) > pc)
+ goto found;
}
if (!s)
}
}
+found:
return (s);
}
else
{
fputs_filtered("(Cannot find method ", stdout);
- fputs_demangled(phys_name, stdout, 0);
+ fputs_demangled(phys_name, stdout, DMGL_PARAMS);
fputs_filtered(" - possibly inlined.)\n", stdout);
}
}
char *copy;
struct symbol *sym_class;
int i1;
+ int is_quoted;
struct symbol **sym_arr;
struct type *t;
char **physnames;
+ char *saved_arg = *argptr;
+ extern char *gdb_completer_quote_characters;
/* Defaults have defaults. */
if (**argptr == '*')
{
- (*argptr)++;
+ if (**argptr == '*')
+ {
+ (*argptr)++;
+ }
pc = parse_and_eval_address_1 (argptr);
values.sals = (struct symtab_and_line *)
xmalloc (sizeof (struct symtab_and_line));
/* Maybe arg is FILE : LINENUM or FILE : FUNCTION */
- s = 0;
+ s = NULL;
+ is_quoted = (strchr (gdb_completer_quote_characters, **argptr) != NULL);
for (p = *argptr; *p; p++)
{
}
while (p[0] == ' ' || p[0] == '\t') p++;
- if (p[0] == ':')
+ if ((p[0] == ':') && !is_quoted)
{
/* C++ */
p1 = p;
while (p != *argptr && p[-1] == ' ') --p;
copy = (char *) alloca (p - *argptr + 1);
- bcopy (*argptr, copy, p - *argptr);
+ memcpy (copy, *argptr, p - *argptr);
copy[p - *argptr] = 0;
/* Discard the class name from the arg. */
char *tmp = alloca (q1 - q + 1);
memcpy (tmp, q, q1 - q);
tmp[q1 - q] = '\0';
- opname = cplus_mangle_opname (tmp, 1);
+ opname = cplus_mangle_opname (tmp, DMGL_ANSI);
if (opname == NULL)
- error ("No mangling for \"%s\"", tmp);
+ {
+ warning ("no mangling for \"%s\"", tmp);
+ cplusplus_hint (saved_arg);
+ return_to_top_level ();
+ }
copy = (char*) alloca (3 + strlen(opname));
sprintf (copy, "__%s", opname);
p = q1;
else
{
copy = (char *) alloca (p - *argptr + 1 + (q1 - q));
- bcopy (*argptr, copy, p - *argptr);
+ memcpy (copy, *argptr, p - *argptr);
copy[p - *argptr] = '\0';
}
else
tmp = copy;
if (tmp[0] == '~')
- error ("The class `%s' does not have destructor defined",
- sym_class->name);
+ warning ("the class `%s' does not have destructor defined",
+ sym_class->name);
else
- error ("The class %s does not have any method named %s",
- sym_class->name, tmp);
+ warning ("the class %s does not have any method named %s",
+ sym_class->name, tmp);
+ cplusplus_hint (saved_arg);
+ return_to_top_level ();
}
}
else
- /* The quotes are important if copy is empty. */
- error("No class, struct, or union named \"%s\"", copy );
+ {
+ /* The quotes are important if copy is empty. */
+ warning ("can't find class, struct, or union named \"%s\"",
+ copy);
+ cplusplus_hint (saved_arg);
+ return_to_top_level ();
+ }
}
/* end of C++ */
p1 = p;
while (p != *argptr && p[-1] == ' ') --p;
copy = (char *) alloca (p - *argptr + 1);
- bcopy (*argptr, copy, p - *argptr);
+ memcpy (copy, *argptr, p - *argptr);
copy[p - *argptr] = 0;
/* Find that file's data. */
/* Arg token is not digits => try it as a variable name
Find the next token (everything up to end or next whitespace). */
- p = *argptr;
- while (*p && *p != ' ' && *p != '\t' && *p != ',') p++;
+ p = skip_quoted (*argptr);
copy = (char *) alloca (p - *argptr + 1);
- bcopy (*argptr, copy, p - *argptr);
- copy[p - *argptr] = 0;
+ memcpy (copy, *argptr, p - *argptr);
+ copy[p - *argptr] = '\0';
+ if ((copy[0] == copy [p - *argptr - 1])
+ && strchr (gdb_completer_quote_characters, copy[0]) != NULL)
+ {
+ char *temp;
+ copy [p - *argptr - 1] = '\0';
+ copy++;
+ if ((temp = expensive_mangler (copy)) != NULL)
+ {
+ copy = temp;
+ }
+ }
while (*p == ' ' || *p == '\t') p++;
*argptr = p;
values.sals = (struct symtab_and_line *)
xmalloc (sizeof (struct symtab_and_line));
values.nelts = 1;
- bzero (&values.sals[0], sizeof (values.sals[0]));
+ memset (&values.sals[0], 0, sizeof (values.sals[0]));
values.sals[0].symtab = sym_symtab;
values.sals[0].line = SYMBOL_LINE (sym);
return values;
!have_partial_symbols () && !have_minimal_symbols ())
error (no_symtab_msg);
- error ("Function %s not defined.", copy);
+ error ("Function \"%s\" not defined.", copy);
return values; /* for lint */
}
char *args, *arg1;
int i;
char *prompt;
+ char *demangled;
values.sals = (struct symtab_and_line *) alloca (nelts * sizeof(struct symtab_and_line));
return_values.sals = (struct symtab_and_line *) xmalloc (nelts * sizeof(struct symtab_and_line));
values.sals[i] = find_pc_line (pc, 0);
values.sals[i].pc = (values.sals[i].end && values.sals[i].pc != pc) ?
values.sals[i].end : pc;
- printf("[%d] file:%s; line number:%d\n",
- (i+2), values.sals[i].symtab->filename, values.sals[i].line);
+ demangled = cplus_demangle (SYMBOL_NAME (sym_arr[i]),
+ DMGL_PARAMS | DMGL_ANSI);
+ printf("[%d] %s at %s:%d\n", (i+2),
+ demangled ? demangled : SYMBOL_NAME (sym_arr[i]),
+ values.sals[i].symtab->filename, values.sals[i].line);
+ if (demangled != NULL)
+ {
+ free (demangled);
+ }
}
else printf ("?HERE\n");
i++;
error ("cancelled");
else if (num == 1)
{
- bcopy (values.sals, return_values.sals, (nelts * sizeof(struct symtab_and_line)));
+ memcpy (return_values.sals, values.sals,
+ (nelts * sizeof(struct symtab_and_line)));
return_values.nelts = nelts;
return return_values;
}
char *name;
int *first;
{
- static unsigned int column;
/* Table of files printed so far. Since a single source file can
result in several partial symbol tables, we need to avoid printing
it more than once. Note: if some of the psymtabs are read in and
if (*first)
{
- column = 0;
*first = 0;
}
else
{
- printf_filtered (",");
- column++;
+ printf_filtered (", ");
}
- if (column != 0 && column + strlen (name) >= 70)
- {
- printf_filtered ("\n");
- column = 0;
- }
- else if (column != 0)
- {
- printf_filtered (" ");
- column++;
- }
+ wrap_here ("");
fputs_filtered (name, stdout);
- column += strlen (name);
}
static void
-sources_info ()
+sources_info (ignore, from_tty)
+ char *ignore;
+ int from_tty;
{
register struct symtab *s;
register struct partial_symtab *ps;
printf_filtered ("Source files for which symbols have been read in:\n\n");
first = 1;
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
+ ALL_SYMTABS (objfile, s)
{
- for (s = objfile -> symtabs; s != NULL; s = s -> next)
- {
- output_source_filename (s -> filename, &first);
- }
+ output_source_filename (s -> filename, &first);
}
printf_filtered ("\n\n");
printf_filtered ("Source files for which symbols will be read in on demand:\n\n");
first = 1;
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
+ ALL_PSYMTABS (objfile, ps)
{
- for (ps = objfile -> psymtabs; ps != NULL; ps = ps -> next)
+ if (!ps->readin)
{
- if (!ps->readin)
- {
- output_source_filename (ps -> filename, &first);
- }
+ output_source_filename (ps -> filename, &first);
}
}
printf_filtered ("\n");
}
static int
-name_match(name)
+name_match (name)
char *name;
{
- char *demangled = cplus_demangle(name, -1);
+ char *demangled = cplus_demangle (name, DMGL_ANSI);
if (demangled != NULL)
{
int cond = re_exec (demangled);
free (demangled);
- return cond;
+ return (cond);
}
- return re_exec(name);
+ return (re_exec (name));
}
#define NAME_MATCH(NAME) name_match(NAME)
/* List all symbols (if REGEXP is 0) or all symbols matching REGEXP.
- If CLASS is zero, list all symbols except functions and type names.
+ If CLASS is zero, list all symbols except functions, type names, and
+ constants (enums).
If CLASS is 1, list only functions.
If CLASS is 2, list only type names.
If CLASS is 3, list only method names.
struct partial_symbol *psym;
struct objfile *objfile;
struct minimal_symbol *msymbol;
- char *val, *q2;
-/* char *mangled;*/
+ char *val;
static char *classnames[]
= {"variable", "function", "type", "method"};
int found_in_file = 0;
enum minimal_symbol_type ourtype = types[class];
enum minimal_symbol_type ourtype2 = types2[class];
-
if (regexp)
{
/* Make sure spacing is right for C++ operators.
matching the regexp. That way we don't have to reproduce all of
the machinery below. */
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
+ ALL_PSYMTABS (objfile, ps)
{
- for (ps = objfile -> psymtabs; ps != NULL; ps = ps -> next)
+ struct partial_symbol *bound, *gbound, *sbound;
+ int keep_going = 1;
+
+ if (ps->readin) continue;
+
+ gbound = objfile->global_psymbols.list + ps->globals_offset + ps->n_global_syms;
+ sbound = objfile->static_psymbols.list + ps->statics_offset + ps->n_static_syms;
+ bound = gbound;
+
+ /* Go through all of the symbols stored in a partial
+ symtab in one loop. */
+ psym = objfile->global_psymbols.list + ps->globals_offset;
+ while (keep_going)
{
- struct partial_symbol *bound, *gbound, *sbound;
- int keep_going = 1;
-
- if (ps->readin) continue;
-
- gbound = objfile->global_psymbols.list + ps->globals_offset + ps->n_global_syms;
- sbound = objfile->static_psymbols.list + ps->statics_offset + ps->n_static_syms;
- bound = gbound;
-
- /* Go through all of the symbols stored in a partial
- symtab in one loop. */
- psym = objfile->global_psymbols.list + ps->globals_offset;
- while (keep_going)
+ if (psym >= bound)
{
- if (psym >= bound)
+ if (bound == gbound && ps->n_static_syms != 0)
{
- if (bound == gbound && ps->n_static_syms != 0)
- {
- psym = objfile->static_psymbols.list + ps->statics_offset;
- bound = sbound;
- }
- else
- keep_going = 0;
- continue;
+ psym = objfile->static_psymbols.list + ps->statics_offset;
+ bound = sbound;
}
else
+ keep_going = 0;
+ continue;
+ }
+ else
+ {
+ QUIT;
+
+ /* If it would match (logic taken from loop below)
+ load the file and go on to the next one */
+ if ((regexp == 0 || NAME_MATCH (SYMBOL_NAME (psym)))
+ && ((class == 0 && SYMBOL_CLASS (psym) != LOC_TYPEDEF
+ && SYMBOL_CLASS (psym) != LOC_BLOCK)
+ || (class == 1 && SYMBOL_CLASS (psym) == LOC_BLOCK)
+ || (class == 2 && SYMBOL_CLASS (psym) == LOC_TYPEDEF)
+ || (class == 3 && SYMBOL_CLASS (psym) == LOC_BLOCK)))
{
- QUIT;
-
- /* If it would match (logic taken from loop below)
- load the file and go on to the next one */
- if ((regexp == 0 || NAME_MATCH (SYMBOL_NAME (psym)))
- && ((class == 0 && SYMBOL_CLASS (psym) != LOC_TYPEDEF
- && SYMBOL_CLASS (psym) != LOC_BLOCK)
- || (class == 1 && SYMBOL_CLASS (psym) == LOC_BLOCK)
- || (class == 2 && SYMBOL_CLASS (psym) == LOC_TYPEDEF)
- || (class == 3 && SYMBOL_CLASS (psym) == LOC_BLOCK)))
- {
- (void) PSYMTAB_TO_SYMTAB(ps);
- keep_going = 0;
- }
+ PSYMTAB_TO_SYMTAB(ps);
+ keep_going = 0;
}
- psym++;
}
+ psym++;
}
}
if (class == 1)
{
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
+ ALL_MSYMBOLS (objfile, msymbol)
{
- for (msymbol = objfile -> msymbols;
- msymbol -> name != NULL; msymbol++)
+ if (msymbol -> type == ourtype || msymbol -> type == ourtype2)
{
- if (msymbol -> type == ourtype || msymbol -> type == ourtype2)
+ if (regexp == 0 || NAME_MATCH (msymbol -> name))
{
- if (regexp == 0 || NAME_MATCH (msymbol -> name))
+ if (0 == find_pc_symtab (msymbol -> address))
{
- if (0 == find_pc_symtab (msymbol -> address))
- {
- found_misc = 1;
- }
+ found_misc = 1;
}
}
}
classnames[class],
regexp);
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
+ ALL_SYMTABS (objfile, s)
{
- for (s = objfile -> symtabs; s != NULL; s = s -> next)
- {
- found_in_file = 0;
- bv = BLOCKVECTOR (s);
- /* Often many files share a blockvector.
- Scan each blockvector only once so that
- we don't get every symbol many times.
- It happens that the first symtab in the list
- for any given blockvector is the main file. */
- if (bv != prev_bv)
- for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
+ found_in_file = 0;
+ bv = BLOCKVECTOR (s);
+ /* Often many files share a blockvector.
+ Scan each blockvector only once so that
+ we don't get every symbol many times.
+ It happens that the first symtab in the list
+ for any given blockvector is the main file. */
+ if (bv != prev_bv)
+ for (i = GLOBAL_BLOCK; i <= STATIC_BLOCK; i++)
+ {
+ b = BLOCKVECTOR_BLOCK (bv, i);
+ /* Skip the sort if this block is always sorted. */
+ if (!BLOCK_SHOULD_SORT (b))
+ sort_block_syms (b);
+ for (j = 0; j < BLOCK_NSYMS (b); j++)
{
- b = BLOCKVECTOR_BLOCK (bv, i);
- /* Skip the sort if this block is always sorted. */
- if (!BLOCK_SHOULD_SORT (b))
- sort_block_syms (b);
- for (j = 0; j < BLOCK_NSYMS (b); j++)
+ QUIT;
+ sym = BLOCK_SYM (b, j);
+ if ((regexp == 0 || NAME_MATCH (SYMBOL_NAME (sym)))
+ && ((class == 0 && SYMBOL_CLASS (sym) != LOC_TYPEDEF
+ && SYMBOL_CLASS (sym) != LOC_BLOCK
+ && SYMBOL_CLASS (sym) != LOC_CONST)
+ || (class == 1 && SYMBOL_CLASS (sym) == LOC_BLOCK)
+ || (class == 2 && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
+ || (class == 3 && SYMBOL_CLASS (sym) == LOC_BLOCK)))
{
- QUIT;
- sym = BLOCK_SYM (b, j);
- if ((regexp == 0 || NAME_MATCH (SYMBOL_NAME (sym)))
- && ((class == 0 && SYMBOL_CLASS (sym) != LOC_TYPEDEF
- && SYMBOL_CLASS (sym) != LOC_BLOCK)
- || (class == 1 && SYMBOL_CLASS (sym) == LOC_BLOCK)
- || (class == 2 && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
- || (class == 3 && SYMBOL_CLASS (sym) == LOC_BLOCK)))
+ if (bpt)
{
- if (bpt)
- {
- /* Set a breakpoint here, if it's a function */
- if (class == 1)
- break_command (SYMBOL_NAME(sym), 0);
- }
- else if (!found_in_file)
- {
- fputs_filtered ("\nFile ", stdout);
- fputs_filtered (s->filename, stdout);
- fputs_filtered (":\n", stdout);
- }
- found_in_file = 1;
-
- if (class != 2 && i == STATIC_BLOCK)
- printf_filtered ("static ");
+ /* Set a breakpoint here, if it's a function */
+ if (class == 1)
+ break_command (SYMBOL_NAME(sym), 0);
+ }
+ else if (!found_in_file)
+ {
+ fputs_filtered ("\nFile ", stdout);
+ fputs_filtered (s->filename, stdout);
+ fputs_filtered (":\n", stdout);
+ }
+ found_in_file = 1;
+
+ if (class != 2 && i == STATIC_BLOCK)
+ printf_filtered ("static ");
+
+ /* Typedef that is not a C++ class */
+ if (class == 2
+ && SYMBOL_NAMESPACE (sym) != STRUCT_NAMESPACE)
+ typedef_print (SYMBOL_TYPE(sym), sym, stdout);
+ /* variable, func, or typedef-that-is-c++-class */
+ else if (class < 2 ||
+ (class == 2 &&
+ SYMBOL_NAMESPACE(sym) == STRUCT_NAMESPACE))
+ {
+ type_print (SYMBOL_TYPE (sym),
+ (SYMBOL_CLASS (sym) == LOC_TYPEDEF
+ ? "" : SYMBOL_NAME (sym)),
+ stdout, 0);
- /* Typedef that is not a C++ class */
- if (class == 2
- && SYMBOL_NAMESPACE (sym) != STRUCT_NAMESPACE)
- typedef_print (SYMBOL_TYPE(sym), sym, stdout);
- /* variable, func, or typedef-that-is-c++-class */
- else if (class < 2 ||
- (class == 2 &&
- SYMBOL_NAMESPACE(sym) == STRUCT_NAMESPACE))
- {
- type_print (SYMBOL_TYPE (sym),
- (SYMBOL_CLASS (sym) == LOC_TYPEDEF
- ? "" : SYMBOL_NAME (sym)),
- stdout, 0);
-
- printf_filtered (";\n");
- }
- else
- {
+ printf_filtered (";\n");
+ }
+ else
+ {
# if 0
- char buf[1024];
- type_print_base (TYPE_FN_FIELD_TYPE(t, i), stdout, 0, 0);
- type_print_varspec_prefix (TYPE_FN_FIELD_TYPE(t, i), stdout, 0);
- sprintf (buf, " %s::", type_name_no_tag (t));
- type_print_method_args (TYPE_FN_FIELD_ARGS (t, i), buf, name, stdout);
+/* FIXME, why is this zapped out? */
+ char buf[1024];
+ type_print_base (TYPE_FN_FIELD_TYPE(t, i), stdout, 0, 0);
+ type_print_varspec_prefix (TYPE_FN_FIELD_TYPE(t, i), stdout, 0);
+ sprintf (buf, " %s::", type_name_no_tag (t));
+ type_print_method_args (TYPE_FN_FIELD_ARGS (t, i), buf, name, stdout);
# endif
- }
}
}
}
- prev_bv = bv;
- }
+ }
+ prev_bv = bv;
}
/* If there are no eyes, avoid all contact. I mean, if there are
if (found_misc || class != 1)
{
found_in_file = 0;
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
+ ALL_MSYMBOLS (objfile, msymbol)
{
- for (msymbol = objfile -> msymbols;
- msymbol -> name != NULL; msymbol++)
+ if (msymbol -> type == ourtype || msymbol -> type == ourtype2)
{
- if (msymbol -> type == ourtype || msymbol -> type == ourtype2)
+ if (regexp == 0 || NAME_MATCH (msymbol -> name))
{
- if (regexp == 0 || NAME_MATCH (msymbol -> name))
+ /* Functions: Look up by address. */
+ if (class != 1 ||
+ (0 == find_pc_symtab (msymbol -> address)))
{
- /* Functions: Look up by address. */
- if (class != 1 &&
- (find_pc_symtab (msymbol -> address) != NULL))
+ /* Variables/Absolutes: Look up by name */
+ if (lookup_symbol (msymbol -> name,
+ (struct block *) 0, VAR_NAMESPACE, 0,
+ (struct symtab **) 0) == NULL)
{
- /* Variables/Absolutes: Look up by name */
- if (lookup_symbol (msymbol -> name,
- (struct block *) 0, VAR_NAMESPACE, 0,
- (struct symtab **) 0) == NULL)
+ if (!found_in_file)
{
- if (!found_in_file)
- {
- printf_filtered ("\nNon-debugging symbols:\n");
- found_in_file = 1;
- }
- printf_filtered (" %08x %s\n",
- msymbol -> address,
- msymbol -> name);
+ printf_filtered ("\nNon-debugging symbols:\n");
+ found_in_file = 1;
}
+ printf_filtered (" %08x %s\n",
+ msymbol -> address,
+ msymbol -> name);
}
}
}
}
static void
-variables_info (regexp)
+variables_info (regexp, from_tty)
char *regexp;
+ int from_tty;
{
list_symbols (regexp, 0, 0);
}
static void
-functions_info (regexp)
+functions_info (regexp, from_tty)
char *regexp;
+ int from_tty;
{
list_symbols (regexp, 1, 0);
}
static void
-types_info (regexp)
+types_info (regexp, from_tty)
char *regexp;
+ int from_tty;
{
list_symbols (regexp, 2, 0);
}
/* Breakpoint all functions matching regular expression. */
static void
-rbreak_command (regexp)
+rbreak_command (regexp, from_tty)
char *regexp;
+ int from_tty;
{
list_symbols (regexp, 1, 1);
}
\f
/* Helper routine for make_symbol_completion_list. */
-int return_val_size, return_val_index;
-char **return_val;
+static int return_val_size;
+static int return_val_index;
+static char **return_val;
+
+/* Test to see if the symbol specified by SYMNAME (or it's demangled
+ equivalent) matches TEXT in the first TEXT_LEN characters. If so,
+ add it to the current completion list. */
static void
-completion_list_add_symbol (symname)
+completion_list_add_symbol (symname, text, text_len)
char *symname;
+ char *text;
+ int text_len;
{
- if (return_val_index + 3 > return_val_size)
- return_val = (char **) xrealloc ((char *) return_val,
- (return_val_size *= 2) * sizeof (char *));
-
- return_val[return_val_index] =
- (char *)xmalloc (1 + strlen (symname));
-
- strcpy (return_val[return_val_index], symname);
-
- return_val[++return_val_index] = (char *)NULL;
+ char *demangled;
+ int newsize;
+
+ /* First see if SYMNAME is a C++ mangled name, and if so, use the
+ demangled name instead, including any parameters. */
+
+ if ((demangled = cplus_demangle (symname, DMGL_PARAMS | DMGL_ANSI)) != NULL)
+ {
+ symname = demangled;
+ }
+
+ /* If we have a match for a completion, then add SYMNAME to the current
+ list of matches. Note that we always make a copy of the string, even
+ if it is one that was returned from cplus_demangle and is already
+ in malloc'd memory. */
+
+ if (strncmp (symname, text, text_len) == 0)
+ {
+ if (return_val_index + 3 > return_val_size)
+ {
+ newsize = (return_val_size *= 2) * sizeof (char *);
+ return_val = (char **) xrealloc ((char *) return_val, newsize);
+ }
+ return_val[return_val_index++] = savestring (symname, strlen (symname));
+ return_val[return_val_index] = NULL;
+ }
+
+ if (demangled != NULL)
+ {
+ free (demangled);
+ }
}
/* Return a NULL terminated array of all symbols (regardless of class) which
begin by matching TEXT. If the answer is no symbols, then the return value
is an array which contains only a NULL pointer.
- Problem: All of the symbols have to be copied because readline
- frees them. I'm not going to worry about this; hopefully there
- won't be that many. */
+ Problem: All of the symbols have to be copied because readline frees them.
+ I'm not going to worry about this; hopefully there won't be that many. */
char **
make_symbol_completion_list (text)
char *text;
{
+ register struct symbol *sym;
register struct symtab *s;
register struct partial_symtab *ps;
register struct minimal_symbol *msymbol;
register struct objfile *objfile;
register struct block *b, *surrounding_static_block = 0;
register int i, j;
+ int text_len;
struct partial_symbol *psym;
- int text_len = strlen (text);
+ text_len = strlen (text);
return_val_size = 100;
return_val_index = 0;
- return_val =
- (char **)xmalloc ((1 + return_val_size) *sizeof (char *));
- return_val[0] = (char *)NULL;
+ return_val = (char **) xmalloc ((return_val_size + 1) * sizeof (char *));
+ return_val[0] = NULL;
/* Look through the partial symtabs for all symbols which begin
by matching TEXT. Add each one that you find to the list. */
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
+ ALL_PSYMTABS (objfile, ps)
{
- for (ps = objfile -> psymtabs; ps != NULL; ps = ps -> next)
+ /* If the psymtab's been read in we'll get it when we search
+ through the blockvector. */
+ if (ps->readin) continue;
+
+ for (psym = objfile->global_psymbols.list + ps->globals_offset;
+ psym < (objfile->global_psymbols.list + ps->globals_offset
+ + ps->n_global_syms);
+ psym++)
{
- /* If the psymtab's been read in we'll get it when we search
- through the blockvector. */
- if (ps->readin) continue;
-
- for (psym = objfile->global_psymbols.list + ps->globals_offset;
- psym < (objfile->global_psymbols.list + ps->globals_offset
- + ps->n_global_syms);
- psym++)
- {
- QUIT; /* If interrupted, then quit. */
- if ((strncmp (SYMBOL_NAME (psym), text, text_len) == 0))
- completion_list_add_symbol (SYMBOL_NAME (psym));
- }
-
- for (psym = objfile->static_psymbols.list + ps->statics_offset;
- psym < (objfile->static_psymbols.list + ps->statics_offset
- + ps->n_static_syms);
- psym++)
- {
- QUIT;
- if ((strncmp (SYMBOL_NAME (psym), text, text_len) == 0))
- completion_list_add_symbol (SYMBOL_NAME (psym));
- }
+ /* If interrupted, then quit. */
+ QUIT;
+ completion_list_add_symbol (SYMBOL_NAME (psym), text, text_len);
+ }
+
+ for (psym = objfile->static_psymbols.list + ps->statics_offset;
+ psym < (objfile->static_psymbols.list + ps->statics_offset
+ + ps->n_static_syms);
+ psym++)
+ {
+ QUIT;
+ completion_list_add_symbol (SYMBOL_NAME (psym), text, text_len);
}
}
anything that isn't a text symbol (everything else will be
handled by the psymtab code above). */
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
+ ALL_MSYMBOLS (objfile, msymbol)
{
- for (msymbol = objfile -> msymbols;
- msymbol ->name != NULL; msymbol++)
+ QUIT;
+ completion_list_add_symbol (msymbol -> name, text, text_len);
+ }
+
+ /* Search upwards from currently selected frame (so that we can
+ complete on local vars. */
+
+ for (b = get_selected_block (); b != NULL; b = BLOCK_SUPERBLOCK (b))
+ {
+ if (!BLOCK_SUPERBLOCK (b))
{
- if (strncmp (text, msymbol -> name, text_len) == 0)
+ surrounding_static_block = b; /* For elmin of dups */
+ }
+
+ /* Also catch fields of types defined in this places which match our
+ text string. Only complete on types visible from current context. */
+
+ for (i = 0; i < BLOCK_NSYMS (b); i++)
+ {
+ sym = BLOCK_SYM (b, i);
+ completion_list_add_symbol (SYMBOL_NAME (sym), text, text_len);
+ if (SYMBOL_CLASS (sym) == LOC_TYPEDEF)
{
- completion_list_add_symbol (msymbol -> name);
+ struct type *t = SYMBOL_TYPE (sym);
+ enum type_code c = TYPE_CODE (t);
+
+ if (c == TYPE_CODE_UNION || c == TYPE_CODE_STRUCT)
+ {
+ for (j = TYPE_N_BASECLASSES (t); j < TYPE_NFIELDS (t); j++)
+ {
+ if (TYPE_FIELD_NAME (t, j))
+ {
+ completion_list_add_symbol (TYPE_FIELD_NAME (t, j),
+ text, text_len);
+ }
+ }
+ }
}
}
}
- /* Search upwards from currently selected frame (so that we can
- complete on local vars. */
+ /* Go through the symtabs and check the externs and statics for
+ symbols which match. */
+
+ ALL_SYMTABS (objfile, s)
+ {
+ QUIT;
+ b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
+ for (i = 0; i < BLOCK_NSYMS (b); i++)
+ {
+ sym = BLOCK_SYM (b, i);
+ completion_list_add_symbol (SYMBOL_NAME (sym), text, text_len);
+ }
+ }
+
+ ALL_SYMTABS (objfile, s)
+ {
+ QUIT;
+ b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK);
+ /* Don't do this block twice. */
+ if (b == surrounding_static_block) continue;
+ for (i = 0; i < BLOCK_NSYMS (b); i++)
+ {
+ sym = BLOCK_SYM (b, i);
+ completion_list_add_symbol (SYMBOL_NAME (sym), text, text_len);
+ }
+ }
+
+ return (return_val);
+}
+
+\f
+/* Find a mangled symbol that corresponds to LOOKFOR using brute force.
+ Basically we go munging through available symbols, demangling each one,
+ looking for a match on the demangled result. */
+
+static char *
+expensive_mangler (lookfor)
+ const char *lookfor;
+{
+ register struct symbol *sym;
+ register struct symtab *s;
+ register struct partial_symtab *ps;
+ register struct minimal_symbol *msymbol;
+ register struct objfile *objfile;
+ register struct block *b, *surrounding_static_block = 0;
+ register int i, j;
+ struct partial_symbol *psym;
+ char *demangled;
+
+ /* Look through the partial symtabs for a symbol that matches */
+
+ ALL_PSYMTABS (objfile, ps)
+ {
+ /* If the psymtab's been read in we'll get it when we search
+ through the blockvector. */
+ if (ps->readin) continue;
+
+ for (psym = objfile->global_psymbols.list + ps->globals_offset;
+ psym < (objfile->global_psymbols.list + ps->globals_offset
+ + ps->n_global_syms);
+ psym++)
+ {
+ QUIT; /* If interrupted, then quit. */
+ demangled = demangle_and_match (SYMBOL_NAME (psym), lookfor,
+ DMGL_PARAMS | DMGL_ANSI);
+ if (demangled != NULL)
+ {
+ free (demangled);
+ return (SYMBOL_NAME (psym));
+ }
+ }
+
+ for (psym = objfile->static_psymbols.list + ps->statics_offset;
+ psym < (objfile->static_psymbols.list + ps->statics_offset
+ + ps->n_static_syms);
+ psym++)
+ {
+ QUIT;
+ demangled = demangle_and_match (SYMBOL_NAME (psym), lookfor,
+ DMGL_PARAMS | DMGL_ANSI);
+ if (demangled != NULL)
+ {
+ free (demangled);
+ return (SYMBOL_NAME (psym));
+ }
+ }
+ }
+
+ /* Scan through the misc symbol vectors looking for a match. */
+
+ ALL_MSYMBOLS (objfile, msymbol)
+ {
+ QUIT;
+ demangled = demangle_and_match (msymbol -> name, lookfor,
+ DMGL_PARAMS | DMGL_ANSI);
+ if (demangled != NULL)
+ {
+ free (demangled);
+ return (msymbol -> name);
+ }
+ }
+
+ /* Search upwards from currently selected frame looking for a match */
+
for (b = get_selected_block (); b; b = BLOCK_SUPERBLOCK (b))
{
if (!BLOCK_SUPERBLOCK (b))
from current context. */
for (i = 0; i < BLOCK_NSYMS (b); i++)
{
- register struct symbol *sym = BLOCK_SYM (b, i);
-
- if (!strncmp (SYMBOL_NAME (sym), text, text_len))
- completion_list_add_symbol (SYMBOL_NAME (sym));
-
+ sym = BLOCK_SYM (b, i);
+ demangled = demangle_and_match (SYMBOL_NAME (sym), lookfor,
+ DMGL_PARAMS | DMGL_ANSI);
+ if (demangled != NULL)
+ {
+ free (demangled);
+ return (SYMBOL_NAME (sym));
+ }
if (SYMBOL_CLASS (sym) == LOC_TYPEDEF)
{
struct type *t = SYMBOL_TYPE (sym);
enum type_code c = TYPE_CODE (t);
if (c == TYPE_CODE_UNION || c == TYPE_CODE_STRUCT)
- for (j = TYPE_N_BASECLASSES (t); j < TYPE_NFIELDS (t); j++)
- if (TYPE_FIELD_NAME (t, j) &&
- !strncmp (TYPE_FIELD_NAME (t, j), text, text_len))
- completion_list_add_symbol (TYPE_FIELD_NAME (t, j));
+ {
+ for (j = TYPE_N_BASECLASSES (t); j < TYPE_NFIELDS (t); j++)
+ {
+ if (TYPE_FIELD_NAME (t, j))
+ {
+ demangled =
+ demangle_and_match (TYPE_FIELD_NAME (t, j),
+ lookfor,
+ DMGL_PARAMS | DMGL_ANSI);
+ if (demangled != NULL)
+ {
+ free (demangled);
+ return (TYPE_FIELD_NAME (t, j));
+ }
+ }
+ }
+ }
}
}
}
/* Go through the symtabs and check the externs and statics for
symbols which match. */
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
+ ALL_SYMTABS (objfile, s)
{
- for (s = objfile ->symtabs; s != NULL; s = s -> next)
+ QUIT;
+ b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
+ for (i = 0; i < BLOCK_NSYMS (b); i++)
{
- b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), GLOBAL_BLOCK);
-
- for (i = 0; i < BLOCK_NSYMS (b); i++)
- if (!strncmp (SYMBOL_NAME (BLOCK_SYM (b, i)), text, text_len))
- completion_list_add_symbol (SYMBOL_NAME (BLOCK_SYM (b, i)));
+ sym = BLOCK_SYM (b, i);
+ demangled = demangle_and_match (SYMBOL_NAME (sym), lookfor,
+ DMGL_PARAMS | DMGL_ANSI);
+ if (demangled != NULL)
+ {
+ free (demangled);
+ return (SYMBOL_NAME (sym));
+ }
}
}
- for (objfile = object_files; objfile != NULL; objfile = objfile -> next)
+ ALL_SYMTABS (objfile, s)
{
- for (s = objfile -> symtabs; s != NULL; s = s -> next)
+ QUIT;
+ b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK);
+ /* Don't do this block twice. */
+ if (b == surrounding_static_block) continue;
+ for (i = 0; i < BLOCK_NSYMS (b); i++)
{
- b = BLOCKVECTOR_BLOCK (BLOCKVECTOR (s), STATIC_BLOCK);
-
- /* Don't do this block twice. */
- if (b == surrounding_static_block) continue;
-
- for (i = 0; i < BLOCK_NSYMS (b); i++)
- if (!strncmp (SYMBOL_NAME (BLOCK_SYM (b, i)), text, text_len))
- completion_list_add_symbol (SYMBOL_NAME (BLOCK_SYM (b, i)));
+ sym = BLOCK_SYM (b, i);
+ demangled = demangle_and_match (SYMBOL_NAME (sym), lookfor,
+ DMGL_PARAMS | DMGL_ANSI);
+ if (demangled != NULL)
+ {
+ free (demangled);
+ return (SYMBOL_NAME (sym));
+ }
}
}
- return (return_val);
+ return (NULL);
}
+
\f
#if 0
/* Add the type of the symbol sym to the type of the current
to in_function_type if it was called correctly).
Note that since we are modifying a type, the result of
- lookup_function_type() should be bcopy()ed before calling
+ lookup_function_type() should be memcpy()ed before calling
this. When not in strict typing mode, the expression
evaluator can choose to ignore this.
#if 0
add_info ("methods", methods_info,
"All method names, or those matching REGEXP::REGEXP.\n\
-If the class qualifier is ommited, it is assumed to be the current scope.\n\
+If the class qualifier is omitted, it is assumed to be the current scope.\n\
If the first REGEXP is omitted, then all methods matching the second REGEXP\n\
are listed.");
#endif