Home | History | Annotate | Download | only in helgrind

Lines Matching defs:thr

142    a pair, (Thr*, ULong), but that takes 16 bytes on a 64-bit target.
143 We pack it into 64 bits by representing the Thr* using a ThrID, a
168 NB3: this probably also relies on the fact that Thr's are never
170 Thr's to thrid values (set up in Thr__new) persists forever.
257 // data decls: Thr, ULong_n_EC //
301 /* A small integer giving a unique identity to this Thr. See
311 1-1 mapping between Thread and Thr structures -- each Thr points
312 at its corresponding Thread, and vice versa. Really, Thr and
357 static void (*main_get_stacktrace)( Thr*, Addr*, UWord ) = NULL;
358 static ExeContext* (*main_get_EC)( Thr* ) = NULL;
1789 /* There's a 1-1 mapping between Thr and ThrIDs -- the latter merely
1790 being compact stand-ins for Thr*'s. Use these functions to map
1792 static ThrID Thr__to_ThrID ( Thr* thr ); /* fwds */
1793 static Thr* Thr__from_ThrID ( ThrID thrid ); /* fwds */
1887 static void VTS__singleton ( /*OUT*/VTS* out, Thr* thr, ULong tym );
1892 static void VTS__tick ( /*OUT*/VTS* out, Thr* me, VTS* vts );
1922 static ULong VTS__indexAt_SLOW ( VTS* vts, Thr* idx );
1929 static void VTS__declare_thread_very_dead ( Thr* idx );
2040 static void VTS__singleton ( /*OUT*/VTS* out, Thr* thr, ULong tym )
2042 tl_assert(thr);
2048 out->ts[hi].thrid = Thr__to_ThrID(thr);
2056 static void VTS__tick ( /*OUT*/VTS* out, Thr* me, VTS* vts )
2215 /* having laboriously determined (thr, tyma, tymb), do something
2417 ULong VTS__indexAt_SLOW ( VTS* vts, Thr* idx )
2435 static void VTS__declare_thread_very_dead ( Thr* thr )
2437 if (0) VG_(printf)("VTQ: tae %p\n", thr);
2439 tl_assert(thr->llexit_done);
2440 tl_assert(thr->joinedwith_done);
2443 nyu = Thr__to_ThrID(thr);
2452 VtsID__rcdec(thr->viR);
2453 VtsID__rcdec(thr->viW);
2454 thr->viR = VtsID_INVALID;
2455 thr->viW = VtsID_INVALID;
2845 /* We begin by sorting the backing table on its .thr values, so as
2847 since it means we must have seen some Thr* exiting more than
2851 /* Sanity check: check for unique .sts.thr values. */
3041 Thr* hbthr = hgthread->hbthr;
3280 /* create a singleton VTS, namely [thr:1] */
3281 static VtsID VtsID__mk_Singleton ( Thr* thr, ULong tym ) {
3283 VTS__singleton(temp_max_sized_VTS, thr,tym);
3288 static VtsID VtsID__tick ( VtsID vi, Thr* idx ) {
3296 static ULong VtsID__indexAt ( VtsID vi, Thr* idx ) {
3306 static Thr* VtsID__findFirst_notLEQ ( VtsID vi1, VtsID vi2 )
3309 Thr* diffthr;
3645 /* Maps ThrID values to their Thr*s (which contain ThrID values that
3648 static XArray* /* of Thr* */ thrid_to_thr_map = NULL;
3654 static ThrID Thr__to_ThrID ( Thr* thr ) {
3655 return thr->thrid;
3657 static Thr* Thr__from_ThrID ( UInt thrid ) {
3658 Thr* thr = *(Thr**)VG_(indexXA)( thrid_to_thr_map, thrid - 1024 );
3659 tl_assert(thr->thrid == thrid);
3660 return thr;
3663 static Thr* Thr__new ( void )
3665 Thr* thr = HG_(zalloc)( "libhb.Thr__new.1", sizeof(Thr) );
3666 thr->viR = VtsID_INVALID;
3667 thr->viW = VtsID_INVALID;
3668 thr->llexit_done = False;
3669 thr->joinedwith_done = False;
3670 thr->filter = HG_(zalloc)( "libhb.Thr__new.2", sizeof(Filter) );
3672 thr->local_Kws_n_stacks
3677 /* Add this Thr* <-> ThrID binding to the mapping, and
3681 HG_(free), sizeof(Thr*) );
3690 thr->thrid = thrid_counter++;
3691 Word ix = VG_(addToXA)( thrid_to_thr_map, &thr );
3692 tl_assert(ix + 1024 == thr->thrid);
3694 return thr;
3697 static void note_local_Kw_n_stack_for ( Thr* thr )
3701 tl_assert(thr);
3707 /* This is the scalar Kw for thr. */
3708 pair.ull = VtsID__indexAt( thr->viW, thr );
3709 pair.ec = main_get_EC( thr );
3711 tl_assert(thr->local_Kws_n_stacks);
3714 nPresent = VG_(sizeXA)( thr->local_Kws_n_stacks );
3719 VG_(dropHeadXA)( thr->local_Kws_n_stacks, nPresent / 2 );
3720 nPresent = VG_(sizeXA)( thr->local_Kws_n_stacks );
3722 VG_(printf)("LOCAL Kw: thr %p, Kw %llu, ec %p (!!! gc !!!)\n",
3723 thr, pair.ull, pair.ec );
3728 = (ULong_n_EC*)VG_(indexXA)( thr->local_Kws_n_stacks, nPresent-1 );
3735 VG_(addToXA)( thr->local_Kws_n_stacks, &pair );
3738 VG_(printf)("LOCAL Kw: thr %p, Kw %llu, ec %p\n",
3739 thr, pair.ull, pair.ec );
4050 static RCEC* get_RCEC ( Thr* thr )
4058 main_get_stacktrace( thr, &example.frames[0], N_FRAMES );
4145 static void event_map_bind ( Addr a, SizeT szB, Bool isW, Thr* thr )
4153 tl_assert(thr);
4154 ThrID thrid = thr->thrid;
4157 WordSetID locksHeldW = thr->hgthread->locksetW;
4159 rcec = get_RCEC( thr );
4197 /* thread 'thr' has an entry at index 'i'. Update its RCEC. */
4280 /*OUT*/Thr** resThr,
4284 Thr* thr, Addr a, SizeT szB, Bool isW )
4301 tl_assert(thr);
4304 ThrID thrid = thr->thrid;
4826 static void record_race_info ( Thr* acc_thr,
4863 Thr* confThr;
4867 (in fact it's the one with the lowest Thr* value). */
4954 Thr* acc_thr,
5019 Thr* acc_thr,
5096 static void zsm_sapply08__msmcread ( Thr* thr, Addr a ) {
5114 svNew = msmcread( svOld, thr,a,1 );
5120 static void zsm_sapply08__msmcwrite ( Thr* thr, Addr a ) {
5138 svNew = msmcwrite( svOld, thr,a,1 );
5146 static void zsm_sapply16__msmcread ( Thr* thr, Addr a ) {
5169 svNew = msmcread( svOld, thr,a,2 );
5176 zsm_sapply08__msmcread( thr, a + 0 );
5177 zsm_sapply08__msmcread( thr, a + 1 );
5180 static void zsm_sapply16__msmcwrite ( Thr* thr, Addr a ) {
5203 svNew = msmcwrite( svOld, thr,a,2 );
5210 zsm_sapply08__msmcwrite( thr, a + 0 );
5211 zsm_sapply08__msmcwrite( thr, a + 1 );
5216 static void zsm_sapply32__msmcread ( Thr* thr, Addr a ) {
5239 svNew = msmcread( svOld, thr,a,4 );
5246 zsm_sapply16__msmcread( thr, a + 0 );
5247 zsm_sapply16__msmcread( thr, a + 2 );
5250 static void zsm_sapply32__msmcwrite ( Thr* thr, Addr a ) {
5273 svNew = msmcwrite( svOld, thr,a,4 );
5280 zsm_sapply16__msmcwrite( thr, a + 0 );
5281 zsm_sapply16__msmcwrite( thr, a + 2 );
5286 static void zsm_sapply64__msmcread ( Thr* thr, Addr a ) {
5303 svNew = msmcread( svOld, thr,a,8 );
5310 zsm_sapply32__msmcread( thr, a + 0 );
5311 zsm_sapply32__msmcread( thr, a + 4 );
5314 Thr* thr, Addr a ) {
5331 svNew = msmcwrite( svOld, thr,a,8 );
5338 zsm_sapply32__msmcwrite( thr, a + 0 );
5339 zsm_sapply32__msmcwrite( thr, a + 4 );
5739 void zsm_sapply08_f__msmcwrite ( Thr* thr, Addr a ) {
5742 if (LIKELY(Filter__ok_to_skip_cwr08(thr->filter, a))) {
5746 zsm_sapply08__msmcwrite(thr, a);
5749 void zsm_sapply16_f__msmcwrite ( Thr* thr, Addr a ) {
5752 if (LIKELY(Filter__ok_to_skip_cwr16(thr->filter, a))) {
5756 zsm_sapply16__msmcwrite(thr, a);
5759 void zsm_sapply32_f__msmcwrite ( Thr* thr, Addr a ) {
5762 if (LIKELY(Filter__ok_to_skip_cwr32(thr->filter, a))) {
5766 zsm_sapply32__msmcwrite(thr, a);
5769 void zsm_sapply64_f__msmcwrite ( Thr* thr, Addr a ) {
5772 if (LIKELY(Filter__ok_to_skip_cwr64(thr->filter, a))) {
5776 zsm_sapply64__msmcwrite(thr, a);
5779 void zsm_sapplyNN_f__msmcwrite ( Thr* thr, Addr a, SizeT len )
5783 zsm_sapply32_f__msmcwrite( thr, a );
5787 zsm_sapply64_f__msmcwrite( thr, a );
5795 zsm_sapply08_f__msmcwrite( thr, a );
5803 zsm_sapply16_f__msmcwrite( thr, a );
5811 zsm_sapply32_f__msmcwrite( thr, a );
5821 zsm_sapply64_f__msmcwrite( thr, a );
5832 zsm_sapply32_f__msmcwrite( thr, a );
5841 zsm_sapply16_f__msmcwrite( thr, a );
5848 zsm_sapply08_f__msmcwrite( thr, a );
5855 void zsm_sapply08_f__msmcread ( Thr* thr, Addr a ) {
5858 if (LIKELY(Filter__ok_to_skip_crd08(thr->filter, a))) {
5862 zsm_sapply08__msmcread(thr, a);
5865 void zsm_sapply16_f__msmcread ( Thr* thr, Addr a ) {
5868 if (LIKELY(Filter__ok_to_skip_crd16(thr->filter, a))) {
5872 zsm_sapply16__msmcread(thr, a);
5875 void zsm_sapply32_f__msmcread ( Thr* thr, Addr a ) {
5878 thr->filter, a))) {
5882 zsm_sapply32__msmcread(thr, a);
5885 void zsm_sapply64_f__msmcread ( Thr* thr, Addr a ) {
5888 if (LIKELY(Filter__ok_to_skip_crd64(thr->filter, a))) {
5892 zsm_sapply64__msmcread(thr, a);
5895 void zsm_sapplyNN_f__msmcread ( Thr* thr, Addr a, SizeT len )
5899 zsm_sapply32_f__msmcread( thr, a );
5903 zsm_sapply64_f__msmcread( thr, a );
5911 zsm_sapply08_f__msmcread( thr, a );
5919 zsm_sapply16_f__msmcread( thr, a );
5927 zsm_sapply32_f__msmcread( thr, a );
5937 zsm_sapply64_f__msmcread( thr, a );
5948 zsm_sapply32_f__msmcread( thr, a );
5957 zsm_sapply16_f__msmcread( thr, a );
5964 zsm_sapply08_f__msmcread( thr, a );
5971 void libhb_Thr_resumes ( Thr* thr )
5973 if (0) VG_(printf)("resume %p\n", thr);
5974 tl_assert(thr);
5975 tl_assert(!thr->llexit_done);
5976 Filter__clear(thr->filter, "libhb_Thr_resumes");
5982 tl_assert(thr->local_Kws_n_stacks);
5983 if (VG_(sizeXA)( thr->local_Kws_n_stacks ) == 0)
5984 note_local_Kw_n_stack_for(thr);
6048 static void show_thread_state ( const HChar* str, Thr* t )
6052 VG_(printf)("thr \"%s\" %p has vi* %u==", str, t, t->viR );
6056 VG_(printf)("thr \"%s\" %p has viR %u==", str, t, t->viR );
6065 Thr* libhb_init (
6066 void (*get_stacktrace)( Thr*, Addr*, UWord ),
6067 ExeContext* (*get_EC)( Thr* )
6070 Thr* thr;
6118 thr = Thr__new();
6119 vi = VtsID__mk_Singleton( thr, 1 );
6120 thr->viR = vi;
6121 thr->viW = vi;
6122 VtsID__rcinc(thr->viR);
6123 VtsID__rcinc(thr->viW);
6125 show_thread_state(" root", thr);
6126 return thr;
6130 Thr* libhb_create ( Thr* parent )
6136 Thr* child = Thr__new();
6304 void libhb_async_exit ( Thr* thr )
6306 tl_assert(thr);
6307 tl_assert(!thr->llexit_done);
6308 thr->llexit_done = True;
6312 tl_assert(thr->filter);
6313 HG_(free)(thr->filter);
6314 thr->filter = NULL;
6319 if (thr->joinedwith_done)
6320 VTS__declare_thread_very_dead(thr);
6324 yes, then we better not free up thr->local_Kws_n_stacks. The
6329 // VG_(deleteXA)(thr->local_Kws_n_stacks);
6330 // thr->local_Kws_n_stacks = NULL;
6335 references to its vector clocks (Thr::viR and Thr::viW). */
6336 void libhb_joinedwith_done ( Thr* thr )
6338 tl_assert(thr);
6339 /* Caller must ensure that this is only ever called once per Thr. */
6340 tl_assert(!thr->joinedwith_done);
6341 thr->joinedwith_done = True;
6342 if (thr->llexit_done)
6343 VTS__declare_thread_very_dead(thr);
6365 void libhb_so_send ( Thr* thr, SO* so, Bool strong_send )
6367 /* Copy the VTSs from 'thr' into the sync object, and then move
6375 { Bool leq = VtsID__cmpLEQ(thr->viW, thr->viR);
6383 so->viR = thr->viR;
6384 so->viW = thr->viW;
6394 so->viR = strong_send ? thr->viR : VtsID__join2( so->viR, thr->viR );
6395 so->viW = strong_send ? thr->viW : VtsID__join2( so->viW, thr->viW );
6401 VtsID__rcdec(thr->viR);
6402 VtsID__rcdec(thr->viW);
6403 thr->viR = VtsID__tick( thr->viR, thr );
6404 thr->viW = VtsID__tick( thr->viW, thr );
6405 if (!thr->llexit_done) {
6406 Filter__clear(thr->filter, "libhb_so_send");
6407 note_local_Kw_n_stack_for(thr);
6409 VtsID__rcinc(thr->viR);
6410 VtsID__rcinc(thr->viW);
6413 show_thread_state("s-send", thr);
6415 show_thread_state("w-send", thr);
6418 void libhb_so_recv ( Thr* thr, SO* so, Bool strong_recv )
6429 VtsID__rcdec(thr->viR);
6430 thr->viR = VtsID__join2( thr->viR, so->viR );
6431 VtsID__rcinc(thr->viR);
6438 //VtsID__rcdec(thr->viR);
6439 //thr->viR = VtsID__tick( thr->viR, thr );
6440 //VtsID__rcinc(thr->viR);
6446 VtsID__rcdec(thr->viW);
6447 thr->viW = VtsID__join2( thr->viW, so->viW );
6448 VtsID__rcinc(thr->viW);
6451 //VtsID__rcdec(thr->viW);
6452 //thr->viW = VtsID__tick( thr->viW, thr );
6453 //VtsID__rcinc(thr->viW);
6456 if (thr->filter)
6457 Filter__clear(thr->filter, "libhb_so_recv");
6458 note_local_Kw_n_stack_for(thr);
6461 show_thread_state("s-recv", thr);
6463 show_thread_state("w-recv", thr);
6469 show_thread_state("d-recv", thr);
6492 static void trace ( Thr* thr, Addr a, SizeT szB, const HChar* s )
6495 VG_(printf)("thr %p (%#lx,%lu) %s: 0x%016llx ", thr,a,szB,s,sv);
6496 show_thread_state("", thr);
6500 void libhb_srange_new ( Thr* thr, Addr a, SizeT szB )
6502 SVal sv = SVal__mkC(thr->viW, thr->viW);
6504 if (0 && TRACEME(a,szB)) trace(thr,a,szB,"nw-before");
6506 Filter__clear_range( thr->filter, a, szB );
6507 if (0 && TRACEME(a,szB)) trace(thr,a,szB,"nw-after ");
6510 void libhb_srange_noaccess_NoFX ( Thr* thr, Addr a, SizeT szB )
6515 void libhb_srange_noaccess_AHAE ( Thr* thr, Addr a, SizeT szB )
6522 Filter__clear_range( thr->filter, a, szB );
6525 void libhb_srange_untrack ( Thr* thr, Addr a, SizeT szB )
6529 if (0 && TRACEME(a,szB)) trace(thr,a,szB,"untrack-before");
6531 Filter__clear_range( thr->filter, a, szB );
6532 if (0 && TRACEME(a,szB)) trace(thr,a,szB,"untrack-after ");
6535 Thread* libhb_get_Thr_hgthread ( Thr* thr ) {
6536 tl_assert(thr);
6537 return thr->hgthread;
6540 void libhb_set_Thr_hgthread ( Thr* thr, Thread* hgthread ) {
6541 tl_assert(thr);
6542 thr->hgthread = hgthread;
6545 void libhb_copy_shadow_state ( Thr* thr, Addr src, Addr dst, SizeT len )
6548 Filter__clear_range( thr->filter, dst, len );