StateAid

Copyright (C) 2006 Flux Studios, Kristian Dupont

StateAid is a utility that allows you to inspect states in your code in a non-linear fashion. It does so by parsing a log file which is then visualized, allowing you to inspect the state at a certain point in time.
This can be especially helpful when debugging concurrent code or any problem that involves large and complex state.

Downloads can be found further down the page.

Screenshot

It Visualizes

StateAid can be thought of as a poor mans omniscient debugger. What you would really like to do when debugging a complex problem is to inspect the state by going back and forth in time to pinpoint the moment where something is wrong. StateAid gives you this functionality if you know which variables to watch. By relying on external data, it is language-independent and platform independent (it currently runs on Windows/.NET, but the data might as well come from some Java code running on a cell phone).

How does it work

StateAid parses a log file. You write expressions for StateAid by using a special syntax, which will allow you to output StateAid-specific information in your normal log stream. A StateAid expression could look like this:

SA Reading = true

This will specify that the variable “Reading” currently has the value “true”. The SA token identifies the line as a StateAid line.
StateAid will turn every such line into a frame. Lines that don’t include the SA token will be silently ignored.
Imagine you have a log file that looks like this:

Opening datafile...
SA Reading = true
SA FileSize = 21932
Reading Header
Closing file
SA Reading = false

This file contains three lines that StateAid would recognize, hence, you would get a sequence of three frames. They would look something like this:

1:

Reading = true
 

2:

Reading = true
FileSize = 21932

3:

Reading = false
FileSize = 21932

As you can tell, state is accumulated over time. The track bar in StateAid allows you to go back and forth in time, enabling you to inspect the state changes and the ordering of these carefully.

Dimensions

If you want to monitor multiple items or sets of items, you may need to organize your view a little. The syntax allows you to arrange your variables in dimensions. For instance, you may have a number of threads maintaining a mode of some sort. In order to monitor a such “mode” variable in three threads, you could add a thread dimension to your log statements. A dimension is added simply by adding a string in brackets [ ] before the SA keyword.
So you might initialize your log to something like this:

[0] SA mode = ready
[2] SA mode = ready
[1] SA mode = ready

This will add three variables, all named “mode”, but for three separate indicies in the first dimension. At frame three you would have:

0
mode = ready
1
mode = ready
2
mode = ready

Using with DebugView

DebugView is a freeware tool by Sysinternals that enables you to monitor the Win32 debug message stream without a debugger. It has served me well over the years and I recommend it for any Windows developer. Anything you write using OutputDebugString, DbgPrint or System.Diagnostics.Debugging.Write will appear in DebugView. You can even use it remotely to monitor a process on another pc.
DebugView allows you to save a log which makes analysis through StateAid even easier. Just insert a number of traces prefixed with “SA”, capture and save the log with DebugView and you are ready to go. As DebugView can add a process id in brackets for each line, you can use this as a process dimension. This allows you to analyze the simultaneous state in various instances of your program simultaneously. Extremely handy for client/server debugging.


Downloads


Download from Source Forge: StateAid v0.1
StateAid requires the .NET framework 2.0 to run. Download from here.

Source Forge project page

-->