pacemaker icon indicating copy to clipboard operation
pacemaker copied to clipboard

RFC: Build: Add support for generating cflow reports for cmdline tools.

Open clumens opened this issue 1 year ago • 2 comments

cflow is a program that generates reports of function call chains in C source files. I find it most useful in determining where a function I want to get rid of is getting called, though it could be used for a bunch of other things.

It's really most useful if you give it a function. Otherwise, it will generate all possible call chains, which is very large. Pass the function you're interested in (and any other extra arguments) via the CFLOW_FLAGS environment variable.

For instance, if you want to see everwhere that calls crm_perror:

$ make -C tools CFLOW_FLAGS="--target crm_perror" cflow

Or, you can see everything that a single function calls:

$ make -C tools CFLOW_FLAGS="--main pcmk__add_mainloop_ipc" cflow

However note that in this case, the per-tool output makes less sense. You'll probably just end up with a bunch of duplicate copies of a single report.

Additionally, if you're only interested in generating a report for a single command line tool, you can do this:

$ make -C tools CFLOW_FLAGS="--target crm_perror" crm_rule.cflow

Other things to note:

  • You do not need to build the source before running this.

  • It will output a lot of warnings about redefinitions, which I think is mostly due to reusing argument names and things like that. It doesn't seem to be causing problems.

  • I have purposefully not added any -Idir include arguments to the call to cflow. It will take these, but it doesn't seem to do much for us at the moment besides slow everything way down.

clumens avatar Aug 22 '23 16:08 clumens