GCC plugin cospy

1 view
Skip to first unread message

Thinker K.F. Li

unread,
Sep 8, 2010, 10:26:39 AM9/8/10
to hacking...@googlegroups.com
Hi All,

這幾天試了一下 GCC plugin,試著寫一個類似 CSS 的功能,但是針對 code 的
call path 加上特定行為,而不是視覺的 style。目前已經能特過 plugin 讀出
source code 裡面的 function name, arguments 還有被 function 呼叫的其它
function 的列表。 source code 可於下面 URL 取得 (hg):

http://hg.assembla.com/cospy

請案裝新版的 GCC (支援 plugin),並在 src/ 目錄下執行

GCC=/path/to/your/gcc make test

如果有錯誤,請檢查一下,看是否要加上 CFLAGS,如

CFLAGS=-I/usr/local/include GCC=/path/to/your/gcc make test

執行後會印出下列畫面
----------------------------------------
Initialize plugin cospy
value:3:test.c
a:int
main:8:test.c
call printf
call value
argc:int
argv:const char**
----------------------------------------
這是用 gcc plugin parse test.c 的結果。

為什麼要為 GCC 加上類似 CSS 的功能呢? 為的是要提供 aspect programming
的功能,讓程式碼更為簡潔。如有興趣,歡迎星期四和我討論。
Reply all
Reply to author
Forward
0 new messages