2 Tests that TSan correctly reports the filename and line number of a racy global variable.
6 from lldbsuite.test.lldbtest import *
7 from lldbsuite.test.decorators import *
8 import lldbsuite.test.lldbutil as lldbutil
12 class TsanGlobalLocationTestCase(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'])
47 "The extended stop info should contain the TSan provided fields",
49 "instrumentation_class",
53 output_lines = self.res.GetOutput().split('\n')
54 json_line = '\n'.join(output_lines[2:])
55 data = json.loads(json_line)
56 self.assertEqual(data["instrumentation_class"], "ThreadSanitizer")
57 self.assertEqual(data["issue_type"], "data-race")
59 self.assertTrue(data["location_filename"].endswith("/main.c"))
61 data["location_line"],
64 '// global variable'))