codeql
codeql copied to clipboard
CPP: Missing code in database
When I compile some projects, I use configure and make to create a database.
But some code in #if or #ifdef. Maybe there are conditions that need to be met for this to be compiled? So when I query for a functioncall that in source code, the result maybe none.
Is there some log info can let me know which part in a file is compiled?
For example, the file in the attachment, when I search for ASN1_STRING_to_UTF8, the result is none.
ssl_verify_openssl.zip
Greetings! Thanks for getting in touch with this question. We unfortunately don't have a super easy way at the moment to see what parts of a file made it into a CodeQL database and which were removed by the preprocessor. However, I can give you a couple of pointers towards writing a query to find this information:
- You could query the exprs table of the database directly to find all source locations with corresponding lines in the DB. Anything that doesn't appear there wasn't seen by the extractor and therefore wasn't compiled.
- You could write a query using the Preprocessor.qll library to find branches with conditions that ended up as false and therefore weren't compiled.
It's a pity that we don't have a less ad-hoc way of surfacing this information at the moment. We've considered something in the CodeQL extension for VS Code to surface this information by for example highlighting parts of files that were/weren't extracted. But until we've had the engineering time to invest in a solution like that one, the above custom queries are the best I can recommend.
Greetings! Thanks for getting in touch with this question. We unfortunately don't have a super easy way at the moment to see what parts of a file made it into a CodeQL database and which were removed by the preprocessor. However, I can give you a couple of pointers towards writing a query to find this information:
- You could query the exprs table of the database directly to find all source locations with corresponding lines in the DB. Anything that doesn't appear there wasn't seen by the extractor and therefore wasn't compiled.
- You could write a query using the Preprocessor.qll library to find branches with conditions that ended up as false and therefore weren't compiled.
It's a pity that we don't have a less ad-hoc way of surfacing this information at the moment. We've considered something in the CodeQL extension for VS Code to surface this information by for example highlighting parts of files that were/weren't extracted. But until we've had the engineering time to invest in a solution like that one, the above custom queries are the best I can recommend.
Thank you very much!I'll try the method you suggested!