From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2135.outbound.protection.outlook.com [40.107.237.135]) by sourceware.org (Postfix) with ESMTPS id C07F33857B99 for ; Sun, 3 Jul 2022 03:58:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C07F33857B99 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=crossfire-tech.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=crossfire-tech.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eA960lPqS4hABmENIJMPLX9DbC7NbNJgZIZeK4x1ZyPzR9kluec2kOHcbWc6jctCFd3ZWkYb/pWRu0SNtnkHJj+Vw5CgCvvY41x0vaReyLUaMpHSSd+JGJWkPm8OvJfZhmQU/rZM4FHGkKSbQbFS+Rtsc3M1vLQzGTLFKvUh0hwMXLoKYmWGGT0mQs6VYwkF9p9v/FmrEu5hBF4lLH15jFUxSloLXGXAnL+Mc+aK549nOkKQXAoQKwTMsb7psmuMRBC5yog2Wb50wmHk9iXbt1umJCObax4004PO2D3HNAoL5ncl5711EbtaYlE767negDom7xvqlsk8MtuC+eltOg== 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=dHu42bl3meic2ybSBk9nxo+j1pAp75H1M9g9YiBYtbc=; b=Ge22I/pthXh43Fx4O4Ji6M0LMCPCOAiO5WTfaO+TteZMNZzq10ag4cKQ1NRlGg4k6sRg4znokLV3dYukndxYv/Db8ogFXLMoQZlI2cGO5rEuc5BdOFSF16zchqTnxzuFANHC2xYyFXrIbNYGmTAnpR4Vv+l+TNXS1fE0l47RcSQQVDlEcWo11dNuQ3h8YYjIc/Kf26XKZ+NkeDeg3Fp01zXTwsWn+p7ua+1IfVT16nMD7Yaoezp8HwLJLhtGvCA3ht86dgr6vBqIjpM7+FuHn3CrXvIODtapuTid7JEYNP9a8xXnj2DODZLASUqB12pCTP16jCpmjfqUBXxa9gP4FQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=crossfire-tech.com; dmarc=pass action=none header.from=crossfire-tech.com; dkim=pass header.d=crossfire-tech.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crossfiretechcom.onmicrosoft.com; s=selector2-crossfiretechcom-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dHu42bl3meic2ybSBk9nxo+j1pAp75H1M9g9YiBYtbc=; b=PqI8yp21cNuaDOvmmcvFkhIY042nyso62HiVeO+0BuuGRT4k21SIvZ1KVsgLdzMAjo6boLCE4PIanddOcvYMcoBIOhLlXvoYFNoUqU1kUt88MZ6qqK0xA5BvdSJA8cErpudrzPMFLCiE09QkJFyuMschvqWFBK8yEPCmqakMupA= Received: from DM5PR1201MB0060.namprd12.prod.outlook.com (2603:10b6:4:51::15) by PH7PR12MB6419.namprd12.prod.outlook.com (2603:10b6:510:1fd::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.18; Sun, 3 Jul 2022 03:58:39 +0000 Received: from DM5PR1201MB0060.namprd12.prod.outlook.com ([fe80::60f7:bab9:28c7:c89f]) by DM5PR1201MB0060.namprd12.prod.outlook.com ([fe80::60f7:bab9:28c7:c89f%8]) with mapi id 15.20.5395.019; Sun, 3 Jul 2022 03:58:39 +0000 From: James Becker To: Pedro Alves , John Baldwin , "gdb@sourceware.org" Subject: Re: gdb for Riscv, single stepping issue Thread-Topic: gdb for Riscv, single stepping issue Thread-Index: AQHYimYYhdX8Id44aEyioFAyRafEfq1k+U0AgAEou4CAAIufAIABCH2AgARXKcA= Date: Sun, 3 Jul 2022 03:58:39 +0000 Message-ID: References: <069ae440-5fc5-b853-e415-e9643e6d8144@FreeBSD.org> <6068e741-8f0f-53b3-0664-548a4930d92c@palves.net> <357a6158-6e3a-ae13-bdd6-cfb5f98fb84f@palves.net> In-Reply-To: <357a6158-6e3a-ae13-bdd6-cfb5f98fb84f@palves.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: suggested_attachment_session_id: 60f171c2-1a55-7afc-0772-10a6eae799f7 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=crossfire-tech.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3efcd500-fe01-4d8d-77cf-08da5ca85030 x-ms-traffictypediagnostic: PH7PR12MB6419:EE_ x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: vc65xiaed6MHPoZFcVakz+Z46crZDeHXxRCY+bBfXnK/20LhdewMQkBPOgFH9rt1xO2I3Uci2rFq+ITjzXVfZVrz0urWd1VqAOmc/T1MDtqIDsaE3LqbQbRpr1j5S2EMphG0StPHHA3YbLVzu89bIFVJRGz9eXBww18sgA3au53v/njnyZ9K9TmAvbE/6maN3pltSOaUwE04kmLk4vf5fe44baW3aq9vbUe1RLOkXEOMXcrTLQVvav2qU4aIBIWOIEBJ4NR3MDP99lPIDCyZEAdcx9JHcXphYQkz8wFgyaxIbL8ykBD7VJSKOCd+oEaILXhonbZX55U4FuyRl4u0+Fs9iW+ClWkelfdhajtfZKL+1I2u69bPN8P/f1kHrok76SykqAKHVKUhku1eMBDxPymNkzulz0teBZppU6ngqFJwwj1ElsizPlRWpaojJ4NKqotUKFh+z4iB4kBuMREA+/i8RjWqx7/oI4X4MUa6quX32+VXyKtkLHo/N/BLExNXncbFNBolls4ch93piQ7qM2AkxG3H7vCQY8Og2gs1wpLiU+7kD6s+FxuRW6GKfArbP6ZDSh0uniHV8Ps7U9uU/8VTmGNHtfqitz9R0eOXCsIaZpconY+bQUXjH5riBFvo25/rWvlR29SWOJgeWJhTqo0Bi50+tMuebnfAJA95QVJtWr77Sp12DKoFUsfXMt0UhmixFRMu/l1kKfrfB0BtRv7N2kg11+OLexjcwwblT5iVElaa1wnsZ0DyNp3K/VFDdfTM30rH4bbciLt5mYo/sv/aftNCRETrbObXtgntc+uR8pRUCx7x3aNZZiddro9x x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM5PR1201MB0060.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(396003)(366004)(136003)(39830400003)(346002)(376002)(53546011)(8936002)(44832011)(52536014)(5660300002)(83380400001)(478600001)(33656002)(7696005)(6506007)(55016003)(2906002)(41300700001)(38100700002)(186003)(38070700005)(110136005)(19627405001)(316002)(122000001)(66476007)(66556008)(66946007)(66446008)(64756008)(76116006)(9686003)(71200400001)(26005)(91956017)(8676002)(86362001); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?tlmGbQdgMVEchwSNbYfaaAtxMlcgvPb6vqpASy89QSNqHvy1A+hMwQ7PlTfh?= =?us-ascii?Q?pwtb4zRIOnt/qmeWsLYWBH4LJw8nY4edUxF5FSmqRpSnLuxRJCFclbkVQfIJ?= =?us-ascii?Q?evrBw/8zShjRByrKEHV0fOeFumf6xQEuRZ0h4GPmPuBPRcAhoEQRVFLX9zlp?= =?us-ascii?Q?zDsgAJyrshw7mAUbVcJopby72gpBQ9MKa7jlaYgWkIV7MdOxGF4GAGe0HbRP?= =?us-ascii?Q?4OzuEczjToK72S27xbDuBidaKQLzST5yZLbe5sno12F391C5lhsfooMqnbkr?= =?us-ascii?Q?6fEp7aO+n/PJ6I6Qxxzzz9IIrjWL8/nMQuttTw0Lhrch/dtkrlt3fp1l0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Ph7TzflDAJYqtNSDlgUS?= =?us-ascii?Q?m7uQLkJhHL49CVWMe8omKPeIcbdmadNeWL0O6CM9mTwqayO9Ui2GHeMutN3i?= =?us-ascii?Q?60ncpZ1LOqJl17lz+WYaeHS473MN/NsqG5NOfW/gj46iuU+ewl3z42qlsAGl?= =?us-ascii?Q?1gabDI16e7gpc5yb3pR2aUoxPIxsAsXNqUJgU2jhfiT+46mDvvGOD9tXZMFK?= =?us-ascii?Q?myBc9ZAejr8ZyVU80jwZADp4xBpPaHRg6OggEZh4o1b9yYbFfFjID9EhUfiY?= =?us-ascii?Q?+KL4Bo9ULvAox8KCuXpjoTP3GaXDIPIeGDN2VreDfsIG+O8kQN6AqqIXK4ep?= =?us-ascii?Q?XfekeeLlafL1THDTXaXJO8+eCL0uxKsyk+CVEXKvY8tb5nEczq8zqFkBvYOq?= =?us-ascii?Q?2Q=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: crossfire-tech.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM5PR1201MB0060.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3efcd500-fe01-4d8d-77cf-08da5ca85030 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Jul 2022 03:58:39.5492 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 48e7eed0-6fcb-4943-9788-b04e82fe6ba6 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: oNCk/g6bhGaPijRVT4YlXFY9Il9Wl5glHBVsVw10TxtBv6gYa0D9ZLzib0qIzd1+HeD1L4GOWgFTK02AYwOW6GBt/LKkRS/myLa39u9AuMs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6419 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gdb@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Jul 2022 03:58:44 -0000 Hi Pedro, I did make the change and recompiled, but I have unfortunately lost my hard= ware program to my client for testing. So it will be a week or two until I can test. Thanks for your help. Jim ________________________________ From: Pedro Alves Sent: Thursday, June 30, 2022 4:40 AM To: John Baldwin ; James Becker ; gdb@sourceware.org Subject: Re: gdb for Riscv, single stepping issue Hi! Jim, could you check whether the patch below addresses the issue for you? I imagine it does, but it'd be good to hear just in case we're missing some more target_read_memory calls somewhere or some such. Pedro Alves On 2022-06-29 18:54, John Baldwin wrote: > On 6/29/22 2:34 AM, Pedro Alves wrote: >> OTOH, riscv_insn::fetch_instruction uses target_read_memory to read 2 by= tes, >> so I wonder whether this is the access in question: >> >> /* All insns are at least 16 bits. */ >> status =3D target_read_memory (addr, buf, 2); >> if (status) >> memory_error (TARGET_XFER_E_IO, addr); >> >> Why is this using target_read_memory instead of target_read_code, though= ? >> If it did that, then the code cache would be involved here too, papering= over >> the issue, presumably. >> > Yes, I had reworked my e-mail part way through and I really meant to talk= about > this code, not the breakpoint code. I agree that target_read_code is pro= bably > more correct in fetch_instruction and would in this case hide the odd beh= avior > of the stub: > > diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c > index 69f2123dcdb..09b2599e958 100644 > --- a/gdb/riscv-tdep.c > +++ b/gdb/riscv-tdep.c > @@ -1661,7 +1661,7 @@ riscv_insn::fetch_instruction (struct gdbarch *gdba= rch, > int instlen, status; > > /* All insns are at least 16 bits. */ > - status =3D target_read_memory (addr, buf, 2); > + status =3D target_read_code (addr, buf, 2); > if (status) > memory_error (TARGET_XFER_E_IO, addr); > > @@ -1672,7 +1672,7 @@ riscv_insn::fetch_instruction (struct gdbarch *gdba= rch, > > if (instlen > 2) > { > - status =3D target_read_memory (addr + 2, buf + 2, instlen - 2); > + status =3D target_read_code (addr + 2, buf + 2, instlen - 2); > if (status) > memory_error (TARGET_XFER_E_IO, addr + 2); > } > >