VGDB
VGDB
with gdb
Thomas Oulevey
ITLT-8
Tools
Valgrind is an instrumentation framework for building dynamic analysis
tools. There are Valgrind tools that can automatically detect many memory
management and threading bugs, and profile your programs in detail.
It runs on many platforms:
X86/Linux, AMD64/Linux, ARM/Linux, ARM64/Linux, PPC32/Linux, PPC64/Linux,
PPC64LE/Linux, S390X/Linux, MIPS32/Linux, MIPS64/Linux, TILEGX/Linux, X86/Solaris, AMD64/Solaris, ARM/Android (2.3.x and later),
ARM64/Android, X86/Android (4.0 and later), MIPS32/Android, X86/Darwin and AMD64/Darwin (Mac OS X 10.10, with initial support for 10.11)
GDB, the GNU Project debugger, allows you to see what is going on `inside'
another program while it executes -- or what another program was doing at
the moment it crashed.
It supports C, C++, D, Go, Objective-C, Fortran, Java, OpenCL C, Pascal,
assembly, Modula-2, and Ada.
Valgrind Output
$ valgrind --leak-check=full ./t
==9612== HEAP SUMMARY:
==9612== in use at exit: 28 bytes in 2 blocks
==9612== total heap usage: 2 allocs, 0 frees, 28 bytes allocated
==9612==
==9612== 7 bytes in 1 blocks are definitely lost in loss record 1 of 2
==9612== at 0x4C29BFD: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==9612== by 0x4EBB529: strdup (in /usr/lib64/libc-2.17.so)
==9612== by 0x40055E: main (toto.c:7)
==9612==
==9612== 21 bytes in 1 blocks are definitely lost in loss record 2 of 2
==9612== at 0x4C29BFD: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==9612== by 0x4EBB529: strdup (in /usr/lib64/libc-2.17.so)
==9612== by 0x400548: main (toto.c:5)
==9612==
==9612== LEAK SUMMARY:
==9612== definitely lost: 28 bytes in 2 blocks
==9612== indirectly lost: 0 bytes in 0 blocks
==9612== possibly lost: 0 bytes in 0 blocks
==9612== still reachable: 0 bytes in 0 blocks
==9612== suppressed: 0 bytes in 0 blocks
==9612==
GDB
$ gdb ./araignee
Cheat sheet :
https://www.sthu.org/code/codesnippets/files/gdb_cheatsheet.pdf
http://users.ece.utexas.edu/~adnan/gdb-refcard.pdf
Mixing the tools together
--vgdb=<no|yes|full> [default: yes]
Valgrind will provide "gdbserver" functionality
when --vgdb=yes or --vgdb=full is specified.
This allows an external GNU GDB debugger to control
and debug your program when it runs on
gdb-dashboard
https://github.com/cyrus-and/gdb-dashboard
Thank you !