0

I want to save the control flow graph produced by eclipse-cdt codan from some C source code as png/jpeg files. I am using codan as a library in my code so it's not an eclipse plugin. So far I have been able to successfully get the cfg using the code below.

CASTFunctionDefinition def = (CASTFunctionDefinition) function.getPhysicalNode().getParent(); //function is of CFunction type
ControlFlowGraphBuilder builder = new ControlFlowGraphBuilder();
builder.build(def);

Doing so, I have a builder containing the control flow graph nodes. The question is how I can get the an ouput image of this graph. the codan library includes a org.eclipse.cdt.codan.ui.cfgview in it. But I couldn't find any solution for my problem. I found the files in cfgview heavily dependent on Eclipse workspace and environment.

kvs
  • 178
  • 2
  • 12
  • I'm not really sure what you're asking here. There is no existing code for exporting a control flow graph as an image, so if you want to do that, you'll need to write that code yourself. The possibilites for how to do that are very open-ended; [Graphviz](http://www.graphviz.org/documentation/) is a popular and well-maintained tool for this kind of job. – HighCommander4 May 28 '19 at 22:52
  • @HighCommander4 Thank you, I thought it might be possible as I took a look into [http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/tree/codan/org.eclipse.cdt.codan.ui.cfgview/src/org/eclipse/cdt/codan/ui/cfgview/views/ControlFlowGraphView.java] and i thought maybe there would be a way using just codan. I haven't tried Graphviz yet but I came to JGraph. which one do you think is easier for a beginner to start with? – kvs Jun 02 '19 at 09:23
  • The code you mention has to do with presenting the control flow graph in the Eclipse UI, with clickable parts and such. There's no automatic translation between such a UI and an image (short of taking a screenshot, I suppose). That said, you could probably use parts of that code as a guide for your own code. – HighCommander4 Jun 02 '19 at 16:02
  • I'm not deeply familiar with either, but perhaps JGraph would be easier as it's written directly in Java, whereas Graphviz is written in C with Java bindings. – HighCommander4 Jun 02 '19 at 16:06

0 Answers0