How does valgrind work?

Valgrind basically runs your application in a “sandbox.” While running in this sandbox, it is able to insert its own instructions to do advanced debugging and profiling. From the manual: Your program is then run on a synthetic CPU provided by the Valgrind core. As new code is executed for the first time, the core … Read more

Android valgrind build fails

For building and installing Valgrind for Android use the bash script below, which I prefer to call build_valgrind.sh To run with RUN_HELLO_JNI_THROUGH_VALGRIND=true you need two additional scripts (bootstrap_valgrind.sh, start_valgrind.sh) in the directory you run the script below from. Running the script with the RUN_HELLO_JNI_THROUGH_VALGRIND=true flag will build the hello-jni application from the samples directory inside … Read more

How to start an android app with valgrind

You can try to clear the logcat first prompt# adb logcat -c prompt# adb logcat You should be able to see the logs coming in once you triggered your application. am start -a android.intent.action.MAIN -n com.example.hellojni/.HelloJni I had problems with my shell script and i used this instead. adb shell setprop wrap.com.example.hellojni “logwrapper /data/local/Inst/bin/valgrind” You … Read more

How do you tell Valgrind to completely suppress a particular .so file?

For most of the suppression types, you omit the wildcard, like so: { name Memcheck:Cond obj:/path/to/lib/lib.so.10.1 } { name Memcheck:Free obj:/path/to/lib/lib.so.10.1 } { name Memcheck:Value8 obj:/path/to/lib/lib.so.10.1 } Note that you must list each type of error separately, you can’t wildcard them. You must also list the entire pathname of the library (as shown by valgrind, … Read more

Valgrind not showing line numbers in spite of -g flag (on Ubuntu 11.10/VirtualBox)

The output you provided in your question contains the following line: ==5190== Use –track-origins=yes to see where uninitialised values come from Per this message you should run ./ex4 like this: valgrind –track-origins=yes ./ex4 To avoid some problems with Valgrind unable to find debug information, you can use static linking: gcc -static -g -o ex4 ex4.c … Read more

Does boost::bind() copy parameters by reference or by value?

By value. 1 But you can make it copy by ref instead: void SomeFunction(const int& value) { boost::bind(…, boost::ref(value)); boost::bind(…, boost::cref(value)); // by const ref } 1 http://www.boost.org/doc/libs/1_46_1/libs/bind/bind.html#Purpose a copy of the value of i is stored into the function object. boost::ref and boost::cref can be used to make the function object store a reference … Read more

Memory Leaks in GTK hello_world program

This answer is compiled from answers to the same question (on the now defunct www.gtkforums.com). GTK+ is pretty lazy when it comes to allocating and deallocating internal buffers needed for the life time of the application. For example it may allocate an area of memory for a lookup table during initialisation which is needed for … Read more