49 "MainThreadChecker instrumentation runtime plugin.",
CreateInstance,
70 static ConstString test_sym(
"__main_thread_checker_on_report");
73 return symbol !=
nullptr;
87 Target &target = process_sp->GetTarget();
96 const RegisterInfo *reginfo = regctx_sp->GetRegisterInfoByName(
"arg1");
100 uint64_t apiname_ptr = regctx_sp->ReadRegisterAsUnsigned(reginfo, 0);
107 if (read_error.
Fail())
110 std::string className;
111 std::string selector;
112 if (apiName.substr(0, 2) ==
"-[") {
113 size_t spacePos = apiName.find(
' ');
114 if (spacePos != std::string::npos) {
115 className = apiName.substr(2, spacePos - 2);
116 selector = apiName.substr(spacePos + 1, apiName.length() - spacePos - 2);
124 for (
unsigned I = 0; I < thread_sp->GetStackFrameCount(); ++I) {
125 StackFrameSP frame = thread_sp->GetStackFrameAtIndex(I);
126 Address addr = frame->GetFrameCodeAddressForSymbolication();
127 if (addr.
GetModule() == runtime_module_sp)
131 if (!responsible_frame)
132 responsible_frame = frame;
140 d->AddStringItem(
"instrumentation_class",
"MainThreadChecker");
141 d->AddStringItem(
"api_name", apiName);
142 d->AddStringItem(
"class_name", className);
143 d->AddStringItem(
"selector", selector);
144 d->AddStringItem(
"description",
145 apiName +
" must be used from main thread only");
146 d->AddIntegerItem(
"tid", thread_sp->GetIndexID());
147 d->AddItem(
"trace", trace_sp);
154 assert(baton &&
"null baton");
163 if (!process_sp || !thread_sp ||
167 if (process_sp->GetModIDRef().IsLastResumeForUserExpression())
174 std::string description = std::string(report->GetAsDictionary()
175 ->GetValueForKey(
"description")
178 thread_sp->SetStopInfo(
180 *thread_sp, description, report));
197 ConstString symbol_name(
"__main_thread_checker_on_report");
198 const Symbol *symbol = runtime_module_sp->FindFirstSymbolWithNameAndType(
201 if (symbol ==
nullptr)
207 Target &target = process_sp->GetTarget();
218 const bool sync =
false;
235 process_sp->GetTarget().RemoveBreakpointByID(BID);
244 threads = std::make_shared<ThreadCollection>();
248 if (info->GetObjectForDotSeparatedPath(
"instrumentation_class")
249 ->GetStringValue() !=
"MainThreadChecker")
252 std::vector<lldb::addr_t> PCs;
253 auto trace = info->GetObjectForDotSeparatedPath(
"trace")->GetAsArray();
263 info->GetObjectForDotSeparatedPath(
"tid");
265 thread_id_obj ? thread_id_obj->GetUnsignedIntegerValue() : 0;
269 bool pcs_are_call_addresses =
true;
270 ThreadSP new_thread_sp = std::make_shared<HistoryThread>(
271 *process_sp, tid, PCs, pcs_are_call_addresses);
275 process_sp->GetExtendedThreadList().AddThread(new_thread_sp);
276 threads->AddThread(new_thread_sp);
#define LLDB_PLUGIN_DEFINE(PluginName)
A section + offset based address class.
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
lldb::addr_t GetOpcodeLoadAddress(Target *target, AddressClass addr_class=AddressClass::eInvalid) const
Get the load address as an opcode load address.
lldb::ModuleSP GetModule() const
Get accessor for the module for this address.
bool IsValid() const
Check if the object state is valid.
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
void SetBreakpointKind(const char *kind)
Set the "kind" description for a breakpoint.
Target & GetTarget()
Accessor for the breakpoint Target.
void SetCallback(BreakpointHitCallback callback, void *baton, bool is_synchronous=false)
Set the callback action invoked when the breakpoint is hit.
A uniqued constant string class.
Execution context objects refer to objects in the execution of the program that is being debugged.
lldb::ThreadSP GetThreadSP() const
Get accessor that creates a strong reference from the weak thread reference contained in this object.
lldb::ProcessSP GetProcessSP() const
Get accessor that creates a strong reference from the weak process reference contained in this object...
lldb::ThreadCollectionSP GetBacktracesFromExtendedStopInfo(StructuredData::ObjectSP info) override
void Activate() override
Register a breakpoint in the runtime library and perform any other necessary initialization.
static lldb::InstrumentationRuntimeSP CreateInstance(const lldb::ProcessSP &process_sp)
StructuredData::ObjectSP RetrieveReportData(ExecutionContextRef exe_ctx_ref)
static bool NotifyBreakpointHit(void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id)
static lldb::InstrumentationRuntimeType GetTypeStatic()
const RegularExpression & GetPatternForRuntimeLibrary() override
Return a regular expression which can be used to identify a valid version of the runtime library.
bool CheckIfRuntimeIsValid(const lldb::ModuleSP module_sp) override
Check whether module_sp corresponds to a valid runtime library.
static llvm::StringRef GetPluginNameStatic()
static lldb::StopInfoSP CreateStopReasonWithInstrumentationData(Thread &thread, std::string description, StructuredData::ObjectSP additional_data)
void SetBreakpointID(lldb::user_id_t ID)
void SetActive(bool IsActive)
lldb::user_id_t GetBreakpointID() const
lldb::ModuleSP GetRuntimeModuleSP()
lldb::ProcessSP GetProcessSP()
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
bool Fail() const
Test for error condition.
General Outline: When we hit a breakpoint we need to package up whatever information is needed to eva...
ExecutionContextRef exe_ctx_ref
lldb::break_id_t GetID() const
void AddIntegerItem(T value)
uint64_t GetUnsignedIntegerValue(uint64_t fail_value=0)
std::shared_ptr< Object > ObjectSP
bool ValueIsAddress() const
Address & GetAddressRef()
size_t ReadCStringFromMemory(const Address &addr, std::string &out_str, Status &error, bool force_live_memory=false)
lldb::BreakpointSP CreateBreakpoint(const FileSpecList *containingModules, const FileSpec &file, uint32_t line_no, uint32_t column, lldb::addr_t offset, LazyBool check_inlines, LazyBool skip_prologue, bool internal, bool request_hardware, LazyBool move_to_nearest_code)
#define LLDB_INVALID_BREAK_ID
#define LLDB_INVALID_ADDRESS
@ DoNoSelectMostRelevantFrame
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::Process > ProcessSP
InstrumentationRuntimeType
@ eInstrumentationRuntimeTypeMainThreadChecker
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
std::shared_ptr< lldb_private::InstrumentationRuntime > InstrumentationRuntimeSP
std::shared_ptr< lldb_private::Module > ModuleSP
std::shared_ptr< lldb_private::ThreadCollection > ThreadCollectionSP
Every register is described in detail including its name, alternate name (optional),...