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]
Cool, I have been bothering you with instant messages and here is the source :lol: thanksss!!!!
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.
create a console application and give main.cpp the following content (so you can try the plug-in) :
#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
The entry for the valgrind-plugin libs is missing frome "debian/codeblocks-contrib.install".
Patch:
--- 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.*
done
If I try to disable the plugin C::B crashes with a segfault without showing the crash-report window.
Nevertheless the crash-report gets written into /tmp directory.
I attach it. It seems to crash in "PluginsConfigurationDlg::OnToggle(...)".
It only happens with Valgrind, egally if I remove it alone, as first or as last plugin.
And there is no "Valgrind"-entry in "default.conf" under "<plugins>".
[attachment deleted by admin]
Quote from: jens on July 13, 2008, 08:14:21 PM
And there is no "Valgrind"-entry in "default.conf" under "<plugins>".
That's ok, since it does not have settings.
Quote from: killerbot on July 14, 2008, 01:14:53 PM
Quote from: jens on July 13, 2008, 08:14:21 PM
And there is no "Valgrind"-entry in "default.conf" under "<plugins>".
That's ok, since it does not have settings.
I meant the entry wher I can find the disabled and enabled status, but I see now that all (installed) plugins are enabled by default and the entry only occurs if a plugins status has toggled at least once.
And that could not happen for Valgrind because of the crash.
Quote from: jens on July 14, 2008, 01:22:25 PM
I meant the entry wher I can find the disabled and enabled status [...]
And that could not happen for Valgrind because of the crash.
Probably due to the crash this setting was not saved. I had the same issue with the svnInside plugin. I disabled the plugin to avoid crashes on exit of C::B. But these settings were always lost until I really removed this plugin.
Quote from: MortenMacFly on July 14, 2008, 02:31:51 PM
Quote from: jens on July 14, 2008, 01:22:25 PM
I meant the entry wher I can find the disabled and enabled status [...]
And that could not happen for Valgrind because of the crash.
Probably due to the crash this setting was not saved. I had the same issue with the svnInside plugin. I disabled the plugin to avoid crashes on exit of C::B. But these settings were always lost until I really removed this plugin.
Afaik the "real" writing is done when C::B closes correctly. If C::B crashes all changes to default.conf are lost.
I can manually disable Valgrind-plugin, if I edit default.conf and set the value for "VALGRIND" to "0".
If I have done this, I can enable Valgrind-plugin from inside C::B, but if I try to redisable it, the crash occurs again.
There is another issue, when I try to check a program on a
some part of your last post got lost ...
Quote from: killerbot on July 14, 2008, 03:33:09 PM
some part of your last post got lost ...
Quote from: jens on July 14, 2008, 03:03:16 PM
There is another issue, when I try to check a program on a
here it should continue:
But, the error is not related to what I thought before (so I can't continue my sentence from above).
Nevertheless it still occurs:
I have a workspace that includes a program and a shared library.
The output directory of the shared library is the same as the one of the program.
If I debug, the debuggerplugin sets the "LD_LIBRARY_PATH" correctly, but the Valgrind-plugin seems not to set it, and so valgrind does not find the library.
The error is not in the "Valgrind messages" list-logger, it's only (more or less hidden) in the xml-output.
The parent-element of the error-message is "<valgrindoutput>". I think, that might be the cause that it is not shown in the list-logger.
the valgrind plug-in is currently very simple, I have tested it on simple applications.
Basically it is just calling valgrind with some parameters, one of those parameters is the name of the application valgrind is ordered to check.
Could you attach valgrind plugin log output.
Here it is.
It seems to be an error message of my executable (or better from linux), not from Valgrind.
[attachment deleted by admin]
There is a missing #include in Valgrind.cpp:
Index: src/plugins/contrib/Valgrind/Valgrind.cpp
===================================================================
--- src/plugins/contrib/Valgrind/Valgrind.cpp (revision 5126)
+++ src/plugins/contrib/Valgrind/Valgrind.cpp (working copy)
@@ -13,6 +13,7 @@
#include <wx/fs_zip.h>
#include <wx/intl.h>
#include <wx/string.h>
+#include <wx/menu.h>
#include <wx/xrc/xmlres.h>
#include "cbproject.h"
#include "manager.h"
Without this compilation failes with wxGTK 2.8.
Quote from: jens on July 14, 2008, 04:07:54 PM
Here it is.
It seems to be an error message of my executable (or better from linux), not from Valgrind.
and this shows the thing I was afraid of :-(, program output and valgrind xml get mixed
Quote from: Der Meister on July 14, 2008, 06:14:33 PM
There is a missing #include in Valgrind.cpp:
Index: src/plugins/contrib/Valgrind/Valgrind.cpp
===================================================================
--- src/plugins/contrib/Valgrind/Valgrind.cpp (revision 5126)
+++ src/plugins/contrib/Valgrind/Valgrind.cpp (working copy)
@@ -13,6 +13,7 @@
#include <wx/fs_zip.h>
#include <wx/intl.h>
#include <wx/string.h>
+#include <wx/menu.h>
#include <wx/xrc/xmlres.h>
#include "cbproject.h"
#include "manager.h"
Without this compilation failes with wxGTK 2.8.
done : thanks !!
Quote from: killerbot on July 15, 2008, 09:37:57 AM
Quote from: jens on July 14, 2008, 04:07:54 PM
Here it is.
It seems to be an error message of my executable (or better from linux), not from Valgrind.
and this shows the thing I was afraid of :-(, program output and valgrind xml get mixed
I can not test it at the moment, but it might be an error output using the error-stream.
In this case it should be possible to filter it.
Sorry,
Were can I download the plugin: it seems that it has been deleted by the administrator.
Thanks by advance. Cheers,
Hilaire
Quote from: elfunesto on July 03, 2009, 02:29:52 PM
Sorry,
Were can I download the plugin: it seems that it has been deleted by the administrator.
Thanks by advance. Cheers,
Hilaire
The valgrind plugin is part of the contrib-plugins and therefore included in the sources and nightlies since svn r5113 (2008-07-09).
Thanks for your quick answer!
Hilaire
I just downloaded the recent C::B nightly build for Windows and couldn't find the Valgrind plugin.
A search in the forum didn't give me any hints, and neither did I find it on http://svn.berlios.de/svnroot/repos/codeblocks/trunk/src/plugins/ (http://svn.berlios.de/svnroot/repos/codeblocks/trunk/src/plugins/), http://valgrind.org/ (http://valgrind.org/) or the Wiki. Really a lack of information here :wink: Anway, I'm sure that I've seen the Valgrind plugin on a recent CodeBlocks installation on Linux, though.
Where can I get that plugin for Windows??
Read this: http://valgrind.org/info/platforms.html (http://valgrind.org/info/platforms.html) and you will understand.
What is the status of this Valgrind plugin?
I would like to try it on an Ubuntu/Amd64 set-up (never used Valgrind before) for profiling, mostly, but I don't want the attempt to turn into a massive time-sink...
Has anyone tried it recently? What works? What doesn't?
Thanks in advance.
- Ken
(BTW, I am running 8.02, Build: Jul 24 2008, 15:20:21, and I can't seem to find the plug-in under Plug-Ins... > Manage Plugins.)
Quote
The valgrind plugin is part of the contrib-plugins and therefore included in the sources and nightlies since svn r5113 (2008-07-09).
Quote from: kfmfe04 on July 13, 2009, 06:11:26 AM
What is the status of this Valgrind plugin?
I would like to try it on an Ubuntu/Amd64 set-up (never used Valgrind before) for profiling, mostly, but I don't want the attempt to turn into a massive time-sink...
Has anyone tried it recently? What works? What doesn't?
Thanks in advance.
- Ken
(BTW, I am running 8.02, Build: Jul 24 2008, 15:20:21, and I can't seem to find the plug-in under Plug-Ins... > Manage Plugins.)
Quote
The valgrind plugin is part of the contrib-plugins and therefore included in the sources and nightlies since svn r5113 (2008-07-09).
Feb 2008 (8.02) is before July 2008 that is why you do not see the plugin.
Tim S
I posted this in a wrong thread, so I put it here and the solution I found:
I am trying to run valgrind plugin, but it says that it needs to specify a XML file.
I have the valgrind version:
valgrind-3.5.0-Debian,
that needs the parameter
--xml-file=<file> XML output to <file>
Is there any place where I can specify it?
Thanks in advance.
Workaround
Ok. I needed to find an older version. I did the following after installing apt-show-versions:
apt-show-versions -a valgrind
valgrind 1:3.5.0-2 install ok installed
valgrind 1:3.3.1-3 lenny http.us.debian.org
valgrind 1:3.5.0-2 testing http.us.debian.org
valgrind 1:3.5.0-2 sid ftp.de.debian.org
valgrind/testing uptodate 1:3.5.0-2
Then downgrade:
sudo apt-get install valgrind=1:3.3.1-3
This is just in case other people may have the same problem that me.
Now it launches.
But it does nothing... The application is run, then I close it. Then nothing.
What is next?
It is well possible that it might not correctly run with valgrind 3.5, since a few things have changed in valgrind.
Currently I am still at 3.2.3 and 3.3.0.
And there i have been using it in august/september and it still worked ;-)
In a few weeks i will be at valgrind 3.5.0, I will look into the issues at that time. Unless people can already give hints on what is going wrong.
You need to pass -xml-fd=0 or 2 (stdout or stderr) to make it happy
Hello,
I'm using Codeblocks together with CMake (Unix Makefile Generator). With these external Makefiles there are no compiler options per target. In the Makefiles i have the -g option enabled but when i try to start valgrind, it complains about the missing -g option... Is there a workaround for this problem ?? Where does valgrind look for this option ?
THX & Greets
Patrock
It looks at the codeblocks project, at the actual target (.cbp file). It doesn't work with external makefiles.
There is a workaround:
uncheck the "This is a custom makefile" check-box in the projects properties,
close the properties dialog (don't use the build-options button at the bottom),
open the build-options,
check the "Produce debugging symbols" checkbox in the "compiler flags" tab,
switch back to the properties,
check "This is a custom makefile" again.
Works for me here.
thanks Jens...
It's working for me too now...
Quote
valgrind --version
valgrind-3.5.0-Debian
valgrind --leak-check=yes --xml=yes "bin/Debug/Bai4"
==8013== --xml=yes has been specified, but there is no XML output
==8013== destination. You must specify an XML output destination
==8013== using --xml-fd=, --xml-file= or --xml=socket=.
valgrind: Bad option '--xml=yes, but no XML destination specified'; aborting.
valgrind: Use --help for more information.
The Valgrind plugin keeps failing with the error message above.
I'm using codeblock svn 5911 on Ubuntu 9.10
Thanks for reporting, I will fix this. It seems the new Valgrind wants an xml file to be specified.
alright I know what to do.
Off course the fun is i will have to check valgrind versions since the changes valgrind has are not backwards compatible.
Old command :
valgrind --leak-check=yes --xml=yes ./DeleteMe
New command :
valgrind --leak-check=yes --xml=yes --xml-file=test.xml ./DeleteMe
Unfortunately the option 'xml-file=test.xml' will be flagged as an error by the old valgrind (valgrind: Bad option '--xml-file=test.xml'; aborting.).
Will start working on it soon.
Why not use:
valgrind --leak-check=yes --xml=yes --xml-fd=1 ./test_cb_stl_debug
--xml-fd=1 -> should mean use file that is the standard output
could work too, yes.
But the special version check logic will be needed, since also this will cause an error on pre 3.5.0 versions of valgrind.
But I think, putting it in a real file will be better, that way regular program output on stdout can not mix with the xml output parts.
Have already coded the change, test session should be carried out tomorrow.
C::B project - debugger branch:
Valgrind -> Run Valgrind::MemCheck says:
"You need to have an (executable) target in your open project before using the plugin!"
I've tried targets: "All" and "src"
QuoteThere is a workaround:
uncheck the "This is a custom makefile" check-box in the projects properties,
close the properties dialog (don't use the build-options button at the bottom),
open the build-options,
check the "Produce debugging symbols" checkbox in the "compiler flags" tab,
switch back to the properties,
check "This is a custom makefile" again.
Works for me here.
I have a project that uses cmake to create Makefiles, and this did not work for me. Where is the source for for the valgrind plugin? I bet I could make it skip this check if a custom makefile is used.
Here you can find it: http://svn.berlios.de/wsvn/codeblocks/trunk/src/plugins/contrib/Valgrind/?rev=6901&peg=6901#a712483b441038dfcd5154953d2e54123
Or if you have a local checkout: src/plugins/contrib/Valgrind
Thanks I am checking it out now.
Edit, I got the the source for it, and I will dig in in the next few days, it doesn't seem like this plugin is really a high priority for anyone else (because it seems to work most of the time) , so I will take my time.