From patchwork Wed Oct 4 16:31:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 23327 Received: (qmail 25898 invoked by alias); 4 Oct 2017 16:31:39 -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 25889 invoked by uid 89); 4 Oct 2017 16:31:39 -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 autolearn=ham version=3.3.2 spammy= X-HELO: sesbmg22.ericsson.net Received: from sesbmg22.ericsson.net (HELO sesbmg22.ericsson.net) (193.180.251.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 04 Oct 2017 16:31:37 +0000 Received: from ESESSHC013.ericsson.se (Unknown_Domain [153.88.183.57]) by sesbmg22.ericsson.net (Symantec Mail Security) with SMTP id B4.11.05471.6EC05D95; Wed, 4 Oct 2017 18:31:34 +0200 (CEST) Received: from EUR01-VE1-obe.outbound.protection.outlook.com (153.88.183.145) by oa.msg.ericsson.com (153.88.183.57) with Microsoft SMTP Server (TLS) id 14.3.352.0; Wed, 4 Oct 2017 18:31:34 +0200 Received: from elxacz23q12.ericsson.se (192.176.1.88) by DBXPR07MB319.eurprd07.prod.outlook.com (2a01:111:e400:941d::13) 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 16:31:29 +0000 From: Simon Marchi To: CC: , , Simon Marchi Subject: [PATCH v3] Fix -list-thread-groups --available logic and add test Date: Wed, 4 Oct 2017 12:31:21 -0400 Message-ID: <1507134681-29620-1-git-send-email-simon.marchi@ericsson.com> In-Reply-To: <92fed2cd-29a3-f074-3419-c066f2134577@redhat.com> References: <92fed2cd-29a3-f074-3419-c066f2134577@redhat.com> MIME-Version: 1.0 X-ClientProxiedBy: AM3PR07CA0109.eurprd07.prod.outlook.com (2603:10a6:207:7::19) To DBXPR07MB319.eurprd07.prod.outlook.com (2a01:111:e400:941d::13) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 30dca279-f465-4aab-4cea-08d50b455ec6 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:DBXPR07MB319; X-Microsoft-Exchange-Diagnostics: 1; DBXPR07MB319; 3:Oa2GQEIDnDANC3bz2fb0TON4y7EWEtbXXyrNqJ1X/Bta4QgwHRQdt081wPq7uzjTN74g1xwJIqJONoQDJkqzwj6Gp5XHIRqmqwdItszshBsYcx0WxZ85qc6H29oH/jKOqOJdL8tvUBvYKtQ/YUzlUpw1ugpbIK52YrVStf7YEMcG49P1qvBe84LpHQOL3+Z6kYyQ+ySZBz7kOk+57YQBj4kezD8eKsUX/u3RguR9eEujQt8Sqp3PwyX+TNSSC+O9; 25:VtlEmCDY41lV5x3O9LqhxZsIRT0Lt5G+VsyWVYtMvGT7srQhmPpawED7IpI2dT/kue74NvOFEKiP/HmquQEDxxT37jfQ1qnNR0qGevaQqeQwjGmQvQ7ZDgzGgJkcuA+Tgp9ZComm3yvvhzExAmSeZE9Pzd1Korc6Hrl0bKoyK1coVmLfVy5LKrbpaDPXj0glVjQjaekYEsL1iwFrCEE0sZlmUPv/S5DBlLnjciU8WsOkfrlPFt9zOlojwA4CdUKr9vzqDUbgS0ae5ebrSR/975Q9nSsZ4vZttA3j1Y9mv2HmWzPF7NNhDoyTBo4fazyHa3BRDtNDQtXx01tnCftC4A==; 31:GrhVE7TriUOOOEg5orbdvFqAlWWWvLvsU80prLdjen7WjTNFtmTAx2jkGjhBK4iBt4eaJi8lnoabjcZGciWXEMitm3mdPU543jfJQ5dM/H2MchqCQEHiR9kaOGjsvx0DoCr8F6+ZCVh3ZeqvznW91gAcj9Z6AIZtGZ7fCpwpgZQjtT3oKGPfAW7Fa5H8ycE3HZRymUni4TC8DKtcV+tQr1f7RsDfwibmDYBl6QxZP8k= X-MS-TrafficTypeDiagnostic: DBXPR07MB319: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=simon.marchi@ericsson.com; X-Microsoft-Exchange-Diagnostics: 1; DBXPR07MB319; 20:l1seAG4MZ6ZdbPbev7GfrfI5B9aTvzOtoPtZXlMLMjD9ASxjFGys3qpTcj1OqOL2Nn5u4d6tX891MLIHdrfAxpuaxOwNnOgGFbmRs0CpQ1wo4eOm9fLcapr8mfaSRWM9oQnLVUJxA1gar9niAQoPtuE8tq3o7k15Hwmo6tzK9XeDbHfAk2tKjEBNI9jllW4SlSNBJajLxrbaXg9wM1EJc338lL9GDEzVrDOdydL2GPiCpfvCJlvyNRjYhyrpEuDDMnIqLgDhky88z2D+rzJqd6wh6BaH5B+I0OB2qfF2VTmNWgIQKsTah5tYkElhi/lYb4fE2V/4wpRp+EbPRXStB112LT0j+v9q7XsCrk/JSqpelWpPgiYuv2jtqPHWYXX3ZVzk5mcwB5Tlble74rkqYENYc5AiIwBsIozsasqrJH5JVs6zg+HSiwSsCDeLwl8fVraOPS0CmvTlHdQcv2h2+K1NfOARoFDpUxrYm/OCRX+fiUpHCG/T20KZqTcXx7Xy; 4:8X/oOy33dLcFQyumd2885Sj17dZJlom6YmQYubR67qX/JuZTN7BZqA+9LDUfCcqAlbPh3y/j89bP7pMUGIyt78Isg1lIl5kRx36UeWuV9TJGCkA47N79suBdB8ngul2HUYClAFsxwcn4643EVKnQWoD0GiUFqXKFuknKgB3k8eRZ0Nyldkcy0I8cmNYFeYv+AwYN/P6y82iKsXLWstb4MQEZBIknLOXaOY0RVWPy3xRznlLnaco9I5J+KxzCPj2cCBmLIO9NXCaFWs2SRM2l5G8XNMIURR/adVBfjcgpA4u53pDkUnD8c/k48Sl1UdypCFEcZ7/LFW84FJxosxq4LKU+WCKql1Xpkohw+X9HBM0= X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(22074186197030)(788757137089); 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)(12181511122)(10201501046)(100000703101)(100105400095)(93006095)(93001095)(3002001)(6041248)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(20161123562025)(20161123560025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DBXPR07MB319; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DBXPR07MB319; X-Forefront-PRVS: 0450A714CB X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(346002)(376002)(39860400002)(54534003)(199003)(189002)(3846002)(76176999)(53416004)(7736002)(66066001)(47776003)(5003940100001)(50226002)(16586007)(316002)(5890100001)(16526018)(101416001)(86362001)(81166006)(50986999)(81156014)(305945005)(8936002)(6506006)(6512007)(53936002)(8676002)(6486002)(6306002)(97736004)(36756003)(106356001)(5660300001)(2950100002)(33646002)(69596002)(6116002)(25786009)(6666003)(230783001)(4326008)(50466002)(107886003)(2361001)(48376002)(105586002)(68736007)(2351001)(2906002)(189998001)(508600001)(6916009)(131093003)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:DBXPR07MB319; H:elxacz23q12.ericsson.se; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX: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; D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FqqmcNo7ETw==; 24:5UAU42K0a8F9oB96U2kbDj/G678TuroKW3rSbLDa8O8vdtV8wmeBgCR/pbkIjCHFemNoDyxw9cu6AN3oKDfOspw64HJQiV0WW6Umvf1KgJ8=; 7:HMWN1wvYIRoslfzEBG2YFqiHpet4zpfdIiU3W81Q1TGCaCOp6SvZDCsCNpsdEx6KKBGZyZsGDYcJVLUJ5VxGlTfRKgXUb/YD/zneKWUEBmaBAKXJbpFkNfLc/vmTGBSZIuV3sFTb/ROsUSkTIWi0Y8ndd1PzRmQ36+D0GTgAY2MpwfQvpql3o8sZ1CUePDHXB78oLu+lYvF3CFXSE7KTOvCDYt2ji5bUhyxi4aWiKf4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2017 16:31:29.9746 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 92e84ceb-fbfd-47ab-be52-080c6b87953f X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBXPR07MB319 X-OriginatorOrg: ericsson.com X-IsSubscribed: yes New in v3: - Replace use_gdb_stub with can_spawn_for_attach. - Call kill_wait_spawned_process on spawn_ids. 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 | 72 ++++++++++++++++++++++ 3 files changed, 102 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..eea27b4 --- /dev/null +++ b/gdb/testsuite/gdb.mi/list-thread-groups-available.exp @@ -0,0 +1,72 @@ +# 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 ![can_spawn_for_attach] { + continue +} + +set string_re {(?:[^\\"]|\\.)*} + +set id_re "id=\"$decimal\"" +set type_re "type=\"process\"" +set description_re "description=\"$string_re\"" +set user_re "user=\"$string_re\"" +set cores_re "cores=\[\"$decimal\"(,\"$decimal\")*\]" + +# List all available processes. +set process_entry_re "{${id_re},${type_re}(,$description_re)?(,$user_re)?(,$cores_re)?}" + +mi_gdb_test \ + "-list-thread-groups --available" \ + "\\^done,groups=\\\[${process_entry_re}(,$process_entry_re)*\\\]" \ + "list available thread groups" + +# List specific processes, make sure there are two entries. +set spawn_id_1 [remote_spawn target $binfile] +set pid_1 [spawn_id_get_pid $spawn_id_1] +set id_re_1 "id=\"$pid_1\"" + +set spawn_id_2 [remote_spawn target $binfile] +set pid_2 [spawn_id_get_pid $spawn_id_2] +set id_re_2 "id=\"$pid_2\"" + +set process_entry_re_1 "{${id_re_1},${type_re}(,$description_re)?(,$user_re)?(,$cores_re)?}" +set process_entry_re_2 "{${id_re_2},${type_re}(,$description_re)?(,$user_re)?(,$cores_re)?}" + +set process_list_re "(${process_entry_re_1},${process_entry_re_2}|${process_entry_re_2},${process_entry_re_1})" + +mi_gdb_test \ + "-list-thread-groups --available i${pid_1} i${pid_2}" \ + "\\^done,groups=\\\[${process_list_re}\\\]" \ + "list available thread groups with filter" + +kill_wait_spawned_process $spawn_id_1 +kill_wait_spawned_process $spawn_id_2