public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Load custom symbols in GDB for Game Boy (RGBDS)
@ 2024-02-05 10:31 Mads Ynddal
  2024-02-05 10:53 ` Jan Vrany
  0 siblings, 1 reply; 3+ messages in thread
From: Mads Ynddal @ 2024-02-05 10:31 UTC (permalink / raw)
  To: gdb

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?

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Load custom symbols in GDB for Game Boy (RGBDS)
  2024-02-05 10:31 Load custom symbols in GDB for Game Boy (RGBDS) Mads Ynddal
@ 2024-02-05 10:53 ` Jan Vrany
  2024-02-05 13:19   ` Mads Ynddal
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Vrany @ 2024-02-05 10:53 UTC (permalink / raw)
  To: gdb

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
> 



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Load custom symbols in GDB for Game Boy (RGBDS)
  2024-02-05 10:53 ` Jan Vrany
@ 2024-02-05 13:19   ` Mads Ynddal
  0 siblings, 0 replies; 3+ messages in thread
From: Mads Ynddal @ 2024-02-05 13:19 UTC (permalink / raw)
  To: jan; +Cc: mads, gdb

> 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].

Thank you! I'll check this out and report back. It sounds very much like what I
need.

> I think it could help in your scenario too, though it is not clear
> to me what .sym file above describes.

The .sym file is simply a text file where every line is an address and text
label. The labels come from the assembly and can denote either a subroutine or
data.

—
Mads Ynddal

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-02-05 13:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-05 10:31 Load custom symbols in GDB for Game Boy (RGBDS) Mads Ynddal
2024-02-05 10:53 ` Jan Vrany
2024-02-05 13:19   ` Mads Ynddal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).