葛亭控制流图从ANSI C code [英] Geting Control Flow Graph from ANSI C code

查看:152
本文介绍了葛亭控制流图从ANSI C code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我测试的ANSI C应用构建工具。只需加载code,视图控制流图,运行试验,标志着这是打所有顶点。我试图从解析code建立CFG全部由我自己。不幸的是它被搞砸了,如果code嵌套。 GCC提供了能够从编译code得到CFG。我可以写解析器它的输出,但我需要行号设置断点。是否有让输出控制流图时行号与 -fdump树-CFG -fdump树-VCG

I'm building tool for testing ansi c applications. Simply load code, view control flow graph, run test, mark all vertexes which was 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?

推荐答案

所以,我做了一些调查研究,这是不是很难得到行号节点。只需添加 LINENO 选项,这些选项之一,得到它。因此,使用 -fdump树-CFG-LINENO -fdump树-VCG-LINENO 。我花了一些时间来检查,如果这些数字的可靠。在 VCG 每个节点的格式标签中包含的两个数图的情况。这些都是对启动和再由该节点psented $ P $ code部分的结束行号。

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.

这篇关于葛亭控制流图从ANSI C code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆