The method identifies likely refactored code by comparing call trees generated from execution traces of two program revisions. It labels pairs of nodes as likely refactored if their contexts are equal and contents similar. A difference call graph is generated by extracting and merging subtrees of the call trees. The method was applied to an open source program, identifying differences within hundreds of lines across five source files at a high level.
Introducing Parameter Sensitivity to Dynamic Code-Clone Analysis MethodsKamiya Toshihiro
Presentation of:
[Position Paper] Toshihiro Kamiya, Introducing Parameter Sensitivity to Dynamic Code-Clone Analysis Methods, Proc. 10th International Workshop on Software Clones (IWSC 2016), pp. 19-20, 2016.
Notice: re-uploaded on March 16, 2016. (Fix "IWSC05's" -> "IWSC15's" on page 5)
An Execution-Semantic and Content-and-Context-Based Code-Clone Detection and ...Kamiya Toshihiro
Toshihiro Kamiya: An Execution-Semantic and Content-and-Context-Based Code-Clone Detection and Analysis,
Proceedings of the 9th IEEE International Workshop on Software Clones (IWSC'15), pp. 1-7 (2015).
19. 19
ステップ2(インデックス生成)の図解
call i
call h
call a
call a
return
call b
return
return
call f
call c
return
call d
return
return
call g
call e
return
return
return
return
i
h
a f g
a b c d e
コールツリーに変換
ステップ2
実行トレースからコールツリーとサマリを生成
20. 20
ステップ2(インデックス生成)の図解
A = { a } A = { b } A = { c } A = { d } A = { e }
A = { a } A = { f } A = { g }
A = { h }
A = { i }i
h
a f g
a b c d e
各節点の属性を求める
ステップ2
実行トレースからコールツリーとサマリを生成
21. 21
ステップ2(インデックス生成)の図解
属性からサマリを求める
A = { a },
S = ϕ
A = { b },
S = ϕ
A = { c },
S = ϕ
A = { d },
S = ϕ
A = { e },
S = ϕ
A = { a },
S = { a, b }
A = { f },
S = { c, d }
A = { g },
S = { e }
A = { h },
S = { a, b, c, d, e, f, g }
A = { i },
S = { a, b, c, d, e, f, g, h }
ステップ2
実行トレースからコールツリーとサマリを生成
22. 22
ステップ3(検索)の図解
A = { a },
S = ϕ
A = { b },
S = ϕ
A = { c },
S = ϕ
A = { d },
S = ϕ
A = { e },
S = ϕ
A = { a },
S = { a, b }
A = { f },
S = { c, d }
A = { g },
S = { e }
A = { h },
S = { a, b, c, d, e, f, g }
A = { i },
S = { a, b, c, d, e, f, g, h }
Q = { a, e, f }
「手続き a と e と f を呼
び出してるところ」
ステップ3前半
検索キーワードの全てを属性に含む「極小」(コールツリー内で深さが極大の)
節点を特定
ステップ3 後半
見つかった節点を根とする部分木から、寄与しない子孫節点を除去
23. 23
ステップ3(検索)の図解
A = { a },
S = ϕ
A = { b },
S = ϕ
A = { c },
S = ϕ
A = { d },
S = ϕ
A = { e },
S = ϕ
A = { a },
S = { a, b }
A = { f },
S = { c, d }
A = { g },
S = { e }
A = { h },
S = { a, b, c, d, e, f, g }
A = { i },
S = { a, b, c, d, e, f, g, h }
Q = { a, e, f } A(n) ∪ S(n) ⊆ Q を満た
し、深さ極大の節点n
ステップ3前半
検索キーワードの全てを属性に含む「極小」(コールツリー内で深さが極大の)
節点を特定
ステップ3 後半
見つかった節点を根とする部分木から、寄与しない子孫節点を除去
24. 24
ステップ3(検索)の図解
A = { a },
S = ϕ
A = { b },
S = ϕ
A = { c },
S = ϕ
A = { d },
S = ϕ
A = { e },
S = ϕ
A = { a },
S = { a, b }
A = { f },
S = { c, d }
A = { g },
S = { e }
A = { h },
S = { a, b, c, d, e, f, g }
A = { i },
S = { a, b, c, d, e, f, g, h }
Q = { a, e, f }
ステップ3前半
検索キーワードの全てを属性に含む「極小」(コールツリー内で深さが極大の)
節点を特定
ステップ3 後半
見つかった節点を根とする部分木から、寄与しない子孫節点を除去
25. 25
ステップ3の図解
A = { a },
S = ϕ
A = { b },
S = ϕ
A = { c },
S = ϕ
A = { d },
S = ϕ
A = { e },
S = ϕ
A = { a },
S = { a, b }
A = { f },
S = { c, d }
A = { g },
S = { e }
A = { h },
S = { a, b, c, d, e, f, g }
A = { i },
S = { a, b, c, d, e, f, g, h }
Q = { a, e, f }
Q の要素それぞれについて、
サマリにその要素を含む
一番浅い節点を探す
ステップ3前半
検索キーワードの全てを属性に含む「極小」(コールツリー内で深さが極大の)
節点を特定
ステップ3 後半
見つかった節点を根とする部分木から、寄与しない子孫節点を除去
26. 26
ステップ3(検索)の図解
A = { a },
S = ϕ
A = { b },
S = ϕ
A = { c },
S = ϕ
A = { d },
S = ϕ
A = { e },
S = ϕ
A = { a },
S = { a, b }
A = { f },
S = { c, d }
A = { g },
S = { e }
A = { h },
S = { a, b, c, d, e, f, g }
A = { i },
S = { a, b, c, d, e, f, g, h }
Q = { a, e, f } 見つかった節点より深い
節点を全て除去する
ステップ3前半
検索キーワードの全てを属性に含む「極小」(コールツリー内で深さが極大の)
節点を特定
ステップ3 後半
見つかった節点を根とする部分木から、寄与しない子孫節点を除去
27. 27
ステップ3(検索)の図解
Q = { a, e, f }
h
a f g
e
call h
call a
return
call f
return
call g
call e
return
return
return
検索結果
実行トレースの一部を
取り出したもの
ステップ3前半
検索キーワードの全てを属性に含む「極小」(コールツリー内で深さが極大の)
節点を特定
ステップ3 後半
見つかった節点を根とする部分木から、寄与しない子孫節点を除去