OSDN Git Service

[lldb/Plugin] Rename MainThreadCheckerRuntime for consistency with plugin (NFC)
authorJonas Devlieghere <jonas@devlieghere.com>
Tue, 21 Jan 2020 23:01:36 +0000 (15:01 -0800)
committerJonas Devlieghere <jonas@devlieghere.com>
Tue, 21 Jan 2020 23:02:41 +0000 (15:02 -0800)
Renames MainThreadCheckerRuntime to
InstrumentationRuntimeMainThreadChecker to be consistent with the
directory structure and plugin name.

lldb/source/API/SystemInitializerFull.cpp
lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/CMakeLists.txt
lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp [moved from lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp with 80% similarity]
lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h [new file with mode: 0644]
lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h [deleted file]
lldb/tools/lldb-test/SystemInitializerTest.cpp

index 799f894..720f1aa 100644 (file)
@@ -55,7 +55,7 @@
 #include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
 #include "Plugins/Instruction/PPC64/EmulateInstructionPPC64.h"
 #include "Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.h"
-#include "Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h"
+#include "Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h"
 #include "Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.h"
 #include "Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.h"
 #include "Plugins/JITLoader/GDB/JITLoaderGDB.h"
@@ -225,7 +225,7 @@ llvm::Error SystemInitializerFull::Initialize() {
   InstrumentationRuntimeASan::Initialize();
   InstrumentationRuntimeTSan::Initialize();
   InstrumentationRuntimeUBSan::Initialize();
-  MainThreadCheckerRuntime::Initialize();
+  InstrumentationRuntimeMainThreadChecker::Initialize();
 
   SymbolVendorELF::Initialize();
   breakpad::SymbolFileBreakpad::Initialize();
@@ -319,7 +319,8 @@ void SystemInitializerFull::Terminate() {
   InstrumentationRuntimeASan::Terminate();
   InstrumentationRuntimeTSan::Terminate();
   InstrumentationRuntimeUBSan::Terminate();
-  MainThreadCheckerRuntime::Terminate();
+  InstrumentationRuntimeMainThreadChecker::Terminate();
+
   wasm::SymbolVendorWasm::Terminate();
   SymbolVendorELF::Terminate();
   breakpad::SymbolFileBreakpad::Terminate();
index 440b176..8095658 100644 (file)
@@ -1,5 +1,5 @@
 add_lldb_library(lldbPluginInstrumentationRuntimeMainThreadChecker PLUGIN
-  MainThreadCheckerRuntime.cpp
+  InstrumentationRuntimeMainThreadChecker.cpp
 
   LINK_LIBS
     lldbBreakpoint
@@ -1,4 +1,4 @@
-//===-- MainThreadCheckerRuntime.cpp ----------------------------*- C++ -*-===//
+//===-- InstrumentationRuntimeMainThreadChecker.cpp -------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,8 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "MainThreadCheckerRuntime.h"
+#include "InstrumentationRuntimeMainThreadChecker.h"
 
+#include "Plugins/Process/Utility/HistoryThread.h"
 #include "lldb/Breakpoint/StoppointCallbackContext.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Target/Target.h"
 #include "lldb/Target/Thread.h"
 #include "lldb/Utility/RegularExpression.h"
-#include "Plugins/Process/Utility/HistoryThread.h"
 
 #include <memory>
 
 using namespace lldb;
 using namespace lldb_private;
 
-MainThreadCheckerRuntime::~MainThreadCheckerRuntime() {
+InstrumentationRuntimeMainThreadChecker::
+    ~InstrumentationRuntimeMainThreadChecker() {
   Deactivate();
 }
 
 lldb::InstrumentationRuntimeSP
-MainThreadCheckerRuntime::CreateInstance(const lldb::ProcessSP &process_sp) {
-  return InstrumentationRuntimeSP(new MainThreadCheckerRuntime(process_sp));
+InstrumentationRuntimeMainThreadChecker::CreateInstance(
+    const lldb::ProcessSP &process_sp) {
+  return InstrumentationRuntimeSP(
+      new InstrumentationRuntimeMainThreadChecker(process_sp));
 }
 
-void MainThreadCheckerRuntime::Initialize() {
+void InstrumentationRuntimeMainThreadChecker::Initialize() {
   PluginManager::RegisterPlugin(
-      GetPluginNameStatic(), "MainThreadChecker instrumentation runtime plugin.",
-      CreateInstance, GetTypeStatic);
+      GetPluginNameStatic(),
+      "MainThreadChecker instrumentation runtime plugin.", CreateInstance,
+      GetTypeStatic);
 }
 
-void MainThreadCheckerRuntime::Terminate() {
+void InstrumentationRuntimeMainThreadChecker::Terminate() {
   PluginManager::UnregisterPlugin(CreateInstance);
 }
 
-lldb_private::ConstString MainThreadCheckerRuntime::GetPluginNameStatic() {
+lldb_private::ConstString
+InstrumentationRuntimeMainThreadChecker::GetPluginNameStatic() {
   return ConstString("MainThreadChecker");
 }
 
-lldb::InstrumentationRuntimeType MainThreadCheckerRuntime::GetTypeStatic() {
+lldb::InstrumentationRuntimeType
+InstrumentationRuntimeMainThreadChecker::GetTypeStatic() {
   return eInstrumentationRuntimeTypeMainThreadChecker;
 }
 
 const RegularExpression &
-MainThreadCheckerRuntime::GetPatternForRuntimeLibrary() {
+InstrumentationRuntimeMainThreadChecker::GetPatternForRuntimeLibrary() {
   static RegularExpression regex(llvm::StringRef("libMainThreadChecker.dylib"));
   return regex;
 }
 
-bool MainThreadCheckerRuntime::CheckIfRuntimeIsValid(
+bool InstrumentationRuntimeMainThreadChecker::CheckIfRuntimeIsValid(
     const lldb::ModuleSP module_sp) {
   static ConstString test_sym("__main_thread_checker_on_report");
   const Symbol *symbol =
@@ -71,7 +77,8 @@ bool MainThreadCheckerRuntime::CheckIfRuntimeIsValid(
 }
 
 StructuredData::ObjectSP
-MainThreadCheckerRuntime::RetrieveReportData(ExecutionContextRef exe_ctx_ref) {
+InstrumentationRuntimeMainThreadChecker::RetrieveReportData(
+    ExecutionContextRef exe_ctx_ref) {
   ProcessSP process_sp = GetProcessSP();
   if (!process_sp)
     return StructuredData::ObjectSP();
@@ -148,15 +155,15 @@ MainThreadCheckerRuntime::RetrieveReportData(ExecutionContextRef exe_ctx_ref) {
   return dict_sp;
 }
 
-bool MainThreadCheckerRuntime::NotifyBreakpointHit(
+bool InstrumentationRuntimeMainThreadChecker::NotifyBreakpointHit(
     void *baton, StoppointCallbackContext *context, user_id_t break_id,
     user_id_t break_loc_id) {
   assert(baton && "null baton");
   if (!baton)
     return false; ///< false => resume execution.
 
-  MainThreadCheckerRuntime *const instance =
-      static_cast<MainThreadCheckerRuntime *>(baton);
+  InstrumentationRuntimeMainThreadChecker *const instance =
+      static_cast<InstrumentationRuntimeMainThreadChecker *>(baton);
 
   ProcessSP process_sp = instance->GetProcessSP();
   ThreadSP thread_sp = context->exe_ctx_ref.GetThreadSP();
@@ -172,9 +179,9 @@ bool MainThreadCheckerRuntime::NotifyBreakpointHit(
 
   if (report) {
     std::string description = report->GetAsDictionary()
-                                ->GetValueForKey("description")
-                                ->GetAsString()
-                                ->GetValue();
+                                  ->GetValueForKey("description")
+                                  ->GetAsString()
+                                  ->GetValue();
     thread_sp->SetStopInfo(
         InstrumentationRuntimeStopInfo::CreateStopReasonWithInstrumentationData(
             *thread_sp, description, report));
@@ -184,7 +191,7 @@ bool MainThreadCheckerRuntime::NotifyBreakpointHit(
   return false;
 }
 
-void MainThreadCheckerRuntime::Activate() {
+void InstrumentationRuntimeMainThreadChecker::Activate() {
   if (IsActive())
     return;
 
@@ -215,15 +222,15 @@ void MainThreadCheckerRuntime::Activate() {
           .CreateBreakpoint(symbol_address, /*internal=*/true,
                             /*hardware=*/false)
           .get();
-  breakpoint->SetCallback(MainThreadCheckerRuntime::NotifyBreakpointHit, this,
-                          true);
+  breakpoint->SetCallback(
+      InstrumentationRuntimeMainThreadChecker::NotifyBreakpointHit, this, true);
   breakpoint->SetBreakpointKind("main-thread-checker-report");
   SetBreakpointID(breakpoint->GetID());
 
   SetActive(true);
 }
 
-void MainThreadCheckerRuntime::Deactivate() {
+void InstrumentationRuntimeMainThreadChecker::Deactivate() {
   SetActive(false);
 
   auto BID = GetBreakpointID();
@@ -237,7 +244,7 @@ void MainThreadCheckerRuntime::Deactivate() {
 }
 
 lldb::ThreadCollectionSP
-MainThreadCheckerRuntime::GetBacktracesFromExtendedStopInfo(
+InstrumentationRuntimeMainThreadChecker::GetBacktracesFromExtendedStopInfo(
     StructuredData::ObjectSP info) {
   ThreadCollectionSP threads;
   threads = std::make_shared<ThreadCollection>();
@@ -245,7 +252,7 @@ MainThreadCheckerRuntime::GetBacktracesFromExtendedStopInfo(
   ProcessSP process_sp = GetProcessSP();
 
   if (info->GetObjectForDotSeparatedPath("instrumentation_class")
-      ->GetStringValue() != "MainThreadChecker")
+          ->GetStringValue() != "MainThreadChecker")
     return threads;
 
   std::vector<lldb::addr_t> PCs;
diff --git a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h
new file mode 100644 (file)
index 0000000..290e3a8
--- /dev/null
@@ -0,0 +1,68 @@
+//===-- InstrumentationRuntimeMainThreadChecker.h----------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_MainThreadCheckerRuntime_h_
+#define liblldb_MainThreadCheckerRuntime_h_
+
+#include "lldb/Target/ABI.h"
+#include "lldb/Target/InstrumentationRuntime.h"
+#include "lldb/Utility/StructuredData.h"
+#include "lldb/lldb-private.h"
+
+namespace lldb_private {
+
+class InstrumentationRuntimeMainThreadChecker
+    : public lldb_private::InstrumentationRuntime {
+public:
+  ~InstrumentationRuntimeMainThreadChecker() override;
+
+  static lldb::InstrumentationRuntimeSP
+  CreateInstance(const lldb::ProcessSP &process_sp);
+
+  static void Initialize();
+
+  static void Terminate();
+
+  static lldb_private::ConstString GetPluginNameStatic();
+
+  static lldb::InstrumentationRuntimeType GetTypeStatic();
+
+  lldb_private::ConstString GetPluginName() override {
+    return GetPluginNameStatic();
+  }
+
+  virtual lldb::InstrumentationRuntimeType GetType() { return GetTypeStatic(); }
+
+  uint32_t GetPluginVersion() override { return 1; }
+
+  lldb::ThreadCollectionSP
+  GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info) override;
+
+private:
+  InstrumentationRuntimeMainThreadChecker(const lldb::ProcessSP &process_sp)
+      : lldb_private::InstrumentationRuntime(process_sp) {}
+
+  const RegularExpression &GetPatternForRuntimeLibrary() override;
+
+  bool CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp) override;
+
+  void Activate() override;
+
+  void Deactivate();
+
+  static bool NotifyBreakpointHit(void *baton,
+                                  StoppointCallbackContext *context,
+                                  lldb::user_id_t break_id,
+                                  lldb::user_id_t break_loc_id);
+
+  StructuredData::ObjectSP RetrieveReportData(ExecutionContextRef exe_ctx_ref);
+};
+
+} // namespace lldb_private
+
+#endif // liblldb_MainThreadCheckerRuntime_h_
diff --git a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h
deleted file mode 100644 (file)
index 1dcbc0f..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-//===-- MainThreadCheckerRuntime.h ------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef liblldb_MainThreadCheckerRuntime_h_
-#define liblldb_MainThreadCheckerRuntime_h_
-
-#include "lldb/Target/ABI.h"
-#include "lldb/Target/InstrumentationRuntime.h"
-#include "lldb/Utility/StructuredData.h"
-#include "lldb/lldb-private.h"
-
-namespace lldb_private {
-  
-  class MainThreadCheckerRuntime : public lldb_private::InstrumentationRuntime {
-  public:
-    ~MainThreadCheckerRuntime() override;
-    
-    static lldb::InstrumentationRuntimeSP
-    CreateInstance(const lldb::ProcessSP &process_sp);
-    
-    static void Initialize();
-    
-    static void Terminate();
-    
-    static lldb_private::ConstString GetPluginNameStatic();
-    
-    static lldb::InstrumentationRuntimeType GetTypeStatic();
-    
-    lldb_private::ConstString GetPluginName() override {
-      return GetPluginNameStatic();
-    }
-    
-    virtual lldb::InstrumentationRuntimeType GetType() { return GetTypeStatic(); }
-    
-    uint32_t GetPluginVersion() override { return 1; }
-    
-    lldb::ThreadCollectionSP
-    GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info) override;
-    
-  private:
-    MainThreadCheckerRuntime(const lldb::ProcessSP &process_sp)
-    : lldb_private::InstrumentationRuntime(process_sp) {}
-    
-    const RegularExpression &GetPatternForRuntimeLibrary() override;
-    
-    bool CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp) override;
-    
-    void Activate() override;
-    
-    void Deactivate();
-    
-    static bool NotifyBreakpointHit(void *baton,
-                                    StoppointCallbackContext *context,
-                                    lldb::user_id_t break_id,
-                                    lldb::user_id_t break_loc_id);
-    
-    StructuredData::ObjectSP RetrieveReportData(ExecutionContextRef exe_ctx_ref);
-  };
-  
-} // namespace lldb_private
-
-#endif // liblldb_MainThreadCheckerRuntime_h_
index 280a118..b6cd146 100644 (file)
@@ -45,7 +45,7 @@
 #include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
 #include "Plugins/Instruction/PPC64/EmulateInstructionPPC64.h"
 #include "Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.h"
-#include "Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h"
+#include "Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h"
 #include "Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.h"
 #include "Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.h"
 #include "Plugins/JITLoader/GDB/JITLoaderGDB.h"
@@ -196,7 +196,7 @@ llvm::Error SystemInitializerTest::Initialize() {
   InstrumentationRuntimeASan::Initialize();
   InstrumentationRuntimeTSan::Initialize();
   InstrumentationRuntimeUBSan::Initialize();
-  MainThreadCheckerRuntime::Initialize();
+  InstrumentationRuntimeMainThreadChecker::Initialize();
 
   SymbolVendorELF::Initialize();
   breakpad::SymbolFileBreakpad::Initialize();
@@ -289,7 +289,8 @@ void SystemInitializerTest::Terminate() {
   InstrumentationRuntimeASan::Terminate();
   InstrumentationRuntimeTSan::Terminate();
   InstrumentationRuntimeUBSan::Terminate();
-  MainThreadCheckerRuntime::Terminate();
+  InstrumentationRuntimeMainThreadChecker::Terminate();
+
   wasm::SymbolVendorWasm::Terminate();
   SymbolVendorELF::Terminate();
   breakpad::SymbolFileBreakpad::Terminate();