From patchwork Fri May 10 15:58:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 32635 Received: (qmail 122162 invoked by alias); 10 May 2019 15:58:16 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 122153 invoked by uid 89); 10 May 2019 15:58:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=Joel, joel X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 10 May 2019 15:58:15 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 9A8911179C1; Fri, 10 May 2019 11:58:13 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id yC3TMW3l8gbQ; Fri, 10 May 2019 11:58:13 -0400 (EDT) Received: from murgatroyd.Home (97-122-168-123.hlrn.qwest.net [97.122.168.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPSA id 4603F1179C3; Fri, 10 May 2019 11:58:13 -0400 (EDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [FYI] Add completion for Ada catch commands Date: Fri, 10 May 2019 09:58:10 -0600 Message-Id: <20190510155810.23696-1-tromey@adacore.com> MIME-Version: 1.0 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 * ada-lang.c (catch_ada_completer): New function. (_initialize_ada_language): Use it. gdb/testsuite/ChangeLog 2019-05-10 Tom Tromey * gdb.ada/info_exc.exp: Add "complete" test. --- 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/ada-lang.c b/gdb/ada-lang.c index e513280a415..dee3a83f98c 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 exceptions = ada_exceptions_list (NULL); + + for (const ada_exc_info &info : exceptions) + { + if (startswith (info.name, word)) + tracker.add_completion + (gdb::unique_xmalloc_ptr (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/gdb.ada/info_exc.exp b/gdb/testsuite/gdb.ada/info_exc.exp index 9a117094586..48bd2cd96f0 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" +}