2 Test ThreadSanitizer when multiple different issues are found.
7 from lldbsuite.test.lldbtest import *
8 from lldbsuite.test.decorators import *
9 import lldbsuite.test.lldbutil as lldbutil
12 class TsanMultipleTestCase(TestBase):
14 mydir = TestBase.compute_mydir(__file__)
16 @expectedFailureAll(oslist=["linux"], bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)")
17 @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default
20 @skipUnlessThreadSanitizer
26 # Call super's setUp().
29 def tsan_tests (self):
30 exe = os.path.join (os.getcwd(), "a.out")
31 self.expect("file " + exe, patterns = [ "Current executable set to .*a.out" ])
33 self.runCmd("env TSAN_OPTIONS=abort_on_error=0")
37 stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason()
38 if stop_reason == lldb.eStopReasonExec:
39 # On OS X 10.10 and older, we need to re-exec to enable interceptors.
40 self.runCmd("continue")
43 while self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason() == lldb.eStopReasonInstrumentation:
46 stop_description = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopDescription(100)
49 (stop_description == "Data race detected") or
50 (stop_description == "Use of deallocated memory detected") or
51 (stop_description == "Thread leak detected") or
52 (stop_description == "Use of an uninitialized or destroyed mutex detected") or
53 (stop_description == "Unlock of an unlocked mutex (or by a wrong thread) detected")
56 self.expect("thread info -s", "The extended stop info should contain the TSan provided fields",
57 substrs = ["instrumentation_class", "description", "mops"])
59 output_lines = self.res.GetOutput().split('\n')
60 json_line = '\n'.join(output_lines[2:])
61 data = json.loads(json_line)
62 self.assertEqual(data["instrumentation_class"], "ThreadSanitizer")
64 backtraces = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReasonExtendedBacktraces(lldb.eInstrumentationRuntimeTypeThreadSanitizer)
65 self.assertTrue(backtraces.GetSize() >= 1)
67 self.runCmd("continue")
69 self.assertEqual(self.dbg.GetSelectedTarget().process.GetState(), lldb.eStateExited, PROCESS_EXITED)