This revision was automatically updated to reflect the committed changes. Closed by commit rG35b0b244401a: [lldb] Introduce DynamicRegisterInfo::CreateFromDict (authored by bulbazord).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D152594/new/ https://reviews.llvm.org/D152594 Files: lldb/include/lldb/Target/DynamicRegisterInfo.h lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp lldb/source/Plugins/Process/scripted/ScriptedThread.cpp lldb/source/Target/DynamicRegisterInfo.cpp Index: lldb/source/Target/DynamicRegisterInfo.cpp =================================================================== --- lldb/source/Target/DynamicRegisterInfo.cpp +++ lldb/source/Target/DynamicRegisterInfo.cpp @@ -20,10 +20,17 @@ using namespace lldb; using namespace lldb_private; -DynamicRegisterInfo::DynamicRegisterInfo( - const lldb_private::StructuredData::Dictionary &dict, - const lldb_private::ArchSpec &arch) { - SetRegisterInfo(dict, arch); +std::unique_ptr<DynamicRegisterInfo> +DynamicRegisterInfo::Create(const StructuredData::Dictionary &dict, + const ArchSpec &arch) { + auto dyn_reg_info = std::make_unique<DynamicRegisterInfo>(); + if (!dyn_reg_info) + return nullptr; + + if (dyn_reg_info->SetRegisterInfo(dict, arch) == 0) + return nullptr; + + return dyn_reg_info; } DynamicRegisterInfo::DynamicRegisterInfo(DynamicRegisterInfo &&info) { Index: lldb/source/Plugins/Process/scripted/ScriptedThread.cpp =================================================================== --- lldb/source/Plugins/Process/scripted/ScriptedThread.cpp +++ lldb/source/Plugins/Process/scripted/ScriptedThread.cpp @@ -341,7 +341,7 @@ LLVM_PRETTY_FUNCTION, "Failed to get scripted thread registers info.", error, LLDBLog::Thread); - m_register_info_sp = std::make_shared<DynamicRegisterInfo>( + m_register_info_sp = DynamicRegisterInfo::Create( *reg_info, m_scripted_process.GetTarget().GetArchitecture()); } Index: lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp =================================================================== --- lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp +++ lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp @@ -128,8 +128,9 @@ if (!dictionary) return nullptr; - m_register_info_up = std::make_unique<DynamicRegisterInfo>( + m_register_info_up = DynamicRegisterInfo::Create( *dictionary, m_process->GetTarget().GetArchitecture()); + assert(m_register_info_up); assert(m_register_info_up->GetNumRegisters() > 0); assert(m_register_info_up->GetNumRegisterSets() > 0); } Index: lldb/include/lldb/Target/DynamicRegisterInfo.h =================================================================== --- lldb/include/lldb/Target/DynamicRegisterInfo.h +++ lldb/include/lldb/Target/DynamicRegisterInfo.h @@ -46,8 +46,8 @@ DynamicRegisterInfo() = default; - DynamicRegisterInfo(const lldb_private::StructuredData::Dictionary &dict, - const lldb_private::ArchSpec &arch); + static std::unique_ptr<DynamicRegisterInfo> + Create(const StructuredData::Dictionary &dict, const ArchSpec &arch); virtual ~DynamicRegisterInfo() = default;
Index: lldb/source/Target/DynamicRegisterInfo.cpp =================================================================== --- lldb/source/Target/DynamicRegisterInfo.cpp +++ lldb/source/Target/DynamicRegisterInfo.cpp @@ -20,10 +20,17 @@ using namespace lldb; using namespace lldb_private; -DynamicRegisterInfo::DynamicRegisterInfo( - const lldb_private::StructuredData::Dictionary &dict, - const lldb_private::ArchSpec &arch) { - SetRegisterInfo(dict, arch); +std::unique_ptr<DynamicRegisterInfo> +DynamicRegisterInfo::Create(const StructuredData::Dictionary &dict, + const ArchSpec &arch) { + auto dyn_reg_info = std::make_unique<DynamicRegisterInfo>(); + if (!dyn_reg_info) + return nullptr; + + if (dyn_reg_info->SetRegisterInfo(dict, arch) == 0) + return nullptr; + + return dyn_reg_info; } DynamicRegisterInfo::DynamicRegisterInfo(DynamicRegisterInfo &&info) { Index: lldb/source/Plugins/Process/scripted/ScriptedThread.cpp =================================================================== --- lldb/source/Plugins/Process/scripted/ScriptedThread.cpp +++ lldb/source/Plugins/Process/scripted/ScriptedThread.cpp @@ -341,7 +341,7 @@ LLVM_PRETTY_FUNCTION, "Failed to get scripted thread registers info.", error, LLDBLog::Thread); - m_register_info_sp = std::make_shared<DynamicRegisterInfo>( + m_register_info_sp = DynamicRegisterInfo::Create( *reg_info, m_scripted_process.GetTarget().GetArchitecture()); } Index: lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp =================================================================== --- lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp +++ lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp @@ -128,8 +128,9 @@ if (!dictionary) return nullptr; - m_register_info_up = std::make_unique<DynamicRegisterInfo>( + m_register_info_up = DynamicRegisterInfo::Create( *dictionary, m_process->GetTarget().GetArchitecture()); + assert(m_register_info_up); assert(m_register_info_up->GetNumRegisters() > 0); assert(m_register_info_up->GetNumRegisterSets() > 0); } Index: lldb/include/lldb/Target/DynamicRegisterInfo.h =================================================================== --- lldb/include/lldb/Target/DynamicRegisterInfo.h +++ lldb/include/lldb/Target/DynamicRegisterInfo.h @@ -46,8 +46,8 @@ DynamicRegisterInfo() = default; - DynamicRegisterInfo(const lldb_private::StructuredData::Dictionary &dict, - const lldb_private::ArchSpec &arch); + static std::unique_ptr<DynamicRegisterInfo> + Create(const StructuredData::Dictionary &dict, const ArchSpec &arch); virtual ~DynamicRegisterInfo() = default;
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits