Lines Matching refs:tid
50 static void thread_append_segment(const DrdThreadId tid, Segment* const sg);
51 static void thread_discard_segment(const DrdThreadId tid, Segment* const sg);
53 const DrdThreadId tid);
54 static Bool thread_conflict_set_up_to_date(const DrdThreadId tid);
150 DrdThreadId DRD_(VgThreadIdToDrdThreadId)(const ThreadId tid) in DRD_()
154 if (tid == VG_INVALID_THREADID) in DRD_()
160 && DRD_(g_threadinfo)[i].vg_threadid == tid) in DRD_()
170 static DrdThreadId DRD_(VgThreadIdToNewDrdThreadId)(const ThreadId tid) in DRD_()
174 tl_assert(DRD_(VgThreadIdToDrdThreadId)(tid) == DRD_INVALID_THREADID); in DRD_()
184 DRD_(g_threadinfo)[i].vg_threadid = tid; in DRD_()
216 DrdThreadId DRD_(PtThreadIdToDrdThreadId)(const PThreadId tid) in DRD_()
220 if (tid != INVALID_POSIX_THREADID) in DRD_()
225 && DRD_(g_threadinfo)[i].pt_threadid == tid) in DRD_()
235 ThreadId DRD_(DrdThreadIdToVgThreadId)(const DrdThreadId tid) in DRD_()
237 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
238 && tid != DRD_INVALID_THREADID); in DRD_()
240 return (DRD_(g_threadinfo)[tid].vg_thread_exists in DRD_()
241 ? DRD_(g_threadinfo)[tid].vg_threadid in DRD_()
334 static void DRD_(thread_delayed_delete)(const DrdThreadId tid) in DRD_()
338 DRD_(g_threadinfo)[tid].vg_thread_exists = False; in DRD_()
339 DRD_(g_threadinfo)[tid].posix_thread_exists = False; in DRD_()
340 DRD_(g_threadinfo)[tid].deletion_seq = s_deletion_head++; in DRD_()
342 VG_(message)(Vg_DebugMsg, "Adding thread %d to the deletion list\n", tid); in DRD_()
413 void DRD_(thread_set_stack_startup)(const DrdThreadId tid, in DRD_()
416 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
417 && tid != DRD_INVALID_THREADID); in DRD_()
418 tl_assert(DRD_(g_threadinfo)[tid].stack_min <= stack_startup); in DRD_()
419 tl_assert(stack_startup <= DRD_(g_threadinfo)[tid].stack_max); in DRD_()
420 DRD_(g_threadinfo)[tid].stack_startup = stack_startup; in DRD_()
424 Addr DRD_(thread_get_stack_min)(const DrdThreadId tid) in DRD_()
426 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
427 && tid != DRD_INVALID_THREADID); in DRD_()
428 return DRD_(g_threadinfo)[tid].stack_min; in DRD_()
435 Addr DRD_(thread_get_stack_min_min)(const DrdThreadId tid) in DRD_()
437 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
438 && tid != DRD_INVALID_THREADID); in DRD_()
439 return DRD_(g_threadinfo)[tid].stack_min_min; in DRD_()
443 Addr DRD_(thread_get_stack_max)(const DrdThreadId tid) in DRD_()
445 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
446 && tid != DRD_INVALID_THREADID); in DRD_()
447 return DRD_(g_threadinfo)[tid].stack_max; in DRD_()
451 SizeT DRD_(thread_get_stack_size)(const DrdThreadId tid) in DRD_()
453 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
454 && tid != DRD_INVALID_THREADID); in DRD_()
455 return DRD_(g_threadinfo)[tid].stack_size; in DRD_()
458 Bool DRD_(thread_get_on_alt_stack)(const DrdThreadId tid) in DRD_()
460 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
461 && tid != DRD_INVALID_THREADID); in DRD_()
462 return DRD_(g_threadinfo)[tid].on_alt_stack; in DRD_()
465 void DRD_(thread_set_on_alt_stack)(const DrdThreadId tid, in DRD_()
468 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
469 && tid != DRD_INVALID_THREADID); in DRD_()
471 DRD_(g_threadinfo)[tid].on_alt_stack = on_alt_stack; in DRD_()
486 void DRD_(thread_delete)(const DrdThreadId tid, const Bool detached) in DRD_()
491 tl_assert(DRD_(IsValidDrdThreadId)(tid)); in DRD_()
493 tl_assert(DRD_(g_threadinfo)[tid].synchr_nesting >= 0); in DRD_()
494 for (sg = DRD_(g_threadinfo)[tid].last; sg; sg = sg_prev) in DRD_()
501 DRD_(g_threadinfo)[tid].valid = False; in DRD_()
502 DRD_(g_threadinfo)[tid].vg_thread_exists = False; in DRD_()
503 DRD_(g_threadinfo)[tid].posix_thread_exists = False; in DRD_()
505 DRD_(g_threadinfo)[tid].detached_posix_thread = False; in DRD_()
507 tl_assert(!DRD_(g_threadinfo)[tid].detached_posix_thread); in DRD_()
508 DRD_(g_threadinfo)[tid].first = 0; in DRD_()
509 DRD_(g_threadinfo)[tid].last = 0; in DRD_()
511 tl_assert(! DRD_(IsValidDrdThreadId)(tid)); in DRD_()
519 void DRD_(thread_finished)(const DrdThreadId tid) in DRD_()
521 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
522 && tid != DRD_INVALID_THREADID); in DRD_()
524 DRD_(g_threadinfo)[tid].vg_thread_exists = False; in DRD_()
526 if (DRD_(g_threadinfo)[tid].detached_posix_thread) in DRD_()
532 DRD_(g_threadinfo)[tid].stack_min = DRD_(g_threadinfo)[tid].stack_max; in DRD_()
540 DRD_(g_threadinfo)[tid].posix_thread_exists = False; in DRD_()
545 void DRD_(drd_thread_atfork_child)(const DrdThreadId tid) in DRD_()
551 if (i == tid) in DRD_()
560 void DRD_(thread_pre_cancel)(const DrdThreadId tid) in DRD_()
562 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
563 && tid != DRD_INVALID_THREADID); in DRD_()
564 tl_assert(DRD_(g_threadinfo)[tid].pt_threadid != INVALID_POSIX_THREADID); in DRD_()
568 DRD_(g_drd_running_tid), tid); in DRD_()
578 void DRD_(thread_set_pthreadid)(const DrdThreadId tid, const PThreadId ptid) in DRD_()
580 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
581 && tid != DRD_INVALID_THREADID); in DRD_()
582 tl_assert(DRD_(g_threadinfo)[tid].pt_threadid == INVALID_POSIX_THREADID in DRD_()
583 || DRD_(g_threadinfo)[tid].pt_threadid == ptid); in DRD_()
585 DRD_(g_threadinfo)[tid].posix_thread_exists = True; in DRD_()
586 DRD_(g_threadinfo)[tid].pt_threadid = ptid; in DRD_()
590 Bool DRD_(thread_get_joinable)(const DrdThreadId tid) in DRD_()
592 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
593 && tid != DRD_INVALID_THREADID); in DRD_()
594 return ! DRD_(g_threadinfo)[tid].detached_posix_thread; in DRD_()
598 void DRD_(thread_set_joinable)(const DrdThreadId tid, const Bool joinable) in DRD_()
600 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
601 && tid != DRD_INVALID_THREADID); in DRD_()
603 tl_assert(DRD_(g_threadinfo)[tid].pt_threadid != INVALID_POSIX_THREADID); in DRD_()
605 DRD_(g_threadinfo)[tid].detached_posix_thread = ! joinable; in DRD_()
609 void DRD_(thread_entering_pthread_create)(const DrdThreadId tid) in DRD_()
611 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
612 && tid != DRD_INVALID_THREADID); in DRD_()
613 tl_assert(DRD_(g_threadinfo)[tid].pt_threadid != INVALID_POSIX_THREADID); in DRD_()
614 tl_assert(DRD_(g_threadinfo)[tid].pthread_create_nesting_level >= 0); in DRD_()
616 DRD_(g_threadinfo)[tid].pthread_create_nesting_level++; in DRD_()
620 void DRD_(thread_left_pthread_create)(const DrdThreadId tid) in DRD_()
622 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
623 && tid != DRD_INVALID_THREADID); in DRD_()
624 tl_assert(DRD_(g_threadinfo)[tid].pt_threadid != INVALID_POSIX_THREADID); in DRD_()
625 tl_assert(DRD_(g_threadinfo)[tid].pthread_create_nesting_level > 0); in DRD_()
627 DRD_(g_threadinfo)[tid].pthread_create_nesting_level--; in DRD_()
631 const char* DRD_(thread_get_name)(const DrdThreadId tid) in DRD_()
633 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
634 && tid != DRD_INVALID_THREADID); in DRD_()
636 return DRD_(g_threadinfo)[tid].name; in DRD_()
640 void DRD_(thread_set_name)(const DrdThreadId tid, const char* const name) in DRD_()
642 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
643 && tid != DRD_INVALID_THREADID); in DRD_()
646 VG_(snprintf)(DRD_(g_threadinfo)[tid].name, in DRD_()
647 sizeof(DRD_(g_threadinfo)[tid].name), in DRD_()
649 tid); in DRD_()
651 VG_(snprintf)(DRD_(g_threadinfo)[tid].name, in DRD_()
652 sizeof(DRD_(g_threadinfo)[tid].name), in DRD_()
654 tid, name); in DRD_()
655 DRD_(g_threadinfo)[tid].name[sizeof(DRD_(g_threadinfo)[tid].name) - 1] = 0; in DRD_()
711 int DRD_(thread_enter_synchr)(const DrdThreadId tid) in DRD_()
713 tl_assert(DRD_(IsValidDrdThreadId)(tid)); in DRD_()
714 return DRD_(g_threadinfo)[tid].synchr_nesting++; in DRD_()
721 int DRD_(thread_leave_synchr)(const DrdThreadId tid) in DRD_()
723 tl_assert(DRD_(IsValidDrdThreadId)(tid)); in DRD_()
724 tl_assert(DRD_(g_threadinfo)[tid].synchr_nesting >= 1); in DRD_()
725 return --DRD_(g_threadinfo)[tid].synchr_nesting; in DRD_()
729 int DRD_(thread_get_synchr_nesting_count)(const DrdThreadId tid) in DRD_()
731 tl_assert(DRD_(IsValidDrdThreadId)(tid)); in DRD_()
732 return DRD_(g_threadinfo)[tid].synchr_nesting; in DRD_()
737 void thread_append_segment(const DrdThreadId tid, Segment* const sg) in thread_append_segment() argument
739 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in thread_append_segment()
740 && tid != DRD_INVALID_THREADID); in thread_append_segment()
743 tl_assert(DRD_(sane_ThreadInfo)(&DRD_(g_threadinfo)[tid])); in thread_append_segment()
746 sg->prev = DRD_(g_threadinfo)[tid].last; in thread_append_segment()
748 if (DRD_(g_threadinfo)[tid].last) in thread_append_segment()
749 DRD_(g_threadinfo)[tid].last->next = sg; in thread_append_segment()
750 DRD_(g_threadinfo)[tid].last = sg; in thread_append_segment()
751 if (DRD_(g_threadinfo)[tid].first == 0) in thread_append_segment()
752 DRD_(g_threadinfo)[tid].first = sg; in thread_append_segment()
755 tl_assert(DRD_(sane_ThreadInfo)(&DRD_(g_threadinfo)[tid])); in thread_append_segment()
764 void thread_discard_segment(const DrdThreadId tid, Segment* const sg) in thread_discard_segment() argument
766 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in thread_discard_segment()
767 && tid != DRD_INVALID_THREADID); in thread_discard_segment()
770 tl_assert(DRD_(sane_ThreadInfo)(&DRD_(g_threadinfo)[tid])); in thread_discard_segment()
777 if (sg == DRD_(g_threadinfo)[tid].first) in thread_discard_segment()
778 DRD_(g_threadinfo)[tid].first = sg->next; in thread_discard_segment()
779 if (sg == DRD_(g_threadinfo)[tid].last) in thread_discard_segment()
780 DRD_(g_threadinfo)[tid].last = sg->prev; in thread_discard_segment()
784 tl_assert(DRD_(sane_ThreadInfo)(&DRD_(g_threadinfo)[tid])); in thread_discard_segment()
792 VectorClock* DRD_(thread_get_vc)(const DrdThreadId tid) in DRD_()
794 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
795 && tid != DRD_INVALID_THREADID); in DRD_()
796 tl_assert(DRD_(g_threadinfo)[tid].last); in DRD_()
797 return &DRD_(g_threadinfo)[tid].last->vc; in DRD_()
803 void DRD_(thread_get_latest_segment)(Segment** sg, const DrdThreadId tid) in DRD_()
806 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
807 && tid != DRD_INVALID_THREADID); in DRD_()
808 tl_assert(DRD_(g_threadinfo)[tid].last); in DRD_()
811 *sg = DRD_(sg_get)(DRD_(g_threadinfo)[tid].last); in DRD_()
941 static Bool thread_consistent_segment_ordering(const DrdThreadId tid, in thread_consistent_segment_ordering() argument
1037 void DRD_(thread_new_segment)(const DrdThreadId tid) in DRD_()
1042 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
1043 && tid != DRD_INVALID_THREADID); in DRD_()
1046 last_sg = DRD_(g_threadinfo)[tid].last; in DRD_()
1047 new_sg = DRD_(sg_new)(tid, tid); in DRD_()
1048 thread_append_segment(tid, new_sg); in DRD_()
1049 if (tid == DRD_(g_drd_running_tid) && last_sg) in DRD_()
1051 DRD_(thread_update_conflict_set)(tid, &last_sg->vc); in DRD_()
1118 static void thread_combine_vc_sync(DrdThreadId tid, const Segment* sg) in thread_combine_vc_sync() argument
1122 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in thread_combine_vc_sync()
1123 && tid != DRD_INVALID_THREADID); in thread_combine_vc_sync()
1124 tl_assert(DRD_(g_threadinfo)[tid].last); in thread_combine_vc_sync()
1128 if (tid != sg->tid) in thread_combine_vc_sync()
1132 DRD_(vc_copy)(&old_vc, &DRD_(g_threadinfo)[tid].last->vc); in thread_combine_vc_sync()
1133 DRD_(vc_combine)(&DRD_(g_threadinfo)[tid].last->vc, vc); in thread_combine_vc_sync()
1138 str2 = DRD_(vc_aprint)(&DRD_(g_threadinfo)[tid].last->vc); in thread_combine_vc_sync()
1139 VG_(message)(Vg_DebugMsg, "thread %d: vc %s -> %s\n", tid, str1, str2); in thread_combine_vc_sync()
1146 DRD_(thread_update_conflict_set)(tid, &old_vc); in thread_combine_vc_sync()
1153 tl_assert(DRD_(vc_lte)(vc, &DRD_(g_threadinfo)[tid].last->vc)); in thread_combine_vc_sync()
1163 void DRD_(thread_new_segment_and_combine_vc)(DrdThreadId tid, const Segment* sg) in DRD_()
1165 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
1166 && tid != DRD_INVALID_THREADID); in DRD_()
1170 thread_append_segment(tid, DRD_(sg_new)(tid, tid)); in DRD_()
1172 thread_combine_vc_sync(tid, sg); in DRD_()
1200 void DRD_(thread_set_record_loads)(const DrdThreadId tid, const Bool enabled) in DRD_()
1202 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
1203 && tid != DRD_INVALID_THREADID); in DRD_()
1206 DRD_(g_threadinfo)[tid].is_recording_loads = enabled; in DRD_()
1210 void DRD_(thread_set_record_stores)(const DrdThreadId tid, const Bool enabled) in DRD_()
1212 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
1213 && tid != DRD_INVALID_THREADID); in DRD_()
1216 DRD_(g_threadinfo)[tid].is_recording_stores = enabled; in DRD_()
1252 static void show_call_stack(const DrdThreadId tid, ExeContext* const callstack) in show_call_stack() argument
1254 const ThreadId vg_tid = DRD_(DrdThreadIdToVgThreadId)(tid); in show_call_stack()
1270 thread_report_conflicting_segments_segment(const DrdThreadId tid, in thread_report_conflicting_segments_segment() argument
1278 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in thread_report_conflicting_segments_segment()
1279 && tid != DRD_INVALID_THREADID); in thread_report_conflicting_segments_segment()
1284 if (i != tid) in thread_report_conflicting_segments_segment()
1326 void DRD_(thread_report_conflicting_segments)(const DrdThreadId tid, in DRD_()
1333 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
1334 && tid != DRD_INVALID_THREADID); in DRD_()
1336 for (p = DRD_(g_threadinfo)[tid].first; p; p = p->next) in DRD_()
1340 thread_report_conflicting_segments_segment(tid, addr, size, in DRD_()
1350 static Bool thread_conflict_set_up_to_date(const DrdThreadId tid) in thread_conflict_set_up_to_date() argument
1362 thread_compute_conflict_set(&computed_conflict_set, tid); in thread_conflict_set_up_to_date()
1383 const DrdThreadId tid) in thread_compute_conflict_set() argument
1387 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in thread_compute_conflict_set()
1388 && tid != DRD_INVALID_THREADID); in thread_compute_conflict_set()
1389 tl_assert(tid == DRD_(g_drd_running_tid)); in thread_compute_conflict_set()
1411 str = DRD_(vc_aprint)(&DRD_(g_threadinfo)[tid].last->vc); in thread_compute_conflict_set()
1414 tid, str); in thread_compute_conflict_set()
1418 p = DRD_(g_threadinfo)[tid].last; in thread_compute_conflict_set()
1428 tid, vc); in thread_compute_conflict_set()
1434 if (j != tid && DRD_(IsValidDrdThreadId)(j)) in thread_compute_conflict_set()
1479 VG_(message)(Vg_DebugMsg, "[%d] new conflict set:\n", tid); in thread_compute_conflict_set()
1481 VG_(message)(Vg_DebugMsg, "[%d] end of new conflict set.\n", tid); in thread_compute_conflict_set()
1490 void DRD_(thread_update_conflict_set)(const DrdThreadId tid, in DRD_()
1497 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
1498 && tid != DRD_INVALID_THREADID); in DRD_()
1500 tl_assert(tid == DRD_(g_drd_running_tid)); in DRD_()
1507 str = DRD_(vc_aprint)(&DRD_(g_threadinfo)[tid].last->vc); in DRD_()
1510 tid, str); in DRD_()
1514 new_vc = &DRD_(g_threadinfo)[tid].last->vc; in DRD_()
1523 if (j == tid || ! DRD_(IsValidDrdThreadId)(j)) in DRD_()
1574 p = DRD_(g_threadinfo)[tid].last; in DRD_()
1577 if (j != tid && DRD_(IsValidDrdThreadId)(j)) in DRD_()
1595 VG_(message)(Vg_DebugMsg, "[%d] updated conflict set:\n", tid); in DRD_()
1597 VG_(message)(Vg_DebugMsg, "[%d] end of updated conflict set.\n", tid); in DRD_()