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