www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - valgrind profiling unrecognized instruction

reply =?UTF-8?B?IsOYaXZpbmQi?= <oivind.loe gmail.com> writes:
I read somewhere that I should be able to profile my D executable
"dboss-test" with valgrind. I have tried using the linux 'perf'
tool, and it works, but I find its output difficult to work with.
I am trying to call my program through valgrind like this:

valgrind --tool=callgrind ./dboss-test

However, it fails with the following errors, talking about an
unrecognized instruction. Anyone know of a workaround / fix for
this?

```
==13666== Callgrind, a call-graph generating cache profiler
==13666== Copyright (C) 2002-2012, and GNU GPL'd, by Josef
Weidendorfer et al.
==13666== Using Valgrind-3.8.1 and LibVEX; rerun with -h for
copyright info
==13666== Command: ./dboss-test --filter=annot
==13666==
==13666== For interactive control, run 'callgrind_control -h'.
vex amd64->IR: unhandled instruction bytes: 0x48 0xDF 0x6D 0xF0
0xEB 0x1A 0x48 0xB9
vex amd64->IR:   REX=1 REX.W=1 REX.R=0 REX.X=0 REX.B=0
vex amd64->IR:   VEX=0 VEX.L=0 VEX.nVVVV=0x0 ESC=NONE
vex amd64->IR:   PFX.66=0 PFX.F2=0 PFX.F3=0
==13666== valgrind: Unrecognised instruction at address 0x137d4b5.
==13666==    at 0x137D4B5:
_D3std9algorithm116__T4sortS684vibe4core4args18__T10readOptionTbZ10readOptionFAyaPbAyaZb9__lambda4VE3std9algorithm12SwapStrategy0TAAyaZ4sortMFNaAAyaZS3std5range93__T11SortedRangeTAAyaS684vibe4core4args18__T10readOptionTbZ10readOptionFAyaPbAyaZb9__lambda4Z11SortedRange
(/usr/include/dmd/phobos/std/algorithm.d:9063)
==13666==    by 0x137D2AD:
_D4vibe4core4args18__T10readOptionTbZ10readOptionFAyaPbAyaZb
(/home/oivind/.dub/packages/vibe-d-master/source/vibe/core/args.d:69)
==13666==    by 0x137ACDF: _D4vibe4core4args4initFZv
(/home/oivind/.dub/packages/vibe-d-master/source/vibe/core/args.d:235)
==13666==    by 0x137D244:
_D4vibe4core4args18__T10readOptionTbZ10readOptionFAyaPbAyaZb
(/home/oivind/.dub/packages/vibe-d-master/source/vibe/core/args.d:66)
==13666==    by 0x135EC57:
_D4vibe4core3log19initializeLogModuleFZv
(/home/oivind/.dub/packages/vibe-d-master/source/vibe/core/log.d:694)
==13666==    by 0x135784F:
_D4vibe4core4core18_sharedStaticCtor3FZv
(/home/oivind/.dub/packages/vibe-d-master/source/vibe/core/core.d:970)
==13666==    by 0x135CE70: _D4vibe4core4core15__modsharedctorFZv
(in /home/oivind/work/quad/dboss/dboss-test)
==13666==    by 0x1415698:
_D2rt5minfo68__T14runModuleFuncsS452rt5minfo11ModuleGroup8runCtorsMFZv9__lambda2Z14runModuleFuncsMFNaAPS6object10ModuleInfoZv
(in /home/oivind/work/quad/dboss/dboss-test)
==13666==    by 0x14153D5: _D2rt5minfo11ModuleGroup8runCtorsMFZv
(in /home/oivind/work/quad/dboss/dboss-test)
==13666==    by 0x13DD028:
_D2rt5minfo13rt_moduleCtorUZv14__foreachbody1MFKS2rt14sections_linux3DSOZi
(in /home/oivind/work/quad/dboss/dboss-test)
==13666==    by 0x13DD2F1:
_D2rt14sections_linux3DSO7opApplyFMDFKS2rt14sections_linux3DSOZiZi
(in /home/oivind/work/quad/dboss/dboss-test)
==13666==    by 0x13DCFF4: rt_moduleCtor (in
/home/oivind/work/quad/dboss/dboss-test)
==13666== Your program just tried to execute an instruction that
Valgrind
==13666== did not recognise.  There are two possible reasons for
this.
==13666== 1. Your program has a bug and erroneously jumped to a
non-code
==13666==    location.  If you are running Memcheck and you just
saw a
==13666==    warning about a bad jump, it's probably your
program's fault.
==13666== 2. The instruction is legitimate but Valgrind doesn't
handle it,
==13666==    i.e. it's Valgrind's fault.  If you think this is
the case or
==13666==    you are not sure, please let us know and we'll try
to fix it.
==13666== Either way, Valgrind will now raise a SIGILL signal
which will
==13666== probably kill your program.
==13666==
==13666== Process terminating with default action of signal 4
(SIGILL)
==13666==  Illegal opcode at address 0x137D4B5
==13666==    at 0x137D4B5:
_D3std9algorithm116__T4sortS684vibe4core4args18__T10readOptionTbZ10readOptionFAyaPbAyaZb9__lambda4VE3std9algorithm12SwapStrategy0TAAyaZ4sortMFNaAAyaZS3std5range93__T11SortedRangeTAAyaS684vibe4core4args18__T10readOptionTbZ10readOptionFAyaPbAyaZb9__lambda4Z11SortedRange
(/usr/include/dmd/phobos/std/algorithm.d:9063)
==13666==    by 0x137D2AD:
_D4vibe4core4args18__T10readOptionTbZ10readOptionFAyaPbAyaZb
(/home/oivind/.dub/packages/vibe-d-master/source/vibe/core/args.d:69)
==13666==    by 0x137ACDF: _D4vibe4core4args4initFZv
(/home/oivind/.dub/packages/vibe-d-master/source/vibe/core/args.d:235)
==13666==    by 0x137D244:
_D4vibe4core4args18__T10readOptionTbZ10readOptionFAyaPbAyaZb
(/home/oivind/.dub/packages/vibe-d-master/source/vibe/core/args.d:66)
==13666==    by 0x135EC57:
_D4vibe4core3log19initializeLogModuleFZv
(/home/oivind/.dub/packages/vibe-d-master/source/vibe/core/log.d:694)
==13666==    by 0x135784F:
_D4vibe4core4core18_sharedStaticCtor3FZv
(/home/oivind/.dub/packages/vibe-d-master/source/vibe/core/core.d:970)
==13666==    by 0x135CE70: _D4vibe4core4core15__modsharedctorFZv
(in /home/oivind/work/quad/dboss/dboss-test)
==13666==    by 0x1415698:
_D2rt5minfo68__T14runModuleFuncsS452rt5minfo11ModuleGroup8runCtorsMFZv9__lambda2Z14runModuleFuncsMFNaAPS6object10ModuleInfoZv
(in /home/oivind/work/quad/dboss/dboss-test)
==13666==    by 0x14153D5: _D2rt5minfo11ModuleGroup8runCtorsMFZv
(in /home/oivind/work/quad/dboss/dboss-test)
==13666==    by 0x13DD028:
_D2rt5minfo13rt_moduleCtorUZv14__foreachbody1MFKS2rt14sections_linux3DSOZi
(in /home/oivind/work/quad/dboss/dboss-test)
==13666==    by 0x13DD2F1:
_D2rt14sections_linux3DSO7opApplyFMDFKS2rt14sections_linux3DSOZiZi
(in /home/oivind/work/quad/dboss/dboss-test)
==13666==    by 0x13DCFF4: rt_moduleCtor (in
/home/oivind/work/quad/dboss/dboss-test)
==13666==
==13666== Events    : Ir
==13666== Collected : 3563265
==13666==
==13666== I   refs:      3,563,265
Illegal instruction (core dumped)
```
Mar 02 2014
next sibling parent Dmitry Olshansky <dmitry.olsh gmail.com> writes:
02-Mar-2014 21:15, "Øivind" пишет:
 I read somewhere that I should be able to profile my D executable
 "dboss-test" with valgrind. I have tried using the linux 'perf'
 tool, and it works, but I find its output difficult to work with.
 I am trying to call my program through valgrind like this:

 valgrind --tool=callgrind ./dboss-test

 However, it fails with the following errors, talking about an
 unrecognized instruction. Anyone know of a workaround / fix for
 this?

FYI https://github.com/D-Programming-Language/phobos/pull/1946 -- Dmitry Olshansky
Mar 02 2014
prev sibling parent =?UTF-8?B?Ik5vcmRsw7Z3Ig==?= <per.nordlow gmail.com> writes:
Note that you can pipe the valgrind outputs through ddemangle (in 
DMD distribution) to get correct symbol references.

/per
Mar 02 2014