From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2114.outbound.protection.outlook.com [40.107.237.114]) by sourceware.org (Postfix) with ESMTPS id EDD1E384D193 for ; Wed, 29 Jun 2022 16:27:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EDD1E384D193 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=l/35ubwXYguP8XYjPO3EXHWB4LweATtxdQI7hpao8U6pi8PLfci3hcxaWZV+au9WmGO9lK1cBYZ9uiY1WLgO4Wjp5C7xuyfdD10BeLOMbWCEhvJEIuYHdnTViZoiLZru6aE1FADjBUArH00aKyo7hJ/X4ZIDsLRI3ehjVOB/TH74kY35AVdaBmLKuC3vxPdliH9TpJJ4MAIdKGiuvuj2YxUuA2BbVG9TZYz8KaEbW3B6MZkP074cHnsEb31ENXw543fUPE8XusD7O4Ywau9VjwoIuUcIEpMOzu8NZsrpTDWpMSZIzj8AXlsTCCWPjGROui3DFGvvPIvGDHEvjOZVLg== 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=m/7Vf1cPUGzGqnkFNgnz26YDb8gyOSvdVO9eGOMnT8k=; b=aWX4sCdB1UW4cwiOvltMogzlENwIOc8l/P2atOXXVo+HpA0dIJT51nCAyGRb4vMuF+B+8hkiS5qNjtENeXmdxBF5b4J+G0k/uQ6d+d2TOvF5fAQd2B0pArRVwRQgX73q7ekM9ND3nrZVParuHgTRaseSpMgw/6JccsmI56kbBpaefZDdnP82up++0KCUmuIiWLguaymY5FGH4X3mi1nFCYdEVyBKMGn+ly3JMBGzt7dC31r/g8RJjWr5hRuEwB8yEeEoogiQsjQZoVJ85z9E78tR9wC+wolJPWRd9K/6t4TylbXXcdXl5KiRB94qvS2ogh3eFZ7TpIoptP79gfRnKQ== 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=m/7Vf1cPUGzGqnkFNgnz26YDb8gyOSvdVO9eGOMnT8k=; b=WhHDzDFUhE35wFQk/hxjs/4PBDGO3wIvf5quLNjujcGJQXoSpPlHVigYae2j4mAUqSMARBVJLR32bBC+ohbfUgsk70U6Ro9jjy4YmU4vVlIya0588JVMBnuys4oidE/anQEFnbiI39NfkqorTs1f1Y9Tns/TXuro789SWneHxCQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=crossfire-tech.com; Received: from DM5PR1201MB0060.namprd12.prod.outlook.com (2603:10b6:4:51::15) by BYAPR12MB3078.namprd12.prod.outlook.com (2603:10b6:a03:a8::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5373.17; Wed, 29 Jun 2022 16:27:46 +0000 Received: from DM5PR1201MB0060.namprd12.prod.outlook.com ([fe80::60f7:bab9:28c7:c89f]) by DM5PR1201MB0060.namprd12.prod.outlook.com ([fe80::60f7:bab9:28c7:c89f%7]) with mapi id 15.20.5373.018; Wed, 29 Jun 2022 16:27:46 +0000 Message-ID: <299a3748-a352-9092-84a0-4175822363ea@crossfire-tech.com> Date: Wed, 29 Jun 2022 11:27:33 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: gdb for Riscv, single stepping issue Content-Language: en-US To: Pedro Alves , John Baldwin , gdb@sourceware.org References: <069ae440-5fc5-b853-e415-e9643e6d8144@FreeBSD.org> <6068e741-8f0f-53b3-0664-548a4930d92c@palves.net> From: James Becker In-Reply-To: <6068e741-8f0f-53b3-0664-548a4930d92c@palves.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: DM6PR06CA0003.namprd06.prod.outlook.com (2603:10b6:5:120::16) To DM5PR1201MB0060.namprd12.prod.outlook.com (2603:10b6:4:51::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 59d2530c-8760-4c13-2cf9-08da59ec4cc4 X-MS-TrafficTypeDiagnostic: BYAPR12MB3078:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: M9Y3Ba7UmTwiTJdQHLsX/kWfvoocmFb/7lrQXlsTYXITAySFp6hLxD2R55R4dG13OTctgj5NSXf/AH2KK/gqVAou0YS+V16ZArJnNRFFlheZGTLcpmzb/nAj9wRrkxY8fUpaTFd0SPclDPLgKI6lQxeEkLlIL2wLIVSgflLFf5zZB6EqWqkE/5wL6PwhK1LtkX8R7EfaA551VztABXSWPKvIraxch2UQaGOFZZUhuZ1cmeBsXObF0ykIAC65tSqDcuSe0wYFQIGW/ypNacgaK60ZGeglUkMjoh0T4acSckDg2gwyQTBJvzcDn1xbPmrmHT6ZviF+pkihup+lPEfrH0EOWz6RHtX99Ughr16HEjS6PTJmcaKHhU/VnsZ+e70XcjBNBYzAiu6wT9bHQHGo6Z9+GTzVM5grNDofZSv1VU0w0us3XyqOXRDJFeA22ZtGff7H82HqfT/jVxC8r48LHMZ3aTfdSa2Ks9IGWdyPLPsTfT1TEhQddTOFWNHLR7xuJd2ImnDpDIRuwPTgBIYxz/vsuC3H8rJlepTf3cjtqMZpB8ox6l+wCy9KPUyUlrlUOHHcHtKbQVAVQn3UZzniTq+MHBKn5k5GXvPTxeXB/CmSSH0G3FD0SKl9qAX/7Tajw3cijacBEHf85WhkP+cAbMJtOt/PHF4l3UKyy8OwvTf1I7yMB+8OBvVoV6UyNkESqBlb87v62+mFy8NgTQaQgWTb8spItFeuYBeBntRcFp+F9S//9c2BAa8IHi6mVVEYxao6aKGem83ZaJgSt/cHl6AIzO4ntJBEj0i+DiXqrD+STwYX7sk0vRp+koWCauIOnSjzadtntPY8r4kYUr7GsXlLNPayHrb2K9iP03wxSnwsaAPmoSlas/xHUjyqTXM1 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)(346002)(376002)(366004)(396003)(136003)(39830400003)(8936002)(110136005)(2616005)(55236004)(66946007)(8676002)(316002)(86362001)(6666004)(66476007)(66556008)(26005)(38350700002)(53546011)(31696002)(41300700001)(6506007)(52116002)(40140700001)(6486002)(15974865002)(6512007)(83380400001)(478600001)(2906002)(5660300002)(38100700002)(36756003)(31686004)(186003)(44832011)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?U1V2Uk1lOHJ2ZzdVRUJzODFiQzFMY0hRaEhVdVBiUkFJNVdqaVVkR1NIektC?= =?utf-8?B?Z2VlakVrOHhoeUF3Y2JncjAva0dTeDlmaXNqUit5TUpWREZSTjh3OWdkMWNO?= =?utf-8?B?amVWcmlPa3ErZ3QxakFmOVBiTE5GYmVyY1gzYUhKZGNXTmpmNDFqNG9Lbzgz?= =?utf-8?B?aHZYOHVIN2JoK2JWUlp1OVJUTWhuQy8yaWh0QU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ERSVmovRFNqMkQraVJ1VUtpcXBGWUdBV0pPNVBMQzRudHVzajlRbHMr?= =?utf-8?B?Y1Bsb0o0VDl4YkcvSjNpenNlWnN5MHlMekREaFU4aHQ4RzVFSk1kMERlTWVy?= =?utf-8?B?ZndMYmwyUENBQ2ZudWtrSUVaK2wwZERvaDZBdlFBNStidGhTQkkxbE9IQ0FE?= =?utf-8?B?cmc9PQ==?= X-OriginatorOrg: crossfire-tech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 59d2530c-8760-4c13-2cf9-08da59ec4cc4 X-MS-Exchange-CrossTenant-AuthSource: DM5PR1201MB0060.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jun 2022 16:27:46.3456 (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: nCROJxwEeA3a9+RPh6Tm7JLZFlE0pAPcXbQDYFI4Z14MEJTIi+M9DTYWq/WIRdn1JUvg5aE3V3AbyKHw6BYBGeVA6dLqGxjj+37efuVskQA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3078 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, T_SCC_BODY_TEXT_LINE, WEIRD_PORT 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@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: Wed, 29 Jun 2022 16:27:52 -0000 Hi Pedro and John, I tried it again, this time with the native gdb attached to riscv-gdb. I set a breakpoint in the native gdb to break at the function call target_read_memory () in riscv-gdb. Then I did a step in the riscv-gdb and hit the breakpoint. It does have a memory length of 2 for the method target_read_memory () Here is the call stack.  Hope it helps: Jim #0  target_read_memory (memaddr=memaddr@entry=340, myaddr=myaddr@entry=0x7ffca4c45990 "\360\356\275\315PV",     len=len@entry=2) at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/target.c:1229 #1  0x00005650cd44f941 in riscv_insn::fetch_instruction (gdbarch=gdbarch@entry=0x5650cdbdeef0, addr=340,     len=len@entry=0x7ffca4c45a10) at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/riscv-tdep.c:1345 #2  0x00005650cd44fa4d in riscv_insn::decode (this=0x7ffca4c45a10, gdbarch=0x5650cdbdeef0, pc=)     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/riscv-tdep.c:1374 #3  0x00005650cd4520b9 in riscv_next_pc_atomic_sequence (next_pc=, pc=340, regcache=0x5650cda77f40)     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/riscv-tdep.c:3635 #4  riscv_software_single_step (regcache=0x5650cda77f40)     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/riscv-tdep.c:3680 #5  0x00005650cd345288 in gdbarch_software_single_step (gdbarch=gdbarch@entry=0x5650cdbdeef0, regcache=0x5650cda77f40)     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/gdbarch.c:3280 #6  0x00005650cd256a96 in insert_single_step_breakpoints (gdbarch=gdbarch@entry=0x5650cdbdeef0)     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/breakpoint.c:14478 #7  0x00005650cd36aa90 in maybe_software_singlestep (pc=, gdbarch=0x5650cdbdeef0)     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/infrun.c:2127 #8  maybe_software_singlestep (gdbarch=gdbarch@entry=0x5650cdbdeef0, pc=340)     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/infrun.c:2121 #9  0x00005650cd371d48 in resume_1 (sig=GDB_SIGNAL_0)     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/infrun.c:2477 #10 resume (sig=GDB_SIGNAL_0) at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/infrun.c:2630 #11 0x00005650cd3728c4 in keep_going_pass_signal (ecs=0x7ffca4c45ca0)     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/infrun.c:7876 --Type for more, q to quit, c to continue without paging-- #12 0x00005650cd372bed in start_step_over () at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/infrun.c:2028 #13 0x00005650cd3789f0 in proceed (addr=addr@entry=18446744073709551615, siggnal=siggnal@entry=GDB_SIGNAL_DEFAULT)     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/infrun.c:3079 #14 0x00005650cd362691 in step_1 (skip_subroutines=0, single_inst=, count_string=)     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/infcmd.c:900 #15 0x00005650cd27f14a in cmd_func (cmd=, args=, from_tty=)     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/cli/cli-decode.c:2181 #16 0x00005650cd4c9c28 in execute_command (p=, p@entry=0x5650cdb65910 "step", from_tty=1)     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/top.c:668 #17 0x00005650cd326685 in command_handler (command=0x5650cdb65910 "step")     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/event-top.c:588 #18 0x00005650cd327551 in command_line_handler (rl=...)     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/event-top.c:773 #19 0x00005650cd326efc in gdb_rl_callback_handler (rl=0x5650ce306580 "step") at /usr/include/c++/9/bits/unique_ptr.h:153 #20 0x00005650cd536f88 in rl_callback_read_char ()     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/readline/readline/callback.c:281 #21 0x00005650cd3261d6 in gdb_rl_callback_read_char_wrapper_noexcept ()     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/event-top.c:177 #22 0x00005650cd326db5 in gdb_rl_callback_read_char_wrapper (client_data=)     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/event-top.c:193 #23 0x00005650cd326108 in stdin_event_handler (error=, client_data=0x5650cd903ef0)     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/event-top.c:516 #24 0x00005650cd5d61d6 in gdb_wait_for_event (block=block@entry=1) --Type for more, q to quit, c to continue without paging--     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdbsupport/event-loop.cc:673 #25 0x00005650cd5d643b in gdb_wait_for_event (block=1)     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdbsupport/event-loop.cc:569 #26 gdb_do_one_event () at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdbsupport/event-loop.cc:215 #27 0x00005650cd3a5035 in start_event_loop () at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/main.c:356 #28 captured_command_loop () at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/main.c:416 #29 0x00005650cd3a6ec5 in captured_main (data=)     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/main.c:1253 #30 gdb_main (args=) at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/main.c:1268 #31 0x00005650cd1f1f50 in main (argc=, argv=)     at /home/crossfire/SweRV/riscv-gnu-toolchain/riscv-gdb/gdb/gdb.c:32 On 6/29/22 04:34, Pedro Alves wrote: > On 2022-06-28 16:52, John Baldwin wrote: >> On 6/27/22 1:40 PM, James Becker wrote: >>> Hello, >>> >>> I have a RISCV-EL2 core running in a Nexys A7 FPGA board. >>> >>> I have openocd for riscv running over jtag with a connection by >>> riscv-gdb to the openocd instance at port 3333. >>> >>> Everything works fine, stepping, break points, load, view memory. >>> >>> But I have one issue: Some of the memory in my design is 4 byte >>> aligned.  Its designed for fast instruction fetch, its known as ICCM. >>> >>> When I have code running in that memory, gdb still works fine for >>> breakpoints, but it will not single step. >>> >>> Looking at the openocd debug files, it appears that gdb is attempting to >>> do a 2 byte read as a part of the single stepping procedure. >>> >>> Since my memory does not support 2 byte reads or writes, this fails. >>> >>> Is there some way that gdb can be configured to not do any 2-byte word >>> reads or writes during single stepping?  I can't seem to find any. >> Hmm, setting breakpoints tries to read 1 byte at a time unless you have >> disabled compressed breakpoints.  It looks like as a local hack you could >> change use-compressed-breakpoints to just read 4 bytes rather than 2 >> initially?  Perhaps this is upstreamable if you make it read 4 bytes if >> the target address is 4 byte aligned and only fall back to reading 2 bytes >> if it isn't? >> > Is that from riscv_breakpoint_kind_from_pc? That uses target_read_code, > so I'd think that since it goes via the code cache, it would read a whole > cache line at once, meaning 64 bytes (show code-cache, show dcache line-size). > > OTOH, riscv_insn::fetch_instruction uses target_read_memory to read 2 bytes, > so I wonder whether this is the access in question: > > /* All insns are at least 16 bits. */ > status = 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. > > Curious that the Riscv stub behaves this way, though. I mean, failing the > access instead of reading in aligned 4 bytes chunks, and doing read-modify-write, > if necessary, hiding the issue from GDB. Even inf-ptrace.c handles unaligned > reads/writes and shorter-than-word-sized reads/writes itself, like: > > static ULONGEST > inf_ptrace_peek_poke (ptid_t ptid, gdb_byte *readbuf, > const gdb_byte *writebuf, > ULONGEST addr, ULONGEST len) > { > ... > /* We transfer aligned words. Thus align ADDR down to a word > boundary and determine how many bytes to skip at the > beginning. */ > ... > /* Read the word, also when doing a partial word write. */ > if (readbuf != NULL || chunk < sizeof (PTRACE_TYPE_RET)) > { > > > I guess this also affects the "x" command at least (e.g., "x/2b $pc"), since that > doesn't use the code cache either. -- Jim Becker CrossFire Technologies Inc 1000 Westgate Dr. Suite 150-I St. Paul, MN 55114 Mobile: +1 303-507-6399 www.CrossFire-Tech.com Warning: The information contained in this electronic mail message (and any attached document) from CrossFire Technologies Inc. is intended only for the personal and confidential use of the designated recipient(s) named above. This information may be considered confidential by CrossFire Technologies Inc, or may be privileged or otherwise exempt from disclosure under law. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received the communication in error, please notify us immediately by telephone and e-mail and destroy any and all copies of this message (and all attached documents) in your possession (whether hard copies or electronically stored copies). This communication is covered by the Electronic Communications Privacy Act, 18 U.S.C. §§ 2510 - 2521. Thank you.