CppCheck plugin

Discussion about CodeLite development process and patches
User avatar
eranif
CodeLite Plugin
Posts: 6373
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: CppCheck plugin

Post by eranif »

jfouche wrote:Here a small patch for codelite_cppcheck workspace and src (to compile with gcc 4.4.0).
thanks I will apply it
jfouche wrote:For your gui, could you send me your fbp to make me use it instead of my csope one ?
I committed it, and I am off to bed now:) feel free to modify / change / add and send me patches.

Eran
Make sure you have read the HOW TO POST thread
jfouche
CodeLite Guru
Posts: 351
Joined: Mon Oct 20, 2008 7:26 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

Re: CppCheck plugin

Post by jfouche »

Almost finished, making some tests. I'll post the patch in a few time
You do not have the required permissions to view the files attached to this post.
Jérémie
User avatar
eranif
CodeLite Plugin
Posts: 6373
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: CppCheck plugin

Post by eranif »

jfouche wrote:Almost finished, making some tests. I'll post the patch in a few time
Nice! waiting for the patch (promise I wont commit anything in the meantime :))

Eran
Make sure you have read the HOW TO POST thread
jfouche
CodeLite Guru
Posts: 351
Joined: Mon Oct 20, 2008 7:26 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

Re: CppCheck plugin

Post by jfouche »

Eran

I'm wondering how to stop the current analysis ?
Do I have to terminate the current process and restart a new one, or is there a better way to do it ? I tried analysis of sqlite3.c, which takes a long time (and codelite_cppcheck take 100% CPU).

[edit] : I modified a little bit your fbp in order to add a status line. Unfortunatly, the CPPCheckerReply::StatusMessage is never sent, probably due to the fact that you send files to codelite_cppcheck one by one. Nevermind for the moment.
Last but not least : Warning, my wxFormBuilder version is greater than yours, so I have to merge my working copy with the trunk version by hand, to be sure you can open it. I'll try to take care...

[edit 2] : calling m_cppcheckProcess->Terminate(); doesn't kill the process :(
Jérémie
jfouche
CodeLite Guru
Posts: 351
Joined: Mon Oct 20, 2008 7:26 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

Re: CppCheck plugin

Post by jfouche »

Hi Eran,
Here is the patch. Can you have a look at the CppCheckPlugin::StopAnalysis() ? Is there a way to really kill the process ?
Feedback is welcome
You do not have the required permissions to view the files attached to this post.
Jérémie
User avatar
eranif
CodeLite Plugin
Posts: 6373
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: CppCheck plugin

Post by eranif »

Hi Jeremie,
To stop the analysis, all we need to do is to kill the process (m_cppcheckProcess->Terminate()) or we can simply clear the m_filelist member so it will stop once it will finish processing the current file.

I prefer to kill the process, since it will be restarted but it will also provide the user with an immediate response with no need to wait
jfouche wrote:m_cppcheckProcess->Terminate();doesn't kill the process
It does. But it is automatically restarted by the plugin (check CppCheckPlugin::OnCppCheckTerminated):

Code: Select all

void CppCheckPlugin::OnCppCheckTerminated(wxProcessEvent& e)
{
	if ( GetCanRestart() ) {
		wxUnusedVar(e);
		m_cppcheckProcess->Disconnect(m_cppcheckProcess->GetUid(), wxEVT_END_PROCESS, wxProcessEventHandler(CppCheckPlugin::OnCppCheckTerminated), NULL, this);
		StartCppCheckDaemon();
	}
}
As you can see the plugin is also acting as watchdog, in case the process is terminated - it will be restarted.
To really shut it down, you need to call:

Code: Select all

SetCanRestart( false );
m_cppcheckProcess->Terminate();

But the above code should be used only in the UnPlug() method. Since in the other cases, we want the cppcheck daemon up.
jfouche wrote:[edit] : I modified a little bit your fbp in order to add a status line. Unfortunatly, the CPPCheckerReply::StatusMessage is never sent, probably due to the fact that you send files to codelite_cppcheck one by one. Nevermind for the moment.
Actually it is an advantage, since we know exactly how long is the progress bar, and when OnReport() is called, we can add +1 to the progress

Eran
Make sure you have read the HOW TO POST thread
jfouche
CodeLite Guru
Posts: 351
Joined: Mon Oct 20, 2008 7:26 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

Re: CppCheck plugin

Post by jfouche »

eranif wrote:
jfouche wrote:m_cppcheckProcess->Terminate();doesn't kill the process
It does. But it is automatically restarted by the plugin (check CppCheckPlugin::OnCppCheckTerminated):
Well I had a try while analysing sqlite3.c. It's easy to see that the process is not killed as it take about 30 MB memory (instead of about 1.5 MB usualy). m_cppcheckProcess->Terminate() was called, and a new process was created : analysis of my test project worked after I pressed STOP button.

After reading youy post, I think I didn't implement correctly the CppCheckPlugin::StopAnalysis(), because I do not need to call StartCppCheckDaemon() after the process destruction (which doesn't occurs in my point of view ;))
Jérémie
User avatar
eranif
CodeLite Plugin
Posts: 6373
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: CppCheck plugin

Post by eranif »

jfouche wrote:After reading youy post, I think I didn't implement correctly the CppCheckPlugin::StopAnalysis(), because I do not need to call StartCppCheckDaemon() after the process destruction (which doesn't occurs in my point of view ;))
I implemented it now in SVN trunk along with all your changes are now committed.

Eran
Make sure you have read the HOW TO POST thread
jfouche
CodeLite Guru
Posts: 351
Joined: Mon Oct 20, 2008 7:26 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

Re: CppCheck plugin

Post by jfouche »

Hi Eran
You updated the [Stop] button a little bit too early : We can't stop analysis for the last file...
Here is a patch

Moreover, some regressions :
- 2 times CppCheck on a project gives you 2 times the files on scintilla.
- clic on scintilla doesn't open file
You do not have the required permissions to view the files attached to this post.
Jérémie
jfouche
CodeLite Guru
Posts: 351
Joined: Mon Oct 20, 2008 7:26 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

Re: CppCheck plugin

Post by jfouche »

Hi Eran

I'm making a settings dialog for CppCheck, and I have a question :
Reading sources, I see that there is a different implementation between WXMSW (codelite_cppcheck is always running in background) and WXMAC/WXGTK (a new codelite_cppcheck is launched for each file). I suppose that I need to restart codelite_cppcheck for WXMSW when I change the settings (ie : command line options). To be more precise, I need to wait the end of the current analysis, stop the process, and start a new one.
Can you confirm this ?

Moreover, I'm surprised of the code in CppCheckPlugin::StartCppCheckDaemon() :

Code: Select all

#ifdef __WXMSW__
	// determine the codelite_cppcheck path:
#if defined (__WXMAC__)
	m_cppcheckPath = wxStandardPaths::Get().GetDataDir();
#else
	wxFileName exePath( wxStandardPaths::Get().GetExecutablePath() );
	m_cppcheckPath = exePath.GetPath();
#endif
Is it possible to have __WXMSW__ and __WXMAC__ defined at the same time ?
Jérémie
Post Reply