Lines Matching refs:tid
48 static void thread_append_segment(const DrdThreadId tid, Segment* const sg);
49 static void thread_discard_segment(const DrdThreadId tid, Segment* const sg);
51 const DrdThreadId tid);
52 static Bool thread_conflict_set_up_to_date(const DrdThreadId tid);
159 DrdThreadId DRD_(VgThreadIdToDrdThreadId)(const ThreadId tid) in DRD_()
163 if (tid == VG_INVALID_THREADID) in DRD_()
169 && DRD_(g_threadinfo)[i].vg_threadid == tid) in DRD_()
179 static DrdThreadId DRD_(VgThreadIdToNewDrdThreadId)(const ThreadId tid) in DRD_()
183 tl_assert(DRD_(VgThreadIdToDrdThreadId)(tid) == DRD_INVALID_THREADID); in DRD_()
193 DRD_(g_threadinfo)[i].vg_threadid = tid; in DRD_()
225 DrdThreadId DRD_(PtThreadIdToDrdThreadId)(const PThreadId tid) in DRD_()
229 if (tid != INVALID_POSIX_THREADID) in DRD_()
234 && DRD_(g_threadinfo)[i].pt_threadid == tid) in DRD_()
244 ThreadId DRD_(DrdThreadIdToVgThreadId)(const DrdThreadId tid) in DRD_()
246 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
247 && tid != DRD_INVALID_THREADID); in DRD_()
249 return (DRD_(g_threadinfo)[tid].vg_thread_exists in DRD_()
250 ? DRD_(g_threadinfo)[tid].vg_threadid in DRD_()
343 static void DRD_(thread_delayed_delete)(const DrdThreadId tid) in DRD_()
347 DRD_(g_threadinfo)[tid].vg_thread_exists = False; in DRD_()
348 DRD_(g_threadinfo)[tid].posix_thread_exists = False; in DRD_()
349 DRD_(g_threadinfo)[tid].deletion_seq = s_deletion_head++; in DRD_()
351 VG_(message)(Vg_DebugMsg, "Adding thread %d to the deletion list\n", tid); in DRD_()
422 void DRD_(thread_set_stack_startup)(const DrdThreadId tid, in DRD_()
425 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
426 && tid != DRD_INVALID_THREADID); in DRD_()
427 tl_assert(DRD_(g_threadinfo)[tid].stack_min <= stack_startup); in DRD_()
428 tl_assert(stack_startup <= DRD_(g_threadinfo)[tid].stack_max); in DRD_()
429 DRD_(g_threadinfo)[tid].stack_startup = stack_startup; in DRD_()
433 Addr DRD_(thread_get_stack_min)(const DrdThreadId tid) in DRD_()
435 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
436 && tid != DRD_INVALID_THREADID); in DRD_()
437 return DRD_(g_threadinfo)[tid].stack_min; in DRD_()
444 Addr DRD_(thread_get_stack_min_min)(const DrdThreadId tid) in DRD_()
446 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
447 && tid != DRD_INVALID_THREADID); in DRD_()
448 return DRD_(g_threadinfo)[tid].stack_min_min; in DRD_()
452 Addr DRD_(thread_get_stack_max)(const DrdThreadId tid) in DRD_()
454 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
455 && tid != DRD_INVALID_THREADID); in DRD_()
456 return DRD_(g_threadinfo)[tid].stack_max; in DRD_()
460 SizeT DRD_(thread_get_stack_size)(const DrdThreadId tid) in DRD_()
462 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
463 && tid != DRD_INVALID_THREADID); in DRD_()
464 return DRD_(g_threadinfo)[tid].stack_size; in DRD_()
467 Bool DRD_(thread_get_on_alt_stack)(const DrdThreadId tid) in DRD_()
469 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
470 && tid != DRD_INVALID_THREADID); in DRD_()
471 return DRD_(g_threadinfo)[tid].on_alt_stack; in DRD_()
474 void DRD_(thread_set_on_alt_stack)(const DrdThreadId tid, in DRD_()
477 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
478 && tid != DRD_INVALID_THREADID); in DRD_()
480 DRD_(g_threadinfo)[tid].on_alt_stack = on_alt_stack; in DRD_()
495 void DRD_(thread_delete)(const DrdThreadId tid, const Bool detached) in DRD_()
500 tl_assert(DRD_(IsValidDrdThreadId)(tid)); in DRD_()
502 tl_assert(DRD_(g_threadinfo)[tid].synchr_nesting >= 0); in DRD_()
503 for (sg = DRD_(g_threadinfo)[tid].sg_last; sg; sg = sg_prev) { in DRD_()
509 DRD_(g_threadinfo)[tid].valid = False; in DRD_()
510 DRD_(g_threadinfo)[tid].vg_thread_exists = False; in DRD_()
511 DRD_(g_threadinfo)[tid].posix_thread_exists = False; in DRD_()
513 DRD_(g_threadinfo)[tid].detached_posix_thread = False; in DRD_()
515 tl_assert(!DRD_(g_threadinfo)[tid].detached_posix_thread); in DRD_()
516 DRD_(g_threadinfo)[tid].sg_first = NULL; in DRD_()
517 DRD_(g_threadinfo)[tid].sg_last = NULL; in DRD_()
519 tl_assert(!DRD_(IsValidDrdThreadId)(tid)); in DRD_()
527 void DRD_(thread_finished)(const DrdThreadId tid) in DRD_()
529 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
530 && tid != DRD_INVALID_THREADID); in DRD_()
532 DRD_(g_threadinfo)[tid].vg_thread_exists = False; in DRD_()
534 if (DRD_(g_threadinfo)[tid].detached_posix_thread) in DRD_()
540 DRD_(g_threadinfo)[tid].stack_min = DRD_(g_threadinfo)[tid].stack_max; in DRD_()
548 DRD_(g_threadinfo)[tid].posix_thread_exists = False; in DRD_()
553 void DRD_(drd_thread_atfork_child)(const DrdThreadId tid) in DRD_()
559 if (i == tid) in DRD_()
571 void DRD_(thread_pre_cancel)(const DrdThreadId tid) in DRD_()
573 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
574 && tid != DRD_INVALID_THREADID); in DRD_()
575 tl_assert(DRD_(g_threadinfo)[tid].pt_threadid != INVALID_POSIX_THREADID); in DRD_()
579 DRD_(g_drd_running_tid), tid); in DRD_()
589 void DRD_(thread_set_pthreadid)(const DrdThreadId tid, const PThreadId ptid) in DRD_()
591 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
592 && tid != DRD_INVALID_THREADID); in DRD_()
593 tl_assert(DRD_(g_threadinfo)[tid].pt_threadid == INVALID_POSIX_THREADID in DRD_()
594 || DRD_(g_threadinfo)[tid].pt_threadid == ptid); in DRD_()
596 DRD_(g_threadinfo)[tid].posix_thread_exists = True; in DRD_()
597 DRD_(g_threadinfo)[tid].pt_threadid = ptid; in DRD_()
601 Bool DRD_(thread_get_joinable)(const DrdThreadId tid) in DRD_()
603 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
604 && tid != DRD_INVALID_THREADID); in DRD_()
605 return ! DRD_(g_threadinfo)[tid].detached_posix_thread; in DRD_()
615 void DRD_(thread_set_joinable)(const DrdThreadId tid, const Bool joinable) in DRD_()
617 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
618 && tid != DRD_INVALID_THREADID); in DRD_()
620 tl_assert(DRD_(g_threadinfo)[tid].pt_threadid != INVALID_POSIX_THREADID); in DRD_()
622 DRD_(g_threadinfo)[tid].detached_posix_thread = ! joinable; in DRD_()
626 void DRD_(thread_entering_pthread_create)(const DrdThreadId tid) in DRD_()
628 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
629 && tid != DRD_INVALID_THREADID); in DRD_()
630 tl_assert(DRD_(g_threadinfo)[tid].pt_threadid != INVALID_POSIX_THREADID); in DRD_()
631 tl_assert(DRD_(g_threadinfo)[tid].pthread_create_nesting_level >= 0); in DRD_()
633 DRD_(g_threadinfo)[tid].pthread_create_nesting_level++; in DRD_()
637 void DRD_(thread_left_pthread_create)(const DrdThreadId tid) in DRD_()
639 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
640 && tid != DRD_INVALID_THREADID); in DRD_()
641 tl_assert(DRD_(g_threadinfo)[tid].pt_threadid != INVALID_POSIX_THREADID); in DRD_()
642 tl_assert(DRD_(g_threadinfo)[tid].pthread_create_nesting_level > 0); in DRD_()
644 DRD_(g_threadinfo)[tid].pthread_create_nesting_level--; in DRD_()
648 const HChar* DRD_(thread_get_name)(const DrdThreadId tid) in DRD_()
650 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
651 && tid != DRD_INVALID_THREADID); in DRD_()
653 return DRD_(g_threadinfo)[tid].name; in DRD_()
657 void DRD_(thread_set_name)(const DrdThreadId tid, const HChar* const name) in DRD_()
659 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
660 && tid != DRD_INVALID_THREADID); in DRD_()
663 VG_(snprintf)(DRD_(g_threadinfo)[tid].name, in DRD_()
664 sizeof(DRD_(g_threadinfo)[tid].name), in DRD_()
666 tid); in DRD_()
668 VG_(snprintf)(DRD_(g_threadinfo)[tid].name, in DRD_()
669 sizeof(DRD_(g_threadinfo)[tid].name), in DRD_()
671 tid, name); in DRD_()
672 DRD_(g_threadinfo)[tid].name[sizeof(DRD_(g_threadinfo)[tid].name) - 1] = 0; in DRD_()
728 int DRD_(thread_enter_synchr)(const DrdThreadId tid) in DRD_()
730 tl_assert(DRD_(IsValidDrdThreadId)(tid)); in DRD_()
731 return DRD_(g_threadinfo)[tid].synchr_nesting++; in DRD_()
738 int DRD_(thread_leave_synchr)(const DrdThreadId tid) in DRD_()
740 tl_assert(DRD_(IsValidDrdThreadId)(tid)); in DRD_()
741 tl_assert(DRD_(g_threadinfo)[tid].synchr_nesting >= 1); in DRD_()
742 return --DRD_(g_threadinfo)[tid].synchr_nesting; in DRD_()
746 int DRD_(thread_get_synchr_nesting_count)(const DrdThreadId tid) in DRD_()
748 tl_assert(DRD_(IsValidDrdThreadId)(tid)); in DRD_()
749 return DRD_(g_threadinfo)[tid].synchr_nesting; in DRD_()
754 void thread_append_segment(const DrdThreadId tid, Segment* const sg) in thread_append_segment() argument
756 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in thread_append_segment()
757 && tid != DRD_INVALID_THREADID); in thread_append_segment()
760 tl_assert(DRD_(sane_ThreadInfo)(&DRD_(g_threadinfo)[tid])); in thread_append_segment()
764 sg->thr_prev = DRD_(g_threadinfo)[tid].sg_last; in thread_append_segment()
766 if (DRD_(g_threadinfo)[tid].sg_last) in thread_append_segment()
767 DRD_(g_threadinfo)[tid].sg_last->thr_next = sg; in thread_append_segment()
768 DRD_(g_threadinfo)[tid].sg_last = sg; in thread_append_segment()
769 if (DRD_(g_threadinfo)[tid].sg_first == NULL) in thread_append_segment()
770 DRD_(g_threadinfo)[tid].sg_first = sg; in thread_append_segment()
773 tl_assert(DRD_(sane_ThreadInfo)(&DRD_(g_threadinfo)[tid])); in thread_append_segment()
782 void thread_discard_segment(const DrdThreadId tid, Segment* const sg) in thread_discard_segment() argument
784 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in thread_discard_segment()
785 && tid != DRD_INVALID_THREADID); in thread_discard_segment()
788 tl_assert(DRD_(sane_ThreadInfo)(&DRD_(g_threadinfo)[tid])); in thread_discard_segment()
795 if (sg == DRD_(g_threadinfo)[tid].sg_first) in thread_discard_segment()
796 DRD_(g_threadinfo)[tid].sg_first = sg->thr_next; in thread_discard_segment()
797 if (sg == DRD_(g_threadinfo)[tid].sg_last) in thread_discard_segment()
798 DRD_(g_threadinfo)[tid].sg_last = sg->thr_prev; in thread_discard_segment()
802 tl_assert(DRD_(sane_ThreadInfo)(&DRD_(g_threadinfo)[tid])); in thread_discard_segment()
810 VectorClock* DRD_(thread_get_vc)(const DrdThreadId tid) in DRD_()
814 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
815 && tid != DRD_INVALID_THREADID); in DRD_()
816 latest_sg = DRD_(g_threadinfo)[tid].sg_last; in DRD_()
824 void DRD_(thread_get_latest_segment)(Segment** sg, const DrdThreadId tid) in DRD_()
829 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
830 && tid != DRD_INVALID_THREADID); in DRD_()
831 latest_sg = DRD_(g_threadinfo)[tid].sg_last; in DRD_()
964 static Bool thread_consistent_segment_ordering(const DrdThreadId tid, in thread_consistent_segment_ordering() argument
1056 void DRD_(thread_new_segment)(const DrdThreadId tid) in DRD_()
1061 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
1062 && tid != DRD_INVALID_THREADID); in DRD_()
1065 last_sg = DRD_(g_threadinfo)[tid].sg_last; in DRD_()
1066 new_sg = DRD_(sg_new)(tid, tid); in DRD_()
1067 thread_append_segment(tid, new_sg); in DRD_()
1068 if (tid == DRD_(g_drd_running_tid) && last_sg) in DRD_()
1070 DRD_(thread_update_conflict_set)(tid, &last_sg->vc); in DRD_()
1136 static void thread_combine_vc_sync(DrdThreadId tid, const Segment* sg) in thread_combine_vc_sync() argument
1140 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in thread_combine_vc_sync()
1141 && tid != DRD_INVALID_THREADID); in thread_combine_vc_sync()
1142 tl_assert(DRD_(g_threadinfo)[tid].sg_first); in thread_combine_vc_sync()
1143 tl_assert(DRD_(g_threadinfo)[tid].sg_last); in thread_combine_vc_sync()
1147 if (tid != sg->tid) { in thread_combine_vc_sync()
1150 DRD_(vc_copy)(&old_vc, DRD_(thread_get_vc)(tid)); in thread_combine_vc_sync()
1151 DRD_(vc_combine)(DRD_(thread_get_vc)(tid), vc); in thread_combine_vc_sync()
1155 str2 = DRD_(vc_aprint)(DRD_(thread_get_vc)(tid)); in thread_combine_vc_sync()
1156 VG_(message)(Vg_DebugMsg, "thread %d: vc %s -> %s\n", tid, str1, str2); in thread_combine_vc_sync()
1163 DRD_(thread_update_conflict_set)(tid, &old_vc); in thread_combine_vc_sync()
1168 tl_assert(DRD_(vc_lte)(vc, DRD_(thread_get_vc)(tid))); in thread_combine_vc_sync()
1178 void DRD_(thread_new_segment_and_combine_vc)(DrdThreadId tid, const Segment* sg) in DRD_()
1180 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
1181 && tid != DRD_INVALID_THREADID); in DRD_()
1185 thread_append_segment(tid, DRD_(sg_new)(tid, tid)); in DRD_()
1187 thread_combine_vc_sync(tid, sg); in DRD_()
1213 void DRD_(thread_set_record_loads)(const DrdThreadId tid, const Bool enabled) in DRD_()
1215 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
1216 && tid != DRD_INVALID_THREADID); in DRD_()
1219 DRD_(g_threadinfo)[tid].is_recording_loads = enabled; in DRD_()
1223 void DRD_(thread_set_record_stores)(const DrdThreadId tid, const Bool enabled) in DRD_()
1225 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
1226 && tid != DRD_INVALID_THREADID); in DRD_()
1229 DRD_(g_threadinfo)[tid].is_recording_stores = enabled; in DRD_()
1263 static void show_call_stack(const DrdThreadId tid, ExeContext* const callstack) in show_call_stack() argument
1265 const ThreadId vg_tid = DRD_(DrdThreadIdToVgThreadId)(tid); in show_call_stack()
1281 thread_report_conflicting_segments_segment(const DrdThreadId tid, in thread_report_conflicting_segments_segment() argument
1289 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in thread_report_conflicting_segments_segment()
1290 && tid != DRD_INVALID_THREADID); in thread_report_conflicting_segments_segment()
1294 if (i != tid) { in thread_report_conflicting_segments_segment()
1336 void DRD_(thread_report_conflicting_segments)(const DrdThreadId tid, in DRD_()
1343 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
1344 && tid != DRD_INVALID_THREADID); in DRD_()
1346 for (p = DRD_(g_threadinfo)[tid].sg_first; p; p = p->thr_next) { in DRD_()
1348 thread_report_conflicting_segments_segment(tid, addr, size, in DRD_()
1357 static Bool thread_conflict_set_up_to_date(const DrdThreadId tid) in thread_conflict_set_up_to_date() argument
1365 thread_compute_conflict_set(&computed_conflict_set, tid); in thread_conflict_set_up_to_date()
1386 const DrdThreadId tid) in thread_compute_conflict_set() argument
1390 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in thread_compute_conflict_set()
1391 && tid != DRD_INVALID_THREADID); in thread_compute_conflict_set()
1392 tl_assert(tid == DRD_(g_drd_running_tid)); in thread_compute_conflict_set()
1410 str = DRD_(vc_aprint)(DRD_(thread_get_vc)(tid)); in thread_compute_conflict_set()
1413 tid, str); in thread_compute_conflict_set()
1417 p = DRD_(g_threadinfo)[tid].sg_last; in thread_compute_conflict_set()
1426 tid, vc); in thread_compute_conflict_set()
1431 if (j != tid && DRD_(IsValidDrdThreadId)(j)) { in thread_compute_conflict_set()
1469 VG_(message)(Vg_DebugMsg, "[%d] new conflict set:\n", tid); in thread_compute_conflict_set()
1471 VG_(message)(Vg_DebugMsg, "[%d] end of new conflict set.\n", tid); in thread_compute_conflict_set()
1480 void DRD_(thread_update_conflict_set)(const DrdThreadId tid, in DRD_()
1487 tl_assert(0 <= (int)tid && tid < DRD_N_THREADS in DRD_()
1488 && tid != DRD_INVALID_THREADID); in DRD_()
1490 tl_assert(tid == DRD_(g_drd_running_tid)); in DRD_()
1496 str = DRD_(vc_aprint)(DRD_(thread_get_vc)(tid)); in DRD_()
1499 tid, str); in DRD_()
1503 new_vc = DRD_(thread_get_vc)(tid); in DRD_()
1512 if (j == tid || ! DRD_(IsValidDrdThreadId)(j)) in DRD_()
1563 p = DRD_(g_threadinfo)[tid].sg_last; in DRD_()
1565 if (j != tid && DRD_(IsValidDrdThreadId)(j)) { in DRD_()
1582 VG_(message)(Vg_DebugMsg, "[%d] updated conflict set:\n", tid); in DRD_()
1584 VG_(message)(Vg_DebugMsg, "[%d] end of updated conflict set.\n", tid); in DRD_()