1 / 4

Dynamic Instrumentation - Valgrind

Dynamic Instrumentation - Valgrind. Developed by Julian Seward at/around Cambridge University,UK Google-O'Reilly Open Source Award for "Best Toolmaker" 2006 A merit (bronze) Open Source Award 2004 Open source works on x86, AMD64, PPC code Easy to execute, e.g.: valgrind --tool=memcheck ls

barbarawong
Download Presentation

Dynamic Instrumentation - Valgrind

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Dynamic Instrumentation - Valgrind • Developed by Julian Seward at/around Cambridge University,UK • Google-O'Reilly Open Source Award for "Best Toolmaker" 2006 • A merit (bronze) Open Source Award 2004 • Open source • works on x86, AMD64, PPC code • Easy to execute, e.g.: • valgrind --tool=memcheck ls • It becomes very popular • One of the two most popular dynamic instrumentation tools • Pin and Valgrind • Very good usability, extendibility, robust • 25MLOC • Mozilla, MIT, CMU-security, Purdue and many other places • Overhead is the problem • 5-10X slowdown without any instrumentation

  2. Valgrind debugging tool • Goal: detect memory errors • Accesses outside of memory bounds • Memory leaks • Great for finding errors that would only show during harsh test cases

  3. Valgrind: Example Errors • Can you find twoerrors in this program? #include <stdlib.h> void f(void) { int* x = malloc(10 * sizeof(int)); x[10] = 0; } int main(void) { f(); return 0; } 1. Invalid memory access 2. Memory never free()’d

  4. Running Example in Valgrind • Running valgrind with the program: • valgrind --leak-check=yes myprog arg1 arg2 • Invalid access output (error 1): • Memory leak output (error 2): ==19182== Invalid write of size 4 ==19182== at 0x804838F: f (example.c:6) ==19182== by 0x80483AB: main (example.c:11) Where the error occurs Process ID ==19182== 40 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==19182== at 0x1B8FF5CD: malloc (vg_replace_malloc.c:130) ==19182== by 0x8048385: f (a.c:5) ==19182== by 0x80483AB: main (a.c:11) Size of the leak

More Related