ca65's "line" output in debug file
Page 1 of 1

Author:  GradualGames [ Thu Feb 16, 2017 8:46 am ]
Post subject:  ca65's "line" output in debug file

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.

Author:  thefox [ Thu Feb 16, 2017 9:57 am ]
Post subject:  Re: ca65's "line" output in debug file

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.

Author:  GradualGames [ Thu Feb 16, 2017 10:01 am ]
Post subject:  Re: ca65's "line" output in debug file

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

Author:  thefox [ Thu Feb 16, 2017 11:00 am ]
Post subject:  Re: ca65's "line" output in debug file

Yes. dbginfo.c / dbginfo.h make up the library. dbgsh.c is a sample program that uses the library.

Page 1 of 1 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group