|
From: Sergei T. <sl...@in...> - 2008-05-17 15:45:56
|
# valgrind version: current SVN
# gcc versions: 4.2.3, 4.3.0
$ cat main.cc
#include <valgrind/valgrind.h>
int main ()
{
VALGRIND_PRINTF_BACKTRACE("hello");
return 0;
}
$ make
g++ -g -O0 -c -o main.o main.cc
g++ -g -O0 main.o -o vg_call
$ valgrind ./vg_call
==3228== Memcheck, a memory error detector.
==3228== Copyright (C) 2002-2008, and GNU GPL'd, by Julian Seward et al.
==3228== Using LibVEX rev exported, a library for dynamic binary translation.
==3228== Copyright (C) 2004-2008, and GNU GPL'd, by OpenWorks LLP.
==3228== Using valgrind-3.4.0.SVN, a dynamic binary instrumentation framework.
==3228== Copyright (C) 2000-2008, and GNU GPL'd, by Julian Seward et al.
==3228== For more details, rerun with: -v
==3228==
**3228** hello
==3228== at 0x80483F2: _ZL25VALGRIND_PRINTF_BACKTRACEPKcz(valgrind.h:3695)
==3228== by 0x804841C: main (main.cc:5)
==3228==
==3228== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 7 from 1)
==3228== malloc/free: in use at exit: 0 bytes in 0 blocks.
==3228== malloc/free: 0 allocs, 0 frees, 0 bytes allocated.
==3228== For counts of detected errors, rerun with: -v
==3228== All heap blocks were freed -- no leaks are possible.
Call stack is usually prettyprinted nicely, but valgrind like macros (and global C++ functions) are not:
# let's analyze --callgrind stats of large C++ project
$ cat callgrind.out.25844 | grep _Z | awk '{print $2}' | grep decode
_ZL12decode_valueRPh
_ZL12decode_valueRPh
_ZL12decode_valueRPh
_ZL19decode_unsigned_intRPKh
_ZL20decode_unsigned_charRPKh
_ZL18decode_escape_charRPKh
$ cat callgrind.out.25844 | grep _Z | awk '{print $2}' | grep decode | xargs c++filt
decode_value(unsigned char*&)
decode_value(unsigned char*&)
decode_value(unsigned char*&)
decode_unsigned_int(unsigned char const*&)
decode_unsigned_char(unsigned char const*&)
decode_escape_char(unsigned char const*&)
|