public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Add completion for Ada catch commands
@ 2019-05-10 15:58 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2019-05-10 15:58 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=71bed2dba6c0706633ead4994cc89e063abf28ea
commit 71bed2dba6c0706633ead4994cc89e063abf28ea
Author: Tom Tromey <tromey@adacore.com>
Date: Fri May 3 17:03:40 2019 -0600
Add completion for Ada catch commands
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.
Diff:
---
gdb/ChangeLog | 5 +++++
gdb/ada-lang.c | 20 ++++++++++++++++++--
gdb/testsuite/ChangeLog | 4 ++++
gdb/testsuite/gdb.ada/info_exc.exp | 4 ++++
4 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 82d6206..f1c39a4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
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.
* gdbthread.h (print_thread_info): Make "requested_threads"
const.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index e513280..dee3a83 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -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", _("\
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 867dc87..252a183 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -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
diff --git a/gdb/testsuite/gdb.ada/info_exc.exp b/gdb/testsuite/gdb.ada/info_exc.exp
index 9a11709..48bd2cd 100644
--- a/gdb/testsuite/gdb.ada/info_exc.exp
+++ b/gdb/testsuite/gdb.ada/info_exc.exp
@@ -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"
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-05-10 15:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-10 15:58 [binutils-gdb] Add completion for Ada catch commands Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).