From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 3ED743896825 for ; Tue, 12 Jan 2021 16:15:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3ED743896825 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 10CGFbjD027795 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 12 Jan 2021 11:15:42 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 10CGFbjD027795 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 5717A1E940; Tue, 12 Jan 2021 11:15:37 -0500 (EST) Subject: Re: How to get past ebreak instruction on RISC-V To: Jan Vrany , gdb@sourceware.org References: <8c7f5386d98b278267611a9a78aea0a0cb5966f3.camel@fit.cvut.cz> From: Simon Marchi Message-ID: <78fcfd1f-4beb-85c2-acf0-c0231fd8c3e7@polymtl.ca> Date: Tue, 12 Jan 2021 11:15:37 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <8c7f5386d98b278267611a9a78aea0a0cb5966f3.camel@fit.cvut.cz> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 12 Jan 2021 16:15:37 +0000 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Tue, 12 Jan 2021 16:15:47 -0000 On 2021-01-12 11:07 a.m., Jan Vrany wrote: > Hi, > > I'm working on RISC-V compiler. To ease debugging of compiled code > I'm inserting `ebreak` instruction to interesting place (entry/exit > points or as a placeholder for unimplemented features). > > For example, the code might look like: > > (gdb) disas 0x0000003FD6A36024, 0x0000003FD6A36048 > Dump of assembler code from 0x3fd6a36024 to 0x3fd6a36048: > => 0x0000003fd6a36024: ebreak > 0x0000003fd6a36028: sd ra,-8(s11) > 0x0000003fd6a3602c: addi s11,s11,-16 > 0x0000003fd6a36030: ld t3,80(s10) > 0x0000003fd6a36034: addiw a0,zero,42 > 0x0000003fd6a36038: addi s11,s11,16 > 0x0000003fd6a3603c: ret > 0x0000003fd6a36040: blt s11,t3,0x3fd6a36000 > 0x0000003fd6a36044: ebreak > End of assembler dump. > (gdb) > > When compiled function is (attempted to) run, it stops on `ebreak` > as expected: > > Thread 2 "main" received signal SIGTRAP, Trace/breakpoint trap. > [Switching to Thread 0x3ff7e681e0 (LWP 428777)] > 0x0000003fd6a36024 in ?? () > > How can I get past the `ebreak` so I can `stepi` thought the following > instructions and debug? Thanks! I suppose you could do "set $pc = 0x3fd6a36028". But really this is something that GDB should be doing automatically, adjusting the PC after hitting that style of breakpoint. Simon