From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2041.outbound.protection.outlook.com [40.107.236.41]) by sourceware.org (Postfix) with ESMTPS id A11143858D1E for ; Mon, 30 Jan 2023 16:33:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A11143858D1E Authentication-Results: sourceware.org; dmarc=fail (p=quarantine dis=none) header.from=amd.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=amd.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YcGd2+ZeWRo2/u2FvqxygknopxApqLhDgeCuO4g+DDwiX4/zGIFf9o0A88C66y+kBuedAIq+Bs5s3qRJB4lBdBhN+KDrrtg+J0zWFcnezoGr6amErnK3nPzb0QIB/IYm1KNSVoDSohNq4RhhRX9pUkXQNsxyvnVCwg6927tR5HlBB5EFwAURD5L5kqJtH8FuVAt0ewJF/l6jr2o8C5K6+f7npuN44JAX8cnQD5FOvcMEcsXWw25n4Vg+D5ZppFfI2Gdxo4K7DsmhGRGsiyVHR7JHy7HrFhkXGkf7CwSJ65Vc2zdrDPUeR1bTNkAfpb3Dl7ASAAWxNDRvqQlcgRKMbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sx/Op3o0oIE5+/hFd7jRW+nDhCmYnglb/hJm2XauA/I=; b=ROLQbPvoa909MkCKfk8FhT0js1o7e9nX1pi5X+G8JsmVSA4A/WYtY9CQHiVOlgLDXJMqZnadknkibmpARYb++353ulb3pdnXEWmplCahGVNASmErAFyZaDl7F7EVV97EVXlRdVBNeCKEzEO+Oi0xtO4fDBazZa/DuFEedDibIWN8tvLVb/evd1wN7SLVQxE02QaTz4IECNIyRoNGEuN1ta++iqb9eJvNqd5cy0AXnj51wDIXh3eoRxbbfq52j1eAEGZ7DWNdzjLWu/7hKUyfP6s0s6Lr2Rjk1XVhNyEbyVAwQZ63uHQOU9An2shvfCZ4yVoy5qJHHzENDKcy4ukPlA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sx/Op3o0oIE5+/hFd7jRW+nDhCmYnglb/hJm2XauA/I=; b=KqCycZ94BG7IQllhd+U/sm4Ab8p/vq3xIBPLSaZL4/5wHYfrI3NdA7fuUY9wx1tmS3/eV3v4VUbWSTZ55e0SVkO9oY7MmqsSmYzzdNPKuO++tglZs9UIbhuFUs+yMsn/zr5oms0bcAR5lZbrVt+zhfLeR95tkFr33N3MntNATlM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from DM4PR12MB5745.namprd12.prod.outlook.com (2603:10b6:8:5c::7) by SJ0PR12MB6783.namprd12.prod.outlook.com (2603:10b6:a03:44e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.36; Mon, 30 Jan 2023 16:33:12 +0000 Received: from DM4PR12MB5745.namprd12.prod.outlook.com ([fe80::5fc0:b696:455b:8330]) by DM4PR12MB5745.namprd12.prod.outlook.com ([fe80::5fc0:b696:455b:8330%3]) with mapi id 15.20.6043.036; Mon, 30 Jan 2023 16:33:12 +0000 Message-ID: <58e6882d-ef47-ca0a-4233-e4cff650db4d@amd.com> Date: Mon, 30 Jan 2023 16:33:06 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH v4] gdb/gcore: interrupt all threads before generating the corefile To: Simon Marchi , gdb-patches@sourceware.org Cc: lsix@lancelotsix.com References: <20221206141248.2485033-1-lancelot.six@amd.com> <9c70aa6a-2a00-a985-c080-33d086597ee7@simark.ca> Content-Language: en-US From: Lancelot SIX In-Reply-To: <9c70aa6a-2a00-a985-c080-33d086597ee7@simark.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR3P281CA0020.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1c::21) To DM4PR12MB5745.namprd12.prod.outlook.com (2603:10b6:8:5c::7) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR12MB5745:EE_|SJ0PR12MB6783:EE_ X-MS-Office365-Filtering-Correlation-Id: 744ab720-20ee-49bf-7b76-08db02dfadb2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gOCfCOR4ig0UAosWjH5QgApsuScFR6NRgPOqpQMm3zh66J0/af4w5AWbMytS+7Ly6rLbfcD7rWfL+NYRBPv7aWLKQ6EjPHbTwZrLnzUUje9KIiWWIU7AXEU6nk9eeUAjMLbjtziPK6fZ8x9ZWK7XanVxK9a19geaoMfNwWS2xBuXm3NE+tzFUapQODZ/o8atIc4ny2pa5zzNfy5/bkHTQV53nZTsnDTDdbrgLxKOe8KE9dt0y/TD+yDWR80Drkr7elQEk4Lx4hkMKdVtC5wAI0up5fWxEr/IyI5mUt2nQIzeBWkTX+uNQcHh0Up3+NYCrIAxNv/GMlDmdVH4+S19vqEQPen39M2gdval/mm2gjd47Qlp9xg4ySdpStKZRA54JBPhudq+66buOQPCxCauOXK2Y+4Z+fc6fbwI7g2X8aDIqIkfVsqru8k2l+TnZUAD0uX2O/6P9QyS86KwGmoUPupk2A/MazQGdQ5AXB9LPWx9i5xzRYaiuv0hIvBYkgTlJpeqc4qldgdncTvL54bcrqEvUYnOcIXdmG+N2klXkcFCvKDori3L9/Q43idW8QqJ2T2dVSL86taf+DDxsqHKrwT2hCHJlaKdhLEeE8Yd/wbOEUQgeqD+cspFXpMRZfNFx1KujHroetFRfa49EGTPqEnogyWaUbrg00S/KgH/NEsVq40SDMBZKv7fMzJFBLe/66iBSbjtVA48T4UxOka5hEH5ILNWQ88oZDT6AF8Wivk+WWZzucdPyW+dgrAKJor5wf43pC7ov9weF/OQXI1wjeh404VkG0gyOmcH5fEelG8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR12MB5745.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(376002)(366004)(346002)(39860400002)(396003)(136003)(451199018)(31696002)(31686004)(8676002)(66476007)(66556008)(4326008)(41300700001)(66946007)(8936002)(83380400001)(86362001)(478600001)(316002)(2906002)(45080400002)(38100700002)(6666004)(6486002)(26005)(6506007)(53546011)(5660300002)(186003)(6512007)(36756003)(2616005)(2004002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?SEpqK3pnQzVBa081MWFOZzN3bVV1aE1sMC9UcmdFUzdKMUp5V0puRys2Y3c1?= =?utf-8?B?VjU1VGV3U1U4QWtsNWxDRkV6ejNHY3RObEtMZS9IZEFENytrQmc2Vzl3czRR?= =?utf-8?B?NjgvaG5Xa1YxR3lYSCtkZVF2LzhzeEN2ZUFjejhRR2trOWJScjRSc0s5NFND?= =?utf-8?B?OEhqM2RtZjY1VmRtK3JhN2pSeXM0azk1SXRLZFhsc3duYlZrMm01TkJIbjNh?= =?utf-8?B?c3oybXJXa0dNbGRRRG90ZnNjL2dTSFl1dkRLVDByNy8xdTk5VG5CVFJyb2ZU?= =?utf-8?B?WFNvNkJS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0eXdWV2J1MHdURkpOcHhXSEUyL0JuMjky?= =?utf-8?Q?dIRvPLFNV0i9u12SskMRDX7nc?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 744ab720-20ee-49bf-7b76-08db02dfadb2 X-MS-Exchange-CrossTenant-AuthSource: DM4PR12MB5745.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jan 2023 16:33:11.9893 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mDI7PgNce7CZE7MlAsbWhuy9nyd/CGSvp28qL3H4vJbFfjmlEzRIfXJsRh6SfpFI7FgwoGoPMo4gHJu1mFOD7w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR12MB6783 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,GIT_PATCH_0,KAM_SHORT,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi, Further comments below: On 06/01/2023 21:27, Simon Marchi wrote: > Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding. > > >> @@ -131,6 +132,28 @@ gcore_command (const char *args, int from_tty) >> if (!target_has_execution ()) >> noprocess (); >> >> + scoped_restore_current_thread restore_current_thread; >> + scoped_disable_commit_resumed disable_commit_resume ("generating coredump"); >> + struct inferior *inf = current_inferior (); >> + scoped_finish_thread_state finish_state (inf->process_target (), >> + ptid_t (inf->pid)); >> + >> + bool all_stop_was_running = false; >> + if (exists_non_stop_target ()) >> + stop_all_threads ("generating coredump", inf); >> + else >> + { >> + all_stop_was_running = any_thread_of_inferior (inf)->executing (); > I'm wondering what happens if you call this while the inferior is doing > an in-line step over, with one thread resumed and the others stopped. I > think the others will have executing == false, so could you fall on one > that isn't executing? > > What if we are in all-stop, but we resumed with schedlock on? > > Note that I'd be fine with merging the patch without considering those > cases, since it's clearly an improvement already. I'll leave it as is for next revision. I am happy to update this later if it turns out a change makes (more) sense. > >> diff --git a/gdb/testsuite/gdb.base/gcore-nonstop.exp b/gdb/testsuite/gdb.base/gcore-nonstop.exp >> new file mode 100644 >> index 00000000000..4a240eb0872 >> --- /dev/null >> +++ b/gdb/testsuite/gdb.base/gcore-nonstop.exp >> @@ -0,0 +1,77 @@ >> +# Copyright 2022 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 testcase checks that when in non-stop mode with some threads running >> +# the gcore command can interrupt all threads, generate a core dump and >> +# restart threads as required. >> + > > Please add a short comment explaining the goal of this test. > I have reworked a bit the description. >> +standard_testfile >> + >> +if { [prepare_for_testing "failed to prepare" \ >> + ${testfile} ${srcfile} {pthreads debug}] } { >> + return >> +} > > prepare_for_testing starts GDB, but it gets restarted below anyway. Use > build_executable to avoid the unnecessary spawn. > Done. >> + >> +save_vars { GDBFLAGS } { >> + append GDBFLAGS " -ex \"set non-stop on\"" >> + clean_restart ${binfile} >> +} >> + >> +set lineno [gdb_get_line_number "Break here"] >> +if { ![runto $lineno] } { >> + return >> +} >> + >> +# We should be stopped in thread 1 while thread 2 is running. >> +gdb_test_sequence "info threads" "info threads" { >> + {Id\s+Target Id\s+Frame} >> + {\*\s+1[^\n]*\n} >> + {\s+2\s+[^\n]*\(running\)[^\n]*\n} >> +} >> + >> +set th1_pc "" >> +gdb_test_multiple "p/x \$pc" "fetch thread 1 PC" { >> + -wrap -re "$::decimal = ($::hex)" { >> + set th1_pc $expect_out(1,string) >> + pass $gdb_test_name >> + } > > Could that use get_hexadecimal_valueof? I do not think it would add anything. get_hexadecimal_valueof in the end does: gdb_test_multiple "print /x ${exp}" $test { -re "\\$\[0-9\]* = (0x\[0-9a-zA-Z\]+).*$gdb_prompt $" { set val $expect_out(1,string) pass "$test" } } return ${val} This does not add anything to what the test already does, so it looks to me it would be a no-op. I'll sent an updated version shortly. Best, Lancelot. > > Simon >