2 Tests that TSan and LLDB have correct thread numbers.
6 from lldbsuite.test.lldbtest import *
7 from lldbsuite.test.decorators import *
8 import lldbsuite.test.lldbutil as lldbutil
12 class TsanThreadNumbersTestCase(TestBase):
14 mydir = TestBase.compute_mydir(__file__)
18 bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)")
19 @expectedFailureNetBSD
20 @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default
22 @skipUnlessThreadSanitizer
28 exe = self.getBuildArtifact("a.out")
31 patterns=["Current executable set to .*a.out"])
35 stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason()
36 if stop_reason == lldb.eStopReasonExec:
37 # On OS X 10.10 and older, we need to re-exec to enable
39 self.runCmd("continue")
41 # the stop reason of the thread should be breakpoint.
42 self.expect("thread list", "A data race should be detected",
43 substrs=['stopped', 'stop reason = Data race detected'])
46 self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason(),
47 lldb.eStopReasonInstrumentation)
49 report_thread_id = self.dbg.GetSelectedTarget(
50 ).process.GetSelectedThread().GetIndexID()
54 "The extended stop info should contain the TSan provided fields",
56 "instrumentation_class",
60 output_lines = self.res.GetOutput().split('\n')
61 json_line = '\n'.join(output_lines[2:])
62 data = json.loads(json_line)
63 self.assertEqual(data["instrumentation_class"], "ThreadSanitizer")
64 self.assertEqual(data["issue_type"], "data-race")
65 self.assertEqual(len(data["mops"]), 2)
67 self.assertEqual(data["mops"][0]["thread_id"], report_thread_id)
69 other_thread_id = data["mops"][1]["thread_id"]
70 self.assertTrue(other_thread_id != report_thread_id)
71 other_thread = self.dbg.GetSelectedTarget(
72 ).process.GetThreadByIndexID(other_thread_id)
73 self.assertTrue(other_thread.IsValid())
75 self.runCmd("thread select %d" % other_thread_id)
79 "The other thread should be stopped in f1 or f2",