Debugging Advice

A place to discuss everything Dragon related that doesn't fall into the other categories.
User avatar
Bosco
Posts: 330
Joined: Tue Mar 04, 2014 11:49 pm
Location: Nottingham, UK

Re: Debugging Advice

Post by Bosco »

CRASH BUG FIXED!! :D

Playing with MAME's debugger I could see the program counter was shooting off into BASIC rom when the game crashed. But I could also see using a memory window onto my Sprite data structure that all of the associated sprite pointers looked fine. So I started a trace just before a section of game which was prone to crashing and hit one first attempt. Then just searched backwards through the trace and `bingo' I could see the problem immediately.

An indirect JSR was jumping to address $0000, stumbling through illegal opcodes and eventually jumping into BASIC rom where it looped indefinitely.

The cause of all this was me failing to clear a collision flag byte when sprites are initialised. This occasionally triggered a false collision on a game item which should under normal circumstances not be collidable. The item's collision look-up was null which is why the pc jumped to address $0000 following the bogus collision.

I have to say MAME's debugger has been invaluable on this but I'd still be interested to know how to create a trace file from XRoar. Ctrl+v will output to the console window, albeit XRoar stops responding in the process, but I'd be interested to know how to output to a file?

Cheers, Steve.
User avatar
robcfg
Posts: 1529
Joined: Sat Apr 04, 2009 10:16 pm
Location: Stockholm, Sweden
Contact:

Re: Debugging Advice

Post by robcfg »

Glad you managed to fix the error!

Obviously MAME debugger isn’t perfect, but is one of the best I’ve found.
User avatar
Bosco
Posts: 330
Joined: Tue Mar 04, 2014 11:49 pm
Location: Nottingham, UK

Re: Debugging Advice

Post by Bosco »

Thanks Rob. :)

A debugger is definitely a valuable tool when staring at your code doesn't yield any results.

It does feel a bit like cheating though, like using reference books to solve a crossword puzzle rather than just what's between your ears. :lol:

Btw, do you know if the MAME debugger can be instructed to pause if the pc register exceeds a specified address range? Would be easier than dealing with huge trace files.
sorchard
Posts: 530
Joined: Sat Jun 07, 2014 9:43 pm
Location: Norwich UK

Re: Debugging Advice

Post by sorchard »

Glad you found it relatively painlessly :)

This should get you a trace file:

Code: Select all

xroar -C -trace >trace.txt
Not sure if you need the -C or not. (capital C). It starts a console under Windows. The '>' at the end of the command line redirects console output to a file.
Stew
User avatar
Bosco
Posts: 330
Joined: Tue Mar 04, 2014 11:49 pm
Location: Nottingham, UK

Re: Debugging Advice

Post by Bosco »

Thanks Stew. :D
Post Reply