aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.c
diff options
context:
space:
mode:
authorTom Tromey <tromey@redhat.com>2012-06-13 15:50:22 +0000
committerTom Tromey <tromey@redhat.com>2012-06-13 15:50:22 +0000
commitd55637df6923689396e58c3d789e82314f4826ec (patch)
tree09d54ca9515512c682efdaad9febaa1983c0d8ae /gdb/breakpoint.c
parent49c4e619f81a66545e2332dc218d9bf31bbb51ad (diff)
downloadgdb-d55637df6923689396e58c3d789e82314f4826ec.zip
gdb-d55637df6923689396e58c3d789e82314f4826ec.tar.gz
gdb-d55637df6923689396e58c3d789e82314f4826ec.tar.bz2
* breakpoint.c (condition_completer): New function.
(_initialize_breakpoint): Use it. * value.c (complete_internalvar): New function. * value.h (complete_internalvar): Declare. testsuite * gdb.base/condbreak.exp: Add tests for "condition" completion.
Diffstat (limited to 'gdb/breakpoint.c')
-rw-r--r--gdb/breakpoint.c59
1 files changed, 58 insertions, 1 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index d76065d..82265cc 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -947,6 +947,62 @@ set_breakpoint_condition (struct breakpoint *b, char *exp,
observer_notify_breakpoint_modified (b);
}
+/* Completion for the "condition" command. */
+
+static VEC (char_ptr) *
+condition_completer (struct cmd_list_element *cmd, char *text, char *word)
+{
+ char *space;
+
+ text = skip_spaces (text);
+ space = skip_to_space (text);
+ if (*space == '\0')
+ {
+ int len;
+ struct breakpoint *b;
+ VEC (char_ptr) *result = NULL;
+
+ if (text[0] == '$')
+ {
+ /* We don't support completion of history indices. */
+ if (isdigit (text[1]))
+ return NULL;
+ return complete_internalvar (&text[1]);
+ }
+
+ /* We're completing the breakpoint number. */
+ len = strlen (text);
+
+ ALL_BREAKPOINTS (b)
+ {
+ int single = b->loc->next == NULL;
+ struct bp_location *loc;
+ int count = 1;
+
+ for (loc = b->loc; loc; loc = loc->next)
+ {
+ char location[50];
+
+ if (single)
+ sprintf (location, "%d", b->number);
+ else
+ sprintf (location, "%d.%d", b->number, count);
+
+ if (strncmp (location, text, len) == 0)
+ VEC_safe_push (char_ptr, result, xstrdup (location));
+
+ ++count;
+ }
+ }
+
+ return result;
+ }
+
+ /* We're completing the expression part. */
+ text = skip_spaces (space);
+ return expression_completer (cmd, text, word);
+}
+
/* condition N EXP -- set break condition of breakpoint N to EXP. */
static void
@@ -15528,10 +15584,11 @@ Type a line containing \"end\" to indicate the end of them.\n\
Give \"silent\" as the first line to make the breakpoint silent;\n\
then no output is printed when it is hit, except what the commands print."));
- add_com ("condition", class_breakpoint, condition_command, _("\
+ c = add_com ("condition", class_breakpoint, condition_command, _("\
Specify breakpoint number N to break only if COND is true.\n\
Usage is `condition N COND', where N is an integer and COND is an\n\
expression to be evaluated whenever breakpoint N is reached."));
+ set_cmd_completer (c, condition_completer);
c = add_com ("tbreak", class_breakpoint, tbreak_command, _("\
Set a temporary breakpoint.\n\