This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

ca65's "line" output in debug file

ca65's "line" output in debug file
by on (#189203)
Does anyone fully understand the data output in ca65's (might actually be the linker that outputs the full file, actually), exhaustive debug file? I was successfully able to write a python script to translate this file into source-level debugging information for FCEUX, however, I encountered an odd situation which I haven't yet been able to explain.

                    #Actual line of code.
                    line_number = line["line"] - 1
                    if 0 <= line_number < len(source_file_lines[file_name]):
                        line_of_code = source_file_lines[file_name][line_number].rstrip().replace("#", "")

In order to get the nl comments in FCEUX to show up as expected above the first instruction associated with the line of code, I had to add this - 1 calculation before grabbing the line of code from the source file. What concerns me is that some of these "line" objects report 0 as the line number, so this doesn't seem correct (i.e., it's not a case of counting from 0 in one case versus counting from 1 in another, I have arrays of source code lines that start from 0 and the debug output also appears to start from 0 for these "line" objects). Yet, most of the time I'm getting correct and expected output in the FCEUX debugger. (i.e., I see my line of code, followed by all the instructions assembled for that line of code, exactly as expected).

Just wondering if anyone out there understands the debug output in more detail and can help me explain why I had to put that - 1 there.
Re: ca65's "line" output in debug file
by on (#189212)
Why not use the dbginfo library ( I really don't understand why many people seem to insist on parsing the format manually.

Whatever you do, the library might help you figure out what you're doing wrong.
Re: ca65's "line" output in debug file
by on (#189213)
Haha, interesting. I didn't even know this existed. That'd be my guess why people parse it themselves. Plus its fun to write little tools in python :D So is this dbginfo library meant to be compiled and used with a standard C compiler outside of cc65 and then just run a debug file through it or...?
Re: ca65's "line" output in debug file
by on (#189218)
Yes. dbginfo.c / dbginfo.h make up the library. dbgsh.c is a sample program that uses the library.