]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/completer: improve tab completion to consider the '-force-condition' flag
authorTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Mon, 7 Dec 2020 08:28:33 +0000 (09:28 +0100)
committerTankut Baris Aktemur <tankut.baris.aktemur@intel.com>
Mon, 7 Dec 2020 08:31:00 +0000 (09:31 +0100)
The commit

  commit 733d554a4625db4ffb89b7a20e1cf27ab071ef4d
  Author: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
  Date:   Tue Oct 27 10:56:03 2020 +0100

  gdb/breakpoint: add flags to 'condition' and 'break' commands to force condition

introduced the '-force-condition' flag to the 'break' command.  This
flag was defined as a keyword like 'thread', 'task', and 'if'.
However, it starts with '-'.  This difference caused an uncovered case
when tab-completing a seemingly complete linespec.

Below, we see "-force-condition" in the completion list, where both
the options and the keywords are listed:

  (gdb) break -function main <TAB>
  -force-condition  -function  -label  -line  -qualified
  -source           if         task    thread

But tab-completing '-' lists only options:

  (gdb) break -function main -<TAB>
  -function   -label      -line       -qualified  -source

This patch fixes the problem by adding keywords to the completion
list, so that we see:

  (gdb) break -function main -<TAB>
  -force-condition  -function  -label  -line  -qualified  -source

gdb/ChangeLog:
2020-12-07  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* completer.c (complete_explicit_location): Also add keywords
that start with '-' to the completion list.

gdb/testsuite/ChangeLog:
2020-12-07  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

* gdb.linespec/explicit.exp: Extend with a test to check completing
'-' after seemingly complete options.

gdb/ChangeLog
gdb/completer.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.linespec/explicit.exp

index 60b3ce44af295644bddc5542cab214a5384d2fc2..bea7a5b67b4a8b2628358861a924537272e63b28 100644 (file)
@@ -1,3 +1,8 @@
+2020-12-07  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
+
+       * completer.c (complete_explicit_location): Also add keywords
+       that start with '-' to the completion list.
+
 2020-12-07  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
 
        * linespec.c (linespec_lexer_lex_keyword): The "-force-condition"
index 83b46a0e4d89f1c805bdf13d06fedc730736478c..7f63ced93d8e486a698c2862fb19dcb77ce0a5f3 100644 (file)
@@ -892,7 +892,11 @@ complete_explicit_location (completion_tracker &tracker,
   int keyword = skip_keyword (tracker, explicit_options, &text);
 
   if (keyword == -1)
-    complete_on_enum (tracker, explicit_options, text, text);
+    {
+      complete_on_enum (tracker, explicit_options, text, text);
+      /* There are keywords that start with "-".   Include them, too.  */
+      complete_on_enum (tracker, linespec_keywords, text, text);
+    }
   else
     {
       /* Completing on value.  */
index 3c28bc75a663f82f619a8017bdf3a28c1b129b66..f5219ea182fb9ce47c5b92434f085f2c44722f5d 100644 (file)
@@ -1,3 +1,8 @@
+2020-12-07  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
+
+       * gdb.linespec/explicit.exp: Extend with a test to check completing
+       '-' after seemingly complete options.
+
 2020-12-07  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>
 
        * gdb.linespec/keywords.exp: Add tests to check positional
index 52a1fce537105f0710dcd9a9d9a3eadf6c93cfeb..c33ab505e347256294695a3098ff097351f94167 100644 (file)
@@ -469,6 +469,20 @@ namespace eval $testfile {
            }
        }
 
+       # Test that after a seemingly finished option argument,
+       # completion for "-" matches both the explicit location
+       # options and the linespec keywords that start with "-".
+       with_test_prefix "complete '-' after options" {
+           test_gdb_complete_multiple "b -function myfunction " "-" "" {
+               "-force-condition"
+               "-function"
+               "-label"
+               "-line"
+               "-qualified"
+               "-source"
+           }
+       }
+
        # Tests that ensure that after "if" we complete on expressions
        # are in cpcompletion.exp.