1 //===-- InstrumentationRuntimeTSan.h ----------------------------*- C++ -*-===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_TSAN_INSTRUMENTATIONRUNTIMETSAN_H
10 #define LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_TSAN_INSTRUMENTATIONRUNTIMETSAN_H
11 
12 #include "lldb/Target/ABI.h"
13 #include "lldb/Target/InstrumentationRuntime.h"
14 #include "lldb/Utility/StructuredData.h"
15 #include "lldb/lldb-private.h"
16 
17 namespace lldb_private {
18 
19 class InstrumentationRuntimeTSan : public lldb_private::InstrumentationRuntime {
20 public:
21   ~InstrumentationRuntimeTSan() override;
22 
23   static lldb::InstrumentationRuntimeSP
24   CreateInstance(const lldb::ProcessSP &process_sp);
25 
26   static void Initialize();
27 
28   static void Terminate();
29 
30   static lldb_private::ConstString GetPluginNameStatic();
31 
32   static lldb::InstrumentationRuntimeType GetTypeStatic();
33 
GetPluginName()34   lldb_private::ConstString GetPluginName() override {
35     return GetPluginNameStatic();
36   }
37 
GetType()38   virtual lldb::InstrumentationRuntimeType GetType() { return GetTypeStatic(); }
39 
GetPluginVersion()40   uint32_t GetPluginVersion() override { return 1; }
41 
42   lldb::ThreadCollectionSP
43   GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info) override;
44 
45 private:
InstrumentationRuntimeTSan(const lldb::ProcessSP & process_sp)46   InstrumentationRuntimeTSan(const lldb::ProcessSP &process_sp)
47       : lldb_private::InstrumentationRuntime(process_sp) {}
48 
49   const RegularExpression &GetPatternForRuntimeLibrary() override;
50 
51   bool CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp) override;
52 
53   void Activate() override;
54 
55   void Deactivate();
56 
57   static bool NotifyBreakpointHit(void *baton,
58                                   StoppointCallbackContext *context,
59                                   lldb::user_id_t break_id,
60                                   lldb::user_id_t break_loc_id);
61 
62   StructuredData::ObjectSP RetrieveReportData(ExecutionContextRef exe_ctx_ref);
63 
64   std::string FormatDescription(StructuredData::ObjectSP report);
65 
66   std::string GenerateSummary(StructuredData::ObjectSP report);
67 
68   lldb::addr_t GetMainRacyAddress(StructuredData::ObjectSP report);
69 
70   std::string GetLocationDescription(StructuredData::ObjectSP report,
71                                      lldb::addr_t &global_addr,
72                                      std::string &global_name,
73                                      std::string &filename, uint32_t &line);
74 
75   lldb::addr_t GetFirstNonInternalFramePc(StructuredData::ObjectSP trace,
76                                           bool skip_one_frame = false);
77 };
78 
79 } // namespace lldb_private
80 
81 #endif // LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_TSAN_INSTRUMENTATIONRUNTIMETSAN_H
82