|
From: Matthias S. <zz...@ge...> - 2015-07-30 20:53:23
|
---
coregrind/m_scheduler/scheduler.c | 8 +++++++-
docs/internals/xml-output-protocol4.txt | 6 ++++++
memcheck/tests/client-msg-as-xml.stderr.exp | 1 +
memcheck/tests/threadname.c | 3 ++-
memcheck/tests/threadname.stderr.exp | 13 +++++++------
memcheck/tests/threadname_xml.stderr.exp | 7 +++++++
6 files changed, 30 insertions(+), 8 deletions(-)
diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c
index 62906ca..429d745 100644
--- a/coregrind/m_scheduler/scheduler.c
+++ b/coregrind/m_scheduler/scheduler.c
@@ -1814,6 +1814,10 @@ Int print_client_message( ThreadId tid, const HChar *format,
VG_(printf_xml)( "<clientmsg>\n" );
VG_(printf_xml)( " <tid>%d</tid>\n", tid );
+ 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" );
@@ -1825,8 +1829,10 @@ Int print_client_message( ThreadId tid, const HChar *format,
if (include_backtrace)
VG_(get_and_pp_StackTrace)( tid, VG_(clo_backtrace_size) );
- if (VG_(clo_xml))
+ if (VG_(clo_xml)) {
VG_(printf_xml)( "</clientmsg>\n" );
+ VG_(printf_xml)("\n");
+ }
return count;
}
diff --git a/docs/internals/xml-output-protocol4.txt b/docs/internals/xml-output-protocol4.txt
index a147eaa..ccb22b4 100644
--- a/docs/internals/xml-output-protocol4.txt
+++ b/docs/internals/xml-output-protocol4.txt
@@ -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).
diff --git a/memcheck/tests/client-msg-as-xml.stderr.exp b/memcheck/tests/client-msg-as-xml.stderr.exp
index af97c61..d7031cf 100644
--- a/memcheck/tests/client-msg-as-xml.stderr.exp
+++ b/memcheck/tests/client-msg-as-xml.stderr.exp
@@ -76,6 +76,7 @@
</stack>
</clientmsg>
+
<status>
<state>FINISHED</state>
<time>...</time>
diff --git a/memcheck/tests/threadname.c b/memcheck/tests/threadname.c
index c0e0b47..d3f6e44 100644
--- a/memcheck/tests/threadname.c
+++ b/memcheck/tests/threadname.c
@@ -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);
diff --git a/memcheck/tests/threadname.stderr.exp b/memcheck/tests/threadname.stderr.exp
index 3321af7..60903ee 100644
--- a/memcheck/tests/threadname.stderr.exp
+++ b/memcheck/tests/threadname.stderr.exp
@@ -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)
diff --git a/memcheck/tests/threadname_xml.stderr.exp b/memcheck/tests/threadname_xml.stderr.exp
index 067b2ff..d6a0a2d 100644
--- a/memcheck/tests/threadname_xml.stderr.exp
+++ b/memcheck/tests/threadname_xml.stderr.exp
@@ -185,6 +185,13 @@
</stack>
</error>
+<clientmsg>
+ <tid>...</tid>
+ <threadname>try1</threadname>
+ <text>I am in child_fn_1
+ </text>
+</clientmsg>
+
<error>
<unique>0x........</unique>
<tid>...</tid>
--
2.5.0
|
|
From: Florian K. <fl...@ei...> - 2015-07-30 21:50:59
|
Thanks for the patch. Applied in r15460 with minor modifications.
Florian
On 30.07.2015 22:52, Matthias Schwarzott wrote:
> ---
> coregrind/m_scheduler/scheduler.c | 8 +++++++-
> docs/internals/xml-output-protocol4.txt | 6 ++++++
> memcheck/tests/client-msg-as-xml.stderr.exp | 1 +
> memcheck/tests/threadname.c | 3 ++-
> memcheck/tests/threadname.stderr.exp | 13 +++++++------
> memcheck/tests/threadname_xml.stderr.exp | 7 +++++++
> 6 files changed, 30 insertions(+), 8 deletions(-)
>
> diff --git a/coregrind/m_scheduler/scheduler.c b/coregrind/m_scheduler/scheduler.c
> index 62906ca..429d745 100644
> --- a/coregrind/m_scheduler/scheduler.c
> +++ b/coregrind/m_scheduler/scheduler.c
> @@ -1814,6 +1814,10 @@ Int print_client_message( ThreadId tid, const HChar *format,
>
> VG_(printf_xml)( "<clientmsg>\n" );
> VG_(printf_xml)( " <tid>%d</tid>\n", tid );
> + 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" );
> @@ -1825,8 +1829,10 @@ Int print_client_message( ThreadId tid, const HChar *format,
> if (include_backtrace)
> VG_(get_and_pp_StackTrace)( tid, VG_(clo_backtrace_size) );
>
> - if (VG_(clo_xml))
> + if (VG_(clo_xml)) {
> VG_(printf_xml)( "</clientmsg>\n" );
> + VG_(printf_xml)("\n");
> + }
>
> return count;
> }
> diff --git a/docs/internals/xml-output-protocol4.txt b/docs/internals/xml-output-protocol4.txt
> index a147eaa..ccb22b4 100644
> --- a/docs/internals/xml-output-protocol4.txt
> +++ b/docs/internals/xml-output-protocol4.txt
> @@ -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).
>
> diff --git a/memcheck/tests/client-msg-as-xml.stderr.exp b/memcheck/tests/client-msg-as-xml.stderr.exp
> index af97c61..d7031cf 100644
> --- a/memcheck/tests/client-msg-as-xml.stderr.exp
> +++ b/memcheck/tests/client-msg-as-xml.stderr.exp
> @@ -76,6 +76,7 @@
> </stack>
> </clientmsg>
>
> +
> <status>
> <state>FINISHED</state>
> <time>...</time>
> diff --git a/memcheck/tests/threadname.c b/memcheck/tests/threadname.c
> index c0e0b47..d3f6e44 100644
> --- a/memcheck/tests/threadname.c
> +++ b/memcheck/tests/threadname.c
> @@ -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);
> diff --git a/memcheck/tests/threadname.stderr.exp b/memcheck/tests/threadname.stderr.exp
> index 3321af7..60903ee 100644
> --- a/memcheck/tests/threadname.stderr.exp
> +++ b/memcheck/tests/threadname.stderr.exp
> @@ -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)
>
> diff --git a/memcheck/tests/threadname_xml.stderr.exp b/memcheck/tests/threadname_xml.stderr.exp
> index 067b2ff..d6a0a2d 100644
> --- a/memcheck/tests/threadname_xml.stderr.exp
> +++ b/memcheck/tests/threadname_xml.stderr.exp
> @@ -185,6 +185,13 @@
> </stack>
> </error>
>
> +<clientmsg>
> + <tid>...</tid>
> + <threadname>try1</threadname>
> + <text>I am in child_fn_1
> + </text>
> +</clientmsg>
> +
> <error>
> <unique>0x........</unique>
> <tid>...</tid>
>
|