Issue
I'm building tool for testing ansi c applications. Simply load code, view control flow graph, run test, mark all vertexes which were hit. I'm trying to build CFG all by myself from parsing code. Unfortunately It gets messed up if code is nested. GCC gives ability to get CFG from compiled code. I might write parser for its output, but I need line numbers for setting breakpoints. Is there way for getting line numbers when outputting Control Flow Graph with -fdump-tree-cfg
or -fdump-tree-vcg
?
Solution
So I've made some more research and it is not hard to get line numbers for nodes. Just add lineno
option to one of those options to get it. So use -fdump-tree-cfg-lineno
or -fdump-tree-vcg-lineno
. It took me some time to check if those numbers are reliable. In case of graph in VCG format label of each node contains two numbers. Those are line numbers for start and end of code portion represented by this node.
Answered By - Eloar Answer Checked By - Katrina (WPSolving Volunteer)