From patchwork Mon Jun 24 23:11:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Waroquiers X-Patchwork-Id: 33366 Received: (qmail 67953 invoked by alias); 24 Jun 2019 23:12:00 -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 67876 invoked by uid 89); 24 Jun 2019 23:12:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=completion, basics, H*Ad:D*be, framea X-HELO: mailsec105.isp.belgacom.be Received: from mailsec105.isp.belgacom.be (HELO mailsec105.isp.belgacom.be) (195.238.20.101) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 24 Jun 2019 23:11:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skynet.be; i=@skynet.be; q=dns/txt; s=securemail; t=1561417917; x=1592953917; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9X82oQkyOuA8IpGmx52cQ75fdT2lutyIGRVhiKkYdpM=; b=t5YmFozeOCMeXqx8qTO/YfVaEM3KZhz2/0/hkxFNPziQ1BN9Rvk5pWHt jC6ckm//4D99U5Um9YsSGPgRFL//PQ==; Received: from 96.218-128-109.adsl-dyn.isp.belgacom.be (HELO md.home) ([109.128.218.96]) by relay.skynet.be with ESMTP/TLS/DHE-RSA-AES128-GCM-SHA256; 25 Jun 2019 01:11:51 +0200 From: Philippe Waroquiers To: gdb-patches@sourceware.org Cc: Philippe Waroquiers Subject: [RFA 2/3] Add tests for new leading-args related commands and arguments. Date: Tue, 25 Jun 2019 01:11:43 +0200 Message-Id: <20190624231144.29220-3-philippe.waroquiers@skynet.be> In-Reply-To: <20190624231144.29220-1-philippe.waroquiers@skynet.be> References: <20190624231144.29220-1-philippe.waroquiers@skynet.be> MIME-Version: 1.0 X-IsSubscribed: yes Test the new leading-args behaviour and completion. Note that gdb.base/leading-args.exp is somewhat copied from with.exp (the test of the with command), while leading-exp.c is a plain copy of with.c. gdb/testsuite/ChangeLog 2019-06-23 Philippe Waroquiers * gdb.base/leading-args.exp: New test. * gdb.base/leading.c: New file. --- gdb/testsuite/gdb.base/leading-args.c | 41 +++++++ gdb/testsuite/gdb.base/leading-args.exp | 155 ++++++++++++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 gdb/testsuite/gdb.base/leading-args.c create mode 100644 gdb/testsuite/gdb.base/leading-args.exp diff --git a/gdb/testsuite/gdb.base/leading-args.c b/gdb/testsuite/gdb.base/leading-args.c new file mode 100644 index 0000000000..c6426625d4 --- /dev/null +++ b/gdb/testsuite/gdb.base/leading-args.c @@ -0,0 +1,41 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2019 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +int xxx1 = 123; + +struct S +{ + int a; + int b; + int c; +}; + +struct S g_s = {1, 2, 3}; + +static void +inc () +{ + g_s.a++;; +} + +int +main () +{ + inc (); + + return 0; +} diff --git a/gdb/testsuite/gdb.base/leading-args.exp b/gdb/testsuite/gdb.base/leading-args.exp new file mode 100644 index 0000000000..e419cceab8 --- /dev/null +++ b/gdb/testsuite/gdb.base/leading-args.exp @@ -0,0 +1,155 @@ +# This testcase is part of GDB, the GNU debugger. + +# Copyright 2019 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test the "leading-args" related commands and arguments. + +load_lib completion-support.exp + +standard_testfile .c + +if {[build_executable "failed to prepare" $testfile $srcfile debug]} { + return -1 +} + +clean_restart $binfile + +# Basic/core tests using user-visible commands. +with_test_prefix "basics" { + # Define an alias to pretty print something. + gdb_test "print g_s" " = {a = 1, b = 2, c = 3}" "simple print" + gdb_test_no_output "alias PP = print = -pretty --" "alias PP" + gdb_test "show leading-args PP" "leading-args PP = -pretty --" + gdb_test "PP g_s" \ + [multi_line \ + " = {" \ + " a = 1," \ + " b = 2," \ + " c = 3" \ + "}"] + + # Define leading-args for "inspect", should not impact "print". + gdb_test_no_output "set leading-args inspect = -pretty --" "inspect -pretty" + gdb_test "show leading-args inspect" "leading-args inspect = -pretty --" + gdb_test "print g_s" " = {a = 1, b = 2, c = 3}" "simple print not impacted" + gdb_test "inspect g_s" \ + [multi_line \ + " = {" \ + " a = 1," \ + " b = 2," \ + " c = 3" \ + "}"] + + # Set hex as default FMT for print. + gdb_test_no_output "set leading-args print = -- /x" "print hex" + gdb_test "inspect g_s" \ + [multi_line \ + " = {" \ + " a = 1," \ + " b = 2," \ + " c = 3" \ + "}"] "inspect g_s still pretty" + gdb_test "print g_s" " = {a = 0x1, b = 0x2, c = 0x3}" "simple print hex" + + # Test disabling leading args. + gdb_test "show enable-leading-args" \ + "Whether GDB prepends leading args when running a command is on\." + gdb_test_no_output "set enable-leading-args off" + gdb_test "print g_s" " = {a = 1, b = 2, c = 3}" \ + "simple print with enable-leading-args off" + gdb_test_no_output "set enable-leading-args on" + + + # Define leading-args for an alias of frame apply all + gdb_test_no_output "alias frame apply tout = frame apply all = -past-entry -past-main" \ + "alias frame apply tout" + gdb_test "show leading-args frame apply tout" \ + "leading-args frame apply tout = -past-entry -past-main" + + # Show all leading args. + gdb_test "show leading-args" \ + [multi_line \ + "leading-args PP = -pretty --" \ + "leading-args frame apply tout = -past-entry -past-main" \ + "leading-args inspect = -pretty --" \ + "leading-args print = -- /x"] "show leading-args" + + # Clear the leading-args of "inspect". + gdb_test_no_output "set leading-args inspect" "clear inspect leading-args" + gdb_test "show leading-args inspect" "leading-args inspect = " + gdb_test "inspect g_s" " = {a = 1, b = 2, c = 3}" "simple inspect" + +} + +# Check errors. +with_test_prefix "errors" { + # Try both an unknown root setting and an unknown prefixed + # setting. The errors come from different locations in the + # sources. + gdb_test "set leading-args xxxx yyyy = -someoption" \ + "Undefined command: \"xxxx\". Try \"help\"\\." + gdb_test "set leading-args frame apply everyframe = -someoption" \ + "Junk after command \"frame apply \": everyframe = -someoption" + + # Try ambiguous command. + gdb_test "set leading-args a" \ + "Ambiguous command \"a\":.*" "ambiguous a" + gdb_test "set leading-args frame a" \ + "Ambiguous frame command \"a\":.*" "ambiguous frame a" +} + + +# Check completion. +with_test_prefix "completion" { + test_gdb_complete_unique \ + "alias set pri" \ + "alias set print" + + test_gdb_complete_unique \ + "alias set print items = set pri" \ + "alias set print items = set print" + + test_gdb_complete_unique \ + "alias set print items = set print ele" \ + "alias set print items = set print elements" + + test_gdb_complete_unique \ + "alias btfu = backt" \ + "alias btfu = backtrace" + + test_gdb_complete_unique \ + "alias btfu = backtrace = -fu" \ + "alias btfu = backtrace = -full" + + test_gdb_complete_unique \ + "alias btfu = backtrace = -full -past-e" \ + "alias btfu = backtrace = -full -past-entry" + + gdb_test_no_output "alias btfu = backtrace = -full -past-entry" \ + "alias btfu" + + # Test completion of 'set leading-args' (sharing most + # of the code that alias command uses to complete after + # the first =. + test_gdb_complete_unique \ + "set leading-args btf" \ + "set leading-args btfu" + + test_gdb_complete_unique \ + "set leading-args btfu = -frame-a" \ + "set leading-args btfu = -frame-arguments" + +}