Valgrind

10

Click here to load reader

Transcript of Valgrind

Page 1: Valgrind

Valgrind

Page 2: Valgrind

Valgrind

● Valgrind is a virtual machine using just-in-time (JIT) compilation techniques, including dynamic recompilation.

● Nothing from the original program ever gets run directly on the host processor.

● Instead, Valgrind first translates the program into a temporary, simpler form called Intermediate Representation (IR), which is a processor-neutral, SSA-based form.

● After the conversion, a tool is free to do whatever transformations it would like on the IR, before Valgrind translates the IR back into machine code and lets the host processor run it.

Page 3: Valgrind

Debugging Demo: Compilation OK

Page 4: Valgrind

Debugging Demo: Mem Leak

Page 5: Valgrind

Debugging Demo: Mem Leak

Page 6: Valgrind

Using free()

Page 7: Valgrind

The ERROR as spotted by gdb

Page 8: Valgrind

Solution

Page 9: Valgrind

More Examples

● https://bitbucket.org/melvin_cabatuan/cprogrammingtour/src

Page 10: Valgrind

END