Hand-written assembly and Python API

Jan Vrany via Gdb <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
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/default/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 <returnFromJIT1>

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 python
API for minimal symbols?

Thanks!

Jan
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.