Skip to content

Instantly share code, notes, and snippets.

@dgoguerra
Created January 28, 2014 09:49
Show Gist options
  • Save dgoguerra/8664855 to your computer and use it in GitHub Desktop.
Save dgoguerra/8664855 to your computer and use it in GitHub Desktop.
Valgrind debugging notes

Remote debugging with GDB and Valgrind

First, Valgrind starts the program to debug:

$ valgrind --vgdb=yes --vgdb-error=0 [valgrind-options] [program] [program-options]

It will halt until GDB is hooked to the process, from another terminal:

$ gdb [program]
$ target remote | vgdb

Branch prediction profiling

Valgrind's tool callgrind is a branch prediction profiler; its output can be visualized with Kcachegrind to generate a call graph of the program, among other things.

$ valgrind --tool=callgrind [program] [program-options]
$ kcachegrind callgrind.out.<pid>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment