diff options
Diffstat (limited to 'source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp')
-rw-r--r-- | source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp b/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp index 89a0f22539365..c1fe0cc8dddaf 100644 --- a/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp +++ b/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp @@ -1,15 +1,15 @@ //===-- OperatingSystemPython.cpp --------------------------------*- C++-*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef LLDB_DISABLE_PYTHON #include "OperatingSystemPython.h" + #include "Plugins/Process/Utility/DynamicRegisterInfo.h" #include "Plugins/Process/Utility/RegisterContextDummy.h" #include "Plugins/Process/Utility/RegisterContextMemory.h" @@ -32,6 +32,8 @@ #include "lldb/Utility/StreamString.h" #include "lldb/Utility/StructuredData.h" +#include <memory> + using namespace lldb; using namespace lldb_private; @@ -52,12 +54,12 @@ OperatingSystem *OperatingSystemPython::CreateInstance(Process *process, FileSpec python_os_plugin_spec(process->GetPythonOSPluginPath()); if (python_os_plugin_spec && FileSystem::Instance().Exists(python_os_plugin_spec)) { - std::unique_ptr<OperatingSystemPython> os_ap( + std::unique_ptr<OperatingSystemPython> os_up( new OperatingSystemPython(process, python_os_plugin_spec)); - if (os_ap.get() && os_ap->IsValid()) - return os_ap.release(); + if (os_up.get() && os_up->IsValid()) + return os_up.release(); } - return NULL; + return nullptr; } ConstString OperatingSystemPython::GetPluginNameStatic() { @@ -72,15 +74,14 @@ const char *OperatingSystemPython::GetPluginDescriptionStatic() { OperatingSystemPython::OperatingSystemPython(lldb_private::Process *process, const FileSpec &python_module_path) - : OperatingSystem(process), m_thread_list_valobj_sp(), m_register_info_ap(), - m_interpreter(NULL), m_python_object_sp() { + : OperatingSystem(process), m_thread_list_valobj_sp(), m_register_info_up(), + m_interpreter(nullptr), m_python_object_sp() { if (!process) return; TargetSP target_sp = process->CalculateTarget(); if (!target_sp) return; - m_interpreter = - target_sp->GetDebugger().GetCommandInterpreter().GetScriptInterpreter(); + m_interpreter = target_sp->GetDebugger().GetScriptInterpreter(); if (m_interpreter) { std::string os_plugin_class_name( @@ -114,9 +115,9 @@ OperatingSystemPython::OperatingSystemPython(lldb_private::Process *process, OperatingSystemPython::~OperatingSystemPython() {} DynamicRegisterInfo *OperatingSystemPython::GetDynamicRegisterInfo() { - if (m_register_info_ap.get() == NULL) { + if (m_register_info_up == nullptr) { if (!m_interpreter || !m_python_object_sp) - return NULL; + return nullptr; Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_OS)); if (log) @@ -127,19 +128,17 @@ DynamicRegisterInfo *OperatingSystemPython::GetDynamicRegisterInfo() { StructuredData::DictionarySP dictionary = m_interpreter->OSPlugin_RegisterInfo(m_python_object_sp); if (!dictionary) - return NULL; + return nullptr; - m_register_info_ap.reset(new DynamicRegisterInfo( + m_register_info_up.reset(new DynamicRegisterInfo( *dictionary, m_process->GetTarget().GetArchitecture())); - assert(m_register_info_ap->GetNumRegisters() > 0); - assert(m_register_info_ap->GetNumRegisterSets() > 0); + assert(m_register_info_up->GetNumRegisters() > 0); + assert(m_register_info_up->GetNumRegisterSets() > 0); } - return m_register_info_ap.get(); + return m_register_info_up.get(); } -//------------------------------------------------------------------ // PluginInterface protocol -//------------------------------------------------------------------ ConstString OperatingSystemPython::GetPluginName() { return GetPluginNameStatic(); } @@ -199,9 +198,9 @@ bool OperatingSystemPython::UpdateThreadList(ThreadList &old_thread_list, StructuredData::ObjectSP thread_dict_obj = threads_list->GetItemAtIndex(i); if (auto thread_dict = thread_dict_obj->GetAsDictionary()) { - ThreadSP thread_sp( - CreateThreadFromThreadInfo(*thread_dict, core_thread_list, - old_thread_list, core_used_map, NULL)); + ThreadSP thread_sp(CreateThreadFromThreadInfo( + *thread_dict, core_thread_list, old_thread_list, core_used_map, + nullptr)); if (thread_sp) new_thread_list.AddThread(thread_sp); } @@ -260,8 +259,8 @@ ThreadSP OperatingSystemPython::CreateThreadFromThreadInfo( if (!thread_sp) { if (did_create_ptr) *did_create_ptr = true; - thread_sp.reset( - new ThreadMemory(*m_process, tid, name, queue, reg_data_addr)); + thread_sp = std::make_shared<ThreadMemory>(*m_process, tid, name, queue, + reg_data_addr); } if (core_number < core_thread_list.GetSize(false)) { @@ -322,8 +321,8 @@ OperatingSystemPython::CreateRegisterContextForThread(Thread *thread, "= 0x%" PRIx64 ", 0x%" PRIx64 ", reg_data_addr = 0x%" PRIx64 ") creating memory register context", thread->GetID(), thread->GetProtocolID(), reg_data_addr); - reg_ctx_sp.reset(new RegisterContextMemory( - *thread, 0, *GetDynamicRegisterInfo(), reg_data_addr)); + reg_ctx_sp = std::make_shared<RegisterContextMemory>( + *thread, 0, *GetDynamicRegisterInfo(), reg_data_addr); } else { // No register data address is provided, query the python plug-in to let it // make up the data as it sees fit @@ -356,8 +355,8 @@ OperatingSystemPython::CreateRegisterContextForThread(Thread *thread, log->Printf("OperatingSystemPython::CreateRegisterContextForThread (tid " "= 0x%" PRIx64 ") forcing a dummy register context", thread->GetID()); - reg_ctx_sp.reset(new RegisterContextDummy( - *thread, 0, target.GetArchitecture().GetAddressByteSize())); + reg_ctx_sp = std::make_shared<RegisterContextDummy>( + *thread, 0, target.GetArchitecture().GetAddressByteSize()); } return reg_ctx_sp; } |