2013-03-07 66 views
6

我能夠使用gnu -cflow生成一個文件的調用圖,但我無法找到如何使用cflow爲多個文件生成調用圖。如何給多個c文件作爲輸入到GNU Cflow?

我嘗試以下

  • 的cflow test.c的,hello.c的

    它爲test.c的調用圖,而不是爲了hello.c的

  • cflow的測試創建。 c hello.c

    它爲hello.c生成callgraph並且不爲test.c創建它c

我不知道如何將多個文件傳遞給cflow。

對此有何想法?

的hello.c

int 
who_am_i (void) 
{ 
    struct passwd *pw; 
    char *user = NULL; 

    pw = getpwuid (geteuid()); 
    if (pw) 
    user = pw->pw_name; 
    else if ((user = getenv ("USER")) == NULL) 
    { 
     fprintf (stderr, "I don't know!\n"); 
     return 1; 
    } 
    printf ("%s\n", user); 
    unused_function(); 
    return 0; 
} 

int 
main (int argc, char **argv) 
{ 
    if (argc > 1) 
    { 
     fprintf (stderr, "usage: whoami\n"); 
     return 1; 
    } 
    return who_am_i(); 
} 
void unused_function() 
{ 
    printf(); 
    error1(); 
    printf(); 
} 
void error1() 
{ 
    error2(); 
} 
void error2() 
{ 

} 

test.c的

int tests() 
{ return 0;} 
+0

你可以發佈hello.c和test.c的內容嗎? – 2013-03-07 07:43:44

+0

@AndreasGrapentin我添加了代碼。我只是不知道如何傳遞多個文件名到cflow。 – Ganeshkumar 2013-03-07 08:44:01

+1

你的第二次調用是正確的。 'tests()'不會顯示在你的調用圖中,因爲它永遠不會被調用。 – 2013-03-07 08:57:45

回答

2
  • cflow的test.c以hello.c的

其實上面的說法是正確的,測試()不在callgraph中顯示,因爲它從來沒有被調用過。通過@AndreasGrapentin

+1

另外,如果你不想要所有函數的圖形,你可以使用--main選項來指定你感興趣的函數。例如,對於who_am_i: 'cflow --main who_am_i hello.c ../ libFolder/*。c' 這包含在cflow的info文件夾中,只需鍵入'info cflow.info'並轉到第2頁 – alexey 2014-11-19 00:46:09

1

給出

回答另一個方便的命令是:

cflow *.c 

注:
此命令會忽略所有子目錄C源文件。

參考:
GNU cflow manual: Chapter 6-Controlling Symbol Types

對於cflow的,以便能夠處理這些聲明,聲明__P作爲一個包裝,例如:

cflow的--symbol __P:包裝的* .c

相關問題