Add completion for Ada catch commands
authorTom Tromey <tromey@adacore.com>
Fri, 3 May 2019 23:03:40 +0000 (17:03 -0600)
committerTom Tromey <tromey@adacore.com>
Fri, 10 May 2019 15:57:42 +0000 (09:57 -0600)
This patch adds a completion function to the "catch exception"
and "catch handlers" commands.

Tested on x86-64 Fedora 29; reviewed off-list by Joel.

gdb/ChangeLog
2019-05-10  Tom Tromey  <tromey@adacore.com>

* ada-lang.c (catch_ada_completer): New function.
(_initialize_ada_language): Use it.

gdb/testsuite/ChangeLog
2019-05-10  Tom Tromey  <tromey@adacore.com>

* gdb.ada/info_exc.exp: Add "complete" test.

gdb/ChangeLog
gdb/ada-lang.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ada/info_exc.exp

index 82d6206f72670e611b3ccc710ee2749d1dc3e9fc..f1c39a4aa3f784a1abcf9700b7cfc4e17091ed42 100644 (file)
@@ -1,3 +1,8 @@
+2019-05-10  Tom Tromey  <tromey@adacore.com>
+
+       * ada-lang.c (catch_ada_completer): New function.
+       (_initialize_ada_language): Use it.
+
 2019-05-10  Tom Tromey  <tromey@adacore.com>
 
        * thread.c (print_thread_info): Make "requested_threads" const.
index e513280a415d5368a9a8ddd3d416637f88016847..dee3a83f98c24854777f967b7998616e65e90b2c 100644 (file)
@@ -13342,6 +13342,22 @@ catch_ada_handlers_command (const char *arg_entry, int from_tty,
                                   from_tty);
 }
 
+/* Completion function for the Ada "catch" commands.  */
+
+static void
+catch_ada_completer (struct cmd_list_element *cmd, completion_tracker &tracker,
+                    const char *text, const char *word)
+{
+  std::vector<ada_exc_info> exceptions = ada_exceptions_list (NULL);
+
+  for (const ada_exc_info &info : exceptions)
+    {
+      if (startswith (info.name, word))
+       tracker.add_completion
+         (gdb::unique_xmalloc_ptr<char> (xstrdup (info.name)));
+    }
+}
+
 /* Split the arguments specified in a "catch assert" command.
 
    ARGS contains the command's arguments (or the empty string if
@@ -14562,7 +14578,7 @@ termination).\n\
 Otherwise, the catchpoint only stops when the name of the exception being\n\
 raised is the same as ARG."),
                     catch_ada_exception_command,
-                     NULL,
+                    catch_ada_completer,
                     CATCH_PERMANENT,
                     CATCH_TEMPORARY);
 
@@ -14570,7 +14586,7 @@ raised is the same as ARG."),
 Catch Ada exceptions, when handled.\n\
 With an argument, catch only exceptions with the given name."),
                     catch_ada_handlers_command,
-                     NULL,
+                     catch_ada_completer,
                     CATCH_PERMANENT,
                     CATCH_TEMPORARY);
   add_catch_command ("assert", _("\
index 867dc874ccca952f57c953f933155d613bd1732c..252a183d979c1e75047a8a29b26a3c271ee68729 100644 (file)
@@ -1,3 +1,7 @@
+2019-05-10  Tom Tromey  <tromey@adacore.com>
+
+       * gdb.ada/info_exc.exp: Add "complete" test.
+
 2019-05-09  Tom de Vries  <tdevries@suse.de>
 
        * gdb.arch/amd64-tailcall-self.S: Make DW_FORM_ref4 references
index 9a11709458640577a577849dd4d8f8b0fae527bc..48bd2cd96f033ceaa94f4bff3309a29cf8d550ae 100644 (file)
@@ -49,3 +49,7 @@ gdb_test "info exceptions const.aint" \
                 "constraint_error: $hex" \
                 "const.aint_global_gdb_e: $hex"]
 
+foreach cmd {exception handlers} {
+    gdb_test "complete catch $cmd const.a" \
+       "catch $cmd const.aint_global_gdb_e"
+}