15ffd83dbSDimitry Andric //===-- InstrumentationRuntimeTSan.h ----------------------------*- C++ -*-===//
25ffd83dbSDimitry Andric //
35ffd83dbSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45ffd83dbSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
55ffd83dbSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65ffd83dbSDimitry Andric //
75ffd83dbSDimitry Andric //===----------------------------------------------------------------------===//
85ffd83dbSDimitry Andric 
95ffd83dbSDimitry Andric #ifndef LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_TSAN_INSTRUMENTATIONRUNTIMETSAN_H
105ffd83dbSDimitry Andric #define LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_TSAN_INSTRUMENTATIONRUNTIMETSAN_H
115ffd83dbSDimitry Andric 
125ffd83dbSDimitry Andric #include "lldb/Target/ABI.h"
135ffd83dbSDimitry Andric #include "lldb/Target/InstrumentationRuntime.h"
145ffd83dbSDimitry Andric #include "lldb/Utility/StructuredData.h"
155ffd83dbSDimitry Andric #include "lldb/lldb-private.h"
165ffd83dbSDimitry Andric 
175ffd83dbSDimitry Andric namespace lldb_private {
185ffd83dbSDimitry Andric 
195ffd83dbSDimitry Andric class InstrumentationRuntimeTSan : public lldb_private::InstrumentationRuntime {
205ffd83dbSDimitry Andric public:
215ffd83dbSDimitry Andric   ~InstrumentationRuntimeTSan() override;
225ffd83dbSDimitry Andric 
235ffd83dbSDimitry Andric   static lldb::InstrumentationRuntimeSP
245ffd83dbSDimitry Andric   CreateInstance(const lldb::ProcessSP &process_sp);
255ffd83dbSDimitry Andric 
265ffd83dbSDimitry Andric   static void Initialize();
275ffd83dbSDimitry Andric 
285ffd83dbSDimitry Andric   static void Terminate();
295ffd83dbSDimitry Andric 
GetPluginNameStatic()30*349cc55cSDimitry Andric   static llvm::StringRef GetPluginNameStatic() { return "ThreadSanitizer"; }
315ffd83dbSDimitry Andric 
325ffd83dbSDimitry Andric   static lldb::InstrumentationRuntimeType GetTypeStatic();
335ffd83dbSDimitry Andric 
GetPluginName()34*349cc55cSDimitry Andric   llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
355ffd83dbSDimitry Andric 
GetType()365ffd83dbSDimitry Andric   virtual lldb::InstrumentationRuntimeType GetType() { return GetTypeStatic(); }
375ffd83dbSDimitry Andric 
385ffd83dbSDimitry Andric   lldb::ThreadCollectionSP
395ffd83dbSDimitry Andric   GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info) override;
405ffd83dbSDimitry Andric 
415ffd83dbSDimitry Andric private:
InstrumentationRuntimeTSan(const lldb::ProcessSP & process_sp)425ffd83dbSDimitry Andric   InstrumentationRuntimeTSan(const lldb::ProcessSP &process_sp)
435ffd83dbSDimitry Andric       : lldb_private::InstrumentationRuntime(process_sp) {}
445ffd83dbSDimitry Andric 
455ffd83dbSDimitry Andric   const RegularExpression &GetPatternForRuntimeLibrary() override;
465ffd83dbSDimitry Andric 
475ffd83dbSDimitry Andric   bool CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp) override;
485ffd83dbSDimitry Andric 
495ffd83dbSDimitry Andric   void Activate() override;
505ffd83dbSDimitry Andric 
515ffd83dbSDimitry Andric   void Deactivate();
525ffd83dbSDimitry Andric 
535ffd83dbSDimitry Andric   static bool NotifyBreakpointHit(void *baton,
545ffd83dbSDimitry Andric                                   StoppointCallbackContext *context,
555ffd83dbSDimitry Andric                                   lldb::user_id_t break_id,
565ffd83dbSDimitry Andric                                   lldb::user_id_t break_loc_id);
575ffd83dbSDimitry Andric 
585ffd83dbSDimitry Andric   StructuredData::ObjectSP RetrieveReportData(ExecutionContextRef exe_ctx_ref);
595ffd83dbSDimitry Andric 
605ffd83dbSDimitry Andric   std::string FormatDescription(StructuredData::ObjectSP report);
615ffd83dbSDimitry Andric 
625ffd83dbSDimitry Andric   std::string GenerateSummary(StructuredData::ObjectSP report);
635ffd83dbSDimitry Andric 
645ffd83dbSDimitry Andric   lldb::addr_t GetMainRacyAddress(StructuredData::ObjectSP report);
655ffd83dbSDimitry Andric 
665ffd83dbSDimitry Andric   std::string GetLocationDescription(StructuredData::ObjectSP report,
675ffd83dbSDimitry Andric                                      lldb::addr_t &global_addr,
685ffd83dbSDimitry Andric                                      std::string &global_name,
695ffd83dbSDimitry Andric                                      std::string &filename, uint32_t &line);
705ffd83dbSDimitry Andric 
715ffd83dbSDimitry Andric   lldb::addr_t GetFirstNonInternalFramePc(StructuredData::ObjectSP trace,
725ffd83dbSDimitry Andric                                           bool skip_one_frame = false);
735ffd83dbSDimitry Andric };
745ffd83dbSDimitry Andric 
755ffd83dbSDimitry Andric } // namespace lldb_private
765ffd83dbSDimitry Andric 
775ffd83dbSDimitry Andric #endif // LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_TSAN_INSTRUMENTATIONRUNTIMETSAN_H
78