Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

I tried following

  • cflow test.c,hello.c

    It generates the callgraph for test.c and not creating it for hello.c

  • cflow test.c hello.c

    It generates the callgraph for hello.c and not creating it for test.c

I don't know how to pass multiple files to 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

int tests()
{ return 0;}
like image 952
gramcha Avatar asked Mar 07 '13 07:03

gramcha


2 Answers

  • cflow test.c hello.c

Actually above statement is correct and tests() does not show up in callgraph, because it is never called.

answer given by @AndreasGrapentin

like image 171
gramcha Avatar answered Oct 07 '22 01:10

gramcha


Another convenient command is:

cflow *.c

Note:
This command will ignore C source files in all sub-directories.

Reference:
GNU cflow manual: Chapter 6-Controlling Symbol Types

For cflow to be able to process such declarations, declare __P as a wrapper, for example:

cflow --symbol __P:wrapper *.c

like image 39
cs_w_y Avatar answered Oct 07 '22 00:10

cs_w_y