Parser and Control Flow Graph Generator for C#
- I need a tool which accepts a C# (C++ would be fine) project, parses it and generates its control flow graph. I've discovered Phoenix yesterday and I'm still not sure whether it is possible using this framework. What I need is the control flow, tokens and line numbers.
I've seen the Control-Flow-Graph Add-In sample in order to see how to obtain a flow graph, however it only takes a function. Note that I do not need a visual representation of the flow graph. I've managed to plug it into Visual Studio 2005 however I still haven't got it working. I've created a Visual C++ project, built it successfully and from Class View I right clicked on a method and clicked on Control Flow Graph. I got "Error loading flow graph" in the caption of the window which is supposed to show the flow graph.
My queries are the following:
- Is it possible to get the control flow graph of a project?
- Is it possible to retain line numbers and tokens?
- Is it possible to get the control flow graph of a project in C#?
- How can I resolve the error with the Add-In sample?
Všechny reakce
Phoenix doesn't work directly with program source -- that is, there is no parsing or lexical analysis.
If your goal is to start with some project and end up with a control flow graph for the functions described therein, you will need to build the project first. You can then you the Phoenix PE reader capability to analyze the MSIL in the assembly and get control flow graphs from there.
Line number and token data is available by looking at the instructions and symbols in the IR for the functions. The phoenix explorer sample shows how to do some this in a standalone application.
To be able to view flow graph information for a project built from C++ code, make sure that the linker options include /profile (found under the project configuration properties, linker, advanced) and /debug (configuration properties, linker, debugging), and that all source files are compiled with /Zi (configuration properties, C/C++, general).
- Fantastic! I just had profiling disabled, I enabled it and it worked fine. Thanks a lot for your help. I'll look into the explorer sample to see whether this is useful for me.
The sample documentation didn't help much. I sort of expected instructions on how to actually see the sample working, possibly including a sample project to test it on. I had to check out how to install the Add-In and I wouldn't have figured this out by myself definitely.
Is there any of this documented somewhere which I might have missed? I came across the walkthroughs but they explain how to develop the samples, installing and using them is excluded.
Thanks a million! I've always found the VS add-in stuff to be confusing. Glad you were able to figure out how to install it.
We have recently reviewed the documentation for most of the walkthroughs but I'll have to check and see if we did anything to describe better how to use the add-in.
Hi, e-Abigail,
now you can get the function's lineno? How to do it? Parse the symbol table? Recently, I am working a related topic, can you give me a section of the code? or Example?
Thanks,

