1 //===-- InstrumentationRuntimeTSan.h ----------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_TSAN_INSTRUMENTATIONRUNTIMETSAN_H
10 #define LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_TSAN_INSTRUMENTATIONRUNTIMETSAN_H
12 #include "lldb/Target/ABI.h"
13 #include "lldb/Target/InstrumentationRuntime.h"
14 #include "lldb/Utility/StructuredData.h"
15 #include "lldb/lldb-private.h"
17 namespace lldb_private
{
19 class InstrumentationRuntimeTSan
: public lldb_private::InstrumentationRuntime
{
21 ~InstrumentationRuntimeTSan() override
;
23 static lldb::InstrumentationRuntimeSP
24 CreateInstance(const lldb::ProcessSP
&process_sp
);
26 static void Initialize();
28 static void Terminate();
30 static llvm::StringRef
GetPluginNameStatic() { return "ThreadSanitizer"; }
32 static lldb::InstrumentationRuntimeType
GetTypeStatic();
34 llvm::StringRef
GetPluginName() override
{ return GetPluginNameStatic(); }
36 virtual lldb::InstrumentationRuntimeType
GetType() { return GetTypeStatic(); }
38 lldb::ThreadCollectionSP
39 GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info
) override
;
42 InstrumentationRuntimeTSan(const lldb::ProcessSP
&process_sp
)
43 : lldb_private::InstrumentationRuntime(process_sp
) {}
45 const RegularExpression
&GetPatternForRuntimeLibrary() override
;
47 bool CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp
) override
;
49 void Activate() override
;
53 static bool NotifyBreakpointHit(void *baton
,
54 StoppointCallbackContext
*context
,
55 lldb::user_id_t break_id
,
56 lldb::user_id_t break_loc_id
);
58 StructuredData::ObjectSP
RetrieveReportData(ExecutionContextRef exe_ctx_ref
);
60 std::string
FormatDescription(StructuredData::ObjectSP report
);
62 std::string
GenerateSummary(StructuredData::ObjectSP report
);
64 lldb::addr_t
GetMainRacyAddress(StructuredData::ObjectSP report
);
66 std::string
GetLocationDescription(StructuredData::ObjectSP report
,
67 lldb::addr_t
&global_addr
,
68 std::string
&global_name
,
69 std::string
&filename
, uint32_t &line
);
71 lldb::addr_t
GetFirstNonInternalFramePc(StructuredData::ObjectSP trace
,
72 bool skip_one_frame
= false);
75 } // namespace lldb_private
77 #endif // LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_TSAN_INSTRUMENTATIONRUNTIMETSAN_H