From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2058.outbound.protection.outlook.com [40.107.6.58]) by sourceware.org (Postfix) with ESMTPS id E43D7383F083 for ; Thu, 8 Dec 2022 01:15:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E43D7383F083 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=St50NSpKfN97jZ7T/HyZOr8MkU8POt1erniZjYVSh0M=; b=Mzp6DOJHc/mutCT3w051dJYCteRxS/S0UgywH22ySl5AmdirHiX8gZVuu2rXXTPdwVoWf8KSn1oP99N7ijQqYapaZtcNQOd8Qf1USIkEfWdu1Q7QwodX0KppyMe3Tw3ylyuAbswCyyYF6kDtOsgjYzfmVpppo03zNOW8AnIyEg4= Received: from DB6P193CA0009.EURP193.PROD.OUTLOOK.COM (2603:10a6:6:29::19) by DU0PR08MB10328.eurprd08.prod.outlook.com (2603:10a6:10:476::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Thu, 8 Dec 2022 01:15:46 +0000 Received: from DBAEUR03FT059.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:29:cafe::2b) by DB6P193CA0009.outlook.office365.com (2603:10a6:6:29::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14 via Frontend Transport; Thu, 8 Dec 2022 01:15:46 +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 DBAEUR03FT059.mail.protection.outlook.com (100.127.142.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5901.16 via Frontend Transport; Thu, 8 Dec 2022 01:15:46 +0000 Received: ("Tessian outbound 2ff13c8f2c05:v130"); Thu, 08 Dec 2022 01:15:46 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 648021982ffad0b2 X-CR-MTA-TID: 64aa7808 Received: from 789690c2256d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6663FBFF-AC6D-4824-9737-F6E3534386F3.1; Thu, 08 Dec 2022 01:15:39 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 789690c2256d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 08 Dec 2022 01:15:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D5G7gWU3ZYOnW/YYtSTt/1Htg6iokeasrMgipDTqhr6Aq9vbmktikkbOHGjY/bodJO6/pvsMNsFEuAOhL2KjvQ6TsR+9AlCKvq02HCj4GVGlavXReErCrZ3x9GC5K8NE7/BHPb8JlYskQPMJ9vgr1jdcdC08UnlMaFOXv127JuA+XKVsLaIgkKugA/zvmkjzGhaPdEXFiIx4zt4yOSndCn6E294HpQuJevDeLRLHF6baX+ftfjG1m+//5SQQYTHuoojAP5pXQ6NzFlY83yYKi7V+ny5sNezxK21JaDicZF77qnUehp7PGligtP4cXl4PJjjBTS6KoMEnDq48enDaNQ== 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=St50NSpKfN97jZ7T/HyZOr8MkU8POt1erniZjYVSh0M=; b=W/nojjwXd5+PqmIjDHoKl4s2QCHiSflfv1Dekvb6mBHAzVtow+6fmuf8Offd1/BdXjd0twR1bpDwPz2RXZYkEFMgSPoFs5xJun/Jhtn9sKRqBj7l/FN8qiIDqHMlVeYSqC0htCJbrUEjrqa495fxfZcku6dbJ38ixDrHYRLn8Z0F+XEz8HP+EjbrFlyIyBZV38Fsmo/Y3p5GABeq9MdJVSxnuLF6fxXwZfbKryIlEuDHeFh+9XtUihBbNzc59ri2GngLPBIMRf24G2L52sGbCFhwpYXMN6wuVGLiGosCub6DwLdl7zzbOFm6dwBbUoF8rGtvXkFl7vNRY4wt6aE9hA== 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=St50NSpKfN97jZ7T/HyZOr8MkU8POt1erniZjYVSh0M=; b=Mzp6DOJHc/mutCT3w051dJYCteRxS/S0UgywH22ySl5AmdirHiX8gZVuu2rXXTPdwVoWf8KSn1oP99N7ijQqYapaZtcNQOd8Qf1USIkEfWdu1Q7QwodX0KppyMe3Tw3ylyuAbswCyyYF6kDtOsgjYzfmVpppo03zNOW8AnIyEg4= 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 AS2PR08MB9713.eurprd08.prod.outlook.com (2603:10a6:20b:607::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.14; Thu, 8 Dec 2022 01:15:30 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::fe5c:b195:a2ad:b19c]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::fe5c:b195:a2ad:b19c%4]) with mapi id 15.20.5880.014; Thu, 8 Dec 2022 01:15:30 +0000 Message-ID: <5268a4e1-7143-91ba-872e-9f942a2e29b2@arm.com> Date: Thu, 8 Dec 2022 01:15:29 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PING] [PATCH v2] gdb: Modify until_break_command to act correctly on SIGTRAMP_FRAME Content-Language: en-US To: Tomas Vanek , gdb-patches@sourceware.org References: <1666353538-15846-1-git-send-email-vanekt@fbl.cz> <7ce34c91-00ab-cf16-a13f-21fa8eada5a9@fbl.cz> From: Luis Machado In-Reply-To: <7ce34c91-00ab-cf16-a13f-21fa8eada5a9@fbl.cz> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO2P265CA0477.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a2::33) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|AS2PR08MB9713:EE_|DBAEUR03FT059:EE_|DU0PR08MB10328:EE_ X-MS-Office365-Filtering-Correlation-Id: d1fa39e4-d3ae-4700-057f-08dad8b9bc4e 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: zcb+/vNJm/d4pvlYjtul+YJ4qDWUXyc2jOI1lQt5PII1gmWtKPktnWHaVhz5ZkHl0YMXdPdknKYfA2xtxYTYiZ2p/aweeyyXwQyAkBAI539T+/P3h+DGjW7l3S8hDDtZJDUB8sUp3HearvVSfteKSzJMMhFJDb2jdmQqnS6gB+3J7C+NCSi8mnG73oSHjOpRP2gukSDqptkd5Xk5wzZWy/1ME1ZCd4PuvgI/g2UjmJ85qr8ZM5cLBtkLqXOCkll68dXK8QELk2fEF1h7Sieww02pMIvce9KrfAV2fAr7N646xc5UurcIKJvalAg9ZRPiH7hOFs9DvoXD+BvaOZPtR3afJwIiq1oxakAVCBzHgw9iYHSPvUpwfGo/cQZCA6cKxVWHOJMVqeEqEKZ15Ex0pq1lqQLRFoyChb4MT7BL4VrRZUKsAJrChH+v/MPfYW+Lw9H0brKwQweEI/xX/U5+nxRCSRXFHy6CWBTsHpKgQXtHBAr8NIzndPQ0KVoU5SSX61FVMtSAPUGRUqvBplXVROXnXvxhEXcnxK4WMsqp5aS/t+b1IqvTSk2xd6tnNHqKCqzBEo4OATTquv7KHRy3XC2omURx/hsTLByeb0xnTrVq8PFAAoAZlle9UWzXgrEmovtvmfSz+OBO4J97merMS69l6+a66Qc99jznTw80wVIz/+QBSf+ILeWQul2U+ZOIRtifgM7dlcnpo21B3FgYdXj0sn0rtHyq5khGB09Csvv87IZoRIccW+39EpQ1mlSH 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:(13230022)(4636009)(376002)(39860400002)(346002)(366004)(396003)(136003)(451199015)(83380400001)(31696002)(38100700002)(44832011)(5660300002)(41300700001)(2906002)(8936002)(8676002)(53546011)(6506007)(26005)(6512007)(316002)(66946007)(6486002)(478600001)(966005)(2616005)(66556008)(66476007)(186003)(86362001)(31686004)(36756003)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB9713 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: DBAEUR03FT059.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 7d6b1890-6f8f-4e2d-537e-08dad8b9b214 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sEyWPpylSI764K/Caaob0YdD/c8B/FVUJ6dCkVpFcNeFDYKN0OF8KIx9wxQGEqLF0S7VVkGrOC2LD2lk2qxa71unG4VBW+KlOIMKAdWtI7bPTxea5nU3JQ0Wq0OizkODPNlPL80p2mU0AXm/PTwvDTgKpJ7QDb2yLwoY39eyuWHuxHon94pzdaZWvdMtTVr8Fj8CYS9QMzJ/awcIswbqirI+bX8iptj16pcrx0CMlDkABTTOEco2sE4boaPfxeVVASbpk4AXEW5yzQbhQQCWeXCoxzrvQotdnG+ig0pDM+y7yFkJKEFV0UGmSlRqOrmLyCUuQubOc6jtTADdcQpTq4nYPDMdtBS8GU+PmOlBHOOM+nhi/6lv8d013ov1QNA2unu/br8UfqckLnbVEtczSpU2HAYEXcehgcR0hnnnhQHquqRFCVTygkGgvUNJIRdqsHU5c74z8ujQnZPxDnoPF5Zig6c7IZzXUtDKfl+Qyu7ttb8mLXnOvpBrPcK0edee8tCu4Vtr8rIFg+nz+du0v4aSJlUWlooTnNx6+3jRwA+ivbqFoQXnI2r2EUbEgO5iKsxLcvvOSirI9GlHZmEshhwzQgHDZXPaOKxJ916tK+18PZw6r8KPXP8fEgqt5+ZJ1a70RFAqkcm8bQwYD5IVtLBYF0GX9xHbroEF5DioeEEPX1iUmGYbt+deIjYcO/YxCPPn/ppL9vWDg55jIYkOniV44x5KG/b8yvAgStzkaEWZhbS36vvVuKubfwL/GViDtWZM6wxHBRfWbZcnw79DPw== 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:(13230022)(4636009)(346002)(396003)(39860400002)(136003)(376002)(451199015)(36840700001)(46966006)(40470700004)(36756003)(36860700001)(82740400003)(70206006)(8676002)(186003)(70586007)(336012)(2616005)(53546011)(83380400001)(31696002)(26005)(6512007)(40460700003)(316002)(478600001)(966005)(86362001)(82310400005)(47076005)(6486002)(6506007)(2906002)(40480700001)(356005)(81166007)(41300700001)(31686004)(8936002)(5660300002)(44832011)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2022 01:15:46.5969 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d1fa39e4-d3ae-4700-057f-08dad8b9bc4e 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: DBAEUR03FT059.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB10328 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00,BODY_8BITS,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,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: On 11/28/22 11:48, Tomas Vanek via Gdb-patches wrote: > On 21/10/2022 13:58, Tomas Vanek wrote: >> This patch partially depends on >> gdb/arm: Terminate frame unwinding in M-profile lockup state >> (without it lockup state is unwound as if it were a normal >> stack frame). >> >> The commands 'advance' and 'until' try to set a breakpoint >> on the bogus return address derived from Arm M-profile magic >> address (actually EXC_RETURN or a PC value indicating lockup). >> >> The offending breakpoint should be set at the return address in >> the caller. The magic value 0xffffffff in LR indicates >> there is no caller (return to this address would lock up the CPU). >> >> Similar behaviour of 'advance' and 'until' is observed in >> an exception handler routine. In this case LR contains e.g. >> 0xfffffff1 (EXC_RETURN) and GDB tries to set a breakpoint at >> 0xfffffff0. It should use a return value stacked by the exception >> instead. >> >> Testbench setup: >> STM32G474, a Cortex-M4 device. Any Cortex-M device can be used. >> A test application (an ordinary blink) with a standard startup >> is loaded to the device flash. >> >> Steps to reproduce the problem: >> >> start GDB server >>   $ openocd -f interface/cmsis-dap.cfg -f target/stm32g4x.cfg >> >> start GDB in second terminal >>   $ arm-none-eabi-gdb blink.elf >> >>   (gdb) target extended-remote localhost:3333 >> >> Reset the device and halt it: >>   (gdb) monitor reset halt >>   target halted due to debug-request, current mode: Thread >>   xPSR: 0x01000000 pc: 0x08000e14 msp: 0x20020000 >> >> Step by one instruction to re-read GDB register cache: >>   (gdb) stepi >> >> Check registers, LR should be 0xffffffff after reset: >>   (gdb) info registers >>   ... >>   sp             0x20020000          0x20020000 >>   lr             0xffffffff          -1 >>   pc             0x8000e16           0x8000e16 >>   xPSR           0x1000000           16777216 >>   ... >> >>   (gdb) set debug remote >> >> Issue 'advance' command: >>   (gdb) advance main >>   [remote] Sending packet: $mfffffffe,2#fa >>   [remote] Packet received: 0000 >>   [remote] Sending packet: $mfffffffe,2#fa >>   [remote] Packet received: 0000 >>   [remote] Sending packet: $m8000526,2#30 >>   [remote] Packet received: 2046 >>   [remote] Sending packet: $Z1,8000526,2#7a >>   [remote] Packet received: OK >>   [remote] packet_ok: Packet Z1 (hardware-breakpoint) is supported >>   [remote] Sending packet: $Z0,fffffffe,2#43 >>   [remote] Packet received: E0E >>   [remote] packet_ok: Packet Z0 (software-breakpoint) is supported >>   Warning: >>   Cannot insert breakpoint 0. >>   Cannot access memory at address 0xfffffffe >> >>   Command aborted. >>   (gdb) >> >> Relevant messages from OpenOCD: >>   Error: Failed to read memory at 0xfffff000 >>   Error: can't add breakpoint: unknown reason >> >> This patch adds skipping over frames that are not suitable for >> guarding with a breakpoint inspired by 'finish' command. >> If no suitable frame is found, a momentary breakpoint is not set. >> >> v2: Comment fixes, bug reference. >> >> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28683 >> Signed-off-by: Tomas Vanek >> --- >>   gdb/breakpoint.c | 22 +++++++++++++++++----- >>   1 file changed, 17 insertions(+), 5 deletions(-) >> >> diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c >> index f6591d4..bb85342 100644 >> --- a/gdb/breakpoint.c >> +++ b/gdb/breakpoint.c >> @@ -10467,6 +10467,7 @@ enum async_reply_reason >>   until_break_command (const char *arg, int from_tty, int anywhere) >>   { >>     frame_info_ptr frame; >> +  frame_info_ptr caller_frame; >>     struct gdbarch *frame_gdbarch; >>     struct frame_id stack_frame_id; >>     struct frame_id caller_frame_id; >> @@ -10505,7 +10506,17 @@ enum async_reply_reason >>     frame = get_selected_frame (NULL); >>     frame_gdbarch = get_frame_arch (frame); >>     stack_frame_id = get_stack_frame_id (frame); >> -  caller_frame_id = frame_unwind_caller_id (frame); >> + >> +  caller_frame = get_prev_frame_always (frame); >> + >> +  while (caller_frame) >> +    { >> +      if (get_frame_type (caller_frame) != TAILCALL_FRAME >> +      && gdbarch_code_of_frame_writable (get_frame_arch (caller_frame), caller_frame)) >> +    break; >> + >> +      caller_frame = get_prev_frame_always (caller_frame); >> +    } >>     /* Keep within the current frame, or in frames called by the current >>        one.  */ >> @@ -10514,14 +10525,15 @@ enum async_reply_reason >>     gdb::optional lj_deleter; >> -  if (frame_id_p (caller_frame_id)) >> +  if (caller_frame) >>       { >>         struct symtab_and_line sal2; >>         struct gdbarch *caller_gdbarch; >> -      sal2 = find_pc_line (frame_unwind_caller_pc (frame), 0); >> -      sal2.pc = frame_unwind_caller_pc (frame); >> -      caller_gdbarch = frame_unwind_caller_arch (frame); >> +      sal2 = find_pc_line (get_frame_pc (caller_frame), 0); >> +      sal2.pc = get_frame_pc (caller_frame); >> +      caller_gdbarch = get_frame_arch (caller_frame); >> +      caller_frame_id = get_frame_id (caller_frame); >>         breakpoint_up caller_breakpoint >>       = set_momentary_breakpoint (caller_gdbarch, sal2, > Would be nice to have some feedback on the generic parts of the above patch. It seems like a useful fix to have.