]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Give some more information in the scheduler information thread status
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Fri, 27 Jul 2018 22:36:35 +0000 (00:36 +0200)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Fri, 27 Jul 2018 22:36:35 +0000 (00:36 +0200)
* In case a thread is executing a syscall, give the syscall no being
  executed.
* Show the address range of the valgrind stack, similarly to the client
  stack

coregrind/m_libcassert.c
coregrind/m_syswrap/syswrap-main.c
coregrind/pub_core_syswrap.h

index a75a650140c28c280a8e892116d25320648de9b3..5afe1ce275b39bea5d74c0e2b0c8fd6f6b8a6e17 100644 (file)
@@ -42,6 +42,7 @@
 #include "pub_core_stacks.h"
 #include "pub_core_stacktrace.h"
 #include "pub_core_syscall.h"
+#include "pub_core_syswrap.h"
 #include "pub_core_tooliface.h"     // For VG_(details).{name,bug_reports_to}
 #include "pub_core_options.h"       // For VG_(clo_xml)
 
@@ -298,17 +299,25 @@ void VG_(client_exit)( Int status )
 static void print_thread_state (Bool stack_usage,
                                 const HChar* prefix, ThreadId i)
 {
-   VgStack *stack 
+   VgStack *stack
       = (VgStack*)VG_(threads)[i].os_state.valgrind_stack_base;
-
-   VG_(printf)("\n%sThread %d: status = %s (lwpid %d)\n", prefix, i, 
+   HChar syscallno[50];
+   // must be large enough for VG_SYSNUM_STRING result + 10.
+
+   if (VG_(is_in_syscall) (i))
+      VG_(sprintf)(syscallno, " syscall %s",
+                   VG_SYSNUM_STRING(VG_(is_in_syscall_no)(i)));
+   else
+      syscallno[0] = 0;
+   VG_(printf)("\n%sThread %d: status = %s%s (lwpid %d)\n", prefix, i,
                VG_(name_of_ThreadStatus)(VG_(threads)[i].status),
+               syscallno,
                VG_(threads)[i].os_state.lwpid);
    if (VG_(threads)[i].status != VgTs_Empty)
       VG_(get_and_pp_StackTrace)( i, BACKTRACE_DEPTH );
    if (stack_usage && VG_(threads)[i].client_stack_highest_byte != 0 ) {
       Addr start, end;
-      
+
       start = end = 0;
       VG_(stack_limits)(VG_(get_SP)(i), &start, &end);
       if (start != end)
@@ -322,8 +331,9 @@ static void print_thread_state (Bool stack_usage,
    }
    if (stack_usage && stack != 0)
       VG_(printf)
-         ("%svalgrind stack top usage: %lu of %lu\n",
+         ("%svalgrind stack range: [%p %p] top usage: %lu of %lu\n",
           prefix,
+          (void*)stack, (void*)((Addr)stack + VG_(clo_valgrind_stacksize) - 1),
           VG_(clo_valgrind_stacksize)
           - VG_(am_get_VgStack_unused_szB) (stack,
                                             VG_(clo_valgrind_stacksize)),
index acee5b5e24608411d087de9ff05004ab0a8064d5..a2876c5fb1d8586da12b5dbdbb51b794496a3bb3 100644 (file)
@@ -1628,7 +1628,7 @@ SyscallInfo *syscallInfo;
 
 /* The scheduler needs to be able to zero out these records after a
    fork, hence this is exported from m_syswrap. */
-void VG_(clear_syscallInfo) ( Int tid )
+void VG_(clear_syscallInfo) ( ThreadId tid )
 {
    vg_assert(syscallInfo);
    vg_assert(tid >= 0 && tid < VG_N_THREADS);
@@ -1636,12 +1636,18 @@ void VG_(clear_syscallInfo) ( Int tid )
    syscallInfo[tid].status.what = SsIdle;
 }
 
-Bool VG_(is_in_syscall) ( Int tid )
+Bool VG_(is_in_syscall) ( ThreadId tid )
 {
    vg_assert(tid >= 0 && tid < VG_N_THREADS);
    return (syscallInfo[tid].status.what != SsIdle);
 }
 
+Word VG_(is_in_syscall_no) (ThreadId tid )
+{
+   vg_assert(tid >= 0 && tid < VG_N_THREADS);
+   return syscallInfo[tid].orig_args.sysno;
+}
+
 static void ensure_initialised ( void )
 {
    Int i;
index e8ba00561c38483344fabda5c64093ccd2ba316b..4e73c073a4023b94bc0c13d7f56387b63a15dc32 100644 (file)
@@ -49,10 +49,13 @@ extern void VG_(client_syscall) ( ThreadId tid, UInt trc );
 extern void VG_(post_syscall)   ( ThreadId tid );
 
 /* Clear this module's private state for thread 'tid' */
-extern void VG_(clear_syscallInfo) ( Int tid );
+extern void VG_(clear_syscallInfo) ( ThreadId tid );
 
 // Returns True if the given thread is currently in a system call
-extern Bool VG_(is_in_syscall) ( Int tid );
+extern Bool VG_(is_in_syscall) ( ThreadId tid );
+
+// If VG_(is_in_syscall) (tid), returns the sysno the given thread is in
+extern Word VG_(is_in_syscall_no) (ThreadId tid );
 
 // Fix up a thread's state when syscall is interrupted by a signal.
 extern void VG_(fixup_guest_state_after_syscall_interrupted)(