From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2061.outbound.protection.outlook.com [40.107.249.61]) by sourceware.org (Postfix) with ESMTPS id 3E9473854160 for ; Fri, 21 Oct 2022 09:48:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3E9473854160 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=XBuH+3LIGXPIrmg4aN5kPh0smM//pzOSte0L3mOpQxkb4G6/LRQP3mRFX+uOcoDgHXRynyqUigNdALhHR2DOnsHL2j48XH6dKGcTgBFWo1W5wFhjhq1pBBW3IcHfrTSRA1yepuTKTkptWX2I4qGejAQ81rbjJlGn32PYdQbJpcsy48KDX4bUdasyJAHmG38LsuUKDlCp2uJHC2xwVzR+i0mR1R9V38Mc8PSBvFsdXPuIHjw4rHjEUr0crMgGSPpU3BNE6wsHbfRkoDyiCAivZAjCdeQEKswv2LiVQeZGOxXr1a4crVEV/dSYAimxTfzZkbjCMzlgPdjgyLQmHjOOmQ== ARC-Message-Signature: i=2; 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=MW0mmP771apvDLbYChDjqM/mdnwoN9XzdICiWziWQug=; b=gMDIzxZYlpN57UWM6O5zvmMX/B5CVrEgPL6bcl+wknsv3jNPnoL0jRQi0/wLEMV4ai3FDY03sq+YLXhIDazT8txXV4SAO1feGrsX8l7BqEQM4IE0+0bkVtLjckXpJEo4+dFYW8XENQvVOAogzxphaP0ojQC+SF3bYA5tq370nvuFDDjjTy86wiCnZzOwQqqaDspJ/q1kRga30pDaykoJYW3arxii8SrpOiTvQFoSV0FaJ3Fyp7EaAw41DSyYrH4ParPKWSHuGnkgO/TrVqn+3HjLAb1lQqUnJVSrDA1vcHjxs9tcF0XLYKogetqBS2Yzi7P2/yu93HTjGd0/BcqVqg== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from AS9PR06CA0508.eurprd06.prod.outlook.com (2603:10a6:20b:49b::32) by AS2PR08MB8746.eurprd08.prod.outlook.com (2603:10a6:20b:55e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34; Fri, 21 Oct 2022 09:48:16 +0000 Received: from AM7EUR03FT062.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:49b:cafe::56) by AS9PR06CA0508.outlook.office365.com (2603:10a6:20b:49b::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.36 via Frontend Transport; Fri, 21 Oct 2022 09:48:16 +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 AM7EUR03FT062.mail.protection.outlook.com (100.127.140.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.16 via Frontend Transport; Fri, 21 Oct 2022 09:48:16 +0000 Received: ("Tessian outbound 73ab5f36653e:v130"); Fri, 21 Oct 2022 09:48:15 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0a79522d99eaefe3 X-CR-MTA-TID: 64aa7808 Received: from 1b38cf413568.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C7BE5043-290A-4F44-B542-432F971A38F9.1; Fri, 21 Oct 2022 09:48:08 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 1b38cf413568.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 21 Oct 2022 09:48:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hr4Sxu8ZBZuDnCVWZTquTSS2+q3iWEZ+3Cjf/NIXcJusKI2fqN40ofnGqd1qAVfeXDNrdKf49tLSHWxKv+fyd+JPWRPnHStEhiBfhp8YFqb+xnkovjZfEl4tMdFkn2czoO26uqWzBoC5WNOocCu0gZVU0+qHbU6ygq03ZTC03Uu6QmVSf+Z2JQBFKYSC5QnN6HvyaczW/QyJWNSxd83/y8jnGLyLZJqZw0Ruzeohc+RQiq4Xi9rBLZpCtywmYOXI0vcy5ZhqXudsk0qxz6L9Rbzktb33XSGCc0/Mpgl0wFKW/A8WD+Su5XtprZU8KlycDE1Qt+V3fSxuJWIYVnKn1g== 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=MW0mmP771apvDLbYChDjqM/mdnwoN9XzdICiWziWQug=; b=aeuRTsCylAM6EG1kdBkhRFoK8jLOeOdtMd4OKCq2EBc1XZSz7OXRNqWefgfooyfmEOXQ0NcE0VLiV5+RFGNULQescsKy/Jm95DWaynZsw2h3a7rZoCn7N9Cf4n8vQghs0XQjXAGBZiW3MwMA0F4i/6Pz+2fZrfPDrilra/YZDBqxUoWETuA/JWHSgCc0CxDswDiGuHIF5A0XFFv3R54DHjg65Ik2cHrkREBGPTKq9yNa/v15t0v7AjICD9C+A5fYJ08xz4noLFGnFLxTT1DmdbGtmFOhoj+AaS7c8QGD6GZxCpC5LPT473JzD/EfHlhdJlGKOTY1Q+ok/TlvzypkaA== 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 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 GV1PR08MB8105.eurprd08.prod.outlook.com (2603:10a6:150:96::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34; Fri, 21 Oct 2022 09:48:02 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::7f57:1601:9b18:7529]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::7f57:1601:9b18:7529%7]) with mapi id 15.20.5723.034; Fri, 21 Oct 2022 09:48:01 +0000 Message-ID: Date: Fri, 21 Oct 2022 10:47:55 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] gdb: Modify until_break_command to act correctly on SIGTRAMP_FRAME Content-Language: en-US To: Tomas Vanek , gdb-patches@sourceware.org, Torbjorn SVENSSON References: <1666035571-19996-1-git-send-email-vanekt@fbl.cz> From: Luis Machado In-Reply-To: <1666035571-19996-1-git-send-email-vanekt@fbl.cz> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: SN6PR16CA0059.namprd16.prod.outlook.com (2603:10b6:805:ca::36) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|GV1PR08MB8105:EE_|AM7EUR03FT062:EE_|AS2PR08MB8746:EE_ X-MS-Office365-Filtering-Correlation-Id: d6e6d825-431f-4027-c42b-08dab349609d 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: 75FcpN4ZKkFITLTokDEDaORAyFAGT5BwimrrLg5KFiMNhmIrfWrJHDD/Bzcxrji6UJpTjK8u0dOf1agqt22mXmJKc/pxPKpCxYcHMoJF/7yHxKvQPY/t9cepZXDqgG0JJdcLOPucUKbhgdOGRIsJTcwIb6n5MhVvozxElm0KfpjJ3g+2WKKi2xtmG8qLKTFkvAB5qmHKJcBGzQX0pbwLa6GLYJlQycAs5kO3HxrYj3nwO5IX3xPxqsfoPNv6nKRUaBmBG3fXAVUCmyqINisHBcOhiQuZ/3rpAFUApXJX7ijYcxOWzP5oU/rfjgue1HBzxdrGX/CbiMwLOL6x248YMJek1vNkqtcO0SWNGCXmn/BU7frQT3SVwvBZeRRmC04pbqb4N7ymifSlm1pvi6q8/wIF+BjzmHC6m8h1dS6T69IXYTuxGySBX8otfnzzghAxOE3+TrD9Ntn89ZqP1cpaLbnviGjGsjupE2SR7YA1pNupv/6rDQr+HUVrYAfOkv6QCKSfISMGTmMMO4Q4/6wZuE6xF4FkfHPgf5E+ctIHwwvtlIBGE5hHhguu2Qn90ZtTiEp6y9GLV33eNM4wPKAJSDK+ttfC/psJUpCs1aJQ2AG7PVr9Nbiq1RQswNn32Yumq8ETnAGTrQz0o8N/RU2sn7pBRsc5qKgA7lfNFbJDJOGR8+LKOPp56L+KMQtooNw0Fr/A7LMsNKFHpqR1A9+KEkFqnnFv7rl0s4lE3kwaiNep2ZgE/TbxMWgSdlBei/IWYSjgpv7i1VlOw4OwLii5P+lbmRO2aqb1ZdduKrwbT2annJ02Rm/qw+2Rqvdc4El/Nu5yE+oB1H+tRSTeAOwXtA== 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)(136003)(39860400002)(346002)(366004)(376002)(396003)(451199015)(31686004)(38100700002)(478600001)(966005)(6486002)(6512007)(8936002)(186003)(316002)(41300700001)(110136005)(83380400001)(66556008)(36756003)(66946007)(86362001)(53546011)(8676002)(31696002)(2906002)(6666004)(2616005)(6506007)(44832011)(26005)(5660300002)(66476007)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8105 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: AM7EUR03FT062.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 2c628dcb-709c-42dd-11e8-08dab34957d5 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dwFZoRlyskdNAE2taJZ5t3qphEJ3LMRCXoMslJ3ATi6eQ3G9ywsZEKfBLwoywg/0H1OSHVInpkL6qpr/1DgMq1igpMXE90fvyo2StT47x9YWN5W5ZXEmd+Xg/KilJAv6YjYe6MSor5X+D576o/0BIVU73xduPoHNqt5AX+wrlNZqdRB0OZRk1Bwt8chB3rJZBeLvo7NCtW2jdw0i6xUDe3KovDG/MSaIEs8ZTSOZBEuff4B7spZ2tnzgroMvqy/IgF550ECiYLhjW2HGeAqAg6cQf3V7CNUrrFIxGsDVEYjMSEqTUqQzaIf8iH5G+2varXDxxQltvwOHEP3gvolkAG+VE4bZW+sjzeD8QUDLx9gFshkRZjJm4PrP8380G29AvHeGBp9sdyZyBVIGqTu33fcDtKmm4g3uv1E3tsBmzPQXVqhrNujYjFT6OuMGkDozodtXBo4+iH7iuN8Me1II6Ed096+BBCLzNKQ/k/gWKQK9XXUj6IFRk5lF6T/Qc5j3xG4OuNs85Hq9F7MAGE0HpLuStkYGaOjRcjaQ72Z3N3nIg2lUjwD27Q8DK/ckaX6i5aQF+4FvEAJGGpMWSMSmJvXIw+QlfBcg5LMtNtxq4KRt9TT0Q2d68nTVAWjzuXryxo6Z6VxFrU5F85mp168XAZcHUxUtfkIOtAt3x9debT8/PD5110rgn1dliTcAG9hS0EjXMAmf7sGxfYIBK67zGD/BmAuyJ1UJwD6rXTsyfXGv+wPxDhOu19qxAcHLQOpkggnumkxhw3ksT1Z0CrBj6jfXwg5GflUuMVZpjE/ZI/zH2yQAdswrsA2pZB/428+YZH+CPA5U52TmN89ImosL4w== 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)(376002)(346002)(39860400002)(396003)(136003)(451199015)(46966006)(36840700001)(40470700004)(86362001)(81166007)(356005)(186003)(6486002)(82740400003)(2906002)(2616005)(966005)(478600001)(82310400005)(40460700003)(70206006)(8676002)(110136005)(44832011)(40480700001)(8936002)(31686004)(36860700001)(47076005)(6666004)(53546011)(6506007)(26005)(6512007)(36756003)(41300700001)(336012)(31696002)(316002)(83380400001)(5660300002)(70586007)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Oct 2022 09:48:16.0501 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d6e6d825-431f-4027-c42b-08dab349609d 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: AM7EUR03FT062.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB8746 X-Spam-Status: No, score=-12.3 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, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Oct 2022 09:48:21 -0000 Hi Tomas, Thanks for the patch. You should reference the bugzilla ticket https://sourceware.org/bugzilla/show_bug.cgi?id=28683. On 10/17/22 20:39, 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 it were normal stack frame) as it were -> as if it were a > > 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 return address to at return -> at the return to the caller function -> in the caller? > the caller function. 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 momentrary breakpoint is not set. momentrary -> momentary > --- > 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, If we use the magic value of 0xFFFFFFFF as a way to stop unwinding, doesn't the until_break_command code handle this automatically? I mean, if there are no outer frames, then it won't attempt to insert a breakpoint. Is that the case?