|
From: Samuel Q. <Sam...@sy...> - 2014-01-14 16:57:29
|
| Maybe you can do it with a shell-script wrapper? Eg:
|
| run-me.sh:
| #! /bin/sh
| LD_PRELOAD=./libfakec.so ./myapp -e
|
| Then run:
|
| valgrind --trace-children=yes ./run-me.sh
This has been my approach. Now I am suspicious that - -trace-children=yes is not working like I hoped. I get the EXACT SAME output whether I have - -trace–children=yes or do not have that option. So I think there must be more to getting - -trace-children=yes to behave like I want.
Here is the output. Every number is the same whether or not I have "- -trace-children=yes".
==13527== HEAP SUMMARY:
==13527== in use at exit: 19,116 bytes in 584 blocks
==13527== total heap usage: 766 allocs, 182 frees, 29,553 bytes allocated
==13527==
==13527== LEAK SUMMARY:
==13527== definitely lost: 0 bytes in 0 blocks
==13527== indirectly lost: 0 bytes in 0 blocks
==13527== possibly lost: 0 bytes in 0 blocks
==13527== still reachable: 19,116 bytes in 584 blocks
==13527== suppressed: 0 bytes in 0 blocks
From: Mike Shal <ma...@gm...<mailto:ma...@gm...>>
Date: Tue, Jan 14 9:29 AM
To: Samuel Quiring <sam...@sy...<mailto:sam...@sy...>>
Cc: "val...@li...<mailto:val...@li...>" <val...@li...<mailto:val...@li...>>
Subject: Re: [Valgrind-users] valgrind with LD_PRELOAD
On Tue, Jan 14, 2014 at 10:14 AM, Samuel Quiring <Sam...@sy...<mailto:Sam...@sy...>> wrote:
Greetings,
I invoke my program as follows:
LD_PRELOAD=./libfakec.so ./my_app –e
The LD_PRELOAD environment variable tells the loader that libfakec.so should be loaded BEFORE every other library including the C runtime, libc.so (see http://stackoverflow.com/questions/426230/what-is-the-ld-preload-trick, for example). I am substituting some of my own routines for standard library calls. My app is working like I want, but the question is how to run the app under valgrind? I tried this:
valgrind LD_PRELOAD=./libfakec.so ./my_app –e
But valgrind gave and error saying that "LD_PRELOAD=./libfakec.so ./my_app –e" is not a valid path. In theory, I could put the LD_PRELOAD before the valgrind invocation:
LD_PRELOAD=./libfakec.so valgrind ./my_app –e
But then valgrind would also be using my special library routines and I am pretty sure that will not work.
Maybe you can do it with a shell-script wrapper? Eg:
run-me.sh:
#! /bin/sh
LD_PRELOAD=./libfakec.so ./myapp -e
Then run:
valgrind --trace-children=yes ./run-me.sh
-Mike
|