views:

545

answers:

3

Hi,

I am trying to draw a control-flow graph(CFG) from source code using the GLEE graph library and C# language. Problem is, I am new to GLEE. I need a tutorial or sample programs/projects to help me get started quickly with GLEE. The source for which I need to draw a CFG has the following structure:

begin myProcedure
  statement 1;
  statement 2;
  if(condition) then
    statement 3;
  else
    statement 4;
  end if
end myProcedure

Any ideas?

A: 

Looks like you are new to C# as well, given that GLEE hasn't been available for nearly 2 years (having been replaced by MSAGL, a paid product which does come with examples) I think you might find it hard to first, find any examples and second, to get any support. It seems you can get MSAGL for $99 at the moment (down from $295), might be worth the investment for the time saved.

Lazarus
+1  A: 

Unless you hard-wire the control flow graph into your answer (homework?), the graphing isn't the hard part of this problem. Extracting the control flow graph from the source code of your language is.

Your example is clearly not C# (BEGIN?), so you will need to find a language parser; you will need something to do name and type resolution (to handle GOTOs to labels or exits of named blocks), and construct a flow graph as a graph data structure. If you are processing something like GCC (a C-like language with indirect GOTOs), you'll need pointer analysis to determine possible targets of indirect GOTOs. If you intend to process C#, or Java, you might be able to extract the control from from the class files (having much the same problems) and then you'll have to map that back to the source code.

It is easiest to do such a task if you have a lot of available machinery (parsing, name-resolution, control-flow graph construction library) on which to build your control-flow graph extractor. The DMS Software Reengineering Toolkit provides all these foundations, as well as parsers for many languages. For C, Java and COBOL, DMS also provides the direct extraction of control flow graphs handling all of the above issues and even data flow graphs too. See sample control and data flow graphs.

Ira Baxter
A: 

http://research.microsoft.com/en-us/downloads/f1303e46-965f-401a-87c3-34e1331d32c5/default.aspx

the download comes with a csharp sample app

ooo