Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

Valgrind plugin

(1/9) > >>

killerbot:
I started the development of a little Valgrind plug-in. At this very moment it is very basic (hey, 2 months ago I didn't even know what Valgrind is).
Attached are the sources and project files for the plug-in. Since Valgrind is only for linux, this is a linux only plug-in. I provide the sources, no binary. Unzip in the plug-ins contrib dir of the CB source tree. It will activate in your CB devel build. If you want it in your output dir or with autotools adjust your update script and top level makefiles accordingly.

Requirements to run it :
 - you must be working on an 'executable' project
 - it must have as such an executable target
 - that target should have the -g compiler option [this is no checked yet, so make sure it is]
 - have Valgrind installed
 - have kcachegrind installed (to view to cachegrind output)

So when you have such a project/target active and you have built it (say the Debug build -> -g option), then select from the Plugins menu : Valgrind, and Valgrind will run your project/target executable and will create a 2 new panes in the Messages panel and dump it's output in there.

Current limitations :
 - currently only for the memcheck/cachegrind tool
 - only tested on some simple apps (console apps)

Attached is also a small test example, where you can see the Valgrind plug-in at work


Future tasks :
- check on the -g option
 - try with xml output --> better parsing and hopefully click to offending line
 - Provide more click to line (next to offending line, this can give information on where something was allocated)
 - configurable : where is the valgrind exe [now your linux system has to be able to find it itself]
 - configurable : which tool, so other things next to memcheck
 - configurable : able to select/specify the options to valgrind tools
 - one day try it on CB itself .........



[attachment deleted by admin]

JGM:
Cool, I have been bothering you with instant messages and here is the source  :lol: thanksss!!!!

killerbot:
the plug-in has been updated and is now available as a contrib plug-in in CB.

So see Cb svn for latest source, or if you want to build it.

killerbot:
create a console application and give main.cpp the following content (so you can try the plug-in) :

--- Code: ---#include <iostream>

using namespace std;

int main()
{
// let's go for a memory leak
int* ArrayI = new int[10];
ArrayI[0] = 0;
// read out of bounds
cout << ArrayI[12] << endl;

//write out of bounds
ArrayI[10] = 15;

// uninitialized variable
int UnInitVar;
if(UnInitVar)
{
cout << "Hello" << endl;;
}

// mismatch new[] delete
char* MyString = new char[10];
delete MyString;

// double delete
int* pInt = new int;
delete pInt;
delete pInt;

// double alloc to same variable --> first one lost
int* First = new int;
First = new int;
delete First;
First = 0;

return 0;
} // end of main

--- End code ---

Jenna:
The entry for the valgrind-plugin libs is missing frome "debian/codeblocks-contrib.install".

Patch:

--- Code: ------ codeblocks-1.0svn.orig/debian/codeblocks-contrib.install    2008-07-09 21:11:39.000000000 +0200
+++ codeblocks-1.0svn.work/debian/codeblocks-contrib.install    2008-07-09 22:25:02.000000000 +0200
@@ -39,6 +39,7 @@
 usr/share/codeblocks/plugins/libRegExTestbed.*
 usr/share/codeblocks/plugins/libSymTab.*
 usr/share/codeblocks/plugins/libThreadSearch.*
+usr/share/codeblocks/plugins/libValgrind.*
 usr/share/codeblocks/plugins/libwxsmith.*
 usr/share/codeblocks/plugins/libwxsmithcontribitems.*


--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version