Re: How to generate statecharts from C code



Responding to Bp_site...

I have to maintain and debug a big program in C language. I'd like to
generate some statecharts from the source code.

Can I find a freeware to reverse C files to UML / statecharts ?

No such thing. The only way this could possibly work is if the C code were constructed with rigid constraints on things like naming conventions that the tool could recognize. Even then the tool would need help with notions like "current state". The problem is that too much information has been lost by the time an FSM design gets to the strictly procedural view of the OOPL code.


For example, suppose I create an OOA/D model with Statecharts and an <implied> event queue manager. Now suppose the actual computing environment is inherently synchronous. The optimal OOP solution would be to eliminate the event queue entirely and replace event generation in the abstract action language with direct method calls to the target object's actions. In that case the event-based processing would be indistinguishable from an application developed without state machines.

So how would the tool know whether a method call was actually invoking a state machine action rather than a "smart" setter (e.g., Matrix.transpose)? Better yet, how would it know what the current state was so that it can infer transitions? That is captured in an attribute value at run time so the only way the tool could know about it would be to explicitly evaluate the contents of an STT used for error checking (if there is one), which requires a pretty smart tool and some heavy-duty coding standards to recognize the STT. (Note that inferring transitions will be a problem even if one has an event queue manager.)


************* There is nothing wrong with me that could not be cured by a capful of Drano.

H. S. Lahman
hsl@xxxxxxxxxxxxxxxxx
Pathfinder Solutions  -- Put MDA to Work
http://www.pathfindermda.com
blog: http://pathfinderpeople.blogs.com/hslahman
(888)OOA-PATH



.