1349cc55cSDimitry Andric //===-- ScriptedThread.cpp ------------------------------------------------===// 2349cc55cSDimitry Andric // 3349cc55cSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4349cc55cSDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 5349cc55cSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6349cc55cSDimitry Andric // 7349cc55cSDimitry Andric //===----------------------------------------------------------------------===// 8349cc55cSDimitry Andric 9349cc55cSDimitry Andric #include "ScriptedThread.h" 10349cc55cSDimitry Andric 11349cc55cSDimitry Andric #include "Plugins/Process/Utility/RegisterContextThreadMemory.h" 12bdd1243dSDimitry Andric #include "Plugins/Process/Utility/StopInfoMachException.h" 13349cc55cSDimitry Andric #include "lldb/Target/OperatingSystem.h" 14349cc55cSDimitry Andric #include "lldb/Target/Process.h" 15349cc55cSDimitry Andric #include "lldb/Target/RegisterContext.h" 16349cc55cSDimitry Andric #include "lldb/Target/StopInfo.h" 17349cc55cSDimitry Andric #include "lldb/Target/Unwind.h" 18349cc55cSDimitry Andric #include "lldb/Utility/DataBufferHeap.h" 1981ad6265SDimitry Andric #include "lldb/Utility/LLDBLog.h" 20349cc55cSDimitry Andric #include <memory> 21bdd1243dSDimitry Andric #include <optional> 22349cc55cSDimitry Andric 23349cc55cSDimitry Andric using namespace lldb; 24349cc55cSDimitry Andric using namespace lldb_private; 25349cc55cSDimitry Andric 26349cc55cSDimitry Andric void ScriptedThread::CheckInterpreterAndScriptObject() const { 27349cc55cSDimitry Andric lldbassert(m_script_object_sp && "Invalid Script Object."); 28349cc55cSDimitry Andric lldbassert(GetInterface() && "Invalid Scripted Thread Interface."); 29349cc55cSDimitry Andric } 30349cc55cSDimitry Andric 3104eeddc0SDimitry Andric llvm::Expected<std::shared_ptr<ScriptedThread>> 3204eeddc0SDimitry Andric ScriptedThread::Create(ScriptedProcess &process, 3304eeddc0SDimitry Andric StructuredData::Generic *script_object) { 3404eeddc0SDimitry Andric if (!process.IsValid()) 3504eeddc0SDimitry Andric return llvm::createStringError(llvm::inconvertibleErrorCode(), 3604eeddc0SDimitry Andric "Invalid scripted process."); 37349cc55cSDimitry Andric 38*06c3fb27SDimitry Andric process.CheckScriptedInterface(); 39349cc55cSDimitry Andric 4004eeddc0SDimitry Andric auto scripted_thread_interface = 4104eeddc0SDimitry Andric process.GetInterface().CreateScriptedThreadInterface(); 4204eeddc0SDimitry Andric if (!scripted_thread_interface) 4304eeddc0SDimitry Andric return llvm::createStringError( 4404eeddc0SDimitry Andric llvm::inconvertibleErrorCode(), 4504eeddc0SDimitry Andric "Failed to create scripted thread interface."); 46349cc55cSDimitry Andric 4704eeddc0SDimitry Andric llvm::StringRef thread_class_name; 4804eeddc0SDimitry Andric if (!script_object) { 49bdd1243dSDimitry Andric std::optional<std::string> class_name = 50349cc55cSDimitry Andric process.GetInterface().GetScriptedThreadPluginName(); 5104eeddc0SDimitry Andric if (!class_name || class_name->empty()) 5204eeddc0SDimitry Andric return llvm::createStringError( 5304eeddc0SDimitry Andric llvm::inconvertibleErrorCode(), 5404eeddc0SDimitry Andric "Failed to get scripted thread class name."); 5504eeddc0SDimitry Andric thread_class_name = *class_name; 56349cc55cSDimitry Andric } 57349cc55cSDimitry Andric 58349cc55cSDimitry Andric ExecutionContext exe_ctx(process); 5904eeddc0SDimitry Andric StructuredData::GenericSP owned_script_object_sp = 60349cc55cSDimitry Andric scripted_thread_interface->CreatePluginObject( 61bdd1243dSDimitry Andric thread_class_name, exe_ctx, process.m_scripted_metadata.GetArgsSP(), 62bdd1243dSDimitry Andric script_object); 6304eeddc0SDimitry Andric 6404eeddc0SDimitry Andric if (!owned_script_object_sp) 6504eeddc0SDimitry Andric return llvm::createStringError(llvm::inconvertibleErrorCode(), 6604eeddc0SDimitry Andric "Failed to create script object."); 6704eeddc0SDimitry Andric if (!owned_script_object_sp->IsValid()) 6804eeddc0SDimitry Andric return llvm::createStringError(llvm::inconvertibleErrorCode(), 6904eeddc0SDimitry Andric "Created script object is invalid."); 7004eeddc0SDimitry Andric 7104eeddc0SDimitry Andric lldb::tid_t tid = scripted_thread_interface->GetThreadID(); 7204eeddc0SDimitry Andric 7304eeddc0SDimitry Andric return std::make_shared<ScriptedThread>(process, scripted_thread_interface, 7404eeddc0SDimitry Andric tid, owned_script_object_sp); 75349cc55cSDimitry Andric } 76349cc55cSDimitry Andric 7704eeddc0SDimitry Andric ScriptedThread::ScriptedThread(ScriptedProcess &process, 7804eeddc0SDimitry Andric ScriptedThreadInterfaceSP interface_sp, 7904eeddc0SDimitry Andric lldb::tid_t tid, 8004eeddc0SDimitry Andric StructuredData::GenericSP script_object_sp) 8104eeddc0SDimitry Andric : Thread(process, tid), m_scripted_process(process), 8204eeddc0SDimitry Andric m_scripted_thread_interface_sp(interface_sp), 8304eeddc0SDimitry Andric m_script_object_sp(script_object_sp) {} 84349cc55cSDimitry Andric 85349cc55cSDimitry Andric ScriptedThread::~ScriptedThread() { DestroyThread(); } 86349cc55cSDimitry Andric 87349cc55cSDimitry Andric const char *ScriptedThread::GetName() { 88349cc55cSDimitry Andric CheckInterpreterAndScriptObject(); 89bdd1243dSDimitry Andric std::optional<std::string> thread_name = GetInterface()->GetName(); 90349cc55cSDimitry Andric if (!thread_name) 91349cc55cSDimitry Andric return nullptr; 92349cc55cSDimitry Andric return ConstString(thread_name->c_str()).AsCString(); 93349cc55cSDimitry Andric } 94349cc55cSDimitry Andric 95349cc55cSDimitry Andric const char *ScriptedThread::GetQueueName() { 96349cc55cSDimitry Andric CheckInterpreterAndScriptObject(); 97bdd1243dSDimitry Andric std::optional<std::string> queue_name = GetInterface()->GetQueue(); 98349cc55cSDimitry Andric if (!queue_name) 99349cc55cSDimitry Andric return nullptr; 100349cc55cSDimitry Andric return ConstString(queue_name->c_str()).AsCString(); 101349cc55cSDimitry Andric } 102349cc55cSDimitry Andric 103349cc55cSDimitry Andric void ScriptedThread::WillResume(StateType resume_state) {} 104349cc55cSDimitry Andric 105349cc55cSDimitry Andric void ScriptedThread::ClearStackFrames() { Thread::ClearStackFrames(); } 106349cc55cSDimitry Andric 107349cc55cSDimitry Andric RegisterContextSP ScriptedThread::GetRegisterContext() { 108349cc55cSDimitry Andric if (!m_reg_context_sp) 109349cc55cSDimitry Andric m_reg_context_sp = CreateRegisterContextForFrame(nullptr); 110349cc55cSDimitry Andric return m_reg_context_sp; 111349cc55cSDimitry Andric } 112349cc55cSDimitry Andric 113349cc55cSDimitry Andric RegisterContextSP 114349cc55cSDimitry Andric ScriptedThread::CreateRegisterContextForFrame(StackFrame *frame) { 115349cc55cSDimitry Andric const uint32_t concrete_frame_idx = 116349cc55cSDimitry Andric frame ? frame->GetConcreteFrameIndex() : 0; 117349cc55cSDimitry Andric 118349cc55cSDimitry Andric if (concrete_frame_idx) 119349cc55cSDimitry Andric return GetUnwinder().CreateRegisterContextForFrame(frame); 120349cc55cSDimitry Andric 121349cc55cSDimitry Andric lldb::RegisterContextSP reg_ctx_sp; 122349cc55cSDimitry Andric Status error; 123349cc55cSDimitry Andric 124bdd1243dSDimitry Andric std::optional<std::string> reg_data = GetInterface()->GetRegisterContext(); 125349cc55cSDimitry Andric if (!reg_data) 12681ad6265SDimitry Andric return ScriptedInterface::ErrorWithMessage<lldb::RegisterContextSP>( 127349cc55cSDimitry Andric LLVM_PRETTY_FUNCTION, "Failed to get scripted thread registers data.", 12881ad6265SDimitry Andric error, LLDBLog::Thread); 129349cc55cSDimitry Andric 130349cc55cSDimitry Andric DataBufferSP data_sp( 131349cc55cSDimitry Andric std::make_shared<DataBufferHeap>(reg_data->c_str(), reg_data->size())); 132349cc55cSDimitry Andric 133349cc55cSDimitry Andric if (!data_sp->GetByteSize()) 13481ad6265SDimitry Andric return ScriptedInterface::ErrorWithMessage<lldb::RegisterContextSP>( 135349cc55cSDimitry Andric LLVM_PRETTY_FUNCTION, "Failed to copy raw registers data.", error, 13681ad6265SDimitry Andric LLDBLog::Thread); 137349cc55cSDimitry Andric 138349cc55cSDimitry Andric std::shared_ptr<RegisterContextMemory> reg_ctx_memory = 139349cc55cSDimitry Andric std::make_shared<RegisterContextMemory>( 140349cc55cSDimitry Andric *this, 0, *GetDynamicRegisterInfo(), LLDB_INVALID_ADDRESS); 141349cc55cSDimitry Andric if (!reg_ctx_memory) 14281ad6265SDimitry Andric return ScriptedInterface::ErrorWithMessage<lldb::RegisterContextSP>( 143349cc55cSDimitry Andric LLVM_PRETTY_FUNCTION, "Failed to create a register context.", error, 14481ad6265SDimitry Andric LLDBLog::Thread); 145349cc55cSDimitry Andric 146349cc55cSDimitry Andric reg_ctx_memory->SetAllRegisterData(data_sp); 147349cc55cSDimitry Andric m_reg_context_sp = reg_ctx_memory; 148349cc55cSDimitry Andric 149349cc55cSDimitry Andric return m_reg_context_sp; 150349cc55cSDimitry Andric } 151349cc55cSDimitry Andric 15281ad6265SDimitry Andric bool ScriptedThread::LoadArtificialStackFrames() { 15381ad6265SDimitry Andric StructuredData::ArraySP arr_sp = GetInterface()->GetStackFrames(); 15481ad6265SDimitry Andric 15581ad6265SDimitry Andric Status error; 15681ad6265SDimitry Andric if (!arr_sp) 15781ad6265SDimitry Andric return ScriptedInterface::ErrorWithMessage<bool>( 15881ad6265SDimitry Andric LLVM_PRETTY_FUNCTION, "Failed to get scripted thread stackframes.", 15981ad6265SDimitry Andric error, LLDBLog::Thread); 16081ad6265SDimitry Andric 16181ad6265SDimitry Andric size_t arr_size = arr_sp->GetSize(); 16281ad6265SDimitry Andric if (arr_size > std::numeric_limits<uint32_t>::max()) 16381ad6265SDimitry Andric return ScriptedInterface::ErrorWithMessage<bool>( 16481ad6265SDimitry Andric LLVM_PRETTY_FUNCTION, 16581ad6265SDimitry Andric llvm::Twine( 16681ad6265SDimitry Andric "StackFrame array size (" + llvm::Twine(arr_size) + 16781ad6265SDimitry Andric llvm::Twine( 168bdd1243dSDimitry Andric ") is greater than maximum authorized for a StackFrameList.")) 16981ad6265SDimitry Andric .str(), 17081ad6265SDimitry Andric error, LLDBLog::Thread); 17181ad6265SDimitry Andric 17281ad6265SDimitry Andric StackFrameListSP frames = GetStackFrameList(); 17381ad6265SDimitry Andric 17481ad6265SDimitry Andric for (size_t idx = 0; idx < arr_size; idx++) { 17581ad6265SDimitry Andric StructuredData::Dictionary *dict; 17681ad6265SDimitry Andric if (!arr_sp->GetItemAtIndexAsDictionary(idx, dict) || !dict) 17781ad6265SDimitry Andric return ScriptedInterface::ErrorWithMessage<bool>( 17881ad6265SDimitry Andric LLVM_PRETTY_FUNCTION, 17981ad6265SDimitry Andric llvm::Twine( 18081ad6265SDimitry Andric "Couldn't get artificial stackframe dictionary at index (" + 18181ad6265SDimitry Andric llvm::Twine(idx) + llvm::Twine(") from stackframe array.")) 18281ad6265SDimitry Andric .str(), 18381ad6265SDimitry Andric error, LLDBLog::Thread); 18481ad6265SDimitry Andric 18581ad6265SDimitry Andric lldb::addr_t pc; 18681ad6265SDimitry Andric if (!dict->GetValueForKeyAsInteger("pc", pc)) 18781ad6265SDimitry Andric return ScriptedInterface::ErrorWithMessage<bool>( 18881ad6265SDimitry Andric LLVM_PRETTY_FUNCTION, 18981ad6265SDimitry Andric "Couldn't find value for key 'pc' in stackframe dictionary.", error, 19081ad6265SDimitry Andric LLDBLog::Thread); 19181ad6265SDimitry Andric 19281ad6265SDimitry Andric Address symbol_addr; 19381ad6265SDimitry Andric symbol_addr.SetLoadAddress(pc, &this->GetProcess()->GetTarget()); 19481ad6265SDimitry Andric 19581ad6265SDimitry Andric lldb::addr_t cfa = LLDB_INVALID_ADDRESS; 19681ad6265SDimitry Andric bool cfa_is_valid = false; 19781ad6265SDimitry Andric const bool behaves_like_zeroth_frame = false; 19881ad6265SDimitry Andric SymbolContext sc; 19981ad6265SDimitry Andric symbol_addr.CalculateSymbolContext(&sc); 20081ad6265SDimitry Andric 20181ad6265SDimitry Andric StackFrameSP synth_frame_sp = std::make_shared<StackFrame>( 20281ad6265SDimitry Andric this->shared_from_this(), idx, idx, cfa, cfa_is_valid, pc, 20381ad6265SDimitry Andric StackFrame::Kind::Artificial, behaves_like_zeroth_frame, &sc); 20481ad6265SDimitry Andric 20581ad6265SDimitry Andric if (!frames->SetFrameAtIndex(static_cast<uint32_t>(idx), synth_frame_sp)) 20681ad6265SDimitry Andric return ScriptedInterface::ErrorWithMessage<bool>( 20781ad6265SDimitry Andric LLVM_PRETTY_FUNCTION, 20881ad6265SDimitry Andric llvm::Twine("Couldn't add frame (" + llvm::Twine(idx) + 20981ad6265SDimitry Andric llvm::Twine(") to ScriptedThread StackFrameList.")) 21081ad6265SDimitry Andric .str(), 21181ad6265SDimitry Andric error, LLDBLog::Thread); 21281ad6265SDimitry Andric } 21381ad6265SDimitry Andric 21481ad6265SDimitry Andric return true; 21581ad6265SDimitry Andric } 21681ad6265SDimitry Andric 217349cc55cSDimitry Andric bool ScriptedThread::CalculateStopInfo() { 218349cc55cSDimitry Andric StructuredData::DictionarySP dict_sp = GetInterface()->GetStopReason(); 219349cc55cSDimitry Andric 220349cc55cSDimitry Andric Status error; 22104eeddc0SDimitry Andric if (!dict_sp) 22281ad6265SDimitry Andric return ScriptedInterface::ErrorWithMessage<bool>( 22304eeddc0SDimitry Andric LLVM_PRETTY_FUNCTION, "Failed to get scripted thread stop info.", error, 22481ad6265SDimitry Andric LLDBLog::Thread); 22504eeddc0SDimitry Andric 226349cc55cSDimitry Andric lldb::StopInfoSP stop_info_sp; 227349cc55cSDimitry Andric lldb::StopReason stop_reason_type; 228349cc55cSDimitry Andric 229349cc55cSDimitry Andric if (!dict_sp->GetValueForKeyAsInteger("type", stop_reason_type)) 23081ad6265SDimitry Andric return ScriptedInterface::ErrorWithMessage<bool>( 231349cc55cSDimitry Andric LLVM_PRETTY_FUNCTION, 232349cc55cSDimitry Andric "Couldn't find value for key 'type' in stop reason dictionary.", error, 23381ad6265SDimitry Andric LLDBLog::Thread); 234349cc55cSDimitry Andric 235349cc55cSDimitry Andric StructuredData::Dictionary *data_dict; 236349cc55cSDimitry Andric if (!dict_sp->GetValueForKeyAsDictionary("data", data_dict)) 23781ad6265SDimitry Andric return ScriptedInterface::ErrorWithMessage<bool>( 238349cc55cSDimitry Andric LLVM_PRETTY_FUNCTION, 23904eeddc0SDimitry Andric "Couldn't find value for key 'data' in stop reason dictionary.", error, 24081ad6265SDimitry Andric LLDBLog::Thread); 241349cc55cSDimitry Andric 242349cc55cSDimitry Andric switch (stop_reason_type) { 243349cc55cSDimitry Andric case lldb::eStopReasonNone: 24404eeddc0SDimitry Andric return true; 245349cc55cSDimitry Andric case lldb::eStopReasonBreakpoint: { 246349cc55cSDimitry Andric lldb::break_id_t break_id; 247349cc55cSDimitry Andric data_dict->GetValueForKeyAsInteger("break_id", break_id, 248349cc55cSDimitry Andric LLDB_INVALID_BREAK_ID); 249349cc55cSDimitry Andric stop_info_sp = 250349cc55cSDimitry Andric StopInfo::CreateStopReasonWithBreakpointSiteID(*this, break_id); 251349cc55cSDimitry Andric } break; 252349cc55cSDimitry Andric case lldb::eStopReasonSignal: { 253*06c3fb27SDimitry Andric uint32_t signal; 254349cc55cSDimitry Andric llvm::StringRef description; 255*06c3fb27SDimitry Andric if (!data_dict->GetValueForKeyAsInteger("signal", signal)) { 256*06c3fb27SDimitry Andric signal = LLDB_INVALID_SIGNAL_NUMBER; 257*06c3fb27SDimitry Andric return false; 258*06c3fb27SDimitry Andric } 259349cc55cSDimitry Andric data_dict->GetValueForKeyAsString("desc", description); 260349cc55cSDimitry Andric stop_info_sp = 261349cc55cSDimitry Andric StopInfo::CreateStopReasonWithSignal(*this, signal, description.data()); 262349cc55cSDimitry Andric } break; 263*06c3fb27SDimitry Andric case lldb::eStopReasonTrace: { 264*06c3fb27SDimitry Andric stop_info_sp = StopInfo::CreateStopReasonToTrace(*this); 265*06c3fb27SDimitry Andric } break; 26604eeddc0SDimitry Andric case lldb::eStopReasonException: { 267bdd1243dSDimitry Andric #if defined(__APPLE__) 268bdd1243dSDimitry Andric StructuredData::Dictionary *mach_exception; 269bdd1243dSDimitry Andric if (data_dict->GetValueForKeyAsDictionary("mach_exception", 270bdd1243dSDimitry Andric mach_exception)) { 271bdd1243dSDimitry Andric llvm::StringRef value; 272bdd1243dSDimitry Andric mach_exception->GetValueForKeyAsString("type", value); 273bdd1243dSDimitry Andric auto exc_type = 274bdd1243dSDimitry Andric StopInfoMachException::MachException::ExceptionCode(value.data()); 27504eeddc0SDimitry Andric 276bdd1243dSDimitry Andric if (!exc_type) 277bdd1243dSDimitry Andric return false; 278bdd1243dSDimitry Andric 279bdd1243dSDimitry Andric uint32_t exc_data_size = 0; 280bdd1243dSDimitry Andric llvm::SmallVector<uint64_t, 3> raw_codes; 281bdd1243dSDimitry Andric 282bdd1243dSDimitry Andric StructuredData::Array *exc_rawcodes; 283bdd1243dSDimitry Andric mach_exception->GetValueForKeyAsArray("rawCodes", exc_rawcodes); 284bdd1243dSDimitry Andric if (exc_rawcodes) { 285bdd1243dSDimitry Andric auto fetch_data = [&raw_codes](StructuredData::Object *obj) { 286bdd1243dSDimitry Andric if (!obj) 287bdd1243dSDimitry Andric return false; 288*06c3fb27SDimitry Andric raw_codes.push_back(obj->GetUnsignedIntegerValue()); 289bdd1243dSDimitry Andric return true; 290bdd1243dSDimitry Andric }; 291bdd1243dSDimitry Andric 292bdd1243dSDimitry Andric exc_rawcodes->ForEach(fetch_data); 293bdd1243dSDimitry Andric exc_data_size = raw_codes.size(); 294bdd1243dSDimitry Andric } 295bdd1243dSDimitry Andric 296bdd1243dSDimitry Andric stop_info_sp = StopInfoMachException::CreateStopReasonWithMachException( 297bdd1243dSDimitry Andric *this, *exc_type, exc_data_size, 298bdd1243dSDimitry Andric exc_data_size >= 1 ? raw_codes[0] : 0, 299bdd1243dSDimitry Andric exc_data_size >= 2 ? raw_codes[1] : 0, 300bdd1243dSDimitry Andric exc_data_size >= 3 ? raw_codes[2] : 0); 301bdd1243dSDimitry Andric 302bdd1243dSDimitry Andric break; 303bdd1243dSDimitry Andric } 304bdd1243dSDimitry Andric #endif 30504eeddc0SDimitry Andric stop_info_sp = 306bdd1243dSDimitry Andric StopInfo::CreateStopReasonWithException(*this, "EXC_BAD_ACCESS"); 30704eeddc0SDimitry Andric } break; 308349cc55cSDimitry Andric default: 30981ad6265SDimitry Andric return ScriptedInterface::ErrorWithMessage<bool>( 310349cc55cSDimitry Andric LLVM_PRETTY_FUNCTION, 311349cc55cSDimitry Andric llvm::Twine("Unsupported stop reason type (" + 312349cc55cSDimitry Andric llvm::Twine(stop_reason_type) + llvm::Twine(").")) 313349cc55cSDimitry Andric .str(), 31481ad6265SDimitry Andric error, LLDBLog::Thread); 315349cc55cSDimitry Andric } 316349cc55cSDimitry Andric 31704eeddc0SDimitry Andric if (!stop_info_sp) 31804eeddc0SDimitry Andric return false; 31904eeddc0SDimitry Andric 320349cc55cSDimitry Andric SetStopInfo(stop_info_sp); 321349cc55cSDimitry Andric return true; 322349cc55cSDimitry Andric } 323349cc55cSDimitry Andric 324349cc55cSDimitry Andric void ScriptedThread::RefreshStateAfterStop() { 325349cc55cSDimitry Andric GetRegisterContext()->InvalidateIfNeeded(/*force=*/false); 32681ad6265SDimitry Andric LoadArtificialStackFrames(); 327349cc55cSDimitry Andric } 328349cc55cSDimitry Andric 329349cc55cSDimitry Andric lldb::ScriptedThreadInterfaceSP ScriptedThread::GetInterface() const { 33004eeddc0SDimitry Andric return m_scripted_thread_interface_sp; 331349cc55cSDimitry Andric } 332349cc55cSDimitry Andric 333349cc55cSDimitry Andric std::shared_ptr<DynamicRegisterInfo> ScriptedThread::GetDynamicRegisterInfo() { 334349cc55cSDimitry Andric CheckInterpreterAndScriptObject(); 335349cc55cSDimitry Andric 336349cc55cSDimitry Andric if (!m_register_info_sp) { 337349cc55cSDimitry Andric StructuredData::DictionarySP reg_info = GetInterface()->GetRegisterInfo(); 3380eae32dcSDimitry Andric 3390eae32dcSDimitry Andric Status error; 340349cc55cSDimitry Andric if (!reg_info) 341bdd1243dSDimitry Andric return ScriptedInterface::ErrorWithMessage< 342bdd1243dSDimitry Andric std::shared_ptr<DynamicRegisterInfo>>( 343bdd1243dSDimitry Andric LLVM_PRETTY_FUNCTION, "Failed to get scripted thread registers info.", 344bdd1243dSDimitry Andric error, LLDBLog::Thread); 345349cc55cSDimitry Andric 346*06c3fb27SDimitry Andric m_register_info_sp = DynamicRegisterInfo::Create( 347349cc55cSDimitry Andric *reg_info, m_scripted_process.GetTarget().GetArchitecture()); 348349cc55cSDimitry Andric } 349349cc55cSDimitry Andric 350349cc55cSDimitry Andric return m_register_info_sp; 351349cc55cSDimitry Andric } 352bdd1243dSDimitry Andric 353bdd1243dSDimitry Andric StructuredData::ObjectSP ScriptedThread::FetchThreadExtendedInfo() { 354bdd1243dSDimitry Andric CheckInterpreterAndScriptObject(); 355bdd1243dSDimitry Andric 356bdd1243dSDimitry Andric Status error; 357bdd1243dSDimitry Andric StructuredData::ArraySP extended_info_sp = GetInterface()->GetExtendedInfo(); 358bdd1243dSDimitry Andric 359bdd1243dSDimitry Andric if (!extended_info_sp || !extended_info_sp->GetSize()) 360bdd1243dSDimitry Andric return ScriptedInterface::ErrorWithMessage<StructuredData::ObjectSP>( 361bdd1243dSDimitry Andric LLVM_PRETTY_FUNCTION, "No extended information found", error); 362bdd1243dSDimitry Andric 363bdd1243dSDimitry Andric return extended_info_sp; 364bdd1243dSDimitry Andric } 365