From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-4323.proton.ch (mail-4323.proton.ch [185.70.43.23]) by sourceware.org (Postfix) with ESMTPS id D0A0A385803E for ; Fri, 29 Apr 2022 13:10:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D0A0A385803E Date: Fri, 29 Apr 2022 13:10:31 +0000 To: Simon Marchi , GDB mailing list From: Jan Vrany Reply-To: Jan Vrany Subject: Re: Hand-written assembly and Python API Message-ID: In-Reply-To: References: <5dce3fb2110facb58974d1ee546c43b6db20b6f4.camel@vrany.io> Feedback-ID: 40767693:user:proton MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Fri, 29 Apr 2022 13:10:42 -0000 On Fri, 2022-04-29 at 08:54 -0400, Simon Marchi wrote: > On 2022-04-29 08:32, Jan Vrany via Gdb wrote: > > Hi folks, > > > > I'm trying to debug a code that uses a handful of > > hand-written assembly routines. For example, one of > > them looks like (its RISC-V but that does not matter): > > > > .text > > .globl returnFromJIT1 > > .type returnFromJIT1,function > > .align 2 > > returnFromJIT1: > > .cfi_startproc > > sd a0,248(s10) > > sd s11,32(s10) > > li a0, 17 > > li a1, 1 > > j cInterpreterFromJIT > > .cfi_endproc > > .size returnFromJIT1, .-returnFromJIT1 > > > > .text > > .globl ... > > > > GDB clealy knows "something" about the assembly routines, it shows > > the source properly and 'info symbol' works too: > > > > (gdb) info symbol 0x3ff75eca24 > > returnFromJIT1 in section .text of /opt/riscv/sysroot/tmp/jdk/lib/de= fault/libj9jit29.so > > > > The problem is how to figure out I'm in (say) `returnFromJIT1` routine > > using Python API: > > > > (gdb) py print(gdb.block_for_pc(0x3ff75eca24).function) > > None > > > > The only way I can think of is to parse value of `gdb.format_address()`= : > > > > (gdb) py print(gdb.format_address(0x3ff75eca24)) > > 0x3ff75eca24 > > > > which is bit awkward (but doable!). > > > > Question is: is there a better way? I can modify the assembly source > > too if there's some directive that may help GDB (.cfi_startproc / .cfi_= endproc > > is clearly not enough). Or do I have to roll up sleeves and implement p= ython > > API for minimal symbols? > > I was going to say "returnFromJIT1" is a minimal symbol, but you clearly > know that already. There is DWARF debug info for assembly when building > with -g (at least when building with gcc / gas), but it only contains > line statements, which allows GDB to show where you are in the source > file (instead of showing disassembly). You won't be able to look up a > block from that. > > I don't know of a way to do it with the current API, unfortunately. > > Simon Thanks!=C2=A0 I was secretly hoping you might know some trick I'm not aware of... Jan