aboutsummaryrefslogtreecommitdiff
path: root/gdb/linespec.c
diff options
context:
space:
mode:
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>2020-12-07 09:20:31 +0100
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>2020-12-07 09:22:06 +0100
commit5759831a2d06600a7eae4697417a388444c8e13b (patch)
treec9d0045d36dded7286e2f52b63978d63f162b828 /gdb/linespec.c
parent21e051b3d666bcd614391142a936a8a8cccfa3cb (diff)
downloadbinutils-5759831a2d06600a7eae4697417a388444c8e13b.zip
binutils-5759831a2d06600a7eae4697417a388444c8e13b.tar.gz
binutils-5759831a2d06600a7eae4697417a388444c8e13b.tar.bz2
gdb/linespec: relax the position of the '-force-condition' flag
The break command's "-force-condition" flag is currently required to be followed by the "if" keyword. This prevents flexibility when using other keywords, e.g. "thread": (gdb) break main -force-condition thread 1 if foo Function "main -force-condition" not defined. Make breakpoint pending on future shared library load? (y or [n]) n Remove the requirement that "-force-condition" is always followed by an "if", so that more flexibility is obtained when positioning keywords. gdb/ChangeLog: 2020-12-07 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * linespec.c (linespec_lexer_lex_keyword): The "-force-condition" keyword may be followed by any keyword. * breakpoint.c (find_condition_and_thread): Advance 'tok' by 'toklen' in the case for "-force-condition". gdb/testsuite/ChangeLog: 2020-12-07 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> * gdb.linespec/keywords.exp: Add tests to check positional flexibility of "-force-condition".
Diffstat (limited to 'gdb/linespec.c')
-rw-r--r--gdb/linespec.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 3bf16c5..9af8e52 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -477,32 +477,45 @@ linespec_lexer_lex_keyword (const char *p)
{
int len = strlen (linespec_keywords[i]);
- /* If P begins with one of the keywords and the next
- character is whitespace, we may have found a keyword.
- It is only a keyword if it is not followed by another
- keyword. */
- if (strncmp (p, linespec_keywords[i], len) == 0
- && isspace (p[len]))
+ /* If P begins with
+
+ - "thread" or "task" and the next character is
+ whitespace, we may have found a keyword. It is only a
+ keyword if it is not followed by another keyword.
+
+ - "-force-condition", the next character may be EOF
+ since this keyword does not take any arguments. Otherwise,
+ it should be followed by a keyword.
+
+ - "if", ALWAYS stop the lexer, since it is not possible to
+ predict what is going to appear in the condition, which can
+ only be parsed after SaLs have been found. */
+ if (strncmp (p, linespec_keywords[i], len) == 0)
{
int j;
- /* Special case: "-force" is always followed by an "if". */
+ if (i == FORCE_KEYWORD_INDEX && p[len] == '\0')
+ return linespec_keywords[i];
+
+ if (!isspace (p[len]))
+ continue;
+
if (i == FORCE_KEYWORD_INDEX)
{
p += len;
p = skip_spaces (p);
- int nextlen = strlen (linespec_keywords[IF_KEYWORD_INDEX]);
- if (!(strncmp (p, linespec_keywords[IF_KEYWORD_INDEX], nextlen) == 0
- && isspace (p[nextlen])))
- return NULL;
- }
+ for (j = 0; linespec_keywords[j] != NULL; ++j)
+ {
+ int nextlen = strlen (linespec_keywords[j]);
- /* Special case: "if" ALWAYS stops the lexer, since it
- is not possible to predict what is going to appear in
- the condition, which can only be parsed after SaLs have
- been found. */
+ if (strncmp (p, linespec_keywords[j], nextlen) == 0
+ && isspace (p[nextlen]))
+ return linespec_keywords[i];
+ }
+ }
else if (i != IF_KEYWORD_INDEX)
{
+ /* We matched a "thread" or "task". */
p += len;
p = skip_spaces (p);
for (j = 0; linespec_keywords[j] != NULL; ++j)