1
- // ===-- MainThreadCheckerRuntime .cpp --------------- -------------*- C++ -*-===//
1
+ // ===-- InstrumentationRuntimeMainThreadChecker .cpp -------------*- C++ -*-===//
2
2
//
3
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
4
// See https://llvm.org/LICENSE.txt for license information.
5
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
8
9
- #include " MainThreadCheckerRuntime .h"
9
+ #include " InstrumentationRuntimeMainThreadChecker .h"
10
10
11
+ #include " Plugins/Process/Utility/HistoryThread.h"
11
12
#include " lldb/Breakpoint/StoppointCallbackContext.h"
12
13
#include " lldb/Core/Module.h"
13
14
#include " lldb/Core/PluginManager.h"
22
23
#include " lldb/Target/Target.h"
23
24
#include " lldb/Target/Thread.h"
24
25
#include " lldb/Utility/RegularExpression.h"
25
- #include " Plugins/Process/Utility/HistoryThread.h"
26
26
27
27
#include < memory>
28
28
29
29
using namespace lldb ;
30
30
using namespace lldb_private ;
31
31
32
- MainThreadCheckerRuntime::~MainThreadCheckerRuntime () {
32
+ InstrumentationRuntimeMainThreadChecker::
33
+ ~InstrumentationRuntimeMainThreadChecker () {
33
34
Deactivate ();
34
35
}
35
36
36
37
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));
39
42
}
40
43
41
- void MainThreadCheckerRuntime ::Initialize () {
44
+ void InstrumentationRuntimeMainThreadChecker ::Initialize () {
42
45
PluginManager::RegisterPlugin (
43
- GetPluginNameStatic (), " MainThreadChecker instrumentation runtime plugin." ,
44
- CreateInstance, GetTypeStatic);
46
+ GetPluginNameStatic (),
47
+ " MainThreadChecker instrumentation runtime plugin." , CreateInstance,
48
+ GetTypeStatic);
45
49
}
46
50
47
- void MainThreadCheckerRuntime ::Terminate () {
51
+ void InstrumentationRuntimeMainThreadChecker ::Terminate () {
48
52
PluginManager::UnregisterPlugin (CreateInstance);
49
53
}
50
54
51
- lldb_private::ConstString MainThreadCheckerRuntime::GetPluginNameStatic () {
55
+ lldb_private::ConstString
56
+ InstrumentationRuntimeMainThreadChecker::GetPluginNameStatic () {
52
57
return ConstString (" MainThreadChecker" );
53
58
}
54
59
55
- lldb::InstrumentationRuntimeType MainThreadCheckerRuntime::GetTypeStatic () {
60
+ lldb::InstrumentationRuntimeType
61
+ InstrumentationRuntimeMainThreadChecker::GetTypeStatic () {
56
62
return eInstrumentationRuntimeTypeMainThreadChecker;
57
63
}
58
64
59
65
const RegularExpression &
60
- MainThreadCheckerRuntime ::GetPatternForRuntimeLibrary () {
66
+ InstrumentationRuntimeMainThreadChecker ::GetPatternForRuntimeLibrary () {
61
67
static RegularExpression regex (llvm::StringRef (" libMainThreadChecker.dylib" ));
62
68
return regex;
63
69
}
64
70
65
- bool MainThreadCheckerRuntime ::CheckIfRuntimeIsValid (
71
+ bool InstrumentationRuntimeMainThreadChecker ::CheckIfRuntimeIsValid (
66
72
const lldb::ModuleSP module_sp) {
67
73
static ConstString test_sym (" __main_thread_checker_on_report" );
68
74
const Symbol *symbol =
@@ -71,7 +77,8 @@ bool MainThreadCheckerRuntime::CheckIfRuntimeIsValid(
71
77
}
72
78
73
79
StructuredData::ObjectSP
74
- MainThreadCheckerRuntime::RetrieveReportData (ExecutionContextRef exe_ctx_ref) {
80
+ InstrumentationRuntimeMainThreadChecker::RetrieveReportData (
81
+ ExecutionContextRef exe_ctx_ref) {
75
82
ProcessSP process_sp = GetProcessSP ();
76
83
if (!process_sp)
77
84
return StructuredData::ObjectSP ();
@@ -148,15 +155,15 @@ MainThreadCheckerRuntime::RetrieveReportData(ExecutionContextRef exe_ctx_ref) {
148
155
return dict_sp;
149
156
}
150
157
151
- bool MainThreadCheckerRuntime ::NotifyBreakpointHit (
158
+ bool InstrumentationRuntimeMainThreadChecker ::NotifyBreakpointHit (
152
159
void *baton, StoppointCallbackContext *context, user_id_t break_id,
153
160
user_id_t break_loc_id) {
154
161
assert (baton && " null baton" );
155
162
if (!baton)
156
163
return false ; // /< false => resume execution.
157
164
158
- MainThreadCheckerRuntime *const instance =
159
- static_cast <MainThreadCheckerRuntime *>(baton);
165
+ InstrumentationRuntimeMainThreadChecker *const instance =
166
+ static_cast <InstrumentationRuntimeMainThreadChecker *>(baton);
160
167
161
168
ProcessSP process_sp = instance->GetProcessSP ();
162
169
ThreadSP thread_sp = context->exe_ctx_ref .GetThreadSP ();
@@ -172,9 +179,9 @@ bool MainThreadCheckerRuntime::NotifyBreakpointHit(
172
179
173
180
if (report) {
174
181
std::string description = report->GetAsDictionary ()
175
- ->GetValueForKey (" description" )
176
- ->GetAsString ()
177
- ->GetValue ();
182
+ ->GetValueForKey (" description" )
183
+ ->GetAsString ()
184
+ ->GetValue ();
178
185
thread_sp->SetStopInfo (
179
186
InstrumentationRuntimeStopInfo::CreateStopReasonWithInstrumentationData (
180
187
*thread_sp, description, report));
@@ -184,7 +191,7 @@ bool MainThreadCheckerRuntime::NotifyBreakpointHit(
184
191
return false ;
185
192
}
186
193
187
- void MainThreadCheckerRuntime ::Activate () {
194
+ void InstrumentationRuntimeMainThreadChecker ::Activate () {
188
195
if (IsActive ())
189
196
return ;
190
197
@@ -215,15 +222,15 @@ void MainThreadCheckerRuntime::Activate() {
215
222
.CreateBreakpoint (symbol_address, /* internal=*/ true ,
216
223
/* hardware=*/ false )
217
224
.get ();
218
- breakpoint->SetCallback (MainThreadCheckerRuntime::NotifyBreakpointHit, this ,
219
- true );
225
+ breakpoint->SetCallback (
226
+ InstrumentationRuntimeMainThreadChecker::NotifyBreakpointHit, this , true );
220
227
breakpoint->SetBreakpointKind (" main-thread-checker-report" );
221
228
SetBreakpointID (breakpoint->GetID ());
222
229
223
230
SetActive (true );
224
231
}
225
232
226
- void MainThreadCheckerRuntime ::Deactivate () {
233
+ void InstrumentationRuntimeMainThreadChecker ::Deactivate () {
227
234
SetActive (false );
228
235
229
236
auto BID = GetBreakpointID ();
@@ -237,15 +244,15 @@ void MainThreadCheckerRuntime::Deactivate() {
237
244
}
238
245
239
246
lldb::ThreadCollectionSP
240
- MainThreadCheckerRuntime ::GetBacktracesFromExtendedStopInfo (
247
+ InstrumentationRuntimeMainThreadChecker ::GetBacktracesFromExtendedStopInfo (
241
248
StructuredData::ObjectSP info) {
242
249
ThreadCollectionSP threads;
243
250
threads = std::make_shared<ThreadCollection>();
244
251
245
252
ProcessSP process_sp = GetProcessSP ();
246
253
247
254
if (info->GetObjectForDotSeparatedPath (" instrumentation_class" )
248
- ->GetStringValue () != " MainThreadChecker" )
255
+ ->GetStringValue () != " MainThreadChecker" )
249
256
return threads;
250
257
251
258
std::vector<lldb::addr_t > PCs;
0 commit comments