Skip to content

Commit fc1e855

Browse files
committed
[lldb/Plugin] Rename MainThreadCheckerRuntime for consistency with plugin (NFC)
Renames MainThreadCheckerRuntime to InstrumentationRuntimeMainThreadChecker to be consistent with the directory structure and plugin name.
1 parent 623c3c4 commit fc1e855

File tree

6 files changed

+111
-101
lines changed

6 files changed

+111
-101
lines changed

lldb/source/API/SystemInitializerFull.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
#include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
5656
#include "Plugins/Instruction/PPC64/EmulateInstructionPPC64.h"
5757
#include "Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.h"
58-
#include "Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h"
58+
#include "Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h"
5959
#include "Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.h"
6060
#include "Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.h"
6161
#include "Plugins/JITLoader/GDB/JITLoaderGDB.h"
@@ -225,7 +225,7 @@ llvm::Error SystemInitializerFull::Initialize() {
225225
InstrumentationRuntimeASan::Initialize();
226226
InstrumentationRuntimeTSan::Initialize();
227227
InstrumentationRuntimeUBSan::Initialize();
228-
MainThreadCheckerRuntime::Initialize();
228+
InstrumentationRuntimeMainThreadChecker::Initialize();
229229

230230
SymbolVendorELF::Initialize();
231231
breakpad::SymbolFileBreakpad::Initialize();
@@ -319,7 +319,8 @@ void SystemInitializerFull::Terminate() {
319319
InstrumentationRuntimeASan::Terminate();
320320
InstrumentationRuntimeTSan::Terminate();
321321
InstrumentationRuntimeUBSan::Terminate();
322-
MainThreadCheckerRuntime::Terminate();
322+
InstrumentationRuntimeMainThreadChecker::Terminate();
323+
323324
wasm::SymbolVendorWasm::Terminate();
324325
SymbolVendorELF::Terminate();
325326
breakpad::SymbolFileBreakpad::Terminate();

lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
add_lldb_library(lldbPluginInstrumentationRuntimeMainThreadChecker PLUGIN
2-
MainThreadCheckerRuntime.cpp
2+
InstrumentationRuntimeMainThreadChecker.cpp
33

44
LINK_LIBS
55
lldbBreakpoint

lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.cpp renamed to lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.cpp

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
//===-- MainThreadCheckerRuntime.cpp ----------------------------*- C++ -*-===//
1+
//===-- InstrumentationRuntimeMainThreadChecker.cpp -------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
55
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#include "MainThreadCheckerRuntime.h"
9+
#include "InstrumentationRuntimeMainThreadChecker.h"
1010

11+
#include "Plugins/Process/Utility/HistoryThread.h"
1112
#include "lldb/Breakpoint/StoppointCallbackContext.h"
1213
#include "lldb/Core/Module.h"
1314
#include "lldb/Core/PluginManager.h"
@@ -22,47 +23,52 @@
2223
#include "lldb/Target/Target.h"
2324
#include "lldb/Target/Thread.h"
2425
#include "lldb/Utility/RegularExpression.h"
25-
#include "Plugins/Process/Utility/HistoryThread.h"
2626

2727
#include <memory>
2828

2929
using namespace lldb;
3030
using namespace lldb_private;
3131

32-
MainThreadCheckerRuntime::~MainThreadCheckerRuntime() {
32+
InstrumentationRuntimeMainThreadChecker::
33+
~InstrumentationRuntimeMainThreadChecker() {
3334
Deactivate();
3435
}
3536

3637
lldb::InstrumentationRuntimeSP
37-
MainThreadCheckerRuntime::CreateInstance(const lldb::ProcessSP &process_sp) {
38-
return InstrumentationRuntimeSP(new MainThreadCheckerRuntime(process_sp));
38+
InstrumentationRuntimeMainThreadChecker::CreateInstance(
39+
const lldb::ProcessSP &process_sp) {
40+
return InstrumentationRuntimeSP(
41+
new InstrumentationRuntimeMainThreadChecker(process_sp));
3942
}
4043

41-
void MainThreadCheckerRuntime::Initialize() {
44+
void InstrumentationRuntimeMainThreadChecker::Initialize() {
4245
PluginManager::RegisterPlugin(
43-
GetPluginNameStatic(), "MainThreadChecker instrumentation runtime plugin.",
44-
CreateInstance, GetTypeStatic);
46+
GetPluginNameStatic(),
47+
"MainThreadChecker instrumentation runtime plugin.", CreateInstance,
48+
GetTypeStatic);
4549
}
4650

47-
void MainThreadCheckerRuntime::Terminate() {
51+
void InstrumentationRuntimeMainThreadChecker::Terminate() {
4852
PluginManager::UnregisterPlugin(CreateInstance);
4953
}
5054

51-
lldb_private::ConstString MainThreadCheckerRuntime::GetPluginNameStatic() {
55+
lldb_private::ConstString
56+
InstrumentationRuntimeMainThreadChecker::GetPluginNameStatic() {
5257
return ConstString("MainThreadChecker");
5358
}
5459

55-
lldb::InstrumentationRuntimeType MainThreadCheckerRuntime::GetTypeStatic() {
60+
lldb::InstrumentationRuntimeType
61+
InstrumentationRuntimeMainThreadChecker::GetTypeStatic() {
5662
return eInstrumentationRuntimeTypeMainThreadChecker;
5763
}
5864

5965
const RegularExpression &
60-
MainThreadCheckerRuntime::GetPatternForRuntimeLibrary() {
66+
InstrumentationRuntimeMainThreadChecker::GetPatternForRuntimeLibrary() {
6167
static RegularExpression regex(llvm::StringRef("libMainThreadChecker.dylib"));
6268
return regex;
6369
}
6470

65-
bool MainThreadCheckerRuntime::CheckIfRuntimeIsValid(
71+
bool InstrumentationRuntimeMainThreadChecker::CheckIfRuntimeIsValid(
6672
const lldb::ModuleSP module_sp) {
6773
static ConstString test_sym("__main_thread_checker_on_report");
6874
const Symbol *symbol =
@@ -71,7 +77,8 @@ bool MainThreadCheckerRuntime::CheckIfRuntimeIsValid(
7177
}
7278

7379
StructuredData::ObjectSP
74-
MainThreadCheckerRuntime::RetrieveReportData(ExecutionContextRef exe_ctx_ref) {
80+
InstrumentationRuntimeMainThreadChecker::RetrieveReportData(
81+
ExecutionContextRef exe_ctx_ref) {
7582
ProcessSP process_sp = GetProcessSP();
7683
if (!process_sp)
7784
return StructuredData::ObjectSP();
@@ -148,15 +155,15 @@ MainThreadCheckerRuntime::RetrieveReportData(ExecutionContextRef exe_ctx_ref) {
148155
return dict_sp;
149156
}
150157

151-
bool MainThreadCheckerRuntime::NotifyBreakpointHit(
158+
bool InstrumentationRuntimeMainThreadChecker::NotifyBreakpointHit(
152159
void *baton, StoppointCallbackContext *context, user_id_t break_id,
153160
user_id_t break_loc_id) {
154161
assert(baton && "null baton");
155162
if (!baton)
156163
return false; ///< false => resume execution.
157164

158-
MainThreadCheckerRuntime *const instance =
159-
static_cast<MainThreadCheckerRuntime *>(baton);
165+
InstrumentationRuntimeMainThreadChecker *const instance =
166+
static_cast<InstrumentationRuntimeMainThreadChecker *>(baton);
160167

161168
ProcessSP process_sp = instance->GetProcessSP();
162169
ThreadSP thread_sp = context->exe_ctx_ref.GetThreadSP();
@@ -172,9 +179,9 @@ bool MainThreadCheckerRuntime::NotifyBreakpointHit(
172179

173180
if (report) {
174181
std::string description = report->GetAsDictionary()
175-
->GetValueForKey("description")
176-
->GetAsString()
177-
->GetValue();
182+
->GetValueForKey("description")
183+
->GetAsString()
184+
->GetValue();
178185
thread_sp->SetStopInfo(
179186
InstrumentationRuntimeStopInfo::CreateStopReasonWithInstrumentationData(
180187
*thread_sp, description, report));
@@ -184,7 +191,7 @@ bool MainThreadCheckerRuntime::NotifyBreakpointHit(
184191
return false;
185192
}
186193

187-
void MainThreadCheckerRuntime::Activate() {
194+
void InstrumentationRuntimeMainThreadChecker::Activate() {
188195
if (IsActive())
189196
return;
190197

@@ -215,15 +222,15 @@ void MainThreadCheckerRuntime::Activate() {
215222
.CreateBreakpoint(symbol_address, /*internal=*/true,
216223
/*hardware=*/false)
217224
.get();
218-
breakpoint->SetCallback(MainThreadCheckerRuntime::NotifyBreakpointHit, this,
219-
true);
225+
breakpoint->SetCallback(
226+
InstrumentationRuntimeMainThreadChecker::NotifyBreakpointHit, this, true);
220227
breakpoint->SetBreakpointKind("main-thread-checker-report");
221228
SetBreakpointID(breakpoint->GetID());
222229

223230
SetActive(true);
224231
}
225232

226-
void MainThreadCheckerRuntime::Deactivate() {
233+
void InstrumentationRuntimeMainThreadChecker::Deactivate() {
227234
SetActive(false);
228235

229236
auto BID = GetBreakpointID();
@@ -237,15 +244,15 @@ void MainThreadCheckerRuntime::Deactivate() {
237244
}
238245

239246
lldb::ThreadCollectionSP
240-
MainThreadCheckerRuntime::GetBacktracesFromExtendedStopInfo(
247+
InstrumentationRuntimeMainThreadChecker::GetBacktracesFromExtendedStopInfo(
241248
StructuredData::ObjectSP info) {
242249
ThreadCollectionSP threads;
243250
threads = std::make_shared<ThreadCollection>();
244251

245252
ProcessSP process_sp = GetProcessSP();
246253

247254
if (info->GetObjectForDotSeparatedPath("instrumentation_class")
248-
->GetStringValue() != "MainThreadChecker")
255+
->GetStringValue() != "MainThreadChecker")
249256
return threads;
250257

251258
std::vector<lldb::addr_t> PCs;
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
//===-- InstrumentationRuntimeMainThreadChecker.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 liblldb_MainThreadCheckerRuntime_h_
10+
#define liblldb_MainThreadCheckerRuntime_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 InstrumentationRuntimeMainThreadChecker
20+
: public lldb_private::InstrumentationRuntime {
21+
public:
22+
~InstrumentationRuntimeMainThreadChecker() override;
23+
24+
static lldb::InstrumentationRuntimeSP
25+
CreateInstance(const lldb::ProcessSP &process_sp);
26+
27+
static void Initialize();
28+
29+
static void Terminate();
30+
31+
static lldb_private::ConstString GetPluginNameStatic();
32+
33+
static lldb::InstrumentationRuntimeType GetTypeStatic();
34+
35+
lldb_private::ConstString GetPluginName() override {
36+
return GetPluginNameStatic();
37+
}
38+
39+
virtual lldb::InstrumentationRuntimeType GetType() { return GetTypeStatic(); }
40+
41+
uint32_t GetPluginVersion() override { return 1; }
42+
43+
lldb::ThreadCollectionSP
44+
GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info) override;
45+
46+
private:
47+
InstrumentationRuntimeMainThreadChecker(const lldb::ProcessSP &process_sp)
48+
: lldb_private::InstrumentationRuntime(process_sp) {}
49+
50+
const RegularExpression &GetPatternForRuntimeLibrary() override;
51+
52+
bool CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp) override;
53+
54+
void Activate() override;
55+
56+
void Deactivate();
57+
58+
static bool NotifyBreakpointHit(void *baton,
59+
StoppointCallbackContext *context,
60+
lldb::user_id_t break_id,
61+
lldb::user_id_t break_loc_id);
62+
63+
StructuredData::ObjectSP RetrieveReportData(ExecutionContextRef exe_ctx_ref);
64+
};
65+
66+
} // namespace lldb_private
67+
68+
#endif // liblldb_MainThreadCheckerRuntime_h_

lldb/source/Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h

Lines changed: 0 additions & 67 deletions
This file was deleted.

lldb/tools/lldb-test/SystemInitializerTest.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.h"
4646
#include "Plugins/Instruction/PPC64/EmulateInstructionPPC64.h"
4747
#include "Plugins/InstrumentationRuntime/ASan/InstrumentationRuntimeASan.h"
48-
#include "Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h"
48+
#include "Plugins/InstrumentationRuntime/MainThreadChecker/InstrumentationRuntimeMainThreadChecker.h"
4949
#include "Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.h"
5050
#include "Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.h"
5151
#include "Plugins/JITLoader/GDB/JITLoaderGDB.h"
@@ -196,7 +196,7 @@ llvm::Error SystemInitializerTest::Initialize() {
196196
InstrumentationRuntimeASan::Initialize();
197197
InstrumentationRuntimeTSan::Initialize();
198198
InstrumentationRuntimeUBSan::Initialize();
199-
MainThreadCheckerRuntime::Initialize();
199+
InstrumentationRuntimeMainThreadChecker::Initialize();
200200

201201
SymbolVendorELF::Initialize();
202202
breakpad::SymbolFileBreakpad::Initialize();
@@ -289,7 +289,8 @@ void SystemInitializerTest::Terminate() {
289289
InstrumentationRuntimeASan::Terminate();
290290
InstrumentationRuntimeTSan::Terminate();
291291
InstrumentationRuntimeUBSan::Terminate();
292-
MainThreadCheckerRuntime::Terminate();
292+
InstrumentationRuntimeMainThreadChecker::Terminate();
293+
293294
wasm::SymbolVendorWasm::Terminate();
294295
SymbolVendorELF::Terminate();
295296
breakpad::SymbolFileBreakpad::Terminate();

0 commit comments

Comments
 (0)