27
Flow-Augmented Call Graph: A New Foundation for Taming API Complexity Qirun Zhang 1009004750 1

Flow-Augmented Call Graph: A New Foundation for Taming API Complexity Qirun Zhang 1009004750 1

Embed Size (px)

Citation preview

Flow-Augmented Call Graph: A New Foundation for Taming API Complexity

Qirun Zhang

1009004750

1

2

Past work: Taming API Complexity

Future plan: in the Presence of Pointers

Outline

• Background• Approach• Evaluation• Conclusion• Q&A

3

Background

4

• Motivation

5

Background

BackgroundA Flow-Augmented Call Graph (FACG) G = (N,E) for procedure P isa directed multigraph in which each node n corresponds to either a caller P or a callee Q, and each weighted edge e represents a call-site augmented with control flow.

Call Graph Flow-Augmented Call Graph6

Background

7

• What is the insight of FACG?

Background

• Why taming API complexity?– For Software maintenances– Most of software are not documented well

– For API documentation maintenanceshttp://msdn.microsoft.com/en-us/library/ms633545(v=VS.85).aspx

Apache Project

Year Function @see also Percentage

2005 1353 6 0.4%

2008 1461 15 1.0%

8

scp SEE ALSO rcp(1), sftp(1), ssh(1), ssh-add(1), ssh-agent(1), ssh-keygen(1), ssh_config(5), sshd(8)

Background

• Research solutions– How API is used

• PLDI-05, OOPSLA-06, ECOOP-09, ASE-07, ICSE-05, AOSD-07

– How API is implemented• Suade (FSE-05), Fran(FSE-07), Altair(FSE-09)

9

Approach

10

Approach

• Overview

11

Approach

• Parsing & Hashing– How to parse the source code?– What kind of elements should be extracted?

• Solution• gcc Gimple IR• API call-site, basic block, conditional block.• Build the CFG

12

Approach

• Handling Function Pointers– Collecting the path conditions– Over-approximate the program behavior– Testing the validation by SMT solver

13

Approach

• Reducing CFG– The CFG considered[1]

– Eliminate the back edge[2]

– Unroll the loop once

[1] Podgurski, A., Lori, Clarke, A.: A formal model of program dependences and its implications for software testing, debugging, and maintenance. IEEE Transactions on Software Engineering 16, 965–979 (1990) [2] Ramanathan, M.K., Grama, A., Jagannathan, S.: Path-sensitive inference of function precedence protocols. In: ICSE. pp. 240–250 (2007)

14

Approach

• Calculating the Flow of Callees– The inflow of the basic block associated with Q

– The outflow of the basic block associated with Q

15

Approach

• Augmenting the Call graph

Call Graph Flow-Augmented Call Graph

16

17

• Augmenting the Call graph

Approach

Approach

• Recommending API– Computing Cosine similarities

18

g0 h0 g1 h1 g2

f0 1 1 0 0 0

f1 1 0 1 0 0

f2 0 0 0 1 1

Evaluation

19

Evaluation• Subject Project

• Experimental Setup– A specific task suggested by Fran [2]: Given a query API,

retrieve other APIs in the same module– Module is defined by original documentation

• http://www.tcl.tk/man/tcl8.4/TclLib/contents.htm

20

[2] Saul, Z.M., Filkov, V., Devanbu, P.T., Bird, C.: Recommending random walks. In: ESEC/SIGSOFT FSE. pp. 15–24 (2007)

20

Evaluation• Case study

21

Evaluation• Quantitative evaluation

– Compare the F1 according to the original documentation

22

Evaluation

• The impact of FACG

WithoutFACG

WithFACG

23

Conclusion

24

Conclusion

• Our contribution– We proposed the Flow-Augmented Call Graph– We applied FACG on API recommendation. Our

approach could advance the state-of-the-arts– We developed a framework for program analysis by

Gcc.

• Future work– Recommendation system?– Static analysis?– SMT solving?

25

Q&A

• Thanks!

26

27