From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id za46DjbL/V9zSAAAWB0awg (envelope-from ) for ; Tue, 12 Jan 2021 11:15:50 -0500 Received: by simark.ca (Postfix, from userid 112) id 2C93F1EF7E; Tue, 12 Jan 2021 11:15:50 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 8E1691E940 for ; Tue, 12 Jan 2021 11:15:49 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0B63A389682E; Tue, 12 Jan 2021 16:15:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B63A389682E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610468149; bh=BEMzRt88OoqwAt7yPm4UgcrGAFqPRHyTIgJjqV0czF8=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=E9mD4ec+jR7ACoru65pKMYLWg31t9gEe60gp1hI+yZoZHGuolKbZWnQLfJzM6iqf1 Z786DajYCRgYfeoCtxaDsxnvFXEhpjR75dvYTUAoZ0E+CSWfUdS5wJjgEc/LdHFtBV 4CpbDSaOpWgLqeL98kGd9F3lx1bqkQaYXWp1Rz14= 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> 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-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: , From: Simon Marchi via Gdb Reply-To: Simon Marchi Errors-To: gdb-bounces@sourceware.org Sender: "Gdb" 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