<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt"><br><br><div class="gmail_quote">On Fri, Dec 7, 2012 at 8:23 PM, Dmitry Vyukov <span dir="ltr"><<a href="mailto:dvyukov@google.com" target="_blank">dvyukov@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Please check lint before committing and remove debug output from<br>
SanitizerCommon.SanitizerSetThreadName test.<br></blockquote><div>done, sorry. r169620.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Also, can we do something with allocator tests? Tsan tests were<br>
running for 1.5sec, not they run for 30sec and 29 are occupied by<br>
allocator tests. Are we are testing in 4 configurations.<br></blockquote><div><br></div><div>I am not seeing this: </div><div><div>% ./projects/compiler-rt/lib/sanitizer_common/tests/Release/SanitizerUnitTest</div></div>
<div>[==========] 39 tests from 3 test cases ran. (4924 ms total)</div><div><br></div><div>If we reduce the load in the tests we will not be catching corner cases that only appear under a load. </div><div><br></div><div>When you run 'make -j32 check-sanitizer', gtest is called in sharded mode, so effectively the running time is less than 1 second. </div>
<div><br></div><div>I guess, we are also running the allocator tests inside the tsan tests (do we?), which would be wrong anyway. </div><div><br></div><div>--kcc </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On Fri, Dec 7, 2012 at 3:27 PM, Kostya Serebryany <<a href="mailto:kcc@google.com">kcc@google.com</a>> wrote:<br>
> Author: kcc<br>
> Date: Fri Dec 7 05:27:24 2012<br>
> New Revision: 169598<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=169598&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=169598&view=rev</a><br>
> Log:<br>
> [sanitizer] implement SanitizerSetThreadName/SanitizerGetThreadName. Just for linux so far (using prctl(PR_GET_NAME))<br>
><br>
> Modified:<br>
> compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h<br>
> compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc<br>
> compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc<br>
><br>
> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h?rev=169598&r1=169597&r2=169598&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h?rev=169598&r1=169597&r2=169598&view=diff</a><br>
> ==============================================================================<br>
> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h (original)<br>
> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common.h Fri Dec 7 05:27:24 2012<br>
> @@ -137,6 +137,13 @@<br>
> void NORETURN SANITIZER_INTERFACE_ATTRIBUTE<br>
> CheckFailed(const char *file, int line, const char *cond, u64 v1, u64 v2);<br>
><br>
> +// Set the name of the current thread to 'name', return true on succees.<br>
> +// The name may be truncated to a system-dependent limit.<br>
> +bool SanitizerSetThreadName(const char *name);<br>
> +// Get the name of the current thread (no more than max_len bytes),<br>
> +// return true on succees. name should have space for at least max_len+1 bytes.<br>
> +bool SanitizerGetThreadName(char *name, int max_len);<br>
> +<br>
> // Specific tools may override behavior of "Die" and "CheckFailed" functions<br>
> // to do tool-specific job.<br>
> void SetDieCallback(void (*callback)(void));<br>
><br>
> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc?rev=169598&r1=169597&r2=169598&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc?rev=169598&r1=169597&r2=169598&view=diff</a><br>
> ==============================================================================<br>
> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc (original)<br>
> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc Fri Dec 7 05:27:24 2012<br>
> @@ -31,6 +31,7 @@<br>
> #include <sys/types.h><br>
> #include <unistd.h><br>
> #include <errno.h><br>
> +#include <sys/prctl.h><br>
><br>
> // Are we using 32-bit or 64-bit syscalls?<br>
> // x32 (which defines __x86_64__) has SANITIZER_WORDSIZE == 32<br>
> @@ -356,6 +357,19 @@<br>
> return IterateForObjectNameAndOffset(addr, offset, filename, filename_size);<br>
> }<br>
><br>
> +bool SanitizerSetThreadName(const char *name) {<br>
> + return 0 == prctl(PR_SET_NAME, (unsigned long)name, 0, 0, 0);<br>
> +}<br>
> +<br>
> +bool SanitizerGetThreadName(char *name, int max_len) {<br>
> + char buff[17];<br>
> + if (prctl(PR_GET_NAME, (unsigned long)buff, 0, 0, 0))<br>
> + return false;<br>
> + internal_strncpy(name, buff, max_len);<br>
> + name[max_len] = 0;<br>
> + return true;<br>
> +}<br>
> +<br>
> } // namespace __sanitizer<br>
><br>
> #endif // __linux__<br>
><br>
> Modified: compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc?rev=169598&r1=169597&r2=169598&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc?rev=169598&r1=169597&r2=169598&view=diff</a><br>
> ==============================================================================<br>
> --- compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc (original)<br>
> +++ compiler-rt/trunk/lib/sanitizer_common/tests/sanitizer_common_test.cc Fri Dec 7 05:27:24 2012<br>
> @@ -11,6 +11,7 @@<br>
> //<br>
> //===----------------------------------------------------------------------===//<br>
> #include "sanitizer_common/sanitizer_common.h"<br>
> +#include "sanitizer_common/sanitizer_libc.h"<br>
> #include "gtest/gtest.h"<br>
><br>
> namespace __sanitizer {<br>
> @@ -78,4 +79,22 @@<br>
> }<br>
> }<br>
><br>
> +#ifdef __linux__<br>
> +TEST(SanitizerCommon, SanitizerSetThreadName) {<br>
> + const char *names[] = {<br>
> + "0123456789012",<br>
> + "01234567890123",<br>
> + "012345678901234", // Larger names will be truncated on linux.<br>
> + };<br>
> +<br>
> + for (size_t i = 0; i < ARRAY_SIZE(names); i++) {<br>
> + EXPECT_TRUE(SanitizerSetThreadName(names[i]));<br>
> + char buff[100];<br>
> + EXPECT_TRUE(SanitizerGetThreadName(buff, sizeof(buff) - 1));<br>
> + Printf("buff: %s\n", buff);<br>
> + EXPECT_EQ(0, internal_strcmp(buff, names[i]));<br>
> + }<br>
> +}<br>
> +#endif<br>
> +<br>
> } // namespace sanitizer<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div>