From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2078.outbound.protection.outlook.com [40.107.20.78]) by sourceware.org (Postfix) with ESMTPS id 37EFA3858D28 for ; Mon, 17 Jul 2023 09:35:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 37EFA3858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q/MO7g7EAEpScB7tHX7ABSiKYS3hmuWYe/sh/a4Tnvc=; b=cjULfMvDEwS5z9suuQXQTfztp+Pw1Exh5rw+xfG7UaFM0Kpis1gb5PbGdi9oD2q2LN2pCmYo//fq1yywF1OQud/kW5NDd4eIV4gpphgOJxKbfH3jCtEhqCWO7ZZCY2CxOZt0m6PbAMMYdy7EcoDXyb+/OCuDYnCjD++ZWmWsS/k= Received: from DUZPR01CA0048.eurprd01.prod.exchangelabs.com (2603:10a6:10:469::17) by DU0PR08MB10357.eurprd08.prod.outlook.com (2603:10a6:10:414::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.31; Mon, 17 Jul 2023 09:35:54 +0000 Received: from DBAEUR03FT015.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:469:cafe::a4) by DUZPR01CA0048.outlook.office365.com (2603:10a6:10:469::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.32 via Frontend Transport; Mon, 17 Jul 2023 09:35:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT015.mail.protection.outlook.com (100.127.142.112) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.32 via Frontend Transport; Mon, 17 Jul 2023 09:35:54 +0000 Received: ("Tessian outbound d7adc65d10b4:v145"); Mon, 17 Jul 2023 09:35:54 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: f57d9ca0040447fe X-CR-MTA-TID: 64aa7808 Received: from f8997f09b4d4.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D59681C8-A162-4C6B-AC0A-07C23613973D.1; Mon, 17 Jul 2023 09:35:48 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f8997f09b4d4.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 17 Jul 2023 09:35:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kSzgL1n7EbPdRiMbXUBwZ/Jm0D9bXke7dvHJIiGk6OvPfj6ldGXACLbpOGawPbOtHn7PnsHAG45v5jU+b1kCPDoQeePYKKAu2XEvkf/38Qpm0kVAST0GLU93Cdhj5CALIU7tN08+xRqj9yDTQ4/YP3UkUBYso9hc2L7FrYxYrc4bqmiU2YseFw9b44lUQHtM+9Z/TAK7ZYVbzl4nH3JptN7cN1szNK6E+Pa8yeZbscBjSWOvEy3wNnppGPRRBgh27tmtLv+wJy98maf/MYMf28CDMVnRepuaiNq66QSxhZ6bBcWiBbxj/wG7NcefeK6zR9DOYbfXfINuUA1JUNKOgw== 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=Q/MO7g7EAEpScB7tHX7ABSiKYS3hmuWYe/sh/a4Tnvc=; b=lP4V86AyVgJz11zlMUmy/XteZPhY5bX2PTmf48NNHYgZab2+T7tveXqUAqvs9XhRJWeG8av10Q0hzpujzBWVd03sfDfK5fs22lvf79gKdRAVxhQudmOAyGHZZyOQlsPxh0Xgp4931Zo5njQDAZ9jB5DBz0LyBdkmWO5Pyj+ZLubytmUNGBkECTQgKSm0BoPl7a4WFAppIe9E1eisnHA0rGUxWDfhhoDZ6HbdioXtLtvaqd8cf5n4vAXgCpwfaTt+2oUcGTyh06lCjGEHEtCvQS65vNqqnog4uhi32SlsELO/1hJTfNkHo3Lli0KKb8nCKXOH9zsaJ9aWDDzZdKmnLA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Q/MO7g7EAEpScB7tHX7ABSiKYS3hmuWYe/sh/a4Tnvc=; b=cjULfMvDEwS5z9suuQXQTfztp+Pw1Exh5rw+xfG7UaFM0Kpis1gb5PbGdi9oD2q2LN2pCmYo//fq1yywF1OQud/kW5NDd4eIV4gpphgOJxKbfH3jCtEhqCWO7ZZCY2CxOZt0m6PbAMMYdy7EcoDXyb+/OCuDYnCjD++ZWmWsS/k= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) by AS4PR08MB7505.eurprd08.prod.outlook.com (2603:10a6:20b:4f7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.31; Mon, 17 Jul 2023 09:35:46 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::8a62:27dd:fe3c:cefd]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::8a62:27dd:fe3c:cefd%7]) with mapi id 15.20.6588.031; Mon, 17 Jul 2023 09:35:45 +0000 Message-ID: <5de00df3-2b6f-7a64-3f59-d2c384f0cbbf@arm.com> Date: Mon, 17 Jul 2023 10:35:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] gdbserver: Install single-step breakpoint for a pending thread whose last_resume_kind is resume_step To: Kevin Buettner , zhiyong.yan@windriver.com Cc: gdb-patches@sourceware.org, tom@tromey.com References: <20230703030458.1192525-1-zhiyong.yan@windriver.com> <20230711114034.5d2fe2cb@f37-zws-nv> Content-Language: en-US From: Luis Machado In-Reply-To: <20230711114034.5d2fe2cb@f37-zws-nv> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P123CA0469.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1a8::6) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|AS4PR08MB7505:EE_|DBAEUR03FT015:EE_|DU0PR08MB10357:EE_ X-MS-Office365-Filtering-Correlation-Id: e99e715a-517c-48ed-0aac-08db86a937d8 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: jB8Pvk7D8eAWURGmCtJEwzKEUX+fkefcyUkJet5jDBRQjLhhHNV8w+apqgt0yr6WiSKbmfrlQSajbBqE/uNeVB9thr0JwK+Xau+zycnw9hodydDMy9RRalQXGXl8zIB/q9QRloCABVupqlDzKXRrQRoIMUciBPVtpD6EPqzu5x/RZcYanHrau869SyKcWJzDGS7CkJB3ZNbkKp2gBedQrmD9tDdbkRtmfyyLR4QhUTgdZuwcSiBH+4FMi6GZqc5W5dX7Eyzg/AQDP9Purpyj3A6kzjPBwNAd0pxdicTFJuwVtgH9Cb3M1x8ZhLKEkksDKNJU59dCXEsEA/qaFZFB3oB63rHymvIjIurJM1m6Xm0415308+o8AG7HgXngzdNdmOdNo6N3GOz81slG0ERYYORQHw03n+NNLElbWS7telBfB15ljHNM0oHhGwzY9rR7B2qQ2z6dCRWRELnIKLZygkt+uyhFVzZl4o+TqXQeCaZsvmVTbWdw/af6Be5QfjGxMSQ6mLxM/WwbRzRvsxxbR4L+ukroZHzT8A6AcuxslDV7sXeulP5O5Qtt6NK/WwrmFD44a4frrs3MCGhGRNM6IWjqM+PDF2E+D2t2LkP4x2bGQTtcpCv/dzhPnX7wfxYI3n26WUqe7IJ/AK+N/a7rgw== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR08MB3919.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(39860400002)(376002)(366004)(396003)(136003)(451199021)(31686004)(478600001)(6486002)(6666004)(83380400001)(31696002)(86362001)(2906002)(53546011)(36756003)(186003)(6506007)(2616005)(966005)(26005)(6512007)(316002)(38100700002)(66556008)(4326008)(66946007)(66476007)(41300700001)(44832011)(8676002)(8936002)(5660300002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR08MB7505 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: c75b4711-54f6-45c6-8c3d-08db86a931df X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Yl4gZsfN1EBxdxEymWsFX8JtjeExJqmdpeWIYWcFcIJB0BpPJ3gAvprve90bNlEvgCRDdtLRYBawX/uuMBgze8vRf+543YvKz1h4G6VHcxTwxvc/2q3lHocFGzFmr1B23J3ffK/M+kDQ4+FiZXTSAIxPCJ4TMs1GUxPQonExyT1WPj9VgvUpfgwXBeYEKJQHfGjfwTdPBobq4ebkSKUl+1deh2FrjCMc9zk20fEwikn1grOeWQWJe8zDY7Cpde0SeLn5GedhLYCSvHP36ytKuW0TqgzIX1qlAmKB/ikJyY4cc5V12J+zgG25Wf4k3CvSIXv1AaUsJp0kWgEzBoEHIEi1PBDAxgHYJMYcTPMR/D603xuJhK2G6wKWDWKt+o1bViW2i3MX3zWQRLGfVfOivZUKOZhTwYjgp7jY9dlmQzxRxBVset/7NO+1wYPEAbs/Xul4YnGP8OmRZlU0j+mEEcgwgFZcjelAl2zW5/TS8SMYwTtZ7cLkQ9q2hUfl2evHnAl44AaxlcodQLaA2aQ7Dcb3MNMxezgjN+DTlerq7oEx8fyps+1YOhqA2DKn4pLebXzT0LAe9/Vab/v+WAC4FJRf+WqqkSgNJgNzib+0OtsC0tbSrkXim+QLAr06N8EZKI48JiDCC5/DOTUHgTEPsXXTNH62GF8aMqSafrvaOF2cT7EQO5Jf0WkY2YoKTTHgDb0fFwYJLq1f6reVMM1k1b+GgpC3iePILIvb3bp+y66nTsL+HEtag9SbF7Gnv6j0EhL20BW73xF6w0be4AkWyg== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230028)(4636009)(39860400002)(346002)(376002)(396003)(136003)(82310400008)(451199021)(40470700004)(36840700001)(46966006)(31686004)(31696002)(86362001)(2906002)(36756003)(44832011)(40460700003)(40480700001)(966005)(6512007)(186003)(336012)(83380400001)(36860700001)(47076005)(53546011)(6506007)(26005)(107886003)(82740400003)(356005)(81166007)(70206006)(6486002)(6666004)(70586007)(316002)(2616005)(4326008)(478600001)(41300700001)(5660300002)(8676002)(8936002)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jul 2023 09:35:54.7401 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e99e715a-517c-48ed-0aac-08db86a937d8 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB10357 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY 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, On 7/11/23 19:42, Kevin Buettner wrote: > Hi Zhiyong, > > See my comments below; there's still one formatting nit, but I also > have a question about whether this is the right place to fix the bug > that you're seeing. > > Also, I've added Luis to the CC list since he knows a lot more about > the ARM architecture than I do. I was aware of this one, but since it is generic code, I thought I'd defer it to the global maintainers. It doesn't look like something that can/should be handled in arch-specific layers. But I can revisit it if people think otherwise. > > On Mon, 3 Jul 2023 11:04:58 +0800 > wrote: > >> From: Zhiyong Yan >> >> Gdb should not assume pending threads always generate "a non-gdbserver trap event", for example "Signal 17" event could happen. Now that resume_stopped_resumed_lwps() -> may_hw_step() assumes that the break point must already exist, resume_one_thread() should ensure the software breaking point is installed although the thread is pending. >> >> Signed-off-by: Zhiyong Yan zhiyong.yan@windriver.com >> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30387 >> --- >> gdbserver/linux-low.cc | 11 ++++++++++- >> 1 file changed, 10 insertions(+), 1 deletion(-) >> >> diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc >> index e6a39202a98..7d8bbf71ddc 100644 >> --- a/gdbserver/linux-low.cc >> +++ b/gdbserver/linux-low.cc >> @@ -4671,7 +4671,16 @@ linux_process_target::resume_one_thread (thread_info *thread, >> proceed_one_lwp (thread, NULL); >> } >> else >> - threads_debug_printf ("leaving LWP %ld stopped", lwpid_of (thread)); >> + { >> + threads_debug_printf ("leaving LWP %ld stopped", lwpid_of (thread)); >> + if (thread->last_resume_kind == resume_step) >> + { >> + /* If resume_step is required by GDB, >> + install single-step breakpoint. */ >> + if (supports_software_single_step()) > > Formatting nit: you need a space between 'supports_software_single_step' > and the left paren. > >> + install_software_single_step_breakpoints (lwp); >> + } >> + } >> >> thread->last_status.set_ignore (); >> lwp->resume = NULL; > > With regard to the change itself... > > If the debugging printf is accurate, the LWP is being left in a > stopped state. If that's the case, then why are software single step > breakpoints being inserted? It seems to me that you'd only want > to insert these breakpoints when the thread is actually about to > resume. > > That said, I have no doubt that this change works for you, so clearly > there's something going on which I do not understand. I'd like to > understand the situation better before approving it. Also, once you > have an explanation, please update the code comments and/or commit log > message as appropriate. My personal preference is for a concise > explanation to be placed in the code comments with any additional, > longer winded explanations or examples being placed in the commit log > message. > > Kevin >