-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
How to make a call graph for a function in C/C++? #8376
Comments
I assume what you're looking for is the tree of callers/callees reachable from a given function? If you don't need to handle function pointers and virtual dispatch, the easiest option is to use
Depending on the format you specify, that will give either a dot text file you can render with graphviz tools, or a DGML file that Visual Studio can support with the optional DGML Viewer component. If you do need to resolve function pointers and virtual dispatch, I'd recommend the |
Thanks, I tried this out and it works well for small codebases. Although, in larger codebases
I replaced calls/calls* respectively with allCalls/allCalls* from One problem I have is lacking speed
What was your reason behind using callee.calls*(root)? I removed it to increase speed and the result is the same. Another problem I have is limiting the call graph so it isn't too big in size. So another thing I tried was to limit the call graph to all functions called in the same file as the root function.
What I did was define the callee as a FunctionCall instead of a Function, and check
|
I'm looking forward to writing a query which will deliver a call graph for a given function.
Preferably a call graph (a picture or similar graphic representation), but if that is
not possible, at least a chain of possible calls.
I already checked the CodeQL documentation and it seems like there is more information
for Java, and I'm not capable of getting a call graph with this C++ module:
https://codeql.github.com/codeql-standard-libraries/cpp/semmle/code/cpp/pointsto/CallGraph.qll/module.CallGraph.html
I would appreciate any guidance.
The text was updated successfully, but these errors were encountered: