From patchwork Wed Oct 4 14:00:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 23324 Received: (qmail 15243 invoked by alias); 4 Oct 2017 14:01:05 -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 14927 invoked by uid 89); 4 Oct 2017 14:01:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:e400, H*RU:193.180.251.58, HX-ClientProxiedBy:2a01, HX-AuditID:sk:c1b4fb3 X-HELO: sessmg22.ericsson.net Received: from sessmg22.ericsson.net (HELO sessmg22.ericsson.net) (193.180.251.58) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 04 Oct 2017 14:00:56 +0000 Received: from ESESSHC010.ericsson.se (Unknown_Domain [153.88.183.48]) by sessmg22.ericsson.net (Symantec Mail Security) with SMTP id 8E.09.16364.599E4D95; Wed, 4 Oct 2017 16:00:53 +0200 (CEST) Received: from EUR01-DB5-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.48) with Microsoft SMTP Server (TLS) id 14.3.352.0; Wed, 4 Oct 2017 16:00:52 +0200 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; Received: from elxacz23q12.ericsson.se (192.176.1.82) by DBXPR07MB320.eurprd07.prod.outlook.com (2a01:111:e400:941d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.5; Wed, 4 Oct 2017 14:00:50 +0000 From: Simon Marchi To: CC: , Simon Marchi Subject: [PATCH] Fix -list-thread-groups --available logic and add test Date: Wed, 4 Oct 2017 10:00:39 -0400 Message-ID: <1507125639-522-1-git-send-email-simon.marchi@ericsson.com> MIME-Version: 1.0 X-ClientProxiedBy: HE1PR0401CA0049.eurprd04.prod.outlook.com (2603:10a6:3:19::17) To DBXPR07MB320.eurprd07.prod.outlook.com (2a01:111:e400:941d::21) X-MS-Office365-Filtering-Correlation-Id: 90504877-5148-41fe-1f89-08d50b305274 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:DBXPR07MB320; X-Microsoft-Exchange-Diagnostics: 1; DBXPR07MB320; 3:iSwn3HczJyOYe3dBFjbHS9k2kN+OaYqiJa0/bEC0EK8W3QXSbapJjzAcIigXj/pHGWNjgpQXDJOpSZBfPWyAFzBh9JbDLCEIjYWLR4YvBicraK0hbRMDirIl2osgZtNauKZZAjpcAu79NISDrE0Loj1mqLHNEOXEE2zLEJjOm8bUShE1ep3rGfi/56nzzL5AftG6zD1X4n8dPSv6hrhdtzgOD239p1esNPd/OfDEwgVL4s1WmGkpPPKMVZ0ewIbj; 25:zxsk4QyrBNvmMJ1RXZbbHdv09OKoLz/zYHK4s3dR0eYSXd6k4LZ8gr7hv4YEwy8fS6e3nINFLjWz7j2HmtZC8Y6u7fKM6yEjZ0yWXJb2+ifSAPXcEEP8aCtr1jlhCnHNmCo48hlVRTVEqToMD3Y2qcC/l21XrZ26dcv2pmPh26BXpxp+cqn9nxaNg8gH+al+XSYH3jF+d6yabMGe4HLn5EW/pIvW2ZYawWYEECiOVLtbckGg6KBdwodJZpBmZGO+ROaCO/wXn70W81+PHWNGMT4+VXVYVZEuiZM50fQFU6/ia8QE4nDZQK2/bzN11lIuR+/67q15OfahTWOTzBtmTg==; 31:DLphlsnh6M896jYJybEj6+WtMFdO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RkfTWFl8grEjb3ITWhkKbdbsiIsE3M/YRbLpH1M5Ec9El/P2+iSKZuch4/z7zpmiaf7g== X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(22074186197030); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(100000703101)(100105400095)(3002001)(6041248)(20161123555025)(20161123562025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DBXPR07MB320; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DBXPR07MB320; X-Forefront-PRVS: 0450A714CB X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(346002)(376002)(189002)(199003)(54534003)(25786009)(6916009)(101416001)(2351001)(6666003)(66066001)(2361001)(50226002)(3846002)(53416004)(5660300001)(16526018)(97736004)(106356001)(33646002)(105586002)(48376002)(50466002)(6116002)(81156014)(6512007)(316002)(50986999)(107886003)(4326008)(81166006)(7736002)(16586007)(6506006)(6306002)(86362001)(305945005)(478600001)(47776003)(5003940100001)(68736007)(8676002)(69596002)(2906002)(36756003)(53936002)(230783001)(189998001)(8936002)(6486002)(131093003)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:DBXPR07MB320; H:elxacz23q12.ericsson.se; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: ericsson.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DBXPR07MB320; 23:6WKR4Pe9BRMXw8SImbCAm9hkRSB1yuE7k2drSvZK8h?= =?us-ascii?Q?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BSlM1LOmpycqB45pwt+XFsMdfKIsM3Nxev0VLEPDRN0R3RmEgSXJ1IGbo4hX4awO2IZXnaKNnmeAR1O1vPBYsHUxIx9E12kDTph/YnTqmlnd8Q+syMviAYehqD50jvvCDI1dPmXRvbK1ajF+xcWkY3OzHruiq4AZJAZ+ub9/7RKUBj6jxTEr7YIr1IvfxvzNtTxLtoZ93IEATPTERRWz9yJr8rh4Lu6xPM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2017 14:00:50.1533 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBXPR07MB320 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes Commit Use std::set in mi-main.c 52f9abe4c739f42cc5f80b2629276493ac6306f9 changed the logic of the "-list-thread-groups --available" by mistake when a pid is passed. It prints all the processes except the one specified by the given pid. The correct behavior is to only print the process corresponding to that pid. this patch fixes that and adds a test. gdb/ChangeLog: * mi/mi-main.c (list_available_thread_groups): Reverse filter logic. gdb/testsuite/ChangeLog: * gdb.mi/list-thread-groups-available.exp: New file. * gdb.mi/list-thread-groups-available.c: New file. --- gdb/mi/mi-main.c | 2 +- .../gdb.mi/list-thread-groups-available.c | 29 +++++++++++++ .../gdb.mi/list-thread-groups-available.exp | 48 ++++++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 gdb/testsuite/gdb.mi/list-thread-groups-available.c create mode 100644 gdb/testsuite/gdb.mi/list-thread-groups-available.exp diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 83b1fcf..289445f 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -801,7 +801,7 @@ list_available_thread_groups (const std::set &ids, int recurse) /* At present, the target will return all available processes and if information about specific ones was required, we filter undesired processes here. */ - if (!ids.empty () && ids.find (pid_i) != ids.end ()) + if (!ids.empty () && ids.find (pid_i) == ids.end ()) continue; ui_out_emit_tuple tuple_emitter (uiout, NULL); diff --git a/gdb/testsuite/gdb.mi/list-thread-groups-available.c b/gdb/testsuite/gdb.mi/list-thread-groups-available.c new file mode 100644 index 0000000..56daec9 --- /dev/null +++ b/gdb/testsuite/gdb.mi/list-thread-groups-available.c @@ -0,0 +1,29 @@ +/* Copyright 2017 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 . */ + +#include + +int +main () +{ + int i; + + for (i = 0; i < 30; i++) + sleep (1); + + return 0; +} diff --git a/gdb/testsuite/gdb.mi/list-thread-groups-available.exp b/gdb/testsuite/gdb.mi/list-thread-groups-available.exp new file mode 100644 index 0000000..d33d3a9 --- /dev/null +++ b/gdb/testsuite/gdb.mi/list-thread-groups-available.exp @@ -0,0 +1,48 @@ +# 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 that -list-thread-groups --available works. + +load_lib mi-support.exp +set MIFLAGS "-i=mi" + +standard_testfile + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } { + untested "failed to compile" + return -1 +} + +if [mi_gdb_start] { + continue +} + +if [use_gdb_stub] { + continue +} + +# List all available processes. +mi_gdb_test \ + "-list-thread-groups --available" \ + "\\^done,groups=\\\[.*\\\]" \ + "list available thread groups" + +# List a specific process. +set spawn_id [remote_spawn target $binfile] +set pid [spawn_id_get_pid $spawn_id] +mi_gdb_test \ + "-list-thread-groups --available i${pid}" \ + "\\^done,groups=\\\[{id=\"${pid}\",type=\"process\",.*}\\\]" \ + "list available thread groups with filter"