Loading CA65's DBG files

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
Sour
Posts: 891
Joined: Sun Feb 07, 2016 6:16 pm

Loading CA65's DBG files

Post by Sour »

I'm finishing up implementing symbols/labels + comments in Mesen's debugger and am currently working on importing labels/comments from the DBG files generated by CC65/CA65.

This is what it looks like at the moment:
Image

I'm currently testing with the example project posted by rainwarrior here (thanks for that, been incredibly helpful so far!). The screenshot above is the result of importing that project's DBG file into Mesen.

However, if at all possible I'd like to test the import's code with other projects (e.g: projects coded in C or ASM, more complex ones that use bank switching, or extra work ram, etc.).
Does anyone have any NES+DBG+Source packages that they'd be willing to share with me, or know where I could find them?
I guess what I'm looking for would be CA65/CC65 open source projects I can easily compile into a NES+DBG. Though it'd be nice to get the DBG/NES files prebuilt as I have little idea what I'm doing when it comes to compiling CC65/CA65 projects. :)

Thanks!
calima
Posts: 1745
Joined: Tue Oct 06, 2015 10:16 am

Re: Loading CA65's DBG files

Post by calima »

Russian Roulette is open source and C:
http://www.romhacking.net/homebrew/88

Lots of CHR bank switching, and it uses save RAM.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Loading CA65's DBG files

Post by tepples »

Sour wrote:I guess what I'm looking for would be CA65/CC65 open source projects I can easily compile into a NES+DBG. Though it'd be nice to get the DBG/NES files prebuilt as I have little idea what I'm doing when it comes to compiling CC65/CA65 projects. :)
My NES projects on GitHub and my cousin's are open source, but they don't have DBG files. (Yet.)

I'm not a regular user of Mesen because of its stated dependency on Windows and my lack of time to see if I can get it up in Mono. So I was planning to look at what else DBG files can do, and I thought first I'd need to know how to parse them. I looked for format documentation but instead noticed the warning in the description of the --dbgfile option:
Please note that debug information generation is currently being developed, so the format of the file and its contents are subject to change without further notice.
So is the only documentation "read dbgfile.c and dbgsyms.c, and read them again every time you update ld65 using Git"?
User avatar
thefox
Posts: 3134
Joined: Mon Jan 03, 2005 10:36 am
Location: 🇫🇮
Contact:

Re: Loading CA65's DBG files

Post by thefox »

tepples wrote:So I was planning to look at what DBG files can do, and I thought first I'd need to know how to parse them. I looked for format documentation but instead noticed the warning in the description of the --dbgfile option:
Please note that debug information generation is currently being developed, so the format of the file and its contents are subject to change without further notice.
So is the only documentation "read dbgfile.c and dbgsyms.c, and read them again every time you update ld65 using Git"?
You can parse the debug files with the dbginfo library provided with cc65: https://github.com/cc65/cc65/tree/master/src/dbginfo

The format itself hasn't changed for many years now, but it's somewhat complicated so it's a good idea to use the library.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi
Sour
Posts: 891
Joined: Sun Feb 07, 2016 6:16 pm

Re: Loading CA65's DBG files

Post by Sour »

Thanks for the help!

After a fair bit of trial and error, I managed to compile thwaite, nova the squirrel and russian roulette and generate working DBG files for them.

It helped me fix some bugs, and the feature is working relatively well for now. (Although it doesn't support work/save ram yet)
Some limitations remain because the labels in Mesen aren't "scoped", so memory addresses that are shared as temporary variables in the code can't be assigned a different label based on where they are used, etc.

For C projects, I set it to display the C code as a comment, it's not perfect, but it's mostly readable.
Image

The import is a GUI-side feature in C#, so I didn't use CC65's code. I was lazy and just solved all of the parsing with regexes - it's certainly not the fastest way to parse it, but the code is a lot easier to understand (in my opinion)

@tepples
Mesen doesn't run under Mono (nor WINE) at the moment (both due to my use of DirectX11)
I had a SDL build that worked under Mono & Ubuntu about half a year ago, but never finished it.
I could probably redo the work in a day or two, so I will most likely get that done in the near-ish future.
Post Reply