From patchwork Sat Apr 13 19:00:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Waroquiers X-Patchwork-Id: 32279 Received: (qmail 25459 invoked by alias); 13 Apr 2019 19:00:42 -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 25389 invoked by uid 89); 13 Apr 2019 19:00:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.3 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=combinations X-HELO: mailsec106.isp.belgacom.be Received: from mailsec106.isp.belgacom.be (HELO mailsec106.isp.belgacom.be) (195.238.20.102) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 13 Apr 2019 19:00:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skynet.be; i=@skynet.be; q=dns/txt; s=securemail; t=1555182039; x=1586718039; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K9rxxBCQQ2lSX0lpFmQPLP10ELFxI8nDhDbirccYUtQ=; b=DN4tAXeiMUbAjWJ9297mjRvBdo8DJEyrvupHTXLKIM7oSy1uUDrf6Tn9 Tu0rJQrxzzwgTo5dIvwqqiMZFz+lkg==; Received: from 212.135-131-109.adsl-dyn.isp.belgacom.be (HELO md.home) ([109.131.135.212]) by relay.skynet.be with ESMTP/TLS/DHE-RSA-AES128-GCM-SHA256; 13 Apr 2019 21:00:34 +0200 From: Philippe Waroquiers To: gdb-patches@sourceware.org Cc: Philippe Waroquiers Subject: [RFA 2/3] Test for slash_command. Date: Sat, 13 Apr 2019 21:00:15 +0200 Message-Id: <20190413190016.11970-3-philippe.waroquiers@skynet.be> In-Reply-To: <20190413190016.11970-1-philippe.waroquiers@skynet.be> References: <20190413190016.11970-1-philippe.waroquiers@skynet.be> MIME-Version: 1.0 X-IsSubscribed: yes gdb/testsuite/ChangeLog 2019-04-13 Philippe Waroquiers * gdb.base/slash_command.exp: New testcase. * gdb.base/slash_command.c: New file. --- gdb/testsuite/gdb.base/slash_command.c | 38 +++++++ gdb/testsuite/gdb.base/slash_command.exp | 125 +++++++++++++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 gdb/testsuite/gdb.base/slash_command.c create mode 100644 gdb/testsuite/gdb.base/slash_command.exp diff --git a/gdb/testsuite/gdb.base/slash_command.c b/gdb/testsuite/gdb.base/slash_command.c new file mode 100644 index 0000000000..d54dfaaf2c --- /dev/null +++ b/gdb/testsuite/gdb.base/slash_command.c @@ -0,0 +1,38 @@ +/* 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 . */ + + +static int x; + +int my_foo_function (int a) +{ + x += a; + return x; +} + +int +main () +{ + int some_ints[5]; + + some_ints[0] = 0; + some_ints[1] = 1; + some_ints[2] = 2; + some_ints[3] = 3; + some_ints[4] = 4; + return my_foo_function (some_ints[4]) > 0; /* break here */ +} diff --git a/gdb/testsuite/gdb.base/slash_command.exp b/gdb/testsuite/gdb.base/slash_command.exp new file mode 100644 index 0000000000..eb83057d2c --- /dev/null +++ b/gdb/testsuite/gdb.base/slash_command.exp @@ -0,0 +1,125 @@ +# 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 . + +# This file verifies the logic to temporarily change some settings +# using the slash command. + +standard_testfile + +if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} { + return -1 +} + +if { ![runto_main] } then { + fail "can't run to main" + return 0 +} +set loc [gdb_get_line_number "break here"] +gdb_test "break $loc" ".*" "set breakpoint" +gdb_continue_to_breakpoint "continue to breakpoint" + +# 'set language' == /lX +proc check_info_function { prefix slash_seq desired_layout } { + gdb_test "$slash_seq info functions my_foo_function" \ + [multi_line \ + "All functions matching regular expression \"my_foo_function\":" \ + "" \ + "File .*slash_command.c:" \ + $desired_layout + ] \ + $prefix + +} +check_info_function "lang_auto" "" \ + "${decimal}: int my_foo_function\\(int\\);" +check_info_function "slash_switch_to_Ada" "/lA" \ + "${decimal}: function my_foo_function \\(a1: int\\) return int;.*" +check_info_function "lang_auto_after_slash" "" \ + "${decimal}: int my_foo_function\\(int\\);" +gdb_test "set language ada" +check_info_function "set_switch_to_Ada" "" \ + "${decimal}: function my_foo_function \\(a1: int\\) return int;.*" +gdb_test "set language auto" + +# 'set print elements' == /Xe +gdb_test "print some_ints" " = \\{0, 1, 2, 3, 4\\}" "default print" +gdb_test "/2e print some_ints" "= \\{0, 1\.\.\.\\}" "temp print 2" +gdb_test "set print elements 2" "" "set default print 2" +gdb_test "print some_ints" "= \\{0, 1\.\.\.\\}" "default print 2" +gdb_test "/2e print some_ints" "= \\{0, 1\.\.\.\\}" "temp print 2, default 2" +gdb_test "/3e print some_ints" "= \\{0, 1, 2\.\.\.\\}" "temp print 3, default 2" +gdb_test "print some_ints" "= \\{0, 1\.\.\.\\}" "default re-print 2" +gdb_test "set print elements 200" +gdb_test "show print elements" "is 200." "default show elt 200" +gdb_test "/100e show print elements" "is 100." "temp show elt 100" +gdb_test "/e show print elements" "is unlimited." "temp show elt unlimited" + +# 'set print array' == /a +gdb_test "/a print some_ints" \ + [multi_line \ + "\\{0," \ + " 1," \ + " 2," \ + " 3," \ + " 4}" \ + ] \ + "temp pretty array" +gdb_test "set print array on" "" "set default print array on" +gdb_test "/!a print some_ints" \ + " = \\{0, 1, 2, 3, 4\\}" "temp print array off" +gdb_test "set print array off" "" "set default print array off" + +# 'set print array-indexes' == /i +set array_index_match \ + "= \\{\\\[0] = 0, \\\[1] = 1, \\\[2] = 2, \\\[3] = 3, \\\[4] = 4\\}" +gdb_test "/i print some_ints" \ + $array_index_match \ + "temp print array-indexes" +gdb_test "set print array-indexes on" "" "set default print array-indexes on" +gdb_test "/i print some_ints" \ + $array_index_match \ + "temp print array-indexes default on" +gdb_test "set print array-indexes off" "" "set default print array-indexes off" + + +# Now, test some combinations of all the above. +foreach slash_seq { + "/lAai2e" + "/ai2elA" + "/2eailA"} { + gdb_test "$slash_seq print some_ints" \ + [multi_line \ + "= \\\(0 => 0," \ + " 1 => 1\.\.\.\\\).*" \ + ] \ + "combination $slash_seq" +} + + +# Error handling. +gdb_test "/123a show print array" \ + [multi_line \ + "Value type for / setting \"a\" \\\(set print array\\\) is 'Boolean on\\\|off'\." \ + "Found unexpected 'Unsigned integer \\\(0 means unlimited\\\)' qualifier at \"123a show print array\"" + ] \ + "unsigned integer must be followed by unsigned setting." + +gdb_test "/!e show print elements" \ + [multi_line \ + "Value type for / setting \"e\" \\\(set print elements\\\) is 'Unsigned integer \\\(0 means unlimited\\\)'\." \ + "Found unexpected 'Boolean on\\\|off' qualifier at \"!e show print elements\"" \ + ] \ + "! must be followed by boolean setting." +