From 6a83143650aeb02e9c53bd5f7b7b5253a6c8b157 Mon Sep 17 00:00:00 2001 From: Kuba Brecka Date: Wed, 23 Mar 2016 15:36:22 +0000 Subject: Add ThreadSanitizer debugging support. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds ThreadSanitizer support into LLDB: - Adding a new InstrumentationRuntime plugin, ThreadSanitizerRuntime, in the same way ASan is implemented. - A breakpoint stops in `__tsan_on_report`, then we extract all sorts of information by evaluating an expression. We then populate this into StopReasonExtendedInfo. - SBThread gets a new API, SBThread::GetStopReasonExtendedBacktraces(), which returns TSan’s backtraces in the form of regular SBThreads. Non-TSan stop reasons return an empty collection. - Added some test cases. Reviewed by Greg Clayton. llvm-svn: 264162 --- .../test/functionalities/tsan/basic/main.c | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 lldb/packages/Python/lldbsuite/test/functionalities/tsan/basic/main.c (limited to 'lldb/packages/Python/lldbsuite/test/functionalities/tsan/basic/main.c') diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/tsan/basic/main.c b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/basic/main.c new file mode 100644 index 00000000000..c082b01a57c --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/functionalities/tsan/basic/main.c @@ -0,0 +1,37 @@ +//===-- main.c --------------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#include +#include +#include + +char *pointer; + +void *f1(void *p) { + pointer[0] = 'x'; // thread1 line + return NULL; +} + +void *f2(void *p) { + pointer[0] = 'y'; // thread2 line + return NULL; +} + +int main (int argc, char const *argv[]) +{ + pointer = (char *)malloc(10); // malloc line + + pthread_t t1, t2; + pthread_create(&t1, NULL, f1, NULL); + pthread_create(&t2, NULL, f2, NULL); + + pthread_join(t1, NULL); + pthread_join(t2, NULL); + + return 0; +} -- cgit v1.2.3