drd_thread.h revision 324a23bea57e0bfc27d9442ec00a8eee8294f01a
1af44c8236f7a73e71b16b707bba56f33af4d01cesewardj/* 2af44c8236f7a73e71b16b707bba56f33af4d01cesewardj This file is part of drd, a data race detector. 3af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 48564292ac4b9adf51c45517cca2878732feb5bb4sewardj Copyright (C) 2006-2008 Bart Van Assche 5af44c8236f7a73e71b16b707bba56f33af4d01cesewardj bart.vanassche@gmail.com 6af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 7af44c8236f7a73e71b16b707bba56f33af4d01cesewardj This program is free software; you can redistribute it and/or 8af44c8236f7a73e71b16b707bba56f33af4d01cesewardj modify it under the terms of the GNU General Public License as 9af44c8236f7a73e71b16b707bba56f33af4d01cesewardj published by the Free Software Foundation; either version 2 of the 10af44c8236f7a73e71b16b707bba56f33af4d01cesewardj License, or (at your option) any later version. 11af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 12af44c8236f7a73e71b16b707bba56f33af4d01cesewardj This program is distributed in the hope that it will be useful, but 13af44c8236f7a73e71b16b707bba56f33af4d01cesewardj WITHOUT ANY WARRANTY; without even the implied warranty of 14af44c8236f7a73e71b16b707bba56f33af4d01cesewardj MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15af44c8236f7a73e71b16b707bba56f33af4d01cesewardj General Public License for more details. 16af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 17af44c8236f7a73e71b16b707bba56f33af4d01cesewardj You should have received a copy of the GNU General Public License 18af44c8236f7a73e71b16b707bba56f33af4d01cesewardj along with this program; if not, write to the Free Software 19af44c8236f7a73e71b16b707bba56f33af4d01cesewardj Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 20af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 02111-1307, USA. 21af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 22af44c8236f7a73e71b16b707bba56f33af4d01cesewardj The GNU General Public License is contained in the file COPYING. 23af44c8236f7a73e71b16b707bba56f33af4d01cesewardj*/ 24af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 25af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 26af44c8236f7a73e71b16b707bba56f33af4d01cesewardj#ifndef __THREAD_H 27af44c8236f7a73e71b16b707bba56f33af4d01cesewardj#define __THREAD_H 28af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 29af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 30324a23bea57e0bfc27d9442ec00a8eee8294f01abart/* Include directives. */ 31f00a85bc55a2790c31670dd21e449a335c739068bart 3209dc13f324a19f1bebf58c7f197a581dc8fb528bbart#include "drd_basics.h" 33af44c8236f7a73e71b16b707bba56f33af4d01cesewardj#include "drd_segment.h" 34d59bb0f2a79bac77cf0f01b20d3d51102d6c71e3bart#include "pub_drd_bitmap.h" 35f00a85bc55a2790c31670dd21e449a335c739068bart#include "pub_tool_libcassert.h" // tl_assert() 36f00a85bc55a2790c31670dd21e449a335c739068bart#include "pub_tool_stacktrace.h" // StackTrace 37f00a85bc55a2790c31670dd21e449a335c739068bart#include "pub_tool_threadstate.h" // VG_N_THREADS 38f00a85bc55a2790c31670dd21e449a335c739068bart 39f00a85bc55a2790c31670dd21e449a335c739068bart 40324a23bea57e0bfc27d9442ec00a8eee8294f01abart/* Defines. */ 41af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 42f00a85bc55a2790c31670dd21e449a335c739068bart#define DRD_N_THREADS VG_N_THREADS 43af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 44af44c8236f7a73e71b16b707bba56f33af4d01cesewardj#define DRD_INVALID_THREADID 0 45af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 46af44c8236f7a73e71b16b707bba56f33af4d01cesewardj/* Note: the PThreadId typedef and the INVALID_POSIX_THREADID depend on the */ 47af44c8236f7a73e71b16b707bba56f33af4d01cesewardj/* operating system and threading library in use. PThreadId must contain at */ 48af44c8236f7a73e71b16b707bba56f33af4d01cesewardj/* least the same number of bits as pthread_t, and INVALID_POSIX_THREADID */ 49af44c8236f7a73e71b16b707bba56f33af4d01cesewardj/* must be a value that will never be returned by pthread_self(). */ 50af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 51af44c8236f7a73e71b16b707bba56f33af4d01cesewardj#define INVALID_POSIX_THREADID ((PThreadId)0) 52af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 53af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 54324a23bea57e0bfc27d9442ec00a8eee8294f01abart/* Type definitions. */ 55f00a85bc55a2790c31670dd21e449a335c739068bart 56af44c8236f7a73e71b16b707bba56f33af4d01cesewardjtypedef UWord PThreadId; 57af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 58f00a85bc55a2790c31670dd21e449a335c739068barttypedef struct 59f00a85bc55a2790c31670dd21e449a335c739068bart{ 601a473c757cae99f11477440d5473be6e5c95e0cebart Segment* first; 611a473c757cae99f11477440d5473be6e5c95e0cebart Segment* last; 621a473c757cae99f11477440d5473be6e5c95e0cebart ThreadId vg_threadid; 631a473c757cae99f11477440d5473be6e5c95e0cebart PThreadId pt_threadid; 64324a23bea57e0bfc27d9442ec00a8eee8294f01abart Addr stack_min_min; /**< Lowest value stack pointer ever had. */ 65324a23bea57e0bfc27d9442ec00a8eee8294f01abart Addr stack_min; /**< Current stack pointer. */ 66324a23bea57e0bfc27d9442ec00a8eee8294f01abart Addr stack_startup; /**<Stack pointer after pthread_create() finished.*/ 67324a23bea57e0bfc27d9442ec00a8eee8294f01abart Addr stack_max; /**< Top of stack. */ 68324a23bea57e0bfc27d9442ec00a8eee8294f01abart SizeT stack_size; /**< Maximum size of stack. */ 69324a23bea57e0bfc27d9442ec00a8eee8294f01abart /** Indicates whether the Valgrind core knows about this thread. */ 701a473c757cae99f11477440d5473be6e5c95e0cebart Bool vg_thread_exists; 71324a23bea57e0bfc27d9442ec00a8eee8294f01abart /** Indicates whether there is an associated POSIX thread ID. */ 721a473c757cae99f11477440d5473be6e5c95e0cebart Bool posix_thread_exists; 73324a23bea57e0bfc27d9442ec00a8eee8294f01abart /** 74324a23bea57e0bfc27d9442ec00a8eee8294f01abart * If true, indicates that there is a corresponding POSIX thread ID and 75324a23bea57e0bfc27d9442ec00a8eee8294f01abart * a corresponding OS thread that is detached. 76324a23bea57e0bfc27d9442ec00a8eee8294f01abart */ 771a473c757cae99f11477440d5473be6e5c95e0cebart Bool detached_posix_thread; 78324a23bea57e0bfc27d9442ec00a8eee8294f01abart /** Wether recording of memory accesses is active. */ 791a473c757cae99f11477440d5473be6e5c95e0cebart Bool is_recording; 80324a23bea57e0bfc27d9442ec00a8eee8294f01abart /** Nesting level of synchronization functions called by the client. */ 811a473c757cae99f11477440d5473be6e5c95e0cebart Int synchr_nesting; 82f00a85bc55a2790c31670dd21e449a335c739068bart} ThreadInfo; 83f00a85bc55a2790c31670dd21e449a335c739068bart 84f00a85bc55a2790c31670dd21e449a335c739068bart 85324a23bea57e0bfc27d9442ec00a8eee8294f01abart/* 86324a23bea57e0bfc27d9442ec00a8eee8294f01abart * Local variables of drd_thread.c that are declared here such that these 87324a23bea57e0bfc27d9442ec00a8eee8294f01abart * can be accessed by inline functions. 88324a23bea57e0bfc27d9442ec00a8eee8294f01abart */ 89f00a85bc55a2790c31670dd21e449a335c739068bart 90324a23bea57e0bfc27d9442ec00a8eee8294f01abartextern DrdThreadId DRD_(g_drd_running_tid); 91324a23bea57e0bfc27d9442ec00a8eee8294f01abartextern ThreadInfo DRD_(g_threadinfo)[DRD_N_THREADS]; 92324a23bea57e0bfc27d9442ec00a8eee8294f01abartextern struct bitmap* DRD_(g_conflict_set); 93f00a85bc55a2790c31670dd21e449a335c739068bart 94f00a85bc55a2790c31670dd21e449a335c739068bart 95324a23bea57e0bfc27d9442ec00a8eee8294f01abart/* Function declarations. */ 96af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 9726f73e12ef03bb04ebee5cccd8da08cddb426341bartvoid thread_trace_context_switches(const Bool t); 98e73b0aad62daf8f8288598d69e82bc4850647dc4bartvoid thread_trace_conflict_set(const Bool t); 9909dc13f324a19f1bebf58c7f197a581dc8fb528bbartBool DRD_(thread_get_trace_fork_join)(void); 10009dc13f324a19f1bebf58c7f197a581dc8fb528bbartvoid DRD_(thread_set_trace_fork_join)(const Bool t); 101a9c37398e4565280266ce663a6c38c3518af2812bartvoid thread_set_segment_merging(const Bool m); 102af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 103af44c8236f7a73e71b16b707bba56f33af4d01cesewardjDrdThreadId VgThreadIdToDrdThreadId(const ThreadId tid); 104af44c8236f7a73e71b16b707bba56f33af4d01cesewardjDrdThreadId NewVgThreadIdToDrdThreadId(const ThreadId tid); 105af44c8236f7a73e71b16b707bba56f33af4d01cesewardjDrdThreadId PtThreadIdToDrdThreadId(const PThreadId tid); 106af44c8236f7a73e71b16b707bba56f33af4d01cesewardjThreadId DrdThreadIdToVgThreadId(const DrdThreadId tid); 107af44c8236f7a73e71b16b707bba56f33af4d01cesewardjDrdThreadId thread_pre_create(const DrdThreadId creator, 108af44c8236f7a73e71b16b707bba56f33af4d01cesewardj const ThreadId vg_created); 109af44c8236f7a73e71b16b707bba56f33af4d01cesewardjDrdThreadId thread_post_create(const ThreadId vg_created); 11009dc13f324a19f1bebf58c7f197a581dc8fb528bbartvoid DRD_(thread_post_join)(DrdThreadId drd_joiner, DrdThreadId drd_joinee); 111af44c8236f7a73e71b16b707bba56f33af4d01cesewardjvoid thread_delete(const DrdThreadId tid); 112af44c8236f7a73e71b16b707bba56f33af4d01cesewardjvoid thread_finished(const DrdThreadId tid); 113af0691b41efd73639efbeaddf9c6238a77089f77bartvoid thread_pre_cancel(const DrdThreadId tid); 114af44c8236f7a73e71b16b707bba56f33af4d01cesewardjvoid thread_set_stack_startup(const DrdThreadId tid, const Addr stack_startup); 115af44c8236f7a73e71b16b707bba56f33af4d01cesewardjAddr thread_get_stack_min(const DrdThreadId tid); 116cac5346ef470359941b12d879608e5f3386b44febartAddr thread_get_stack_min_min(const DrdThreadId tid); 117d43f8d3d9f5b2b2096c19d732d98c4382c53da4bbartAddr thread_get_stack_max(const DrdThreadId tid); 118cac5346ef470359941b12d879608e5f3386b44febartSizeT thread_get_stack_size(const DrdThreadId tid); 119af44c8236f7a73e71b16b707bba56f33af4d01cesewardjvoid thread_set_pthreadid(const DrdThreadId tid, const PThreadId ptid); 120af44c8236f7a73e71b16b707bba56f33af4d01cesewardjBool thread_get_joinable(const DrdThreadId tid); 121af44c8236f7a73e71b16b707bba56f33af4d01cesewardjvoid thread_set_joinable(const DrdThreadId tid, const Bool joinable); 1228b09d4f037c6399658b610228c7bbc0c6133d9dasewardjvoid thread_set_vg_running_tid(const ThreadId vg_tid); 1238b09d4f037c6399658b610228c7bbc0c6133d9dasewardjvoid thread_set_running_tid(const ThreadId vg_tid, 1248b09d4f037c6399658b610228c7bbc0c6133d9dasewardj const DrdThreadId drd_tid); 1250268dfacec38138a01a58d05a038826e26b6c436bartint thread_enter_synchr(const DrdThreadId tid); 1260268dfacec38138a01a58d05a038826e26b6c436bartint thread_leave_synchr(const DrdThreadId tid); 1270268dfacec38138a01a58d05a038826e26b6c436bartint thread_get_synchr_nesting_count(const DrdThreadId tid); 128af44c8236f7a73e71b16b707bba56f33af4d01cesewardjvoid thread_new_segment(const DrdThreadId tid); 129af44c8236f7a73e71b16b707bba56f33af4d01cesewardjVectorClock* thread_get_vc(const DrdThreadId tid); 130a2b6e1bbcc45fcb42ac0441a2e5b4d40c3671ec6bartvoid thread_get_latest_segment(Segment** sg, const DrdThreadId tid); 131af44c8236f7a73e71b16b707bba56f33af4d01cesewardjvoid thread_combine_vc(const DrdThreadId joiner, const DrdThreadId joinee); 132af44c8236f7a73e71b16b707bba56f33af4d01cesewardjvoid thread_combine_vc2(const DrdThreadId tid, const VectorClock* const vc); 133dfbae6e4dd55ec44ade79a92fe70317b8dbefd88bart 134af44c8236f7a73e71b16b707bba56f33af4d01cesewardjvoid thread_stop_using_mem(const Addr a1, const Addr a2); 1350268dfacec38138a01a58d05a038826e26b6c436bartvoid thread_start_recording(const DrdThreadId tid); 1360268dfacec38138a01a58d05a038826e26b6c436bartvoid thread_stop_recording(const DrdThreadId tid); 137af44c8236f7a73e71b16b707bba56f33af4d01cesewardjvoid thread_print_all(void); 138af44c8236f7a73e71b16b707bba56f33af4d01cesewardjvoid thread_report_races(const DrdThreadId tid); 139af44c8236f7a73e71b16b707bba56f33af4d01cesewardjvoid thread_report_races_segment(const DrdThreadId tid, 140af44c8236f7a73e71b16b707bba56f33af4d01cesewardj const Segment* const p); 141af44c8236f7a73e71b16b707bba56f33af4d01cesewardjvoid thread_report_all_races(void); 142af44c8236f7a73e71b16b707bba56f33af4d01cesewardjvoid thread_report_conflicting_segments(const DrdThreadId tid, 143af44c8236f7a73e71b16b707bba56f33af4d01cesewardj const Addr addr, 144af44c8236f7a73e71b16b707bba56f33af4d01cesewardj const SizeT size, 145af44c8236f7a73e71b16b707bba56f33af4d01cesewardj const BmAccessTypeT access_type); 146af44c8236f7a73e71b16b707bba56f33af4d01cesewardjULong thread_get_context_switch_count(void); 147af44c8236f7a73e71b16b707bba56f33af4d01cesewardjULong thread_get_report_races_count(void); 148af44c8236f7a73e71b16b707bba56f33af4d01cesewardjULong thread_get_discard_ordered_segments_count(void); 149e73b0aad62daf8f8288598d69e82bc4850647dc4bartULong thread_get_update_conflict_set_count(ULong* dsnsc, ULong* dscvc); 150e73b0aad62daf8f8288598d69e82bc4850647dc4bartULong thread_get_conflict_set_bitmap_creation_count(void); 151e73b0aad62daf8f8288598d69e82bc4850647dc4bartULong thread_get_conflict_set_bitmap2_creation_count(void); 152af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 153af44c8236f7a73e71b16b707bba56f33af4d01cesewardj 154324a23bea57e0bfc27d9442ec00a8eee8294f01abart/* Inline function definitions. */ 155324a23bea57e0bfc27d9442ec00a8eee8294f01abart 156bf80e12418014298bef23cddea3249dee74e5b96bartstatic __inline__ 157bf80e12418014298bef23cddea3249dee74e5b96bartBool IsValidDrdThreadId(const DrdThreadId tid) 158bf80e12418014298bef23cddea3249dee74e5b96bart{ 159bf80e12418014298bef23cddea3249dee74e5b96bart return (0 <= (int)tid && tid < DRD_N_THREADS && tid != DRD_INVALID_THREADID 160324a23bea57e0bfc27d9442ec00a8eee8294f01abart && ! (DRD_(g_threadinfo)[tid].vg_thread_exists == False 161324a23bea57e0bfc27d9442ec00a8eee8294f01abart && DRD_(g_threadinfo)[tid].posix_thread_exists == False 162324a23bea57e0bfc27d9442ec00a8eee8294f01abart && DRD_(g_threadinfo)[tid].detached_posix_thread == False)); 163bf80e12418014298bef23cddea3249dee74e5b96bart} 164bf80e12418014298bef23cddea3249dee74e5b96bart 165088656233045bfaa98d73a9a83eab0a412bd3f2bbartstatic __inline__ 1661ea5fff9a68ea6d56cb946eb709838bd40562a79bartDrdThreadId thread_get_running_tid(void) 1671ea5fff9a68ea6d56cb946eb709838bd40562a79bart{ 168324a23bea57e0bfc27d9442ec00a8eee8294f01abart tl_assert(DRD_(g_drd_running_tid) != DRD_INVALID_THREADID); 169324a23bea57e0bfc27d9442ec00a8eee8294f01abart return DRD_(g_drd_running_tid); 1701ea5fff9a68ea6d56cb946eb709838bd40562a79bart} 1711ea5fff9a68ea6d56cb946eb709838bd40562a79bart 172088656233045bfaa98d73a9a83eab0a412bd3f2bbartstatic __inline__ 173e73b0aad62daf8f8288598d69e82bc4850647dc4bartstruct bitmap* thread_get_conflict_set(void) 1741a473c757cae99f11477440d5473be6e5c95e0cebart{ 175324a23bea57e0bfc27d9442ec00a8eee8294f01abart return DRD_(g_conflict_set); 1761a473c757cae99f11477440d5473be6e5c95e0cebart} 1771a473c757cae99f11477440d5473be6e5c95e0cebart 178088656233045bfaa98d73a9a83eab0a412bd3f2bbartstatic __inline__ 179f00a85bc55a2790c31670dd21e449a335c739068bartBool running_thread_is_recording(void) 180f00a85bc55a2790c31670dd21e449a335c739068bart{ 1818b4b2eee19af852047cafd270c48c09d8adea33fbart#ifdef ENABLE_DRD_CONSISTENCY_CHECKS 182324a23bea57e0bfc27d9442ec00a8eee8294f01abart tl_assert(0 <= (int)DRD_(g_drd_running_tid) && DRD_(g_drd_running_tid) < DRD_N_THREADS 183324a23bea57e0bfc27d9442ec00a8eee8294f01abart && DRD_(g_drd_running_tid) != DRD_INVALID_THREADID); 184589f9487830f84b24108bed90b4d71c392640dc9bart#endif 185324a23bea57e0bfc27d9442ec00a8eee8294f01abart return (DRD_(g_threadinfo)[DRD_(g_drd_running_tid)].synchr_nesting == 0 186324a23bea57e0bfc27d9442ec00a8eee8294f01abart && DRD_(g_threadinfo)[DRD_(g_drd_running_tid)].is_recording); 1871a473c757cae99f11477440d5473be6e5c95e0cebart} 1881a473c757cae99f11477440d5473be6e5c95e0cebart 189088656233045bfaa98d73a9a83eab0a412bd3f2bbartstatic __inline__ 1901ea5fff9a68ea6d56cb946eb709838bd40562a79bartvoid thread_set_stack_min(const DrdThreadId tid, const Addr stack_min) 1911ea5fff9a68ea6d56cb946eb709838bd40562a79bart{ 1928b4b2eee19af852047cafd270c48c09d8adea33fbart#ifdef ENABLE_DRD_CONSISTENCY_CHECKS 193f0cdc606f274069652b956e4852da270b2f3dd6abart tl_assert(0 <= (int)tid 194f0cdc606f274069652b956e4852da270b2f3dd6abart && tid < DRD_N_THREADS 195f0cdc606f274069652b956e4852da270b2f3dd6abart && tid != DRD_INVALID_THREADID); 1961ea5fff9a68ea6d56cb946eb709838bd40562a79bart#endif 197324a23bea57e0bfc27d9442ec00a8eee8294f01abart DRD_(g_threadinfo)[tid].stack_min = stack_min; 1988b4b2eee19af852047cafd270c48c09d8adea33fbart#ifdef ENABLE_DRD_CONSISTENCY_CHECKS 199fda6492f6b5c2c91fd7b46e94bb696adca553c81bart /* This function can be called after the thread has been created but */ 200fda6492f6b5c2c91fd7b46e94bb696adca553c81bart /* before drd_post_thread_create() has filled in stack_max. */ 201324a23bea57e0bfc27d9442ec00a8eee8294f01abart tl_assert(DRD_(g_threadinfo)[tid].stack_min < DRD_(g_threadinfo)[tid].stack_max 202324a23bea57e0bfc27d9442ec00a8eee8294f01abart || DRD_(g_threadinfo)[tid].stack_max == 0); 2031ea5fff9a68ea6d56cb946eb709838bd40562a79bart#endif 204324a23bea57e0bfc27d9442ec00a8eee8294f01abart if (UNLIKELY(stack_min < DRD_(g_threadinfo)[tid].stack_min_min)) 205e773de4785187ef787703968b13cdf76b4721cb7bart { 206324a23bea57e0bfc27d9442ec00a8eee8294f01abart DRD_(g_threadinfo)[tid].stack_min_min = stack_min; 2071ea5fff9a68ea6d56cb946eb709838bd40562a79bart } 2081ea5fff9a68ea6d56cb946eb709838bd40562a79bart} 2091ea5fff9a68ea6d56cb946eb709838bd40562a79bart 210324a23bea57e0bfc27d9442ec00a8eee8294f01abart/** 211324a23bea57e0bfc27d9442ec00a8eee8294f01abart * Return true if and only if the specified address is on the stack of the 212324a23bea57e0bfc27d9442ec00a8eee8294f01abart * currently scheduled thread. 213088656233045bfaa98d73a9a83eab0a412bd3f2bbart */ 214088656233045bfaa98d73a9a83eab0a412bd3f2bbartstatic __inline__ 215088656233045bfaa98d73a9a83eab0a412bd3f2bbartBool thread_address_on_stack(const Addr a) 216088656233045bfaa98d73a9a83eab0a412bd3f2bbart{ 217324a23bea57e0bfc27d9442ec00a8eee8294f01abart return (DRD_(g_threadinfo)[DRD_(g_drd_running_tid)].stack_min <= a 218324a23bea57e0bfc27d9442ec00a8eee8294f01abart && a < DRD_(g_threadinfo)[DRD_(g_drd_running_tid)].stack_max); 219088656233045bfaa98d73a9a83eab0a412bd3f2bbart} 220088656233045bfaa98d73a9a83eab0a412bd3f2bbart 2211a473c757cae99f11477440d5473be6e5c95e0cebart/** Return a pointer to the latest segment for the specified thread. */ 222088656233045bfaa98d73a9a83eab0a412bd3f2bbartstatic __inline__ 2231a473c757cae99f11477440d5473be6e5c95e0cebartSegment* thread_get_segment(const DrdThreadId tid) 2241a473c757cae99f11477440d5473be6e5c95e0cebart{ 2258b4b2eee19af852047cafd270c48c09d8adea33fbart#ifdef ENABLE_DRD_CONSISTENCY_CHECKS 22674a5f21b1495a9e28c648b179b821ffb23484244bart tl_assert(0 <= (int)tid && tid < DRD_N_THREADS 2271a473c757cae99f11477440d5473be6e5c95e0cebart && tid != DRD_INVALID_THREADID); 228324a23bea57e0bfc27d9442ec00a8eee8294f01abart tl_assert(DRD_(g_threadinfo)[tid].last); 229589f9487830f84b24108bed90b4d71c392640dc9bart#endif 230324a23bea57e0bfc27d9442ec00a8eee8294f01abart return DRD_(g_threadinfo)[tid].last; 231f00a85bc55a2790c31670dd21e449a335c739068bart} 232f00a85bc55a2790c31670dd21e449a335c739068bart 233a79df6ed701ed416ba6241e5b0dd95fae8fa35f9bart/** Return a pointer to the latest segment for the running thread. */ 234088656233045bfaa98d73a9a83eab0a412bd3f2bbartstatic __inline__ 235a79df6ed701ed416ba6241e5b0dd95fae8fa35f9bartSegment* running_thread_get_segment(void) 236a79df6ed701ed416ba6241e5b0dd95fae8fa35f9bart{ 237324a23bea57e0bfc27d9442ec00a8eee8294f01abart return thread_get_segment(DRD_(g_drd_running_tid)); 238a79df6ed701ed416ba6241e5b0dd95fae8fa35f9bart} 239f00a85bc55a2790c31670dd21e449a335c739068bart 240af44c8236f7a73e71b16b707bba56f33af4d01cesewardj#endif // __THREAD_H 241