Hi,

On Friday 22 February 2008, Bart Van Assche wrote:
> >  > This would be useful for exp-drd too. What I do now is to compare the
> >  > result of VG_(get_running_tid)() with a cached value in order to
> >  > detect when Valgrind scheduled another thread. This test is performed
> >  > upon every load, every store, and every time the stack pointer is
> >  > modified.
> >
> >  I thought we had such an event -- I thought Josef used it in Callgrind.
> >  In include/pub_tool_tooliface.h I see:
> >
> >  track_start_client_code

Actually, I use this one. But I do not fully rely on it.
Callgrind has the "nice" property that it instruments a callback at begin
of every basic block. And there, I adjust to VG_(get_running_tid)().

In Callgrind, I have the additional requirement the reliable track enter/leave
of signal handlers. This is not possible with the hooks provided by valgrind,
e.g. in the case of a longjmp from signal handler into regular code.

> >  track_stop_client_code
> >  track_pre_thread_ll_create
> >  track_pre_thread_ll_create
> >  track_pre_thread_ll_exit
> >
> >  Are any of these good enough?  (I really thought we had a
> >  track_thread_switch event...)
> 
> The above is not sufficient. I have tried in exp-drd to only update
> the cached thread ID when one of the above events was generated. The
> result was that for several test cases the cached thread ID was not
> equal to VG_(get_running_tid()). An example of such a test case is
> exp-drd/tests/sigalrm.c.

Did you research the reason for this?

I have this quite old comment before my "TID adjustment" (bbcc.c:536):

  /* This is needed because thread switches can not reliable be tracked
   * with callback CLG_(run_thread) only: we have otherwise no way to get
   * the thread ID after a signal handler returns.
   * This could be removed again if that bug is fixed in Valgrind.
   * This is in the hot path but hopefully not to costly.
   */

Josef


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Valgrind-developers mailing list
Valgrind-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-developers

Reply via email to