I'm parsing compilation_commands.json to cppcheck with --project. In this each having the minimum 8 included paths provided(using -I). For each on average it is taking 3-4 secs and total it is taking 12 mins for 220 files.
Is this expected behavior when more included paths provided?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It sounds expected. If a -I is not provided then the headers are probably not included and there will be less code to parse. Cppcheck is designed to check the code even without all headers.
I would recommend that you don't include 3rd party headers, use --library instead.
I would recommend that the internal headers are included by -I.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In that case is it possible below any. My concern is to decrease execution time.
a. Incremental checking - means calling cppcheck for only modified files. So that no need to do for all files everytime.
b. Duplicate includes - means there are 220 files in my database file. There is a high chance of included paths getting repeated. If cppcheck ignore checking already check path the time will be saved.
Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
it should save ~95% time or so.
do you get various files in the cppcheck build dir.. if you have 100 source files then the cppcheck build dir should contain 100+ files..
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, I see files in cppcheck build dir. I have total 208 source files and in cppcheck build dir i'm seeing total 208 files. And if I rebuild without changing any source file, 36 files(A1) are getting updated to latest timestamp.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can you also try to run cppcheck with --showtime=summary option.. what is the output from that when you recheck a unchanged folder? Also stupid question.. you did use the exact same arguments when you rechecked the code right?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have some cases where addition of just one more include path (leading to more header files being found) will lead to a huge increase in analysis time.
No path to system headers, only my own headers.
"Cppcheck is designed to check the code even without all headers".
But I guess that without my headers the Class checks (missing member variable initialization etc.) are not possible?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
But I guess that without my headers the Class checks (missing member variable initialization etc.) are not possible?
Yes. I do recommend that you include your headers. In theory it would have been good to always use configuration files that had deeper information also but Cppcheck is not good enough and the work for users would have been too much.
Last edit: Daniel Marjamäki 2021-04-29
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I see recursively passing project root directory is executing very quickly instead of passing with database file i.e., --project option.
But I see with the recursive solution it is not finding errors in some header files. Intentionally added array out of bound error and run cppcheck. Strangely it is not at all reporting if header file located in a folder named with include.
I'm giving -D flags, some excluded paths with -i option, and only one included path(cppcheck unable to find one macro, so had to provide this path), --enable=warning, --enable=style, -j 16 --enable=performance, --library=compiler.cfg, --xml, --quiet, --inline-suppr, --suppress=preprocessorErrorDirective --suppress=:projectRoot/vendor/*.h
Using cppcheck 2.4.1 version
We really want to speed up cppcheck exection as it is taking 10 mins with database file. With recursive method only executing in 20 sec.
Any suggestions is really helpful.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
But I see with the recursive solution it is not finding errors in some header files. Intentionally added array out of bound error and run cppcheck. Strangely it is not at all reporting if header file located in a folder named with include.
Very strange! Of course that should work.
Any suggestions is really helpful.
I will suggest that you use --cppcheck-build-dir that can really speed up the analysis. However we discovered that option has been broken for some time. It will be fixed in cppcheck-2.6 that is released soonish.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Downloaded version 2.6-rc1 from github and tried the --cppcheck-build-dir, but it is not saving time at all. Creating the folder cppcheck-build-dir before running the cppcheck, PFA for complete command. I see .a1 and .snalyzerinfo are creating in cppcheck-build-dir.
It's hard to trouble shoot without seeing any code. is there any code you could share? A single file. Maybe some kind of example code that includes public API?
would it be possible to download the code in D:/Test/shared/source/cmsis somewhere and test on just that to start with?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes, I ran cppcheck on the lib folder and it is saving time greatly for 2nd time run.
In our case we are using compile_comands.json(Attached the json info for a single file which includes many included paths and -D flags) with --project option
For us also passing project directory recursively is quick but we see some missing errors in header files. And with --cppcheck-build-dir I see .a1 and .snalyzerinfo files are generating and not creating/updating for 2nd run, only files.txt is getting updated still it is saving hardly 2 mins.
I'm parsing compilation_commands.json to cppcheck with --project. In this each having the minimum 8 included paths provided(using -I). For each on average it is taking 3-4 secs and total it is taking 12 mins for 220 files.
Is this expected behavior when more included paths provided?
It sounds expected. If a
-I
is not provided then the headers are probably not included and there will be less code to parse. Cppcheck is designed to check the code even without all headers.I would recommend that you don't include 3rd party headers, use
--library
instead.I would recommend that the internal headers are included by
-I
.Hi Daniel,
In that case is it possible below any. My concern is to decrease execution time.
a. Incremental checking - means calling cppcheck for only modified files. So that no need to do for all files everytime.
b. Duplicate includes - means there are 220 files in my database file. There is a high chance of included paths getting repeated. If cppcheck ignore checking already check path the time will be saved.
Thanks.
We have incremental analysis, use
--cppcheck-build-dir
.I can't understand why we are not writing about this in the manual. :-(
Maybe something should be put in the help output to better draw peoples attention to it.
Performance options
-j, --cppcheck-build-dir
I tried giving --cppcheck-build-dir, Hardly it is saving 15-20 seconds.
Can be saved more time?
it should save ~95% time or so.
do you get various files in the cppcheck build dir.. if you have 100 source files then the cppcheck build dir should contain 100+ files..
Hi Daniel,
Yes, I see files in cppcheck build dir. I have total 208 source files and in cppcheck build dir i'm seeing total 208 files. And if I rebuild without changing any source file, 36 files(A1) are getting updated to latest timestamp.
hmm that is unexpected. Not sure .. does it help if you provide
-D
flag(s) and don't say--force
?Can you also try to run cppcheck with
--showtime=summary
option.. what is the output from that when you recheck a unchanged folder? Also stupid question.. you did use the exact same arguments when you rechecked the code right?I have some cases where addition of just one more include path (leading to more header files being found) will lead to a huge increase in analysis time.
No path to system headers, only my own headers.
"Cppcheck is designed to check the code even without all headers".
But I guess that without my headers the Class checks (missing member variable initialization etc.) are not possible?
Yes. I do recommend that you include your headers. In theory it would have been good to always use configuration files that had deeper information also but Cppcheck is not good enough and the work for users would have been too much.
Last edit: Daniel Marjamäki 2021-04-29
Thanks - for the answer, and for the work with Cppcheck.
Hi Daniel,
I see recursively passing project root directory is executing very quickly instead of passing with database file i.e., --project option.
But I see with the recursive solution it is not finding errors in some header files. Intentionally added array out of bound error and run cppcheck. Strangely it is not at all reporting if header file located in a folder named with include.
I'm giving -D flags, some excluded paths with -i option, and only one included path(cppcheck unable to find one macro, so had to provide this path), --enable=warning, --enable=style, -j 16 --enable=performance, --library=compiler.cfg, --xml, --quiet, --inline-suppr, --suppress=preprocessorErrorDirective --suppress=:projectRoot/vendor/*.h
Using cppcheck 2.4.1 version
We really want to speed up cppcheck exection as it is taking 10 mins with database file. With recursive method only executing in 20 sec.
Any suggestions is really helpful.
Very strange! Of course that should work.
I will suggest that you use
--cppcheck-build-dir
that can really speed up the analysis. However we discovered that option has been broken for some time. It will be fixed in cppcheck-2.6 that is released soonish.Ok. When can we expect v2.6 release on worst case.
Thanks.
I would expect next weekend. but worst case, well I don't know.
we made a release candidate yesterday:
https://sourceforge.net/p/cppcheck/discussion/development/thread/600fea08c7/?page=1&limit=25#f132
Downloaded version 2.6-rc1 from github and tried the --cppcheck-build-dir, but it is not saving time at all. Creating the folder cppcheck-build-dir before running the cppcheck, PFA for complete command. I see .a1 and .snalyzerinfo are creating in cppcheck-build-dir.
Do I miss anything here?
you need to run cppcheck at least twice to see the speedup..
the first "cppcheck" will be as slow as before.
the second "cppcheck" should be a lot faster.
Yes, I'm expecting time save for 2nd run while not changing anything.
But it is not happening like that.
It's hard to trouble shoot without seeing any code. is there any code you could share? A single file. Maybe some kind of example code that includes public API?
would it be possible to download the code in D:/Test/shared/source/cmsis somewhere and test on just that to start with?
you can download cppcheck source code here: https://github.com/danmar/cppcheck/archive/refs/heads/main.zip
if you for testing purposes unpack that and run this command twice:
Can you reproduce that the second command is faster?
Thanks for the reply Daniel.
Yes, I ran cppcheck on the lib folder and it is saving time greatly for 2nd time run.
In our case we are using compile_comands.json(Attached the json info for a single file which includes many included paths and -D flags) with --project option
For us also passing project directory recursively is quick but we see some missing errors in header files. And with --cppcheck-build-dir I see .a1 and .snalyzerinfo files are generating and not creating/updating for 2nd run, only files.txt is getting updated still it is saving hardly 2 mins.
@danielmarjamaki
Could you please suggest a solution?
It would help if I could reproduce this.
With a compile database I get a speedup:
I guess that your compile command file does not matter.
If you use
--file-filter
on some file as I did here can you see if it goes faster?If it does not go faster I wonder if you can validate the generated
*.a1
file. Check if it is valid xml. For instance:xmllint --noout b/token.a1