#include "objfiles.h"
#include "gdbcmd.h"
#include "call-cmds.h"
-#include "gnu-regex.h"
+#include "gdb_regex.h"
#include "expression.h"
#include "language.h"
#include "demangle.h"
/* Prototype for one function in parser-defs.h,
instead of including that entire file. */
-extern char *find_template_name_end PARAMS ((char *));
+extern char *find_template_name_end (char *);
/* Prototypes for local functions */
-static int find_methods PARAMS ((struct type *, char *, struct symbol **));
+static int find_methods (struct type *, char *, struct symbol **);
-static void completion_list_add_name PARAMS ((char *, char *, int, char *,
- char *));
+static void completion_list_add_name (char *, char *, int, char *, char *);
-static void build_canonical_line_spec PARAMS ((struct symtab_and_line *,
- char *, char ***));
+static void build_canonical_line_spec (struct symtab_and_line *,
+ char *, char ***);
-static struct symtabs_and_lines decode_line_2 PARAMS ((struct symbol *[],
- int, int, char ***));
+static struct symtabs_and_lines decode_line_2 (struct symbol *[],
+ int, int, char ***);
-static void rbreak_command PARAMS ((char *, int));
+static void rbreak_command (char *, int);
-static void types_info PARAMS ((char *, int));
+static void types_info (char *, int);
-static void functions_info PARAMS ((char *, int));
+static void functions_info (char *, int);
-static void variables_info PARAMS ((char *, int));
+static void variables_info (char *, int);
-static void sources_info PARAMS ((char *, int));
+static void sources_info (char *, int);
-static void output_source_filename PARAMS ((char *, int *));
+static void output_source_filename (char *, int *);
-char *operator_chars PARAMS ((char *, char **));
+char *operator_chars (char *, char **);
-static int find_line_common PARAMS ((struct linetable *, int, int *));
+static int find_line_common (struct linetable *, int, int *);
-static struct partial_symbol *lookup_partial_symbol PARAMS
- ((struct partial_symtab *, const char *,
- int, namespace_enum));
+static struct partial_symbol *lookup_partial_symbol (struct partial_symtab *,
+ const char *, int,
+ namespace_enum);
-static struct partial_symbol *fixup_psymbol_section PARAMS ((struct
- partial_symbol *, struct objfile *));
+static struct symtab *lookup_symtab_1 (char *);
-static struct symtab *lookup_symtab_1 PARAMS ((char *));
+static void cplusplus_hint (char *);
-static void cplusplus_hint PARAMS ((char *));
-
-static struct symbol *find_active_alias PARAMS ((struct symbol * sym,
- CORE_ADDR addr));
+static struct symbol *find_active_alias (struct symbol *sym, CORE_ADDR addr);
/* This flag is used in hppa-tdep.c, and set in hp-symtab-read.c */
/* Signals the presence of objects compiled by HP compilers */
int hp_som_som_object_present = 0;
-static void fixup_section PARAMS ((struct general_symbol_info *,
- struct objfile *));
+static void fixup_section (struct general_symbol_info *, struct objfile *);
-static int file_matches PARAMS ((char *, char **, int));
+static int file_matches (char *, char **, int);
-static void print_symbol_info PARAMS ((namespace_enum,
- struct symtab *, struct symbol *,
- int, char *));
+static void print_symbol_info (namespace_enum,
+ struct symtab *, struct symbol *, int, char *);
-static void print_msymbol_info PARAMS ((struct minimal_symbol *));
+static void print_msymbol_info (struct minimal_symbol *);
-static void symtab_symbol_info PARAMS ((char *, namespace_enum, int));
+static void symtab_symbol_info (char *, namespace_enum, int);
-static void overload_list_add_symbol PARAMS ((struct symbol * sym,
- char *oload_name));
+static void overload_list_add_symbol (struct symbol *sym, char *oload_name);
-void _initialize_symtab PARAMS ((void));
+void _initialize_symtab (void);
/* */
symbols. Remove when loose ends are cleaned up. FIXME -fnf */
static void
-cplusplus_hint (name)
- char *name;
+cplusplus_hint (char *name)
{
while (*name == '\'')
name++;
in the symtab filename will also work. */
static struct symtab *
-lookup_symtab_1 (name)
- char *name;
+lookup_symtab_1 (char *name)
{
register struct symtab *s;
register struct partial_symtab *ps;
of variations if the first lookup doesn't work. */
struct symtab *
-lookup_symtab (name)
- char *name;
+lookup_symtab (char *name)
{
register struct symtab *s;
#if 0
in the psymtab filename will also work. */
struct partial_symtab *
-lookup_partial_symtab (name)
- char *name;
+lookup_partial_symtab (char *name)
{
register struct partial_symtab *pst;
register struct objfile *objfile;
specified by SIGNATURE_ID. Note that this function is g++ specific. */
char *
-gdb_mangle_name (type, method_id, signature_id)
- struct type *type;
- int method_id, signature_id;
+gdb_mangle_name (struct type *type, int method_id, int signature_id)
{
int mangled_name_len;
char *mangled_name;
/* Find which partial symtab on contains PC and SECTION. Return 0 if none. */
struct partial_symtab *
-find_pc_sect_psymtab (pc, section)
- CORE_ADDR pc;
- asection *section;
+find_pc_sect_psymtab (CORE_ADDR pc, asection *section)
{
register struct partial_symtab *pst;
register struct objfile *objfile;
ALL_PSYMTABS (objfile, pst)
{
-#if defined(HPUXHPPA)
- if (pc >= pst->textlow && pc <= pst->texthigh)
-#else
if (pc >= pst->textlow && pc < pst->texthigh)
-#endif
{
struct minimal_symbol *msymbol;
struct partial_symtab *tpst;
for (tpst = pst; tpst != NULL; tpst = tpst->next)
{
-#if defined(HPUXHPPA)
- if (pc >= tpst->textlow && pc <= tpst->texthigh)
-#else
if (pc >= tpst->textlow && pc < tpst->texthigh)
-#endif
{
struct partial_symbol *p;
Backward compatibility, no section */
struct partial_symtab *
-find_pc_psymtab (pc)
- CORE_ADDR pc;
+find_pc_psymtab (CORE_ADDR pc)
{
return find_pc_sect_psymtab (pc, find_pc_mapped_section (pc));
}
Return 0 if none. Check all psymtabs if PSYMTAB is 0. */
struct partial_symbol *
-find_pc_sect_psymbol (psymtab, pc, section)
- struct partial_symtab *psymtab;
- CORE_ADDR pc;
- asection *section;
+find_pc_sect_psymbol (struct partial_symtab *psymtab, CORE_ADDR pc,
+ asection *section)
{
struct partial_symbol *best = NULL, *p, **pp;
CORE_ADDR best_pc;
Check all psymtabs if PSYMTAB is 0. Backwards compatibility, no section. */
struct partial_symbol *
-find_pc_psymbol (psymtab, pc)
- struct partial_symtab *psymtab;
- CORE_ADDR pc;
+find_pc_psymbol (struct partial_symtab *psymtab, CORE_ADDR pc)
{
return find_pc_sect_psymbol (psymtab, pc, find_pc_mapped_section (pc));
}
out of the minimal symbols and stash that in the debug symbol. */
static void
-fixup_section (ginfo, objfile)
- struct general_symbol_info *ginfo;
- struct objfile *objfile;
+fixup_section (struct general_symbol_info *ginfo, struct objfile *objfile)
{
struct minimal_symbol *msym;
msym = lookup_minimal_symbol (ginfo->name, NULL, objfile);
if (msym)
- ginfo->bfd_section = SYMBOL_BFD_SECTION (msym);
+ {
+ ginfo->bfd_section = SYMBOL_BFD_SECTION (msym);
+ ginfo->section = SYMBOL_SECTION (msym);
+ }
}
struct symbol *
-fixup_symbol_section (sym, objfile)
- struct symbol *sym;
- struct objfile *objfile;
+fixup_symbol_section (struct symbol *sym, struct objfile *objfile)
{
if (!sym)
return NULL;
return sym;
}
-static struct partial_symbol *
-fixup_psymbol_section (psym, objfile)
- struct partial_symbol *psym;
- struct objfile *objfile;
+struct partial_symbol *
+fixup_psymbol_section (struct partial_symbol *psym, struct objfile *objfile)
{
if (!psym)
return NULL;
can probably assume it will never hit the C++ code). */
struct symbol *
-lookup_symbol (name, block, namespace, is_a_field_of_this, symtab)
- const char *name;
- register const struct block *block;
- const namespace_enum namespace;
- int *is_a_field_of_this;
- struct symtab **symtab;
+lookup_symbol (const char *name, register const struct block *block,
+ const namespace_enum namespace, int *is_a_field_of_this,
+ struct symtab **symtab)
{
register struct symbol *sym;
register struct symtab *s = NULL;
register struct block *b;
register struct minimal_symbol *msymbol;
+ if (case_sensitivity == case_sensitive_off)
+ {
+ char *copy;
+ int len, i;
+
+ len = strlen (name);
+ copy = (char *) alloca (len + 1);
+ for (i= 0; i < len; i++)
+ copy[i] = tolower (name[i]);
+ copy[len] = 0;
+ name = copy;
+ }
+
/* Search specified block and its superiors. */
while (block != 0)
*symtab = NULL;
return 0;
}
-
+
/* Look, in partial_symtab PST, for symbol NAME. Check the global
symbols if GLOBAL, the static symbols if not */
static struct partial_symbol *
-lookup_partial_symbol (pst, name, global, namespace)
- struct partial_symtab *pst;
- const char *name;
- int global;
- namespace_enum namespace;
+lookup_partial_symbol (struct partial_symtab *pst, const char *name, int global,
+ namespace_enum namespace)
{
+ struct partial_symbol *temp;
struct partial_symbol **start, **psym;
struct partial_symbol **top, **bottom, **center;
int length = (global ? pst->n_global_syms : pst->n_static_syms);
int do_linear_search = 1;
-
+
if (length == 0)
{
return (NULL);
}
-
start = (global ?
pst->objfile->global_psymbols.list + pst->globals_offset :
pst->objfile->static_psymbols.list + pst->statics_offset);
-
+
if (global) /* This means we can use a binary search. */
{
do_linear_search = 0;
if (!(center < top))
abort ();
if (!do_linear_search
- && (SYMBOL_LANGUAGE (*center) == language_cplus
- || SYMBOL_LANGUAGE (*center) == language_java
- ))
+ && (SYMBOL_LANGUAGE (*center) == language_java))
{
do_linear_search = 1;
}
}
if (!(top == bottom))
abort ();
- while (STREQ (SYMBOL_NAME (*top), name))
+
+ /* djb - 2000-06-03 - Use SYMBOL_MATCHES_NAME, not a strcmp, so
+ we don't have to force a linear search on C++. Probably holds true
+ for JAVA as well, no way to check.*/
+ while (SYMBOL_MATCHES_NAME (*top,name))
{
if (SYMBOL_NAMESPACE (*top) == namespace)
{
- return (*top);
+ return (*top);
}
top++;
}
we should also do a linear search. */
if (do_linear_search)
- {
+ {
for (psym = start; psym < start + length; psym++)
{
if (namespace == SYMBOL_NAMESPACE (*psym))
struct type *
-lookup_transparent_type (name)
- const char *name;
+lookup_transparent_type (const char *name)
{
register struct symbol *sym;
register struct symtab *s = NULL;
executables that have no main() ? */
struct partial_symtab *
-find_main_psymtab ()
+find_main_psymtab (void)
{
register struct partial_symtab *pst;
register struct objfile *objfile;
tested for a match. */
struct symbol *
-lookup_block_symbol (block, name, namespace)
- register const struct block *block;
- const char *name;
- const namespace_enum namespace;
+lookup_block_symbol (register const struct block *block, const char *name,
+ const namespace_enum namespace)
{
register int bot, top, inc;
register struct symbol *sym;
If no alias is active, then return SYM. */
static struct symbol *
-find_active_alias (sym, addr)
- struct symbol *sym;
- CORE_ADDR addr;
+find_active_alias (struct symbol *sym, CORE_ADDR addr)
{
struct range_list *r;
struct alias_list *aliases;
lexical block, described by a struct block BL. */
struct symbol *
-block_function (bl)
- struct block *bl;
+block_function (struct block *bl)
{
while (BLOCK_FUNCTION (bl) == 0 && BLOCK_SUPERBLOCK (bl) != 0)
bl = BLOCK_SUPERBLOCK (bl);
psymtabs and read in another symtab if necessary. */
struct symtab *
-find_pc_sect_symtab (pc, section)
- CORE_ADDR pc;
- asection *section;
+find_pc_sect_symtab (CORE_ADDR pc, asection *section)
{
register struct block *b;
struct blockvector *bv;
b = BLOCKVECTOR_BLOCK (bv, GLOBAL_BLOCK);
if (BLOCK_START (b) <= pc
-#if defined(HPUXHPPA)
- && BLOCK_END (b) >= pc
-#else
&& BLOCK_END (b) > pc
-#endif
&& (distance == 0
|| BLOCK_END (b) - BLOCK_START (b) < distance))
{
/* Might want to error() here (in case symtab is corrupt and
will cause a core dump), but maybe we can successfully
continue, so let's not. */
- /* FIXME-32x64: assumes pc fits in a long */
warning ("\
-(Internal error: pc 0x%lx in read in psymtab, but not in symtab.)\n",
- (unsigned long) pc);
+(Internal error: pc 0x%s in read in psymtab, but not in symtab.)\n",
+ paddr_nz (pc));
s = PSYMTAB_TO_SYMTAB (ps);
}
return (s);
read in another symtab if necessary. Backward compatibility, no section */
struct symtab *
-find_pc_symtab (pc)
- CORE_ADDR pc;
+find_pc_symtab (CORE_ADDR pc)
{
return find_pc_sect_symtab (pc, find_pc_mapped_section (pc));
}
line *0x2345" cause psymtabs to be converted to symtabs). */
struct symbol *
-find_addr_symbol (addr, symtabp, symaddrp)
- CORE_ADDR addr;
- struct symtab **symtabp;
- CORE_ADDR *symaddrp;
+find_addr_symbol (CORE_ADDR addr, struct symtab **symtabp, CORE_ADDR *symaddrp)
{
struct symtab *symtab, *best_symtab;
struct objfile *objfile;
/* If it's worth the effort, we could be using a binary search. */
struct symtab_and_line
-find_pc_sect_line (pc, section, notcurrent)
- CORE_ADDR pc;
- struct sec *section;
- int notcurrent;
+find_pc_sect_line (CORE_ADDR pc, struct sec *section, int notcurrent)
{
struct symtab *s;
register struct linetable *l;
/* Backward compatibility (no section) */
struct symtab_and_line
-find_pc_line (pc, notcurrent)
- CORE_ADDR pc;
- int notcurrent;
+find_pc_line (CORE_ADDR pc, int notcurrent)
{
asection *section;
}
\f
-static struct symtab *find_line_symtab PARAMS ((struct symtab *, int,
- int *, int *));
+static struct symtab *find_line_symtab (struct symtab *, int, int *, int *);
/* Find line number LINE in any symtab whose name is the same as
SYMTAB.
If not found, return NULL. */
static struct symtab *
-find_line_symtab (symtab, line, index, exact_match)
- struct symtab *symtab;
- int line;
- int *index;
- int *exact_match;
+find_line_symtab (struct symtab *symtab, int line, int *index, int *exact_match)
{
int exact;
The source file is specified with a struct symtab. */
int
-find_line_pc (symtab, line, pc)
- struct symtab *symtab;
- int line;
- CORE_ADDR *pc;
+find_line_pc (struct symtab *symtab, int line, CORE_ADDR *pc)
{
struct linetable *l;
int ind;
Returns 0 if could not find the specified line. */
int
-find_line_pc_range (sal, startptr, endptr)
- struct symtab_and_line sal;
- CORE_ADDR *startptr, *endptr;
+find_line_pc_range (struct symtab_and_line sal, CORE_ADDR *startptr,
+ CORE_ADDR *endptr)
{
CORE_ADDR startaddr;
struct symtab_and_line found_sal;
Set *EXACT_MATCH nonzero if the value returned is an exact match. */
static int
-find_line_common (l, lineno, exact_match)
- register struct linetable *l;
- register int lineno;
- int *exact_match;
+find_line_common (register struct linetable *l, register int lineno,
+ int *exact_match)
{
register int i;
register int len;
}
int
-find_pc_line_pc_range (pc, startptr, endptr)
- CORE_ADDR pc;
- CORE_ADDR *startptr, *endptr;
+find_pc_line_pc_range (CORE_ADDR pc, CORE_ADDR *startptr, CORE_ADDR *endptr)
{
struct symtab_and_line sal;
sal = find_pc_line (pc, 0);
of real code inside the function. */
static struct symtab_and_line
-find_function_start_sal PARAMS ((struct symbol * sym, int));
+find_function_start_sal (struct symbol *sym, int);
static struct symtab_and_line
-find_function_start_sal (sym, funfirstline)
- struct symbol *sym;
- int funfirstline;
+find_function_start_sal (struct symbol *sym, int funfirstline)
{
CORE_ADDR pc;
struct symtab_and_line sal;
beginning of the substring of the operator text.
Otherwise, return "". */
char *
-operator_chars (p, end)
- char *p;
- char **end;
+operator_chars (char *p, char **end)
{
*end = "";
if (strncmp (p, "operator", 8))
reader because the type of the baseclass might still be stubbed
when the definition of the derived class is parsed. */
-static int total_number_of_methods PARAMS ((struct type * type));
+static int total_number_of_methods (struct type *type);
static int
-total_number_of_methods (type)
- struct type *type;
+total_number_of_methods (struct type *type)
{
int n;
int count;
Note that this function is g++ specific. */
static int
-find_methods (t, name, sym_arr)
- struct type *t;
- char *name;
- struct symbol **sym_arr;
+find_methods (struct type *t, char *name, struct symbol **sym_arr)
{
int i1 = 0;
int ibase;
line spec is `filename:linenum'. */
static void
-build_canonical_line_spec (sal, symname, canonical)
- struct symtab_and_line *sal;
- char *symname;
- char ***canonical;
+build_canonical_line_spec (struct symtab_and_line *sal, char *symname,
+ char ***canonical)
{
char **canonical_arr;
char *canonical_name;
canonical_arr[0] = canonical_name;
}
+
+
+/* Find an instance of the character C in the string S that is outside
+ of all parenthesis pairs, single-quoted strings, and double-quoted
+ strings. */
+static char *
+find_toplevel_char (char *s, char c)
+{
+ int quoted = 0; /* zero if we're not in quotes;
+ '"' if we're in a double-quoted string;
+ '\'' if we're in a single-quoted string. */
+ int depth = 0; /* number of unclosed parens we've seen */
+ char *scan;
+
+ for (scan = s; *scan; scan++)
+ {
+ if (quoted)
+ {
+ if (*scan == quoted)
+ quoted = 0;
+ else if (*scan == '\\' && *(scan + 1))
+ scan++;
+ }
+ else if (*scan == c && ! quoted && depth == 0)
+ return scan;
+ else if (*scan == '"' || *scan == '\'')
+ quoted = *scan;
+ else if (*scan == '(')
+ depth++;
+ else if (*scan == ')' && depth > 0)
+ depth--;
+ }
+
+ return 0;
+}
+
+
/* Parse a string that specifies a line number.
Pass the address of a char * variable; that variable will be
advanced over the characters actually parsed.
can use as appropriate instead of make_symbol_completion_list. */
struct symtabs_and_lines
-decode_line_1 (argptr, funfirstline, default_symtab, default_line, canonical)
- char **argptr;
- int funfirstline;
- struct symtab *default_symtab;
- int default_line;
- char ***canonical;
+decode_line_1 (char **argptr, int funfirstline, struct symtab *default_symtab,
+ int default_line, char ***canonical)
{
struct symtabs_and_lines values;
#ifdef HPPA_COMPILER_BUG
&& strchr (gdb_completer_quote_characters, **argptr) != NULL);
has_parens = ((pp = strchr (*argptr, '(')) != NULL
- && (pp = strchr (pp, ')')) != NULL);
+ && (pp = strrchr (pp, ')')) != NULL);
/* Now that we're safely past the has_parens check,
* put back " if (condition)" so outer layers can see it
/* Maybe we were called with a line range FILENAME:LINENUM,FILENAME:LINENUM
and we must isolate the first half. Outer layers will call again later
- for the second half */
- if ((ii = strchr (*argptr, ',')) != NULL)
- has_comma = 1;
+ for the second half.
+
+ Don't count commas that appear in argument lists of overloaded
+ functions, or in quoted strings. It's stupid to go to this much
+ trouble when the rest of the function is such an obvious roach hotel. */
+ ii = find_toplevel_char (*argptr, ',');
+ has_comma = (ii != 0);
+
/* Temporarily zap out second half to not
* confuse the code below.
* This is undone below. Do not change ii!!
}
while (p[0] == ' ' || p[0] == '\t')
p++;
+
/* if the closing double quote was left at the end, remove it */
- if (is_quote_enclosed && ((pp = strchr (p, '"')) != NULL))
- if (!*(pp + 1))
- *pp = '\0';
+ if (is_quote_enclosed)
+ {
+ char *closing_quote = strchr (p, '"');
+ if (closing_quote && closing_quote[1] == '\0')
+ *closing_quote = '\0';
+ }
/* Now that we've safely parsed the first half,
* put back ',' so outer layers can see it
/* First check for "global" namespace specification,
of the form "::foo". If found, skip over the colons
and jump to normal symbol processing */
- if ((*argptr == p) || (p[-1] == ' ') || (p[-1] == '\t'))
+ if (p[0] == ':'
+ && ((*argptr == p) || (p[-1] == ' ') || (p[-1] == '\t')))
saved_arg2 += 2;
/* We have what looks like a class or namespace
p = skip_quoted (*argptr);
}
+ if (is_quote_enclosed && **argptr == '"')
+ (*argptr)++;
+
copy = (char *) alloca (p - *argptr + 1);
memcpy (copy, *argptr, p - *argptr);
copy[p - *argptr] = '\0';
}
struct symtabs_and_lines
-decode_line_spec (string, funfirstline)
- char *string;
- int funfirstline;
+decode_line_spec (char *string, int funfirstline)
{
struct symtabs_and_lines sals;
if (string == 0)
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 (name, first)
- char *name;
- int *first;
+output_source_filename (char *name, int *first)
{
/* Table of files printed so far. Since a single source file can
result in several partial symbol tables, we need to avoid printing
}
static void
-sources_info (ignore, from_tty)
- char *ignore;
- int from_tty;
+sources_info (char *ignore, int from_tty)
{
register struct symtab *s;
register struct partial_symtab *ps;
/* Free any memory associated with a search. */
void
-free_search_symbols (symbols)
- struct symbol_search *symbols;
+free_search_symbols (struct symbol_search *symbols)
{
struct symbol_search *p;
struct symbol_search *next;
}
}
+static void
+do_free_search_symbols_cleanup (void *symbols)
+{
+ free_search_symbols (symbols);
+}
+
+struct cleanup *
+make_cleanup_free_search_symbols (struct symbol_search *symbols)
+{
+ return make_cleanup (do_free_search_symbols_cleanup, symbols);
+}
+
+
/* Search the symbol table for matches to the regular expression REGEXP,
returning the results in *MATCHES.
if (kind < LABEL_NAMESPACE)
error ("must search on specific namespace");
- ourtype = types[(int) (kind - LABEL_NAMESPACE)];
- ourtype2 = types2[(int) (kind - LABEL_NAMESPACE)];
- ourtype3 = types3[(int) (kind - LABEL_NAMESPACE)];
- ourtype4 = types4[(int) (kind - LABEL_NAMESPACE)];
+ ourtype = types[(int) (kind - VARIABLES_NAMESPACE)];
+ ourtype2 = types2[(int) (kind - VARIABLES_NAMESPACE)];
+ ourtype3 = types3[(int) (kind - VARIABLES_NAMESPACE)];
+ ourtype4 = types4[(int) (kind - VARIABLES_NAMESPACE)];
sr = *matches = NULL;
tail = NULL;
if (tail == NULL)
{
sr = psr;
- old_chain = make_cleanup ((make_cleanup_func)
- free_search_symbols, sr);
+ old_chain = make_cleanup_free_search_symbols (sr);
}
else
tail->next = psr;
if (tail == NULL)
{
sr = psr;
- old_chain = make_cleanup ((make_cleanup_func)
- free_search_symbols, &sr);
+ old_chain = make_cleanup_free_search_symbols (sr);
}
else
tail->next = psr;
regarding the match to gdb_stdout.
*/
static void
-print_symbol_info (kind, s, sym, block, last)
- namespace_enum kind;
- struct symtab *s;
- struct symbol *sym;
- int block;
- char *last;
+print_symbol_info (namespace_enum kind, struct symtab *s, struct symbol *sym,
+ int block, char *last)
{
if (last == NULL || strcmp (last, s->filename) != 0)
{
/* Typedef that is not a C++ class */
if (kind == TYPES_NAMESPACE
&& SYMBOL_NAMESPACE (sym) != STRUCT_NAMESPACE)
- c_typedef_print (SYMBOL_TYPE (sym), sym, gdb_stdout);
+ typedef_print (SYMBOL_TYPE (sym), sym, gdb_stdout);
/* variable, func, or typedef-that-is-c++-class */
else if (kind < TYPES_NAMESPACE ||
(kind == TYPES_NAMESPACE &&
for non-debugging symbols to gdb_stdout.
*/
static void
-print_msymbol_info (msymbol)
- struct minimal_symbol *msymbol;
+print_msymbol_info (struct minimal_symbol *msymbol)
{
printf_filtered (" %08lx %s\n",
(unsigned long) SYMBOL_VALUE_ADDRESS (msymbol),
matches.
*/
static void
-symtab_symbol_info (regexp, kind, from_tty)
- char *regexp;
- namespace_enum kind;
- int from_tty;
+symtab_symbol_info (char *regexp, namespace_enum kind, int from_tty)
{
static char *classnames[]
=
/* must make sure that if we're interrupted, symbols gets freed */
search_symbols (regexp, kind, 0, (char **) NULL, &symbols);
- old_chain = make_cleanup ((make_cleanup_func) free_search_symbols, symbols);
+ old_chain = make_cleanup_free_search_symbols (symbols);
printf_filtered (regexp
? "All %ss matching regular expression \"%s\":\n"
: "All defined %ss:\n",
- classnames[(int) (kind - LABEL_NAMESPACE - 1)], regexp);
+ classnames[(int) (kind - VARIABLES_NAMESPACE)], regexp);
for (p = symbols; p != NULL; p = p->next)
{
}
static void
-variables_info (regexp, from_tty)
- char *regexp;
- int from_tty;
+variables_info (char *regexp, int from_tty)
{
symtab_symbol_info (regexp, VARIABLES_NAMESPACE, from_tty);
}
static void
-functions_info (regexp, from_tty)
- char *regexp;
- int from_tty;
+functions_info (char *regexp, int from_tty)
{
symtab_symbol_info (regexp, FUNCTIONS_NAMESPACE, from_tty);
}
+
static void
-types_info (regexp, from_tty)
- char *regexp;
- int from_tty;
+types_info (char *regexp, int from_tty)
{
symtab_symbol_info (regexp, TYPES_NAMESPACE, from_tty);
}
#if 0
/* Tiemann says: "info methods was never implemented." */
static void
-methods_info (regexp)
- char *regexp;
+methods_info (char *regexp)
{
symtab_symbol_info (regexp, METHODS_NAMESPACE, 0, from_tty);
}
#endif /* 0 */
/* Breakpoint all functions matching regular expression. */
+#ifdef UI_OUT
+void
+rbreak_command_wrapper (char *regexp, int from_tty)
+{
+ rbreak_command (regexp, from_tty);
+}
+#endif
static void
-rbreak_command (regexp, from_tty)
- char *regexp;
- int from_tty;
+rbreak_command (char *regexp, int from_tty)
{
struct symbol_search *ss;
struct symbol_search *p;
struct cleanup *old_chain;
search_symbols (regexp, FUNCTIONS_NAMESPACE, 0, (char **) NULL, &ss);
- old_chain = make_cleanup ((make_cleanup_func) free_search_symbols, ss);
+ old_chain = make_cleanup_free_search_symbols (ss);
for (p = ss; p != NULL; p = p->next)
{
or if a and b have the same pc range.
Return zero otherwise. */
int
-contained_in (a, b)
- struct block *a, *b;
+contained_in (struct block *a, struct block *b)
{
if (!a || !b)
return 0;
characters. If so, add it to the current completion list. */
static void
-completion_list_add_name (symname, sym_text, sym_text_len, text, word)
- char *symname;
- char *sym_text;
- int sym_text_len;
- char *text;
- char *word;
+completion_list_add_name (char *symname, char *sym_text, int sym_text_len,
+ char *text, char *word)
{
int newsize;
int i;
I'm not going to worry about this; hopefully there won't be that many. */
char **
-make_symbol_completion_list (text, word)
- char *text;
- char *word;
+make_symbol_completion_list (char *text, char *word)
{
register struct symbol *sym;
register struct symtab *s;
*/
int
-in_prologue (pc, func_start)
- CORE_ADDR pc;
- CORE_ADDR func_start;
+in_prologue (CORE_ADDR pc, CORE_ADDR func_start)
{
struct symtab_and_line sal;
CORE_ADDR func_addr, func_end;
- if (!find_pc_partial_function (pc, NULL, &func_addr, &func_end))
- goto nosyms; /* Might be in prologue */
-
- sal = find_pc_line (func_addr, 0);
-
- if (sal.line == 0)
- goto nosyms;
-
- /* sal.end is the address of the first instruction past sal.line. */
- if (sal.end > func_addr
- && sal.end <= func_end) /* Is prologue in function? */
- return pc < sal.end; /* Yes, is pc in prologue? */
-
- /* The line after the prologue seems to be outside the function. In this
- case, tell the caller to find the prologue the hard way. */
-
- return 1;
+ /* We have several sources of information we can consult to figure
+ this out.
+ - Compilers usually emit line number info that marks the prologue
+ as its own "source line". So the ending address of that "line"
+ is the end of the prologue. If available, this is the most
+ reliable method.
+ - The minimal symbols and partial symbols, which can usually tell
+ us the starting and ending addresses of a function.
+ - If we know the function's start address, we can call the
+ architecture-defined SKIP_PROLOGUE function to analyze the
+ instruction stream and guess where the prologue ends.
+ - Our `func_start' argument; if non-zero, this is the caller's
+ best guess as to the function's entry point. At the time of
+ this writing, handle_inferior_event doesn't get this right, so
+ it should be our last resort. */
+
+ /* Consult the partial symbol table, to find which function
+ the PC is in. */
+ if (! find_pc_partial_function (pc, NULL, &func_addr, &func_end))
+ {
+ CORE_ADDR prologue_end;
-/* Come here when symtabs don't contain line # info. In this case, it is
- likely that the user has stepped into a library function w/o symbols, or
- is doing a stepi/nexti through code without symbols. */
+ /* We don't even have minsym information, so fall back to using
+ func_start, if given. */
+ if (! func_start)
+ return 1; /* We *might* be in a prologue. */
-nosyms:
+ prologue_end = SKIP_PROLOGUE (func_start);
-/* If func_start is zero (meaning unknown) then we don't know whether pc is
- in the prologue or not. I.E. it might be. */
+ return func_start <= pc && pc < prologue_end;
+ }
- if (!func_start)
- return 1;
+ /* If we have line number information for the function, that's
+ usually pretty reliable. */
+ sal = find_pc_line (func_addr, 0);
-/* We need to call the target-specific prologue skipping functions with the
- function's start address because PC may be pointing at an instruction that
- could be mistakenly considered part of the prologue. */
+ /* Now sal describes the source line at the function's entry point,
+ which (by convention) is the prologue. The end of that "line",
+ sal.end, is the end of the prologue.
+
+ Note that, for functions whose source code is all on a single
+ line, the line number information doesn't always end up this way.
+ So we must verify that our purported end-of-prologue address is
+ *within* the function, not at its start or end. */
+ if (sal.line == 0
+ || sal.end <= func_addr
+ || func_end <= sal.end)
+ {
+ /* We don't have any good line number info, so use the minsym
+ information, together with the architecture-specific prologue
+ scanning code. */
+ CORE_ADDR prologue_end = SKIP_PROLOGUE (func_addr);
- func_start = SKIP_PROLOGUE (func_start);
+ return func_addr <= pc && pc < prologue_end;
+ }
- return pc < func_start;
+ /* We have line number info, and it looks good. */
+ return func_addr <= pc && pc < sal.end;
}
characters. If so, add it to the current completion list. */
static void
-overload_list_add_symbol (sym, oload_name)
- struct symbol *sym;
- char *oload_name;
+overload_list_add_symbol (struct symbol *sym, char *oload_name)
{
int newsize;
int i;
/* skip symbols that cannot match */
if (strcmp (sym_name, oload_name) != 0)
- return;
+ {
+ free (sym_name);
+ return;
+ }
/* If there is no type information, we can't do anything, so skip */
if (SYMBOL_TYPE (sym) == NULL)
struct symbol **
-make_symbol_overload_list (fsym)
- struct symbol *fsym;
+make_symbol_overload_list (struct symbol *fsym)
{
register struct symbol *sym;
register struct symtab *s;
register struct partial_symtab *ps;
register struct objfile *objfile;
- register struct minimal_symbol *msymbol;
register struct block *b, *surrounding_static_block = 0;
register int i;
/* The name we are completing on. */
sym_return_val = (struct symbol **) xmalloc ((sym_return_val_size + 1) * sizeof (struct symbol *));
sym_return_val[0] = NULL;
- /* Comment and #if 0 from Rajiv Mirani <mirani@cup.hp.com>.
- However, leaving #if 0's around is uncool. We need to figure out
- what this is really trying to do, decide whether we want that,
- and either fix it or delete it. --- Jim Blandy, Mar 1999 */
-
- /* ??? RM: What in hell is this? overload_list_add_symbol expects a symbol,
- * not a partial_symbol or a minimal_symbol. And it looks at the type field
- * of the symbol, and we don't know the type of minimal and partial symbols
- */
-#if 0
/* Look through the partial symtabs for all symbols which begin
- by matching OLOAD_NAME. Add each one that you find to the list. */
+ by matching OLOAD_NAME. Make sure we read that symbol table in. */
ALL_PSYMTABS (objfile, ps)
{
{
/* If interrupted, then quit. */
QUIT;
- overload_list_add_symbol (*psym, oload_name);
+ /* This will cause the symbol table to be read if it has not yet been */
+ s = PSYMTAB_TO_SYMTAB (ps);
}
for (psym = objfile->static_psymbols.list + ps->statics_offset;
psym++)
{
QUIT;
- overload_list_add_symbol (*psym, oload_name);
+ /* This will cause the symbol table to be read if it has not yet been */
+ s = PSYMTAB_TO_SYMTAB (ps);
}
}
- /* At this point scan through the misc symbol vectors and add each
- symbol you find to the list. Eventually we want to ignore
- anything that isn't a text symbol (everything else will be
- handled by the psymtab code above). */
-
- ALL_MSYMBOLS (objfile, msymbol)
- {
- QUIT;
- overload_list_add_symbol (msymbol, oload_name);
- }
-#endif
-
/* Search upwards from currently selected frame (so that we can
complete on local vars. */
\f
void
-_initialize_symtab ()
+_initialize_symtab (void)
{
add_info ("variables", variables_info,
"All global and static variable names, or those matching REGEXP.");
add_info ("functions", functions_info,
"All function names, or those matching REGEXP.");
+
/* FIXME: This command has at least the following problems:
1. It prints builtin types (in a very strange and confusing fashion).
2. It doesn't print right, e.g. with