简体   繁体   English

如何提供多个c文件作为GNU Cflow的输入?

[英]how to give more than one c file as input to GNU Cflow?

I was able to generate the callgraph of one file using gnu - cflow, but I was not able to find out how to generate the call graph for multiple files using cflow. 我能够使用gnu-cflow生成一个文件的调用图,但我无法找到如何使用cflow为多个文件生成调用图。

I tried following 我试过跟随

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

    It generates the callgraph for test.c and not creating it for hello.c 它为test.c生成调用图,而不是为hello.c创建调用图

  • cflow test.c hello.c cflow test.c hello.c

    It generates the callgraph for hello.c and not creating it for test.c 它为hello.c生成调用图,而不是为test.c创建调用图

I don't know how to pass multiple files to cflow. 我不知道如何将多个文件传递给cflow。

Any idea about this? 对此有何想法?

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 test.c的

int tests()
{ return 0;}
  • cflow test.c hello.c cflow test.c hello.c

Actually above statement is correct and tests() does not show up in callgraph, because it is never called. 实际上上面的语句是正确的,并且tests()没有出现在callgraph中,因为它从未被调用过。

answer given by @AndreasGrapentin @AndreasGrapentin给出了答案

Another convenient command is: 另一个方便的命令是:

cflow *.c

Note: 注意:
This command will ignore C source files in all sub-directories. 此命令将忽略所有子目录中的C源文件。

Reference: 参考:
GNU cflow manual: Chapter 6-Controlling Symbol Types GNU cflow手册:第6章 - 控制符号类型

For cflow to be able to process such declarations, declare __P as a wrapper, for example: 要使cflow能够处理此类声明,请将__P声明为包装器,例如:

cflow --symbol __P:wrapper *.c cflow --symbol __P:wrapper * .c

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM