]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Added thread_get_stack_size() and thread_get_stack_min_min().
authorBart Van Assche <bvanassche@acm.org>
Sat, 29 Mar 2008 09:27:08 +0000 (09:27 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sat, 29 Mar 2008 09:27:08 +0000 (09:27 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7800

exp-drd/drd_thread.c
exp-drd/drd_thread.h

index 001fd4d810502e17070c885c54090a680c67aad8..55bf0fd11401b58538fe4effba5b3d50b2e6e09e 100644 (file)
@@ -127,6 +127,7 @@ DrdThreadId VgThreadIdToNewDrdThreadId(const ThreadId tid)
       s_threadinfo[i].vg_threadid   = tid;
       s_threadinfo[i].pt_threadid   = INVALID_POSIX_THREADID;
       s_threadinfo[i].stack_min     = 0;
+      s_threadinfo[i].stack_min_min = 0;
       s_threadinfo[i].stack_startup = 0;
       s_threadinfo[i].stack_max     = 0;
       s_threadinfo[i].is_recording  = True;
@@ -221,6 +222,8 @@ DrdThreadId thread_post_create(const ThreadId vg_created)
   s_threadinfo[created].stack_max     = VG_(thread_get_stack_max)(vg_created);
   s_threadinfo[created].stack_startup = s_threadinfo[created].stack_max;
   s_threadinfo[created].stack_min     = s_threadinfo[created].stack_max;
+  s_threadinfo[created].stack_min_min = s_threadinfo[created].stack_max;
+  s_threadinfo[created].stack_size    = VG_(thread_get_stack_size)(vg_created);
   tl_assert(s_threadinfo[created].stack_max != 0);
 
   return created;
@@ -245,6 +248,13 @@ Addr thread_get_stack_min(const DrdThreadId tid)
   return s_threadinfo[tid].stack_min;
 }
 
+Addr thread_get_stack_min_min(const DrdThreadId tid)
+{
+  tl_assert(0 <= tid && tid < DRD_N_THREADS
+            && tid != DRD_INVALID_THREADID);
+  return s_threadinfo[tid].stack_min_min;
+}
+
 Addr thread_get_stack_max(const DrdThreadId tid)
 {
   tl_assert(0 <= tid && tid < DRD_N_THREADS
@@ -252,6 +262,13 @@ Addr thread_get_stack_max(const DrdThreadId tid)
   return s_threadinfo[tid].stack_max;
 }
 
+SizeT thread_get_stack_size(const DrdThreadId tid)
+{
+  tl_assert(0 <= tid && tid < DRD_N_THREADS
+            && tid != DRD_INVALID_THREADID);
+  return s_threadinfo[tid].stack_size;
+}
+
 /** Clean up thread-specific data structures. Call this just after 
  *  pthread_join().
  */
index bbfbbd8296eb4ccc399e05f00469b163bb6d2266..bffa6a7ec15b8110036b549b490edc3f5f702760 100644 (file)
@@ -60,9 +60,11 @@ typedef struct
   Segment*  last;
   ThreadId  vg_threadid;
   PThreadId pt_threadid;
-  Addr      stack_min;
-  Addr      stack_startup;
-  Addr      stack_max;
+  Addr      stack_min_min; /** Lowest value stack pointer ever had. */
+  Addr      stack_min;     /** Current stack pointer. */
+  Addr      stack_startup; /** Stack pointer after pthread_create() finished.*/
+  Addr      stack_max;     /** Top of stack. */
+  SizeT     stack_size;    /** Maximum size of stack. */
   /// Indicates whether the Valgrind core knows about this thread.
   Bool      vg_thread_exists;
   /// Indicates whether there is an associated POSIX thread ID.
@@ -103,7 +105,9 @@ void thread_delete(const DrdThreadId tid);
 void thread_finished(const DrdThreadId tid);
 void thread_set_stack_startup(const DrdThreadId tid, const Addr stack_startup);
 Addr thread_get_stack_min(const DrdThreadId tid);
+Addr thread_get_stack_min_min(const DrdThreadId tid);
 Addr thread_get_stack_max(const DrdThreadId tid);
+SizeT thread_get_stack_size(const DrdThreadId tid);
 void thread_set_pthreadid(const DrdThreadId tid, const PThreadId ptid);
 Bool thread_get_joinable(const DrdThreadId tid);
 void thread_set_joinable(const DrdThreadId tid, const Bool joinable);
@@ -172,6 +176,10 @@ void thread_set_stack_min(const DrdThreadId tid, const Addr stack_min)
 #if 0
     tl_assert(s_threadinfo[tid].stack_min < s_threadinfo[tid].stack_max);
 #endif
+    if (UNLIKELY(stack_min < s_threadinfo[tid].stack_min_min))
+    {
+      s_threadinfo[tid].stack_min_min = stack_min;
+    }
   }
 }