Added the per-thread property 'on_alt_stack'.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@11326
This commit is contained in:
Bart Van Assche
2010-09-02 14:43:18 +00:00
parent 22ddb6a319
commit f9870efee2
2 changed files with 31 additions and 0 deletions

View File

@@ -181,6 +181,7 @@ static DrdThreadId DRD_(VgThreadIdToNewDrdThreadId)(const ThreadId tid)
DRD_(g_threadinfo)[i].stack_startup = 0;
DRD_(g_threadinfo)[i].stack_max = 0;
DRD_(thread_set_name)(i, "");
DRD_(g_threadinfo)[i].on_alt_stack = False;
DRD_(g_threadinfo)[i].is_recording_loads = True;
DRD_(g_threadinfo)[i].is_recording_stores = True;
DRD_(g_threadinfo)[i].pthread_create_nesting_level = 0;
@@ -420,6 +421,31 @@ SizeT DRD_(thread_get_stack_size)(const DrdThreadId tid)
return DRD_(g_threadinfo)[tid].stack_size;
}
Bool DRD_(thread_get_on_alt_stack)(const DrdThreadId tid)
{
tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
&& tid != DRD_INVALID_THREADID);
return DRD_(g_threadinfo)[tid].on_alt_stack;
}
void DRD_(thread_set_on_alt_stack)(const DrdThreadId tid,
const Bool on_alt_stack)
{
tl_assert(0 <= (int)tid && tid < DRD_N_THREADS
&& tid != DRD_INVALID_THREADID);
tl_assert(on_alt_stack == !!on_alt_stack);
DRD_(g_threadinfo)[tid].on_alt_stack = on_alt_stack;
}
Int DRD_(thread_get_threads_on_alt_stack)(void)
{
int i, n = 0;
for (i = 1; i < DRD_N_THREADS; i++)
n += DRD_(g_threadinfo)[i].on_alt_stack;
return n;
}
/**
* Clean up thread-specific data structures. Call this just after
* pthread_join().

View File

@@ -77,6 +77,7 @@ typedef struct
Addr stack_max; /**< Top of stack. */
SizeT stack_size; /**< Maximum size of stack. */
char name[64]; /**< User-assigned thread name. */
Bool on_alt_stack;
/** Indicates whether the Valgrind core knows about this thread. */
Bool vg_thread_exists;
/** Indicates whether there is an associated POSIX thread ID. */
@@ -142,6 +143,10 @@ Addr DRD_(thread_get_stack_min)(const DrdThreadId tid);
Addr DRD_(thread_get_stack_min_min)(const DrdThreadId tid);
Addr DRD_(thread_get_stack_max)(const DrdThreadId tid);
SizeT DRD_(thread_get_stack_size)(const DrdThreadId tid);
Bool DRD_(thread_get_on_alt_stack)(const DrdThreadId tid);
void DRD_(thread_set_on_alt_stack)(const DrdThreadId tid,
const Bool on_alt_stack);
Int DRD_(thread_get_threads_on_alt_stack)(void);
void DRD_(thread_set_pthreadid)(const DrdThreadId tid, const PThreadId ptid);
Bool DRD_(thread_get_joinable)(const DrdThreadId tid);
void DRD_(thread_set_joinable)(const DrdThreadId tid, const Bool joinable);