FCEUX debugging with conditional breakpoints (w/ solution)

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
FCEUX debugging with conditional breakpoints (w/ solution)
by on (#75485)
Tonight I was trying to determine where in my code a screwed up value was being written to a specific memory location. Specifically, I wanted to know when the value '$#ee' was being written to ZP memory location '$28'.

I was unable to find any comprehensive documentation on the full syntax of what can be put into the "condition" text input field in the breakpoint dialog box.

So I dug into the source code for FCEUX and found the parser:

http://fceux.sourcearchive.com/document ... ource.html

The grammar is listed near the top of the source file, right under the GPL banner. I won't quote it here.

I had been staring at the problem for too long. thefox helped me. This is what we did, and it worked.
  1. Set address = '28' (no quotes)
  2. Click 'write'
  3. Memory should be 'CPU' (the default)
  4. Condition = 'X == #ee' (no quotes)

I was omitting the '#' and that was screwing it up. The first three bullet points I assume that all of us using FCEUX's debugger have already figured out. I knew that this memory location was only every written to by the 'X' register, so I used 'X'. Had I used all three, I could have typed 'R' instead (as in 'R == $ee').

I hope that this info can help others. It was a bit annoying to track down.

Again, thanks to our arctic fox for his help.

(edited, to fix typo found by mottzilla)

by on (#75496)
Your line 4 has one = and should be two. It confused me. I never could figure out the condition thing either and gave up ever trying to use it. Thanks for clearing that up.

by on (#75497)
Fixed. Thanks for pointing that out.

Tepples, I suck a wikifing things. Are you willing to massage my post into a usable wiki article?

by on (#75501)
Thanks for sharing this. I have tried guessing the syntax for the conditional breaks once without much luck.

by on (#75522)
I don't remember where I read about the breakpoint condition syntax, but I agree, it's not well documented at all.

by on (#75524)
Done.

http://wiki.nesdev.com/w/index.php/FCEUX_breakpoints

by on (#87180)
Sorry for digging up an old thread, but I just wanted to say thank you for this investigation -- I needed to use conditional breakpoints in FCEUX today and was saddened by the lack of documentation in Help and so on. This thread/the wiki entry tepples made = for the win.
Re: FCEUX debugging with conditional breakpoints (w/ solutio
by on (#99020)
I've expanded this article and added more information I discovered by examining the FCEUX source code: http://wiki.nesdev.com/w/index.php/FCEUX_debugger

I submitted this stuff to the FCEUX sourceforge as a ticket, so it may eventually get incorporated into the documentation, but for now I thought it would be useful on out wiki.

Aha, I was directed toward this: http://www.fceux.com/web/help/fceux.html?DebuggerUsageIntermediate.html

I guess I'd missed it because it's in the FAQ/Guides section and I only read the Debug section. It covers most of what I've already covered, and a bit more.