]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix wrong stack range output by commit 7daa08611 (more info in scheduler state)
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Mon, 30 Jul 2018 20:28:48 +0000 (22:28 +0200)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Mon, 30 Jul 2018 20:56:31 +0000 (22:56 +0200)
The stack base starts at the beginning of the protection page/zone,
so we need to add VG_STACK_GUARD_SZB to get the real lowest usable
byte.
As the VgStack is an opaque type, add a function in aspacemgr to
return the Addr of the first lowest usable byte.

coregrind/m_aspacemgr/aspacemgr-common.c
coregrind/m_libcassert.c
coregrind/pub_core_aspacemgr.h

index bbfe19d5e1af520f49dbe2bb341cf0e006b4f692..95c8dd3db36ecb6ebddbc658ea31ced3dd708a49 100644 (file)
@@ -505,6 +505,10 @@ SizeT VG_(am_get_VgStack_unused_szB)( const VgStack* stack, SizeT limit )
    return i * sizeof(UInt);
 }
 
+Addr VG_(am_valgrind_stack_low_addr)( const VgStack* stack)
+{
+   return (Addr)&stack->bytes[VG_STACK_GUARD_SZB];
+}
 
 /*--------------------------------------------------------------------*/
 /*--- end                                                          ---*/
index 5afe1ce275b39bea5d74c0e2b0c8fd6f6b8a6e17..2792f6da2432d09a8dabca5f5beaf99f272a477d 100644 (file)
@@ -329,15 +329,19 @@ static void print_thread_state (Bool stack_usage,
                      prefix,
                      (void*)VG_(get_SP)(i));
    }
-   if (stack_usage && stack != 0)
+   if (stack_usage && stack != 0) {
+      Addr stack_low_addr = VG_(am_valgrind_stack_low_addr) (stack);
+
       VG_(printf)
          ("%svalgrind stack range: [%p %p] top usage: %lu of %lu\n",
           prefix,
-          (void*)stack, (void*)((Addr)stack + VG_(clo_valgrind_stacksize) - 1),
+          (void*)stack_low_addr,
+          (void*)((Addr)stack_low_addr + VG_(clo_valgrind_stacksize) - 1),
           VG_(clo_valgrind_stacksize)
           - VG_(am_get_VgStack_unused_szB) (stack,
                                             VG_(clo_valgrind_stacksize)),
           (SizeT) VG_(clo_valgrind_stacksize));
+   }
 }
 
 // Print the scheduler status.
index 67ec52825eb55dce9c6b5f441d04c91b63fdca66..2d80119c4c3ff9092d91e649591ce1bfd23cf959 100644 (file)
@@ -361,6 +361,9 @@ extern VgStack* VG_(am_alloc_VgStack)( /*OUT*/Addr* initial_sp );
 extern SizeT VG_(am_get_VgStack_unused_szB)( const VgStack* stack,
                                              SizeT limit ); 
 
+/* Returns the Addr of the lowest usable byte of stack. */
+extern Addr VG_(am_valgrind_stack_low_addr)( const VgStack* stack);
+
 // DDD: this is ugly
 #if defined(VGO_darwin)
 typedef