On Tue, 2014-01-14 at 07:14 -0800, Samuel Quiring wrote:

>     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.
> 
> 
> Is there a way around this?  I am running on CentOS 6.5.


I guess that your second question, related to running a shell script
and its children under Valgrind is related to setting LD_PRELOAD
in the run.sh.
I am not sure that this will solve the possible problem.

Here are some elements:

There are 2 stages for starting your program under valgrind.
The stage 1 is the valgrind launcher (this is the "valgrind"
executable).
This is a normal executable, dynamically linked, and depends
on some "standard shared libs" as shown by
ldd valgrind
        linux-gate.so.1 =>  (0x007ab000)
        libc.so.6 => /lib/libc.so.6 (0x00214000)
        /lib/ld-linux.so.2 (0x001f2000)

valgrind (stage 1) will then launch the stage 2, which is
the specific tool as requested on the command line (e.g. memcheck)
and for the needed platform (e.g. x86).
So, it will e.g. launch memcheck-x86-linux, which is not a dynamic
executable:
ldd memcheck-x86-linux 
        not a dynamic executable

As long as your LD_PRELOAD does not change the behaviour of
the libraries used by valgrind stage 1, then valgrind stage 1
should work properly.
If your LD_PRELOAD replaces things part of e.g. libc, you might
have problems in valgrind stage 1.


If you cannot make all that work, there might be ways to solve that:

* maybe statically link the valgrind stage 1 ?
* otherwise, modify the function setup_client_env in 
    coregrind/m_initimg/initimg-linux.c
  so as to add your specific LD_PRELOAD string only for the client.
  (but I suspect that will however then not work with
    --trace-children=yes, as then the LD_PRELOAD will be used
   by the valgrind stage 1 used to launch the tool on a forked/exec-ed
   children.

Hope this helps, give some feedback about what has worked (or not).

We might maybe need to add a valgrind option
   --client-ld-preload=...... 
to avoid such problem ?
Or alternatively, statically link valgrind (but that means that
valgrind can then only be built if all libs for static linking
are available).



Philippe



------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to