stop parsing breakpoint command if invalid keyword found

With an Ada program, trying to break on a specific Ada task, but
with the wrong capitalization of the `task' keyword, we currently
get only pieces of the "garbage" that caused the error:

    (gdb) b *rendez_vous'address TASK 2
    Garbage 2 at end of command

Pushing this a little further:

    (gdb) b *rendez_vous'address TASK Task TaSK 2
    Garbage 2 at end of command

Another interesting failure mode:

    (gdb) b *rendez_vous'address TASK if
    Argument required (expression to compute).

The parser skipped `TASK', then found the `if' keyword, and thus
started looking for a condition.

This patch fixes the problem by aborting the parsing as soon as
an invalid keyword is found.  This makes it consistent with the
case where the REST parameter is passed as NULL (where an error
is raised immediately after seeing the first invalid keyword).

It also introduces a new testcase that reproduces all above scenarios.

gdb/ChangeLog:

        * breakpoint.c (find_condition_and_thread): Stop parsing
        as soon as the first invalid keyword is found.

gdb/testsuite/ChangeLog:

        * gdb.ada/bad-task-bp-keyword: New testcase.
This commit is contained in:
Joel Brobecker
2012-06-05 13:50:13 +00:00
parent e23d4a9c47
commit ccab2054e9
5 changed files with 130 additions and 1 deletions

View File

@@ -8940,7 +8940,7 @@ find_condition_and_thread (char *tok, CORE_ADDR pc,
else if (rest)
{
*rest = savestring (tok, strlen (tok));
tok += toklen;
return;
}
else
error (_("Junk at end of arguments."));