I would like the ability to specify dump file locations from the command line. I've just started using that feature at work, and it's very inconvenient having the dump files written to the source directory. I have patches that I am more than happy to share, but the bug tracker is private, and there's nobody in chat.
the GUI writes the dump files in a custom location (in the cppcheck-build-dir).. but there is no way to access that feature from command line. Maybe your --dump= command is ok but as far as I see you then need to invoke cppcheck separately on each source file.
Can you please open a Pull Request in github?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Would it suit your needs if you can specify a folder where all the dump files will be saved?
your default option to put the dump files in current directory makes sense. however it must be handled when different files have the same filename "subfolder1/file.c" and "subfolder2/file.c".
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
And yeah, I forgot that cppcheck allows you to check multiple files at once (I'm just using it like a compilert). Maybe if we were to mirror the relative directory location from the current working directory (or --dump-dir?), if checking a directory?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I had a closer look at this today. My original proposal doesn't appear to work, as cppcheck also allows multiple file or directory arguments. So how about maybe just appending a (2) after the name if a dump file exists?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Actually no, that would make it so that I would never quite be sure if the file I was looking at was actually for my current run or some previous run if I failed to clean my output. I definitely wouldn't want that
How about prepending a numbered directory name in front of a relative directory name in the dump file output directory (in the case of a recursive directory argument)? That would require some rather extensive changes to the code though, as the files map would likely have to change from a size_t to a struct value for size, arg number, and basename. Then pass in the desired dump name into the check function?
Does that sound reasonable?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would recommend that "Cppcheck build dir" is used overall... so if that is specified then how about writing the dump files there in the CLI also to start with? Then the GUI and CLI works the same.
In the "Cppcheck build dir", a files.txt is generated the contains a mapping for source files and files in the Cppcheck build dir. Here is an example files.txt I got when analysing Cppcheck lib..
In the GUI, the dump file for lib/analyzerinfo.cpp will get the name analyzerinfo.a1.dump. That name is guaranteed to be unique even if there are many files with the name "analyzerinfo.cpp" in different folders. The extensions will be "a1", "a2", "a3", ...
Would this be a good solution for you?
Last edit: Daniel Marjamäki 2017-11-16
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would like the ability to specify dump file locations from the command line. I've just started using that feature at work, and it's very inconvenient having the dump files written to the source directory. I have patches that I am more than happy to share, but the bug tracker is private, and there's nobody in chat.
Last edit: David Brady 2017-11-02
I agree.
the GUI writes the dump files in a custom location (in the cppcheck-build-dir).. but there is no way to access that feature from command line. Maybe your
--dump=
command is ok but as far as I see you then need to invoke cppcheck separately on each source file.Can you please open a Pull Request in github?
Would it suit your needs if you can specify a folder where all the dump files will be saved?
your default option to put the dump files in current directory makes sense. however it must be handled when different files have the same filename "subfolder1/file.c" and "subfolder2/file.c".
I'll see about setting up a github account.
And yeah, I forgot that cppcheck allows you to check multiple files at once (I'm just using it like a compilert). Maybe if we were to mirror the relative directory location from the current working directory (or --dump-dir?), if checking a directory?
I had a closer look at this today. My original proposal doesn't appear to work, as cppcheck also allows multiple file or directory arguments. So how about maybe just appending a (2) after the name if a dump file exists?
Actually no, that would make it so that I would never quite be sure if the file I was looking at was actually for my current run or some previous run if I failed to clean my output. I definitely wouldn't want that
How about prepending a numbered directory name in front of a relative directory name in the dump file output directory (in the case of a recursive directory argument)? That would require some rather extensive changes to the code though, as the files map would likely have to change from a size_t to a struct value for size, arg number, and basename. Then pass in the desired dump name into the check function?
Does that sound reasonable?
I would recommend that "Cppcheck build dir" is used overall... so if that is specified then how about writing the dump files there in the CLI also to start with? Then the GUI and CLI works the same.
In the "Cppcheck build dir", a files.txt is generated the contains a mapping for source files and files in the Cppcheck build dir. Here is an example files.txt I got when analysing Cppcheck lib..
In the GUI, the dump file for lib/analyzerinfo.cpp will get the name analyzerinfo.a1.dump. That name is guaranteed to be unique even if there are many files with the name "analyzerinfo.cpp" in different folders. The extensions will be "a1", "a2", "a3", ...
Would this be a good solution for you?
Last edit: Daniel Marjamäki 2017-11-16
By the way.. it is not important what the filenames of the dumpfiles are. They can be "1.dump", "2.dump", "3.dump", ....
All information the addons need are in the dumpfile.
In the long run I think it would be nice with a builtin functionality in Cppcheck that would execute the addons. Like:
And ideally the user does not need to worry about the dumpfiles at all.