Link to main page
and to computing
./myexe his_arguments
you should simply do this:valgrind ./myexe his_arguments
It is very usefull to add debug information to the executable at the compilation stage. Consider using -g in your g++ compilation command line. In order to put valgrind's large output into a log file, and to deepen its checks, try this:valgrind --show-reachable=yes --leak-check=full --log-file-exactly=output.valgrind ./myexe his_arguments
First two options increase the size of the output. The third option redirects the output to the output.valgrind logfile.--suppressions=$ROOTSYS/etc/valgrind-root.supp
It could be needed to explicitely resolve the full path to this file. Change then $ROOTSYS accordingly (see the output of echo $ROOTSYS).--demangle=no
. The easiest way to generate a suppression rule file is to fast valgrind to generate it itself, using the --gen-suppressions=all option in the command line. After each error, in valgrind output, the corresponding suppression rule is written. Just copy-and-paste it into your suppression file. To be more generic, wildcard characters * can be used. As an example, here is a list of suppression rules that prevents valgrind from outputing errors related to the ROOT framework, for a specific program (called Delphes).
class MyClass {
private:
unsigned int N;
float * data;
// ...
public:
MyClass();
MyClass(const MyClass & mine);
MyClass & operator=(const MyClass & mine);
// ...
}
MyClass::MyClass() {
N = 42;
data = new float[N];
//...
}
MyClass::MyClass(const MyClass & mine) {
N = mine.N;
data = new float[N];
for (unsigned int i=0; i<N; i++) data[i] = mine.data[i];
}
MyClass& operator=(const MyClass & mine) {
if(this==&ET) return *this;
N = mine.N;
data = new float[N];
for (unsigned int i=0; i<N; i++) data[i] = mine.data[i];
return *this;
}
MyClass::~MyClass() { delete [] data; }
int main(int argc, char *argv[]) {
int appargc = 2;
char *appName= new char[20]; sprintf(appName,"Delphes");
char *appOpt= new char[20]; sprintf(appOpt,"-b");
char *appargv[] = {appName,appOpt};
TApplication app(appName, &appargc, appargv);
delete [] appName;
delete [] appOpt;
//...
}
Dernière mise-à-jour: 21/03/2009