aboutsummaryrefslogtreecommitdiff
path: root/gdb/parse.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2012-12-07 20:09:11 +0000
committerTom Tromey <tromey@redhat.com>2012-12-07 20:09:11 +0000
commit2f68a89553836f68b8676beda9287c93e489bc6e (patch)
tree660cfb00b6001f1f1c3ee19051b85682cf2ce286 /gdb/parse.c
parent155da5173d74221a3099c22c27de1e8e2214982b (diff)
downloadgdb-2f68a89553836f68b8676beda9287c93e489bc6e.zip
gdb-2f68a89553836f68b8676beda9287c93e489bc6e.tar.gz
gdb-2f68a89553836f68b8676beda9287c93e489bc6e.tar.bz2
* ada-lang.c (ada_make_symbol_completion_list): Add 'code'
argument, assertion. * c-exp.y (typebase): Add completion productions. * completer.c (expression_completer): Handle tag completion. * expression.h (parse_expression_for_completion): Add argument. * f-lang.c (f_make_symbol_completion_list): Add 'code' argument. * language.h (struct language_defn) <la_make_symbol_completion_list>: Add 'code' argument. * parse.c (expout_tag_completion_type, expout_completion_name): New globals. (mark_struct_expression): Add assertion. (mark_completion_tag): New function. (parse_exp_in_context): Initialize new globals. (parse_expression_for_completion): Add 'code' argument. Handle tag completion. * parser-defs.h (mark_completion_tag): Declare. * symtab.c (default_make_symbol_completion_list_break_on): Add 'code' argument. Update. (default_make_symbol_completion_list): Add 'code' argument. (make_symbol_completion_list): Update. (make_symbol_completion_type): New function. * symtab.h (default_make_symbol_completion_list_break_on) (default_make_symbol_completion_list): Update. (make_symbol_completion_type): Declare. testsuite * gdb.base/break1.c (enum some_enum, union some_union): New. (some_enum_global, some_union_global, some_value): New globals. * gdb.base/completion.exp: Add tag completion tests.
Diffstat (limited to 'gdb/parse.c')
-rw-r--r--gdb/parse.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/gdb/parse.c b/gdb/parse.c
index 984c0d2..8e558e3 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -88,6 +88,13 @@ int parse_completion;
'->'. This is set when parsing and is only used when completing a
field name. It is -1 if no dereference operation was found. */
static int expout_last_struct = -1;
+
+/* If we are completing a tagged type name, this will be nonzero. */
+static enum type_code expout_tag_completion_type = TYPE_CODE_UNDEF;
+
+/* The token for tagged type name completion. */
+static char *expout_completion_name;
+
static unsigned int expressiondebug = 0;
static void
@@ -578,9 +585,32 @@ write_exp_msymbol (struct minimal_symbol *msymbol)
void
mark_struct_expression (void)
{
+ gdb_assert (parse_completion
+ && expout_tag_completion_type == TYPE_CODE_UNDEF);
expout_last_struct = expout_ptr;
}
+/* Indicate that the current parser invocation is completing a tag.
+ TAG is the type code of the tag, and PTR and LENGTH represent the
+ start of the tag name. */
+
+void
+mark_completion_tag (enum type_code tag, const char *ptr, int length)
+{
+ gdb_assert (parse_completion
+ && expout_tag_completion_type == TYPE_CODE_UNDEF
+ && expout_completion_name == NULL
+ && expout_last_struct == -1);
+ gdb_assert (tag == TYPE_CODE_UNION
+ || tag == TYPE_CODE_STRUCT
+ || tag == TYPE_CODE_CLASS
+ || tag == TYPE_CODE_ENUM);
+ expout_tag_completion_type = tag;
+ expout_completion_name = xmalloc (length + 1);
+ memcpy (expout_completion_name, ptr, length);
+ expout_completion_name[length] = '\0';
+}
+
/* Recognize tokens that start with '$'. These include:
@@ -1124,6 +1154,9 @@ parse_exp_in_context (char **stringptr, CORE_ADDR pc, const struct block *block,
paren_depth = 0;
type_stack.depth = 0;
expout_last_struct = -1;
+ expout_tag_completion_type = TYPE_CODE_UNDEF;
+ xfree (expout_completion_name);
+ expout_completion_name = NULL;
comma_terminates = comma;
@@ -1244,7 +1277,8 @@ parse_expression (char *string)
*NAME must be freed by the caller. */
struct type *
-parse_expression_for_completion (char *string, char **name)
+parse_expression_for_completion (char *string, char **name,
+ enum type_code *code)
{
struct expression *exp = NULL;
struct value *val;
@@ -1259,6 +1293,15 @@ parse_expression_for_completion (char *string, char **name)
parse_completion = 0;
if (except.reason < 0 || ! exp)
return NULL;
+
+ if (expout_tag_completion_type != TYPE_CODE_UNDEF)
+ {
+ *code = expout_tag_completion_type;
+ *name = expout_completion_name;
+ expout_completion_name = NULL;
+ return NULL;
+ }
+
if (expout_last_struct == -1)
{
xfree (exp);