• 沒有找到結果。

2. 相關研究

2.2. 版本資料庫

以下分為兩個部份討論,首先將簡單介紹 SCM(Software Configuration Management)之概念,其後再介紹結合 SCM 之程式分析之研究。

2.2.1.

SOFTWARE CONFIGURATION MANAGEMENT

在軟體專案發展中,程式碼會不停的地修改,此時便需要一架構用以協調多人、多 時之發展過程,SCM 即用以處理此問題,Zeller[10]的研究中定義 SCM 為一套方法用以 組織及控制演變之系統,其具備以下七類功能:

z Identification-辨認出系統內之各部份(component),使其能被明確存取;

z Control-控制專案的版本並確保其與初版(basline)對應關係之一致;

z Status Accounting-紀錄各元件之變動過程並統計;

z Audit and Review-確保專案之完整性,即各元件間不相衝突;

z Manufacture-以較佳的方式產出專案;

z Process management-確保專案生命週期(project life cyclte)與開發團體之政策 (policy)一致;

z Team work-協調多人發展

在版本變動紀錄的功能上,直觀的方法乃是 Checkin/Checkout Model,其完整紀錄 各版本之內容,如 git 即採用此種方法,此方法雖然簡單且存取快速,然而會造成需要 較大的儲存空間。另一種目前常見的方式乃是 Change-Oriented Model,在其系統內僅完 整留存最新或最舊之一版,視不同的實際系統而定,其它的版本則以差異(diff)的方式存

紀錄下變動的行號與行數,因此若比較 version 1 與 version 2 則會產出 add 5 1

Line F

此表示在 version 1 之第五行之後加入一行 line F,同樣地,若比較 version 2 及 version 3 則以下列方式表示:

del 2 1

此表示在 version 1 之第二行之後刪去一行,由於刪去的內容在新版中已不復存在,因此 不需在 diff 中紀錄被刪除之內容,若要取得被刪除之內容,只需在舊版中找到相對應的 行數(此例為第二行)即可知道變動內容。

由上例可顯示,若只紀錄差異,則將會比紀錄完整版本更能節省儲存空間,但缺點 是當取出版本距離基準版越遠時,因為要不斷地計算各版本間之差異,系統之效率會越 差。

目前常用的 SCM 系統有 CVS (Concurrent Version System)或 SVN (subversion)[11],SVN 為 CVS 之改進,此二者皆為 change-oriented model。由於歷史緣故 CVS 仍較為普遍,目 前大部份著名的開放原始碼專案仍使用 CVS,而本研究所分析之 OpenSSH 專案仍是以 CVS 之形式存在,應該第三章的方法設計將以 CVS 做為主要的處理目標。

2.2.2. 應用版本資料庫之文件製作

目前已有多種研究利用版本資料庫(revision history database)做為分析工具,黃與劉

[12]在其研究中透過對檔案與目錄層級的分析,判別出重要的目模組(即目錄),依此進

而界定開發者在發展過程之重要性,但是該研究並沒有處理函式層級以下之分析;

Cubranic[13]則是將開發過程中的各項資訊予以連結,例如將錯誤回報庫(bugzilla)與版本 變動差異(diff)建立關係,當使用者查詢如函式或變數名稱時,該系統可依相關度列出曾 發生過的相關歷史事件,雖然已針對個別檔案內部進行部份分析,但並沒有針對各程式 語言的特性發展,反而像是關鍵字搜尋的方式,在使用時仍可能陷於大量的資料中。

另一類的研究結合版本資料庫與程式分析,[14]揭示在進行此工作時應有的預備工 作以及注意事項,以該研究為基礎,Zimmermann 等人使用 association rule(於本章末節 介紹)之分析方法找出程式碼中常被同時修改的 program entity,此 program entity 常是 函式或變數,然而該文並無針對函式及變數的不同特性設計方法,且使用 association rule 的方法無法描述 entity 在程式內之先後關係(於本章末節將會詳細說明)。另外[2, 3, 5]

則同樣使用 association rule 之方法,其中[3, 5]用以找出程式中具相關的函式組,而[2]

則將變數融入函式相關性的分析中,詳細的內見下表比較。

最後介紹的方法則不使用 association rule 分析,[4]直接比較不同版本之 AST 以了 解程式內部細項(entity)之演變情形。

表 1 結合版本庫之方法比較

Guide Software Changes[6]

各種 電腦 語言

ROSE (Reengineering Of Softwave Evolution)

Each revision diff

{processor_cost} Î {i386_cost,

i486_cost, k6_cost}

當 processor_cost 修 改時,則 i386_cost、

i486_cost 及 k6_cost 也會跟著修改

They process the revision history database to fetch the fetch each revision and then group changes in various files into one transaction.

Rules are mined from these transactions. The rules and their supports and confidences (parameter in data mining algorithm) of the rules are provided to the users together.

System specific Rule[5]

C 語言 函式 Edison Design Group C parser

10 lines in a revision

{GlobalLock}Î{Glo balUnlock}

當 GlobalLock 加入 時,則預期

GlobalUnlock 會在十 行內加入。

此論文限制其 pattern 長度為2

Mining pair-wise pattern for two types: called after and conditionally called after. The former is simple pair-wise call pattern. But the later introduced the branch concept. For example, {…var = func_a(…); if (var==0) then func_b(…);}

func_b is triggered by var, which is the return value of func_a.

Repository is used for testing whether each pair is steadily added in the same revision.

Matching Method calls[3]

JAVA 函式及

變數

文中未提實際 工具,但仍使用

each revision diff

同上

除 pattern 次數外,加

By applying associative rules, they find

pair-wise patterns in Static phase. For corrective

的中介。 定 pattern 之可用性 pattern must be one-line check-in at least once.

Execute the program and analyze the dynamic traces to see whether the patterns are violated or not. The Corrective ranking is more effective than regular ranking.

PR-Miner[2] C 語言 函式 (modified) GCC intra-procedur e

Some implicit programming rules can be represented as the set of execution pattern of program elements. In this paper, the pattern size is not limited to 2 program element but also they mined both function and variable as program element.

AST structure, function call 及 variable)之修 改、刪除、增加或更 名。

To verify whether the program elements are added, changed, deleted or renamed in successive revision. These elements are

structure, function, variable, typedef. They diff ASTs in successive revisions.

本論文 C 語言 函式及

變數

Cvsup 及 CIL Each revision diff

後述 後述

相關文件