Hi,
I am trying to profile the following code in callgrind:
#include <iostream>
#include <string>
#include <boost/xpressive/xpressive.hpp>
using namespace boost::xpressive;
struct grammar
{
sregex _tuple;
sregex _element;
sregex _identifier;
grammar()
{
_tuple = '(' >> by_ref(_element) >> *(',' >> by_ref(_element)) >>
')';
_element = by_ref(_identifier) | _tuple;
_identifier = (_w | '_') >> *(_w | _d | '_');
}
};
int main()
{
grammar g;
if (regex_match(std::string("(a,(b,c))"), g._tuple))
std::cout << "match" << std::endl;
else
std::cout << "unmatched" << std::endl;
return 0;
}
It uses boost.xpressive which is a regular expression library that makes
heavy use of c++ templates and hence long symbol names! Here is the output
of "valgrind --tool=callgrind -v -d ./test1":
--32649:1:debuglog DebugLog system started by Stage 1, level 1 logging
requested
--32649:1:launcher tool 'callgrind' requested
--32649:1:launcher selected platform 'amd64-linux'
--32649:1:launcher launching /usr/lib/valgrind/amd64-linux/callgrind
--32649:1:debuglog DebugLog system started by Stage 2 (main), level 1
logging requested
--32649:1:main Welcome to Valgrind version 3.4.1-Debian debug logging
--32649:1:main Checking current stack is plausible
--32649:1:main Checking initial stack was noted
--32649:1:main Starting the address space manager
--32649:1:main Address space manager is running
--32649:1:main Starting the dynamic memory manager
--32649:1:mallocfr newSuperblock at 0x402001000 (pszB 4194280) owner
VALGRIND/tool
--32649:1:main Dynamic memory manager is running
--32649:1:main Initialise m_debuginfo
--32649:1:main Getting stage1's name
--32649:1:main Get hardware capabilities ...
--32649:1:main ... arch = AMD64, hwcaps = amd64-sse2
--32649:1:main Getting the working directory at startup
--32649:1:main ... /home/stuff/stuff/src/xpressive
--32649:1:main Split up command line
--32649:1:main (early_) Process Valgrind's command line options
--32649:1:main Create initial image
--32649:1:initimg Loading client
--32649:1:initimg Setup client env
--32649:1:initimg Setup client stack: size will be 8388608
--32649:1:initimg Setup client data (brk) segment
--32649:1:main Setup file descriptors
--32649:1:main Create fake /proc/<pid>/cmdline
--32649:1:main Initialise the tool part 1 (pre_clo_init)
--32649:1:main Print help and quit, if requested
--32649:1:main (main_) Process Valgrind's command line options, setup
logging
--32649:1:main Print the preamble...
==32649== Callgrind, a call-graph generating cache profiler.
==32649== Copyright (C) 2002-2008, and GNU GPL'd, by Josef Weidendorfer et
al.
==32649== Using LibVEX rev 1884, a library for dynamic binary translation.
==32649== Copyright (C) 2004-2008, and GNU GPL'd, by Openstuffs LLP.
==32649== Using valgrind-3.4.1-Debian, a dynamic binary instrumentation
framework.
==32649== Copyright (C) 2000-2008, and GNU GPL'd, by Julian Seward et al.
==32649==
--32649-- Command line
--32649-- ./test1
--32649-- Startup, with flags:
--32649-- --suppressions=/usr/lib/valgrind/debian-libc6-dbg.supp
--32649-- --tool=callgrind
--32649-- -v
--32649-- -d
--32649-- Contents of /proc/version:
--32649-- Linux version 2.6.28-13-generic (bui...@yellow) (gcc version
4.3.3 (Ubuntu 4.3.3-5ubuntu4) ) #44-Ubuntu SMP Tue Jun 2 07:55:09 UTC 2009
--32649-- Arch and hwcaps: AMD64, amd64-sse2
--32649-- Page sizes: currently 4096, max supported 4096
--32649-- Valgrind library directory: /usr/lib/valgrind
--32649:1:main ...finished the preamble
--32649:1:main Initialise the tool part 2 (post_clo_init)
==32649== For interactive control, run 'callgrind_control -h'.
--32649:1:main Initialise TT/TC
--32649:1:main Initialise redirects
--32649:1:mallocfr newSuperblock at 0x40247C000 (pszB 1048552) owner
VALGRIND/dinfo
--32649:1:main Load initial debug info
--32649-- Reading syms from /home/stuff/stuff/src/xpressive/test1 (0x400000)
--32649-- Reading syms from /lib/ld-2.9.so (0x4000000)
--32649-- Reading debug info from /lib/ld-2.9.so ..
--32649-- .. CRC mismatch (computed 2aeecd7e wanted a5503f5d)
--32649-- Reading debug info from /usr/lib/debug/lib/ld-2.9.so ..
--32649:1:mallocfr newSuperblock at 0x40257C000 (pszB 1048552) owner
VALGRIND/dinfo
--32649-- Reading syms from /usr/lib/valgrind/amd64-linux/callgrind
(0x38000000)
--32649-- object doesn't have a dynamic symbol table
--32649:1:mallocfr newSuperblock at 0x40267C000 (pszB 1048552) owner
VALGRIND/dinfo
--32649:1:mallocfr newSuperblock at 0x40277C000 (pszB 1048552) owner
VALGRIND/dinfo
--32649:1:mallocfr newSuperblock at 0x40287C000 (pszB 2052072) owner
VALGRIND/dinfo
--32649:1:mallocfr newSuperblock at 0x402A71000 (pszB 4100072) owner
VALGRIND/dinfo
--32649:1:redir transfer ownership V -> C of 0x3802c000 .. 0x3802cfff
--32649:1:main Initialise scheduler (phase 1)
--32649:1:sched sched_init_phase1
--32649:1:main Tell tool about initial permissions
--32649:1:main Initialise scheduler (phase 2)
--32649:1:sched sched_init_phase2: tid_main=1, cls_end=0x7ff000fff,
cls_sz=8388608
--32649:1:main Finalise initial image
--32649:1:main Initialise signal management
--32649:1:mallocfr newSuperblock at 0x402E5A000 (pszB 1048552) owner
VALGRIND/core
--32649:1:main
--32649:1:main
--32649:1:aspacem <<< SHOW_SEGMENTS: Memory layout at client startup (31
segments, 4 segnames)
--32649:1:aspacem ( 0) /usr/lib/valgrind/amd64-linux/callgrind
--32649:1:aspacem ( 1) /home/stuff/stuff/src/xpressive/test1
--32649:1:aspacem ( 2) /lib/ld-2.9.so
--32649:1:aspacem 0: RSVN 0000000000-00003fffff 4194304 ----- SmFixed
--32649:1:aspacem 1: file 0000400000-0000419fff 106496 r-x-- d=0x803
i=73705 o=0 (1)
--32649:1:aspacem 2: RSVN 000041a000-0000618fff 2093056 ----- SmFixed
--32649:1:aspacem 3: file 0000619000-000061afff 8192 rw--- d=0x803
i=73705 o=102400 (1)
--32649:1:aspacem 4: RSVN 000061b000-0003ffffff 57m ----- SmFixed
--32649:1:aspacem 5: file 0004000000-000401ffff 131072 r-x-- d=0x804
i=516463 o=0 (2)
--32649:1:aspacem 6: 0004020000-000421efff 2093056
--32649:1:aspacem 7: file 000421f000-0004220fff 8192 rw--- d=0x804
i=516463 o=126976 (2)
--32649:1:aspacem 8: anon 0004221000-0004221fff 4096 rwx--
--32649:1:aspacem 9: RSVN 0004222000-0004a20fff 8384512 ----- SmLower
--32649:1:aspacem 10: 0004a21000-0037ffffff 821m
--32649:1:aspacem 11: FILE 0038000000-003802bfff 180224 r-x-- d=0x804
i=65879 o=0 (0)
--32649:1:aspacem 12: file 003802c000-003802cfff 4096 r-x-- d=0x804
i=65879 o=180224 (0)
--32649:1:aspacem 13: FILE 003802d000-00381c2fff 1662976 r-x-- d=0x804
i=65879 o=184320 (0)
--32649:1:aspacem 14: 00381c3000-00383c1fff 2093056
--32649:1:aspacem 15: FILE 00383c2000-00383c3fff 8192 rw--- d=0x804
i=65879 o=1843200 (0)
--32649:1:aspacem 16: ANON 00383c4000-0038b72fff 8056832 rw---
--32649:1:aspacem 17: 0038b73000-0401ffffff 15508m
--32649:1:aspacem 18: RSVN 0402000000-0402000fff 4096 ----- SmFixed
--32649:1:aspacem 19: ANON 0402001000-0402f59fff 15m rwx--
--32649:1:aspacem 20: 0402f5a000-07fe800fff 16312m
--32649:1:aspacem 21: RSVN 07fe801000-07feffefff 8380416 ----- SmUpper
--32649:1:aspacem 22: anon 07fefff000-07ff000fff 8192 rwx--
--32649:1:aspacem 23: 07ff001000-07ffffffff 15m
--32649:1:aspacem 24: RSVN 0800000000-7fffe7455fff 131039g ----- SmFixed
--32649:1:aspacem 25: ANON 7fffe7456000-7fffe746afff 86016 rw---
--32649:1:aspacem 26: RSVN 7fffe746b000-7fffe75fefff 1654784 ----- SmFixed
--32649:1:aspacem 27: ANON 7fffe75ff000-7fffe75fffff 4096 r-x--
--32649:1:aspacem 28: RSVN 7fffe7600000-ffffffffff5fffff 16383e -----
SmFixed
--32649:1:aspacem 29: ANON ffffffffff600000-ffffffffff600fff 4096 r-x--
--32649:1:aspacem 30: RSVN ffffffffff601000-ffffffffffffffff 9m -----
SmFixed
--32649:1:aspacem >>>
--32649:1:main
--32649:1:main
--32649:1:main Running thread 1
--32649:1:syswrap- entering VG_(main_thread_wrapper_NORETURN)
--32649:1:aspacem allocated thread stack at 0x402f5a000 size 81920
--32649:1:syswrap- run_a_thread_NORETURN(tid=1): pre-thread_wrapper
--32649:1:syswrap- thread_wrapper(tid=1): entry
--32649-- Found runtime_resolve (amd64-def): ld-2.9.so +0x14ac0=0x4015550,
length 110
--32649:1:transtab allocate sector 0
--32649:1:mallocfr newSuperblock at 0x404E86000 (pszB 65512) owner
VALGRIND/ttaux
--32649-- Reading syms from /usr/lib/valgrind/amd64-linux/vgpreload_core.so
(0x4a21000)
--32649-- Reading syms from /usr/lib/debug/libstdc++.so.6.0.10 (0x4c23000)
--32649-- Reading syms from /lib/libm-2.9.so (0x4f51000)
--32649-- Reading debug info from /lib/libm-2.9.so ..
--32649-- .. CRC mismatch (computed c14b75b7 wanted 1d0b308f)
--32649-- Reading debug info from /usr/lib/debug/lib/libm-2.9.so ..
--32649:1:mallocfr newSuperblock at 0x404E96000 (pszB 1048552) owner
VALGRIND/dinfo
--32649-- Reading syms from /lib/libgcc_s.so.1 (0x51d6000)
--32649-- Reading debug info from /lib/libgcc_s.so.1 ..
--32649-- .. CRC mismatch (computed 5e1e8b97 wanted 48127249)
--32649-- Reading debug info from /usr/lib/debug/lib/libgcc_s.so.1 ..
--32649-- Reading syms from /lib/libc-2.9.so (0x53ee000)
--32649-- Reading debug info from /lib/libc-2.9.so ..
--32649-- .. CRC mismatch (computed bb7f9209 wanted dcd904d7)
--32649-- Reading debug info from /usr/lib/debug/lib/libc-2.9.so ..
--32649:1:mallocfr newSuperblock at 0x404F96000 (pszB 1048552) owner
VALGRIND/dinfo
--32649:1:mallocfr newSuperblock at 0x405096000 (pszB 1048552) owner
VALGRIND/dinfo
--32649:1:mallocfr newSuperblock at 0x405196000 (pszB 2052072) owner
VALGRIND/dinfo
--32649:1:mallocfr newSuperblock at 0x40538B000 (pszB 4100072) owner
VALGRIND/dinfo
--32649:1:mallocfr newSuperblock at 0x405774000 (pszB 65512) owner
VALGRIND/demangle
--32649-- Symbol match: found runtime_resolve: ld-2.9.so +0x15550=0x4015550
Segmentation fault
My valgrind version is valgrind-3.4.1-Debian.
------------------------------------------------------------------------------
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users