summaryrefslogtreecommitdiff
path: root/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2020-07-26 19:36:28 +0000
committerDimitry Andric <dim@FreeBSD.org>2020-07-26 19:36:28 +0000
commitcfca06d7963fa0909f90483b42a6d7d194d01e08 (patch)
tree209fb2a2d68f8f277793fc8df46c753d31bc853b /lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker
parent706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff)
Notes
Diffstat (limited to 'lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker')
-rw-r--r--lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp (renamed from lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp)65
-rw-r--r--lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h68
-rw-r--r--lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h67
3 files changed, 105 insertions, 95 deletions
diff --git a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
index b73b6c0953683..72d28c3474576 100644
--- a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp
+++ b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp
@@ -1,4 +1,4 @@
-//===-- MainThreadCheckerRuntime.cpp ----------------------------*- C++ -*-===//
+//===-- InstrumentationRuntimeMainThreadChecker.cpp -----------------------===//
//
// 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"
@@ -22,47 +23,54 @@
#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() {
+LLDB_PLUGIN_DEFINE(InstrumentationRuntimeMainThreadChecker)
+
+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 +79,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 +157,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();
@@ -171,10 +180,10 @@ bool MainThreadCheckerRuntime::NotifyBreakpointHit(
instance->RetrieveReportData(context->exe_ctx_ref);
if (report) {
- std::string description = report->GetAsDictionary()
- ->GetValueForKey("description")
- ->GetAsString()
- ->GetValue();
+ std::string description = std::string(report->GetAsDictionary()
+ ->GetValueForKey("description")
+ ->GetAsString()
+ ->GetValue());
thread_sp->SetStopInfo(
InstrumentationRuntimeStopInfo::CreateStopReasonWithInstrumentationData(
*thread_sp, description, report));
@@ -184,7 +193,7 @@ bool MainThreadCheckerRuntime::NotifyBreakpointHit(
return false;
}
-void MainThreadCheckerRuntime::Activate() {
+void InstrumentationRuntimeMainThreadChecker::Activate() {
if (IsActive())
return;
@@ -215,15 +224,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 +246,7 @@ void MainThreadCheckerRuntime::Deactivate() {
}
lldb::ThreadCollectionSP
-MainThreadCheckerRuntime::GetBacktracesFromExtendedStopInfo(
+InstrumentationRuntimeMainThreadChecker::GetBacktracesFromExtendedStopInfo(
StructuredData::ObjectSP info) {
ThreadCollectionSP threads;
threads = std::make_shared<ThreadCollection>();
@@ -245,7 +254,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
index 0000000000000..1435ae8d367fd
--- /dev/null
+++ b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h
@@ -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 LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_MAINTHREADCHECKER_INSTRUMENTATIONRUNTIMEMAINTHREADCHECKER_H
+#define LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_MAINTHREADCHECKER_INSTRUMENTATIONRUNTIMEMAINTHREADCHECKER_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 // LLDB_SOURCE_PLUGINS_INSTRUMENTATIONRUNTIME_MAINTHREADCHECKER_INSTRUMENTATIONRUNTIMEMAINTHREADCHECKER_H
diff --git a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h b/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h
deleted file mode 100644
index 1dcbc0f6bc89a..0000000000000
--- a/lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h
+++ /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_