Re: Load custom symbols in GDB for Game Boy (RGBDS)

Jan Vrany via Gdb <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
Hi, 

On Mon, 2024-02-05 at 11:31 +0100, Mads Ynddal wrote:
> Hi,
> 
> I’m in the process of implementing GDB remote serial protocol in my
> Game Boy
> emulator PyBoy. I have a rudimentary setup working, and can step
> instructions,
> add breakpoints given an address, continue execution, display memory
> etc.
> 
> The biggest challenge is loading symbols from the RGBDS
> assembler/linker package
> for the Game Boy Z80 variant (not to be confused with the "gbz80"
> platform from
> GNU Assembler). RGBDS outputs its own .sym file-format like this
> mock-up:
> 
> ; File generated by rgblink
> 00:0000 main
> 00:0006 main.erase
> 00:0015 main.memcpy
> ...
> 01:00d3 main.B2
> 02:00db main.O
> 10:00e3 main.Y2
> 1b:00fc exit
> 
> The first digits of each line is the ROM/RAM bank number, and after
> the colon,
> the 16-bit memory address, then a space and the label for this
> location.
> 
> What would be the easiest way to get GDB to load these symbols? Would
> a Python
> extension for GDB help?

I had a similar problem of loading "symbols" for JITed code. In order
to do that, I extended Python API to allow creating symbol tables and
line number tables from Python [1], see test/example [2]. 
I think it could help in your scenario too, though it is not clear 
to me what .sym file above describes.

Jan

[1]:
https://sourceware.org/git/?p=binutils-gdb.git;a=shortlog;h=refs/heads/users/jv/wip/feature-py-jit-api

[2]:
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdb/testsuite/gdb.python/py-jit.py;h=c894c4a5f68da21ac34d23c3ad183e07e8b97416;hb=fe9dd76b752c981679cb0d330585e19cffd13e0d


> 
> And does GDB support ROM/RAM banks? I.e. displaying memory from a
> specific ROM
> bank, or add a breakpoint to specific bank+address.
> 
> Best regards,
> —
> Mads Ynddal
>
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.