2 Tests that TSan correctly reports the filename and line number of a racy global C++ variable.
8 from lldbsuite.test.lldbtest import *
9 from lldbsuite.test.decorators import *
10 import lldbsuite.test.lldbutil as lldbutil
14 class TsanCPPGlobalLocationTestCase(TestBase):
16 mydir = TestBase.compute_mydir(__file__)
20 bugnumber="non-core functionality, need to reenable and fix later (DES 2014.11.07)")
21 @skipIfFreeBSD # llvm.org/pr21136 runtimes not yet available by default
23 @skipUnlessThreadSanitizer
29 # Call super's setUp().
33 exe = os.path.join(os.getcwd(), "a.out")
36 patterns=["Current executable set to .*a.out"])
40 stop_reason = self.dbg.GetSelectedTarget().process.GetSelectedThread().GetStopReason()
41 if stop_reason == lldb.eStopReasonExec:
42 # On OS X 10.10 and older, we need to re-exec to enable
44 self.runCmd("continue")
46 # the stop reason of the thread should be breakpoint.
47 self.expect("thread list", "A data race should be detected",
48 substrs=['stopped', 'stop reason = Data race detected'])
52 "The extended stop info should contain the TSan provided fields",
54 "instrumentation_class",
58 output_lines = self.res.GetOutput().split('\n')
59 json_line = '\n'.join(output_lines[2:])
60 data = json.loads(json_line)
61 self.assertEqual(data["instrumentation_class"], "ThreadSanitizer")
62 self.assertEqual(data["issue_type"], "data-race")
64 self.assertTrue(data["location_filename"].endswith("/main.cpp"))
66 data["location_line"],
69 '// global variable'))