Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add callgraph ninja target #4412

Open
hadess opened this issue Oct 24, 2018 · 1 comment
Open

Add callgraph ninja target #4412

hadess opened this issue Oct 24, 2018 · 1 comment

Comments

@hadess
Copy link

hadess commented Oct 24, 2018

In a manner similar to the scan-build ninja target, it would be great if it was possible to create a target that output a callgraph as a "dot" file.

The current process goes something like this:

  • Set CC="clang" CPPFLAGS="-emit-llvm" and run your build as usual, until clang is unable to link your files with file not recognized: File format not recognized (the generated .o files are LLVM IR bitcode).
  • Merge the .o files for your target (a library in this case): llvm-link -o foo *.o
  • Generate a callgraph.dot file with that: cat foo | opt -dot-callgraph

And then trying using graphviz' dot to generate a callgraph. Or use cat foo | opt -print-callgraph to print a human-readable output, etc.

@hadess
Copy link
Author

hadess commented Oct 24, 2018

I also found cflow, for C files, which is probably slightly easier to use, although I don't know how accurate its C parsing is.

$ cflow <list of files.c>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant