/* Symbol table lookup for the GNU debugger, GDB.
Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
- 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008
+ 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2007, 2008, 2009
Free Software Foundation, Inc.
This file is part of GDB.
#include "observer.h"
#include "gdb_assert.h"
#include "solist.h"
+#include "macrotab.h"
+#include "macroscope.h"
/* Prototypes for local functions */
not include the data ranges. */
msymbol = lookup_minimal_symbol_by_pc_section (pc, section);
if (msymbol
- && (msymbol->type == mst_data
- || msymbol->type == mst_bss
- || msymbol->type == mst_abs
- || msymbol->type == mst_file_data
- || msymbol->type == mst_file_bss))
+ && (MSYMBOL_TYPE (msymbol) == mst_data
+ || MSYMBOL_TYPE (msymbol) == mst_bss
+ || MSYMBOL_TYPE (msymbol) == mst_abs
+ || MSYMBOL_TYPE (msymbol) == mst_file_data
+ || MSYMBOL_TYPE (msymbol) == mst_file_bss))
return NULL;
/* Try just the PSYMTABS_ADDRMAP mapping first as it has better granularity
on the partial_symtab's texthigh and textlow. */
msymbol = lookup_minimal_symbol_by_pc_section (pc, section);
if (msymbol
- && (msymbol->type == mst_data
- || msymbol->type == mst_bss
- || msymbol->type == mst_abs
- || msymbol->type == mst_file_data
- || msymbol->type == mst_file_bss))
+ && (MSYMBOL_TYPE (msymbol) == mst_data
+ || MSYMBOL_TYPE (msymbol) == mst_bss
+ || MSYMBOL_TYPE (msymbol) == mst_abs
+ || MSYMBOL_TYPE (msymbol) == mst_file_data
+ || MSYMBOL_TYPE (msymbol) == mst_file_bss))
return NULL;
/* Search all symtabs for the one whose file contains our address, and which
Only symbols of KIND are searched:
FUNCTIONS_DOMAIN - search all functions
TYPES_DOMAIN - search all type names
- METHODS_DOMAIN - search all methods NOT IMPLEMENTED
VARIABLES_DOMAIN - search all symbols, excluding functions, type names,
and constants (enums)
&& ((kind == VARIABLES_DOMAIN && SYMBOL_CLASS (*psym) != LOC_TYPEDEF
&& SYMBOL_CLASS (*psym) != LOC_BLOCK)
|| (kind == FUNCTIONS_DOMAIN && SYMBOL_CLASS (*psym) == LOC_BLOCK)
- || (kind == TYPES_DOMAIN && SYMBOL_CLASS (*psym) == LOC_TYPEDEF)
- || (kind == METHODS_DOMAIN && SYMBOL_CLASS (*psym) == LOC_BLOCK))))
+ || (kind == TYPES_DOMAIN && SYMBOL_CLASS (*psym) == LOC_TYPEDEF))))
{
PSYMTAB_TO_SYMTAB (ps);
keep_going = 0;
&& SYMBOL_CLASS (sym) != LOC_BLOCK
&& SYMBOL_CLASS (sym) != LOC_CONST)
|| (kind == FUNCTIONS_DOMAIN && SYMBOL_CLASS (sym) == LOC_BLOCK)
- || (kind == TYPES_DOMAIN && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
- || (kind == METHODS_DOMAIN && SYMBOL_CLASS (sym) == LOC_BLOCK))))
+ || (kind == TYPES_DOMAIN && SYMBOL_CLASS (sym) == LOC_TYPEDEF))))
{
/* match */
psr = (struct symbol_search *) xmalloc (sizeof (struct symbol_search));
return p;
}
+/* Type of the user_data argument passed to add_macro_name. The
+ contents are simply whatever is needed by
+ completion_list_add_name. */
+struct add_macro_name_data
+{
+ char *sym_text;
+ int sym_text_len;
+ char *text;
+ char *word;
+};
+
+/* 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,
+ void *user_data)
+{
+ struct add_macro_name_data *datum = (struct add_macro_name_data *) user_data;
+ completion_list_add_name ((char *) name,
+ datum->sym_text, datum->sym_text_len,
+ datum->text, datum->word);
+}
+
char **
default_make_symbol_completion_list (char *text, char *word)
{
}
}
+ if (current_language->la_macro_expansion == macro_expansion_c)
+ {
+ struct macro_scope *scope;
+ struct add_macro_name_data datum;
+
+ datum.sym_text = sym_text;
+ datum.sym_text_len = sym_text_len;
+ datum.text = text;
+ datum.word = word;
+
+ /* Add any macros visible in the default scope. Note that this
+ may yield the occasional wrong result, because an expression
+ might be evaluated in a scope other than the default. For
+ example, if the user types "break file:line if <TAB>", the
+ resulting expression will be evaluated at "file:line" -- but
+ at there does not seem to be a way to detect this at
+ completion time. */
+ scope = default_macro_scope ();
+ if (scope)
+ {
+ macro_for_each_in_scope (scope->file, scope->line,
+ add_macro_name, &datum);
+ xfree (scope);
+ }
+
+ /* User-defined macros are always visible. */
+ macro_for_each (macro_user_macros, add_macro_name, &datum);
+ }
+
return (return_val);
}