0

I'm trying to debug a chunk of code that's mostly a straightforward 16-state state machine, although there are some cases where the transitions are not very simple (the data the state changes operate on are about 200 bytes of data in a couple C++ classes).

We're finding the machine ending up in a "final" state much earlier than expected. Since I'm not yet intimately familiar with the code, I'm hoping I can try to make out the different states and transitions in a way that will make it easier for me to quickly identify and debug the different transition paths.

Are there any useful tools or techniques for mapping out a state machine like this?

It might be worth noting that I'm doing this from a reverse-engineering standpoint, so there is no planning documentation for the system available to me.

ProdigySim
  • 2,825
  • 1
  • 21
  • 17
  • How do you identify the current state while debugging? If it's just 16 states why not draw them on a piece of paper and note the index or whatever the program uses to store the state? – Christian Oct 05 '12 at 10:28
  • 1
    State machines are hard to debug with just breakpoints. Logging is the best way. – Hans Passant Oct 05 '12 at 11:14

1 Answers1

0

You can look into formal model checking tools, such as UPPAAL. This tool can be used for modelling and verification of any system that can be modelled as networks of timed automata - this includes state machines. I have used it previously to verify e.g. invariants and reachability of possible states.

Vandhunden
  • 426
  • 4
  • 11