【程序分析】函数调用图 | 控制流图 | 过程间控制流图 | 数据流图 | 值流图 | 分析敏感性

CG(call graph)和CFG(control-flow graph)都是表示程序控制流的有向图。

1 函数调用图:CG(call graph)

一个CG是表示整个程序中方法(函数)之间调用关系的图,图中的节点是方法,边表示调用关系。例如方法foo()调用了方法bar(),则CG中应有一条从foo()到bar()的有向边。

2 控制流图:CFG(control-flow graph)

一个CFG是表示一个方法内的程序执行流的图,图中的节点是语句(指令),边表示执行流。例如语句A执行后的下一条语句是B,则CFG中应有一条从A到B的有向边。

相关的详细介绍:
《Lecture 24: Control Flow Graphs》
https://www.cs.cornell.edu/courses/cs412/2008sp/lectures/lec24.pdf

3 过程间控制流图:ICFG(interprocedural control-flow graph)

ICFG(interprocedural control-flow graph)的信息就是CG加上CFG的信息。
ICFG可以看做是给所有方法的CFG加上这些方法之间互相调用的边(CG)所形成的图。调用边(call edge)从调用语句(call site)连到被调方法(callee)的入口。与CG不同的是,ICFG除了调用边,还包含相应的返回边(return edge),从callee的出口连到call site之后执行的下一个语句。

4 数据流图:DFG(data flow graph)

一块代码:

quad( a, b, c)
t1 = a*c;
t2 = 4*t1;
t3 = b*b;
t4 = t3 - t2;
t5 = sqrt( t4);
t6 = -b;
t7 = t6 - t5;
t8 = t7 + t5;
t9 = 2*a;
r1 = t7/t9;
r2 = t8/t9;

对应的数据流图是:
在这里插入图片描述

5 值流图:VFG(value flow graph)

值流图是什么:
《 Flow-Sensitive Pointer Analysis for Millions of Lines of Code 解读》
https://blog.csdn.net/a173373310/article/details/119167140?spm=1001.2014.3001.5501

如何构建值流图:
《SVF: Interprocedural Static Value-Flow Analysis in LLVM》
https://yuleisui.github.io/publications/cc16.pdf

6 分析敏感性

流敏感(flow-sensitive)
路径敏感(path-sensitive)
上下文敏感(context-sensitive)
域敏感(field-sensitive)
参见:https://bbs.huaweicloud.com/blogs/234041


参考:https://www.zhihu.com/question/267555156/answer/326573874

https://blog.csdn.net/weixin_39278265/article/details/115536865

https://blog.csdn.net/a173373310/article/details/119275037

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值