Message ID | AS8P193MB12851EAC96A002B34CB57EBBE4042@AS8P193MB1285.EURP193.PROD.OUTLOOK.COM |
---|---|
State | New |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2A4F33858401 for <patchwork@sourceware.org>; Fri, 12 Apr 2024 07:29:54 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05olkn2020.outbound.protection.outlook.com [40.92.90.20]) by sourceware.org (Postfix) with ESMTPS id 8B7DF3858C50 for <gdb-patches@sourceware.org>; Fri, 12 Apr 2024 07:29:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8B7DF3858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=hotmail.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=hotmail.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8B7DF3858C50 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.92.90.20 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1712906972; cv=pass; b=IzHTg1vYiTpdjoXBuj7kLQa6smgHTZZkzRnCePxskaaVEYopt6qFcVn7YMJGQnKtTAYv/YKL6lG32GU8vR/esQigjL5iHJfm+AubdEWRQMEONdyPDDhKDwaQbGEWX34V7CwbN6PTPDsbSWvWm0pH+Xj12eeOG+mZljd+RlU+wYA= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1712906972; c=relaxed/simple; bh=iVV/Md5xsH1u6+MQOEe/l89sgjoCjsRV0UJlMlO8W3o=; h=DKIM-Signature:Message-ID:Date:To:From:Subject:MIME-Version; b=PdzVfrAoRlQ7ksUhWEKOmuIBJeIO6EQarFn7k2SQHoE0IfGSJumwXSv+4fOuys4HIZELpSjLhG+qtpdRXc0Whh8D4KOLH0DyU+CGUyUsclSdFB8thRTz36hXR8blYP5k27dgcZKJX+u4uSfpRDmQvWsQSC6BDKmS+ldrwgnlNcY= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NNPnUI3BHcpiM5ZLbUDWv0bmDYW2nvieuy1WyAUD3h43Oal6kqDzGLtn1jQZmppgEjGj4ZCUSHI88yEkQH6ClAOGELb1Gy6Hgo/psoiD0niJaX0WJt4KZAD9SnsHiwrhX0hMUQaUBnbRAkcrW4PmVJ83Gj3ekJVMUBYwWOSnsEAp8ZanmxXC4JoStka3+aMmWCD3GE/5mZNBwh3zmkUFwON44I6w0nHtOaPTiadgZpr70UQ5c5H3yZmd+feLdQitB1mCDkkfSMtknHR8kBTjrC0K13XVQMExRiBB6Mo+Ao/y6BD35eJ+QRyAr3ylOF6QsRnOfj756165Z1ARn2ppmg== 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=N3m0gXU0rVbXOdo7JZ9OnUoeGz9CWQ/Ir4oy082p458=; b=MIFgkQmzefZW5ISo2ST57V9xT6g8LVFZznqQsH5XyNbA/8r5ZaM8jbF29WWkHKeMBYRgHcgPw9ZKCsofdvLm2c2HOnxu+dj01qCwcdCARjS7Pos1/J6+jEiR/87z3XwUPB9H3D5MWLBTQ9uqt3kI4IozvJPXsL0JihJ4ttYft/iEeeMpz07sfjEtlghHf6n9s1klQTRy1DOQsXRiHmcPAxSWV4vnx+nNhtxOoRVJ7kLccgXkJxozzghg6uEyHu35xibcMWXgcdV2vUsJbEBVgIFJ31i8qDHbNWPtWU1H2vbkK5FdUHVW/ZNJsnxyNZjBWJo8uRbxeINeK18Ao+mVHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=HOTMAIL.DE; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N3m0gXU0rVbXOdo7JZ9OnUoeGz9CWQ/Ir4oy082p458=; b=N+nXPYh0Ot2JOVUqyMi6+1Eo7N5XHTYEksNgBO9UZeRpRdCIjRDFMlHS8Ndz7R4KAAZgvkbWmXAWW5ajFyy7CdUTpITTgCmsK5gGymnzX8XbPdXBHDjLs91dbTS3XxWebMxb3j6zNe2nVHp2nnppMYAQ+J7MnYtypNgK2QvW3HhbNmGH0rzrQ5GZ1eTQR9EivXZJ5yjzTk0VluZ7ZQpVXYPrytFerhqf0F6G3YR/PtGo4t3nuPmyEBhiGiC9SZR1AosVdZcQkbGWvxSKNWp21lq6i7JYBi5+m2Ecg1i/+kFP3zT1hcemwnded/Sr3CIVkKXZgemRhCen/k8r55W9WA== Received: from AS8P193MB1285.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:333::21) by DBAP193MB0827.EURP193.PROD.OUTLOOK.COM (2603:10a6:10:1cf::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.43; Fri, 12 Apr 2024 07:29:28 +0000 Received: from AS8P193MB1285.EURP193.PROD.OUTLOOK.COM ([fe80::5403:f1ad:efaf:1f71]) by AS8P193MB1285.EURP193.PROD.OUTLOOK.COM ([fe80::5403:f1ad:efaf:1f71%4]) with mapi id 15.20.7409.053; Fri, 12 Apr 2024 07:29:28 +0000 Message-ID: <AS8P193MB12851EAC96A002B34CB57EBBE4042@AS8P193MB1285.EURP193.PROD.OUTLOOK.COM> Date: Fri, 12 Apr 2024 09:31:17 +0200 User-Agent: Mozilla Thunderbird Content-Language: en-US To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org> From: Bernd Edlinger <bernd.edlinger@hotmail.de> Subject: [PATCH] sim: riscv: Fix PC at gdb breakpoints Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TMN: [3Bhec/kMMTxS1mxVdlSUjB9uO4iqRmF2KRFj3n6OaThJdpXp17gFdaWNH2q9bSca] X-ClientProxiedBy: FR0P281CA0176.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:b4::15) To AS8P193MB1285.EURP193.PROD.OUTLOOK.COM (2603:10a6:20b:333::21) X-Microsoft-Original-Message-ID: <3512fb1d-3068-42a4-8143-7e57dbad69fa@hotmail.de> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P193MB1285:EE_|DBAP193MB0827:EE_ X-MS-Office365-Filtering-Correlation-Id: f07f93ff-6856-4727-eb68-08dc5ac2488b X-MS-Exchange-SLBlob-MailProps: znQPCv1HvwVEZyEzMyx1wEODNf7RE11Se69meG4rfQAxUYjUN2Mjj+l547gRbCtJKZZspxmB4CJqulmaRmKLhYjpNiMMp7r4C7yu4pNLTDIS7PWYyAGvGRwqYz/x6j52B6ryiqqsDrPKc9KTkYlldcmkv2vHLU5RYycQBGYnyrum56zW5YcC0wPMqpeCkYFfjK9SRJavoPkmV+Bymp3BZ3t0VU8kG+4hVwHQ6hYuvZmtaPHlED8lW/WGZp6Zfo8mfBTES3lCv+MKxc0voslu6LA1oP7qDNki3SmPRn68suhlHfpa7y6gkucFGdvbCgDq8jfLCDLuoEXjt7VdoaLmKdcGdXaMwfocrlamEV2NKxB+O79vfr/6vqM1PPlMfr5FUqQpFLG40sCaRk39VDve9PpcmJG5pEkET//hWQjdq09H8f2HkGl4apAMEia/0xfhhMXWXhe3Uq3sHTipbcPsrAhp8Hl4TMEva2d2pfMBMWmpt9UjWiIfviJnag2pw7KT0A9TOu43wfDtl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/i9/0rs9W+jJ2JAR+M2Q5QbAzC8TKuAkTqelWzULyWu6RR47Gkreq9kx?= =?utf-8?q?ed+Z8qHRXRJ2Y8+hId//ND3LmWGm4lYNdpicv2HJ1FhCDd9PS2/2HJVGOgnzzHX8Z?= =?utf-8?q?/Ra70CrFgpSHN+kaGBJ+pbT899BiHw65j7fEsZUNmI04D9G7PXWLw1puHruWvVz/i?= =?utf-8?q?T4JrBQt7Vy0H+kE5q6umiFLhV2nf7z6YHm4uL+NnWUcjMBNQ9W/g3tvsAufcPI2nb?= =?utf-8?q?mmsGH0VsK2ctVFTYyALQy2gdyLYD0uCAiIJftrU7DMg4vr+h52fNoWZn6eutno6iz?= =?utf-8?q?BaNZuNJR6UzAgSs4?= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-80ceb.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: f07f93ff-6856-4727-eb68-08dc5ac2488b X-MS-Exchange-CrossTenant-AuthSource: AS8P193MB1285.EURP193.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2024 07:29:28.4325 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAP193MB0827 X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org |
Series |
sim: riscv: Fix PC at gdb breakpoints
|
|
Checks
Context | Check | Description |
---|---|---|
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 | success | Testing passed |
linaro-tcwg-bot/tcwg_gdb_build--master-arm | success | Testing passed |
linaro-tcwg-bot/tcwg_gdb_check--master-arm | fail | Testing failed |
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 | success | Testing passed |
Commit Message
Bernd Edlinger
April 12, 2024, 7:31 a.m. UTC
The uncompressed EBREAK instruction does not work correctly this way, and the comment saying that GDB expects us to step over EBREAK is just wrong. The PC was always 4 bytes too high, which skips one instruction at break and step over commands, and causes complete chaos. The compressed EBREAK was already implemented correctly. Tested by using gdb's "target sim" and single-stepping. --- sim/riscv/sim-main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
Comments
Bernd Edlinger <bernd.edlinger@hotmail.de> writes: > The uncompressed EBREAK instruction does not work > correctly this way, and the comment saying that > GDB expects us to step over EBREAK is just wrong. > The PC was always 4 bytes too high, which skips one > instruction at break and step over commands, and > causes complete chaos. The compressed EBREAK was > already implemented correctly. > > Tested by using gdb's "target sim" and single-stepping. Thanks for fixing this. For the record, in v1.12 of the RISC-V privileged architecture specification, section 3.3.1: Environment Call and Breakpoint documents that the $pc value should be the address of the EBREAK instruction, not the address of the following instruction. Approved-By: Andrew Burgess <aburgess@redhat.com> Thanks, Andrew > --- > sim/riscv/sim-main.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c > index 0876d455570..66b99e40314 100644 > --- a/sim/riscv/sim-main.c > +++ b/sim/riscv/sim-main.c > @@ -624,9 +624,7 @@ execute_i (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op) > break; > case MATCH_EBREAK: > TRACE_INSN (cpu, "ebreak;"); > - /* GDB expects us to step over EBREAK. */ > - sim_engine_halt (sd, cpu, NULL, riscv_cpu->pc + 4, sim_stopped, > - SIM_SIGTRAP); > + sim_engine_halt (sd, cpu, NULL, riscv_cpu->pc, sim_stopped, SIM_SIGTRAP); > break; > case MATCH_ECALL: > TRACE_INSN (cpu, "ecall;"); > -- > 2.25.1
On 4/12/24 11:44, Andrew Burgess wrote: > Bernd Edlinger <bernd.edlinger@hotmail.de> writes: > >> The uncompressed EBREAK instruction does not work >> correctly this way, and the comment saying that >> GDB expects us to step over EBREAK is just wrong. >> The PC was always 4 bytes too high, which skips one >> instruction at break and step over commands, and >> causes complete chaos. The compressed EBREAK was >> already implemented correctly. >> >> Tested by using gdb's "target sim" and single-stepping. > > Thanks for fixing this. > > For the record, in v1.12 of the RISC-V privileged architecture > specification, section 3.3.1: Environment Call and Breakpoint documents > that the $pc value should be the address of the EBREAK instruction, not > the address of the following instruction. > > Approved-By: Andrew Burgess <aburgess@redhat.com> > > Thanks, > Andrew > Pushed. Thanks Bernd.
diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c index 0876d455570..66b99e40314 100644 --- a/sim/riscv/sim-main.c +++ b/sim/riscv/sim-main.c @@ -624,9 +624,7 @@ execute_i (SIM_CPU *cpu, unsigned_word iw, const struct riscv_opcode *op) break; case MATCH_EBREAK: TRACE_INSN (cpu, "ebreak;"); - /* GDB expects us to step over EBREAK. */ - sim_engine_halt (sd, cpu, NULL, riscv_cpu->pc + 4, sim_stopped, - SIM_SIGTRAP); + sim_engine_halt (sd, cpu, NULL, riscv_cpu->pc, sim_stopped, SIM_SIGTRAP); break; case MATCH_ECALL: TRACE_INSN (cpu, "ecall;");