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

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

Dec 30, 2015

Download

Documents

Steven Tate
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 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

Page 2: 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

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

Outline

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

3

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

Background

4

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

• Motivation

5

Background

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

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

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

Background

7

• What is the insight of FACG?

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

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)

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

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

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

Approach

10

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

Approach

• Overview

11

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

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

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

Approach

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

13

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

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

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

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

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

Approach

• Augmenting the Call graph

Call Graph Flow-Augmented Call Graph

16

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

17

• Augmenting the Call graph

Approach

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

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

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

Evaluation

19

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

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

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

Evaluation• Case study

21

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

Evaluation• Quantitative evaluation

– Compare the F1 according to the original documentation

22

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

Evaluation

• The impact of FACG

WithoutFACG

WithFACG

23

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

Conclusion

24

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

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

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

Q&A

• Thanks!

26

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

27