]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
In VALGRIND_PRINTF write out the thread name to xml.
authorFlorian Krohm <florian@eich-krohm.de>
Thu, 30 Jul 2015 21:49:49 +0000 (21:49 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Thu, 30 Jul 2015 21:49:49 +0000 (21:49 +0000)
Patch by Matthias Schwarzott <zzam@gentoo.org>.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15460

NEWS
coregrind/m_scheduler/scheduler.c
docs/internals/xml-output-protocol4.txt
memcheck/tests/threadname.c
memcheck/tests/threadname.stderr.exp
memcheck/tests/threadname_xml.stderr.exp

diff --git a/NEWS b/NEWS
index 6d95f9583c624073b4eb776baf154bd5c6ab1d66..b3e0eebae9b5fb8ed7e88d3463f3a0dbf10ef20a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -277,6 +277,7 @@ n-i-bz  (vex 3098) Avoid generation of Neon insns on non-Neon hosts
 n-i-bz  Enable rt_sigpending syscall on ppc64 linux.
 n-i-bz  mremap did not work properly on shared memory
 n-i-bz  Fix incorrect sizeof expression in syswrap-xen.c reported by Coverity
+n-i-bz  In VALGRIND_PRINTF write out thread name, if any, to xml
 
 
 Release 3.10.1 (25 November 2014)
index 62906cac3006b8f37c195336373878e171720684..7d0ad0ce435291f40ec8e48922d3f6023baf5a15 100644 (file)
@@ -1814,6 +1814,9 @@ Int print_client_message( ThreadId tid, const HChar *format,
 
       VG_(printf_xml)( "<clientmsg>\n" );
       VG_(printf_xml)( "  <tid>%d</tid>\n", tid );
+      const ThreadState *tst = VG_(get_ThreadState)(tid);
+      if (tst->thread_name)
+         VG_(printf_xml)("  <threadname>%s</threadname>\n", tst->thread_name);
       VG_(printf_xml)( "  <text>" );
       count = VG_(vprintf_xml)( xml_format, *vargsp );
       VG_(printf_xml)( "  </text>\n" );
index a147eaa4cbb7f144148ac18606c8a43502854497..ccb22b44d63bc41bf24dd10ff3ec61e0699b4a01 100644 (file)
@@ -719,6 +719,7 @@ Definition:
 
 <clientmsg>
   <tid>INT</tid>
+  <threadname>NAME</threadname>    if set
   <text>...</text>
 </clientmsg>
 
@@ -726,12 +727,17 @@ OR
 
 <clientmsg>
   <tid>INT</tid>
+  <threadname>NAME</threadname>    if set
   <text>...</text>
   STACK
 </clientmsg>
 
 * The <tid> tag indicates the Valgrind thread number.
 
+* The <threadname> tag identifies the name of the thread if it was
+  set by the client application. If no name was set, the tag is
+  omitted.
+
 * The <text> tag indicates the message as specified in the client request
   (properly translated to XML).
 
index c0e0b47e5f06a524fbfd4c6911ba9c3107e58ca6..d3f6e44491df9c6cb72e894862ea045780a979de 100644 (file)
@@ -11,7 +11,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <assert.h>
-
+#include "valgrind.h"
 
 static pthread_t children[3];
 
@@ -49,6 +49,7 @@ void* child_fn_1 ( void* arg )
 #  endif
 
   bad_things(3);
+  VALGRIND_PRINTF("%s", "I am in child_fn_1\n");
 
   r = pthread_create(&children[2], NULL, child_fn_2, NULL);
   assert(!r);
index 3321af761bb27dac5ccae48b5d78d53292990714..60903eee199d69e9cdb9f1ca07b479fae9c7607c 100644 (file)
@@ -1,20 +1,20 @@
 Invalid write of size 1
    at 0x........: bad_things (threadname.c:21)
-   by 0x........: main (threadname.c:81)
+   by 0x........: main (threadname.c:82)
  Address 0x........ is 0 bytes after a block of size 1 alloc'd
    at 0x........: malloc (vg_replace_malloc.c:...)
    by 0x........: bad_things (threadname.c:20)
-   by 0x........: main (threadname.c:81)
+   by 0x........: main (threadname.c:82)
 
 Thread 2:
 Invalid write of size 1
    at 0x........: bad_things (threadname.c:21)
-   by 0x........: child_fn_0 (threadname.c:66)
+   by 0x........: child_fn_0 (threadname.c:67)
    ...
  Address 0x........ is 0 bytes after a block of size 2 alloc'd
    at 0x........: malloc (vg_replace_malloc.c:...)
    by 0x........: bad_things (threadname.c:20)
-   by 0x........: child_fn_0 (threadname.c:66)
+   by 0x........: child_fn_0 (threadname.c:67)
    ...
 
 Thread 3 try1:
@@ -28,6 +28,7 @@ Invalid write of size 1
    by 0x........: child_fn_1 (threadname.c:51)
    ...
 
+I am in child_fn_1
 Thread 4 012345678901234:
 Invalid write of size 1
    at 0x........: bad_things (threadname.c:21)
@@ -42,9 +43,9 @@ Invalid write of size 1
 Thread 1:
 Invalid write of size 1
    at 0x........: bad_things (threadname.c:21)
-   by 0x........: main (threadname.c:89)
+   by 0x........: main (threadname.c:90)
  Address 0x........ is 0 bytes after a block of size 5 alloc'd
    at 0x........: malloc (vg_replace_malloc.c:...)
    by 0x........: bad_things (threadname.c:20)
-   by 0x........: main (threadname.c:89)
+   by 0x........: main (threadname.c:90)
 
index 067b2ff13bb4ab6e73f80c549d63c4d0693d41e3..3f9e593e2fa3f05ac87875232816c57cd7393d6f 100644 (file)
   </stack>
 </error>
 
+<clientmsg>
+  <tid>...</tid>
+  <threadname>try1</threadname>
+  <text>I am in child_fn_1
+  </text>
+</clientmsg>
 <error>
   <unique>0x........</unique>
   <tid>...</tid>