From patchwork Thu Oct 25 20:11:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philippe Waroquiers X-Patchwork-Id: 29896 Received: (qmail 26279 invoked by alias); 25 Oct 2018 20:11:30 -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 26203 invoked by uid 89); 25 Oct 2018 20:11:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.7 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.2 spammy=arg_i, xyz, arg_c, arg_ X-HELO: mailsec114.isp.belgacom.be Received: from mailsec114.isp.belgacom.be (HELO mailsec114.isp.belgacom.be) (195.238.20.110) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 25 Oct 2018 20:11:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=skynet.be; i=@skynet.be; q=dns/txt; s=securemail; t=1540498286; x=1572034286; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=f3ZuWmPqh+cYMBiLtxjgjVYVXxvz7ksdfae24p89Fyo=; b=G6l3oDNVmYbVdBt5sO9e2Suz0oXmRhE8XB0RhzBfJHWUSubk7+Cv66Uh KGp20cfVqGd0maG/hfJpbMDU8kRrKA==; Received: from 110.212-243-81.adsl-dyn.isp.belgacom.be (HELO md.home) ([81.243.212.110]) by relay.skynet.be with ESMTP/TLS/DHE-RSA-AES128-GCM-SHA256; 25 Oct 2018 22:11:14 +0200 From: Philippe Waroquiers To: gdb-patches@sourceware.org Cc: Philippe Waroquiers Subject: [RFVv4 5/5] Add a test case for info args|functions|locals|variables [-q] [-t TYPEREGEXP] [NAMEREGEXP] Date: Thu, 25 Oct 2018 22:11:07 +0200 Message-Id: <20181025201107.24828-6-philippe.waroquiers@skynet.be> In-Reply-To: <20181025201107.24828-1-philippe.waroquiers@skynet.be> References: <20181025201107.24828-1-philippe.waroquiers@skynet.be> MIME-Version: 1.0 X-IsSubscribed: yes Add a test case for info args|functions|locals|variables [-q] [-t TYPEREGEXP] [NAMEREGEXP] gdb/testsuite/ChangeLog 2018-10-25 Philippe Waroquiers * gdb.base/info_qt.c: New file. * gdb.base/info_qt.exp: New file. --- gdb/testsuite/gdb.base/info_qt.c | 78 +++++++++ gdb/testsuite/gdb.base/info_qt.exp | 252 +++++++++++++++++++++++++++++ 2 files changed, 330 insertions(+) create mode 100644 gdb/testsuite/gdb.base/info_qt.c create mode 100644 gdb/testsuite/gdb.base/info_qt.exp diff --git a/gdb/testsuite/gdb.base/info_qt.c b/gdb/testsuite/gdb.base/info_qt.c new file mode 100644 index 0000000000..479557124f --- /dev/null +++ b/gdb/testsuite/gdb.base/info_qt.c @@ -0,0 +1,78 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2018 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 . */ + +typedef int entier; + +int info_qt_inc = 0; +entier info_qt_ent = 0; + +static void +setup_done (void) +{ +} + +static void +setup (char arg_c, int arg_i, int arg_j) +{ + char loc_arg_c = arg_c; + int loc_arg_i = arg_i; + int loc_arg_j = arg_j; + + info_qt_inc += loc_arg_c + loc_arg_i + loc_arg_j; + setup_done (); +} + +void info_fun1 (void) +{ + info_qt_inc++; + info_qt_ent++; +} + +int info_fun2 (char c) +{ + info_qt_inc += c; + return info_qt_inc; +} + +int info_fun2bis (char c) +{ + info_qt_inc += c; + return info_qt_inc; +} + +entier info_fun2xxx (char arg_c, int arg_i, int arg_j) +{ + info_qt_inc += arg_c + arg_i + arg_j; + return info_qt_inc; +} + +entier info_fun2yyy (char arg_c, int arg_i, int arg_j) +{ + setup (arg_c, arg_i, arg_j); + info_qt_inc += arg_c + arg_i + arg_j; + return info_qt_inc; +} + +int +main (int argc, char **argv, char **envp) +{ + info_fun1 (); + (void) info_fun2 ('a'); + (void) info_fun2bis ('b'); + (void) info_fun2xxx ('c', 1, 2); + (void) info_fun2yyy ('d', 3, 4); +} diff --git a/gdb/testsuite/gdb.base/info_qt.exp b/gdb/testsuite/gdb.base/info_qt.exp new file mode 100644 index 0000000000..83084a3ce8 --- /dev/null +++ b/gdb/testsuite/gdb.base/info_qt.exp @@ -0,0 +1,252 @@ +# This testcase is part of GDB, the GNU debugger. + +# Copyright 2018 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 test verifies the TYPEREGEXP and NAMEREGEXP matching logic +# in the commands +# info [args|functions|locals|variables] [-q] [-t TYPEREGEXP] [NAMEREGEXP]. + + +standard_testfile + +if { [prepare_for_testing "failed to prepare" ${testfile}] } { + return -1 +} + +clean_restart ${binfile} + +if ![runto setup_done] then { + fail "can't run to setup_done" + return 0 +} + +set any "\[^\r\n\]*" +set ws "\[ \t\]\+" +set number "\[0-9]\+" + + +############# Test 'info functions'. + +with_test_prefix "info functions nameregexp" { + foreach_with_prefix cmd { + "info functions info_fun" + "info functions -- info_fun" + "info functions ^info_fun" } { + gdb_test $cmd \ + [multi_line \ + "All functions matching regular expression \".*info_fun.*\":" \ + "" \ + "File .*info_qt.c:" \ + "${number}: void info_fun1\\\(void\\\);" \ + "${number}: int info_fun2\\\(char\\\);" \ + "${number}: int info_fun2bis\\\(char\\\);" \ + "${number}: entier info_fun2xxx\\\(char, int, int\\\);" \ + "${number}: entier info_fun2yyy\\\(char, int, int\\\);" \ + ] \ + "info functions info_fun" + } +} + +with_test_prefix "info functions nameregexp quiet" { + foreach_with_prefix cmd { + "info functions -q info_fun" + "info functions -q -- info_fun" } { + gdb_test $cmd \ + [multi_line \ + "" \ + "File .*info_qt.c:" \ + "${number}: void info_fun1\\\(void\\\);" \ + "${number}: int info_fun2\\\(char\\\);" \ + "${number}: int info_fun2bis\\\(char\\\);" \ + "${number}: entier info_fun2xxx\\\(char, int, int\\\);" \ + "${number}: entier info_fun2yyy\\\(char, int, int\\\);" \ + ] \ + "info functions -q info_fun" + } +} + +with_test_prefix "info functions nameregexp quiet no match" { + foreach_with_prefix cmd { + "info functions -q nowaythiscanmatch" + "info functions -q -- -q" } { + gdb_test_no_output $cmd "quiet info functions empty output" + } +} + +with_test_prefix "info functions typeregexp nameregexp" { + foreach_with_prefix cmd { + "info functions -t entier -q info_fun" + "info functions -q -t 'entier (' -- info_fun" + "info functions -q -t '(char, int, int)' -- info_fun" + "info functions -q -t 'entier (char, int, int)' -- info_fun" } { + gdb_test $cmd \ + [multi_line \ + "" \ + "File .*info_qt.c:" \ + "${number}: entier info_fun2xxx\\\(char, int, int\\\);" \ + "${number}: entier info_fun2yyy\\\(char, int, int\\\);" \ + ] \ + "info functions -q info_fun" + } +} + +with_test_prefix "info functions typeregexp nameregexp no match" { + gdb_test_no_output "info functions -t ganze_Zahl -q info_fun" \ + "quiet output info functions no matching type" +} + +############# Test 'info variables'. + +with_test_prefix "info variables nameregexp" { + foreach_with_prefix cmd { + "info variables info_qt" + "info variables -- info_qt" + "info variables ^info_qt" } { + gdb_test $cmd \ + [multi_line \ + "All variables matching regular expression \".*info_qt.*\":" \ + "" \ + "File .*info_qt.c:" \ + "${number}: entier info_qt_ent;" \ + "${number}: int info_qt_inc;" \ + ] \ + "info functions info_fun" + } +} + +with_test_prefix "info variables nameregexp quiet no match" { + foreach_with_prefix cmd { + "info variables -q nowaythiscanmatch" + "info variables -q -- -q" } { + gdb_test_no_output $cmd "quiet info variables empty output" + } +} + +with_test_prefix "info variables typeregexp nameregexp quiet" { + foreach_with_prefix cmd { + "info variables -t entier -q info_qt" + "info variables -q -t entier -- info_qt" } { + gdb_test $cmd \ + [multi_line \ + "" \ + "File .*info_qt.c:" \ + "${number}: entier info_qt_ent;" \ + ] \ + "info variables -q -t entier info_fun" + } +} + +with_test_prefix "info variables typeregexp nameregexp quiet no match" { + gdb_test_no_output "info variables -t ganze_Zahl -q info_at" \ + "quiet output info variables no matching type" +} + + + +############# Test 'info args' in function setup. + +gdb_test "frame 1" ".* in setup .*" "set frame 1 for info args" + +with_test_prefix "info args matching all args" { + foreach_with_prefix cmd { + "info args" + "info args arg_" + "info args g" + "info args -- .*" } { + gdb_test $cmd \ + [multi_line \ + "arg_c = 100 'd'" \ + "arg_i = 3" \ + "arg_j = 4" \ + ] \ + "info args" + } +} + +with_test_prefix "info args matching some args" { + foreach_with_prefix cmd { + "info args -t int" + "info args arg_[ij]"} { + gdb_test $cmd \ + [multi_line \ + "arg_i = 3" \ + "arg_j = 4" \ + ] \ + "info args" + } +} + +with_test_prefix "info args no match" { + gdb_test "info args nowaythiscanmatch" "No matching arguments." "no matching args" + gdb_test_no_output "info args -q nowaythiscanmatch" "quiet no matching args" + gdb_test_no_output "info args -q -t entier" "quiet no matching args with type" +} + +############# Test 'info locals' in function setup. + +gdb_test "frame 1" ".* in setup .*" "set frame 1 for info locals" + +with_test_prefix "info locals matching all locals" { + foreach_with_prefix cmd { + "info locals" + "info locals loc_arg_" + "info locals g" + "info locals -- .*" } { + gdb_test $cmd \ + [multi_line \ + "loc_arg_c = 100 'd'" \ + "loc_arg_i = 3" \ + "loc_arg_j = 4" \ + ] \ + "info locals" + } +} + +with_test_prefix "info locals matching some locals" { + foreach_with_prefix cmd { + "info locals -t int" + "info locals arg_[ij]" + "info locals loc_arg_[ij]"} { + gdb_test $cmd \ + [multi_line \ + "loc_arg_i = 3" \ + "loc_arg_j = 4" \ + ] \ + "info args" + } +} + +with_test_prefix "info locals no match" { + gdb_test "info locals nowaythiscanmatch" "No matching locals." "no matching locals" + gdb_test_no_output "info locals -q nowaythiscanmatch" "quiet no matching locals" + gdb_test_no_output "info locals -q -t ganze_Zahl loc" "quiet no matching locals with type" +} + +# Verify that the rest of the args is taken as a single regexp. +with_test_prefix "rest of args as single regexp" { + gdb_test "info functions abc def" \ + "All functions matching regular expression \\\"abc def\\\":" \ + "single regexp" + + gdb_test "info functions -t uvw abc def" \ + "All functions matching regular expression \\\"abc def\\\" with type matching regulation expression \\\"uvw\\\":" \ + "-t noquote single regexp" + + gdb_test "info functions -t 'uvw xyz' abc def" \ + "All functions matching regular expression \\\"abc def\\\" with type matching regulation expression \\\"uvw xyz\\\":" \ + "-t quote single regexp" +}