4

I'm trying to build a list of available tools for parsing a complete source code package and extracting all of the functions/methods as separate pieces. My goal is to run a tool or script, immediately know how many functions are in the package, and to easily examine the complete set of segmented functions one-by-one as needed.

Right now I'm using the NiCad clone detection tool, which includes an extract script written in TXL (a tree transformation language). Each function is pulled out and stored as a unique entity in an XML document, so handling the list of functions is very convenient. NiCad included extract tools for C, Java, and Python. I'm mostly concerned with C, but it's also nice to have the rest available. We don't have a C++ parser set up yet - that would be handy.

I've also used Doxygen, which has the added bonus of identifying the call graph. There's a lot of markup in these files though, so it's a bit of extra work to parse Doxygen's output to get them into a plain list of functions.

Has anyone used a tool that extracts the full set of functions/methods? Do you have recommendations or warnings? If you've written your own, is it available somewhere?

Thanks!

4

1 に答える 1

0

Linux の nm ツールを使用できます。「nmは、オブジェクトファイルからシンボルをリストするために使用されます」。詳細については、nm の man ページを参照してください。サンプル nm は、参照用にここにコピーされます。

void fun1() {
    return;
}

void fun() {
     fun1();
}
int main()
{
     fun();
     return 0;
}

「nm a.out | grep T」を実行したときの上記プログラムの Nm

08048470 T __libc_csu_fini
08048400 T __libc_csu_init
080484ac T _fini
080482b8 T _init
08048320 T _start
080483d9 T fun
080483d4 T fun1
080483e3 T main
于 2012-07-20T07:36:49.627 に答える