From patchwork Sat Jun 10 13:59:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 20892 Received: (qmail 66127 invoked by alias); 10 Jun 2017 13:59:45 -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 66105 invoked by uid 89); 10 Jun 2017 13:59:44 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-pg0-f41.google.com Received: from mail-pg0-f41.google.com (HELO mail-pg0-f41.google.com) (74.125.83.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 10 Jun 2017 13:59:42 +0000 Received: by mail-pg0-f41.google.com with SMTP id v18so33873677pgb.1 for ; Sat, 10 Jun 2017 06:59:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=YT7B5721mG6pgI//oKi+AhQnrlwOyimotJoTJvW+9+E=; b=aZiMlEntfQ15FcWecr7wkCsdkR9hjD8CrlmLh8Bjk2uTvLYyl0yE7D/wxtNctnQE09 QT7D+BkFnR8/esI3+4SzVxQZ3MHlx9QzsGehTQB5YadkCGHtXK0YHmJ4e8Ops8ZF7xT7 6D+HS37+qRc7fzdJF6Zcb9L1EmD67mAL4p0+8ueJDymi5s5NH9uQLHFC90HAYv0vFfkn 5XlMU0muked1bIyz5KZHWVXZTPdWFdGUPiSNxQeTzExuhpFYZzbi0jslnUdesIt+brSC fpy5WYvQoEJQ2qfl61Y8xMkye9lD7Gr94IsbhBsV9PSop7/5rlMTWKrzriKrJ2ipnik7 JbfQ== X-Gm-Message-State: AODbwcCZKfxL5YAsV8g/WNCd0C7E8l+e+Gsj884m3QNT65hqEIk8Q7jK KGcOwYWZO8pTnedTZ5W5+Q== X-Received: by 10.98.5.130 with SMTP id 124mr47243598pff.209.1497103185156; Sat, 10 Jun 2017 06:59:45 -0700 (PDT) Received: from localhost (g212.61-193-241.ppp.wakwak.ne.jp. [61.193.241.212]) by smtp.gmail.com with ESMTPSA id m25sm8399905pfk.15.2017.06.10.06.59.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 10 Jun 2017 06:59:44 -0700 (PDT) From: Stafford Horne To: GDB patches Cc: Stafford Horne Subject: [PATCH v2 1/4] reggroups: Add test and docs for `info reg $reggroup` feature Date: Sat, 10 Jun 2017 22:59:30 +0900 Message-Id: <610bf98f1e81cb24047a4d5db7bd420cbd79031d.1497102900.git.shorne@gmail.com> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes Until now this feature has existed but was not documented. Adding docs and tests. gdb/ChangeLog: 2017-06-06 Stafford Horne * infcmd.c (_initialize_infcmd): Add help for info reg $reggroup feature. gdb/doc/ChangeLog: 2017-06-06 Stafford Horne * gdb.texinfo (Registers): Document info reg $reggroup feature. gdb/testsuite/ChangeLog: 2017-06-06 Stafford Horne * gdb.base/reggroups.c: New file. * gdb.base/reggroups.exp: New file. --- gdb/doc/gdb.texinfo | 5 +++ gdb/infcmd.c | 8 +++-- gdb/testsuite/gdb.base/reggroups.c | 5 +++ gdb/testsuite/gdb.base/reggroups.exp | 63 ++++++++++++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 gdb/testsuite/gdb.base/reggroups.c create mode 100644 gdb/testsuite/gdb.base/reggroups.exp diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 8d7a1c9..a5e4257 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -10879,6 +10879,11 @@ and vector registers (in the selected stack frame). Print the names and values of all registers, including floating-point and vector registers (in the selected stack frame). +@item info registers @var{reggroup} @dots{} +Print the name and value of the registers in each of the specified +@var{reggroup}. The @var{reggoup} can be any of those returned by +@code{maint print reggroups}. + @item info registers @var{regname} @dots{} Print the @dfn{relativized} value of each specified register @var{regname}. As discussed in detail below, register values are normally relative to diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 09060b5..145f317 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -3423,13 +3423,17 @@ interrupt all running threads in non-stop mode, use the -a option.")); c = add_info ("registers", nofp_registers_info, _("\ List of integer registers and their contents, for selected stack frame.\n\ -Register name as argument means describe only that register.")); +Register name as argument means describe only that register.\n\ +Register group name as argument means describe the registers in the\n\ +named register group.")); add_info_alias ("r", "registers", 1); set_cmd_completer (c, reg_or_group_completer); c = add_info ("all-registers", all_registers_info, _("\ List of all registers and their contents, for selected stack frame.\n\ -Register name as argument means describe only that register.")); +Register name as argument means describe only that register.\n\ +Register group name as argument means describe the registers in the\n\ +named register group.")); set_cmd_completer (c, reg_or_group_completer); add_info ("program", program_info, diff --git a/gdb/testsuite/gdb.base/reggroups.c b/gdb/testsuite/gdb.base/reggroups.c new file mode 100644 index 0000000..8e8f518 --- /dev/null +++ b/gdb/testsuite/gdb.base/reggroups.c @@ -0,0 +1,5 @@ +int +main() +{ + return 0; +} diff --git a/gdb/testsuite/gdb.base/reggroups.exp b/gdb/testsuite/gdb.base/reggroups.exp new file mode 100644 index 0000000..c10f025 --- /dev/null +++ b/gdb/testsuite/gdb.base/reggroups.exp @@ -0,0 +1,63 @@ +# This testcase is part of GDB, the GNU debugger. + +# Copyright 2017 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 listing reggroups and the registers in each group. + +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 +} + +proc fetch_reggroups {test} { + global gdb_prompt + global expect_out + + set reggroups {} + gdb_test_multiple "maint print reggroups" "get reggroups" { + -re "maint print reggroups\r\n" { + exp_continue + } + -re "^ Group\[ \t\]+Type\[ \t\]+\r\n" { + exp_continue + } + -re "^ (\[0-9a-zA-Z\-\]+)\[ \t\]+(user|internal)\[ \t\]+\r\n" { + lappend reggroups $expect_out(1,string) + exp_continue + } + -re ".*$gdb_prompt $" { + if { [llength $reggroups] != 0 } { + pass $test + } else { + fail "$test - didn't fetch any reggroups" + } + } + } + + return $reggroups +} + +set reggroups [fetch_reggroups "fetch reggroups"] + +foreach reggroup $reggroups { + gdb_test "info reg $reggroup" ".*" "info reg $reggroup" +}