diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:06:29 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2019-01-19 10:06:29 +0000 |
commit | 94994d372d014ce4c8758b9605d63fae651bd8aa (patch) | |
tree | 51c0b708bd59f205d6b35cb2a8c24d62f0c33d77 /source/API | |
parent | 39be7ce23363d12ae3e49aeb1fdb2bfeb892e836 (diff) | |
download | src-94994d372d014ce4c8758b9605d63fae651bd8aa.tar.gz src-94994d372d014ce4c8758b9605d63fae651bd8aa.zip |
Vendor import of lldb trunk r351319 (just before the release_80 branchvendor/lldb/lldb-trunk-r351319
Notes
Notes:
svn path=/vendor/lldb/dist/; revision=343181
svn path=/vendor/lldb/lldb-trunk-r351319/; revision=343182; tag=vendor/lldb/lldb-trunk-r351319
Diffstat (limited to 'source/API')
54 files changed, 878 insertions, 458 deletions
diff --git a/source/API/CMakeLists.txt b/source/API/CMakeLists.txt index be9d4115cecc..e4ec64e537af 100644 --- a/source/API/CMakeLists.txt +++ b/source/API/CMakeLists.txt @@ -4,6 +4,11 @@ endif() get_property(LLDB_ALL_PLUGINS GLOBAL PROPERTY LLDB_PLUGINS) +if(NOT LLDB_DISABLE_PYTHON) + get_target_property(lldb_scripts_dir swig_wrapper BINARY_DIR) + set(lldb_python_wrapper ${lldb_scripts_dir}/LLDBWrapPython.cpp) +endif() + add_lldb_library(liblldb SHARED SBAddress.cpp SBAttachInfo.cpp @@ -29,6 +34,7 @@ add_lldb_library(liblldb SHARED SBFrame.cpp SBFunction.cpp SBHostOS.cpp + SBInitializerOptions.cpp SBInstruction.cpp SBInstructionList.cpp SBLanguageRuntime.cpp @@ -72,7 +78,7 @@ add_lldb_library(liblldb SHARED SBWatchpoint.cpp SBUnixSignals.cpp SystemInitializerFull.cpp - ${LLDB_WRAP_PYTHON} + ${lldb_python_wrapper} LINK_LIBS lldbBase @@ -91,24 +97,26 @@ add_lldb_library(liblldb SHARED Support ) -add_dependencies(lldb-suite liblldb) +if(lldb_python_wrapper) + add_dependencies(liblldb swig_wrapper) -if (MSVC) - set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0") -else() - set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " -w") -endif() + if (MSVC) + set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0") + else() + set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " -w") + endif() -set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1) -if (CLANG_CL) - set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING - PROPERTY COMPILE_FLAGS " -Wno-unused-function") + set_source_files_properties(${lldb_python_wrapper} PROPERTIES GENERATED ON) + if (CLANG_CL) + set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING + PROPERTY COMPILE_FLAGS " -Wno-unused-function") + endif() + if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND + NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") + set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING + PROPERTY COMPILE_FLAGS " -Wno-sequence-point -Wno-cast-qual") + endif () endif() -if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND - NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") - set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING - PROPERTY COMPILE_FLAGS " -Wno-sequence-point -Wno-cast-qual") -endif () set_target_properties(liblldb PROPERTIES @@ -143,6 +151,6 @@ else() ) endif() -if (LLDB_WRAP_PYTHON) - add_dependencies(liblldb swig_wrapper) +if(LLDB_BUILD_FRAMEWORK) + include(LLDBFramework) endif() diff --git a/source/API/SBAddress.cpp b/source/API/SBAddress.cpp index d12197e66ddd..09ec6c3f10db 100644 --- a/source/API/SBAddress.cpp +++ b/source/API/SBAddress.cpp @@ -62,7 +62,7 @@ bool lldb::operator==(const SBAddress &lhs, const SBAddress &rhs) { } bool SBAddress::IsValid() const { - return m_opaque_ap.get() != NULL && m_opaque_ap->IsValid(); + return m_opaque_ap != NULL && m_opaque_ap->IsValid(); } void SBAddress::Clear() { m_opaque_ap.reset(new Address()); } @@ -156,7 +156,7 @@ Address *SBAddress::operator->() { return m_opaque_ap.get(); } const Address *SBAddress::operator->() const { return m_opaque_ap.get(); } Address &SBAddress::ref() { - if (m_opaque_ap.get() == NULL) + if (m_opaque_ap == NULL) m_opaque_ap.reset(new Address()); return *m_opaque_ap; } @@ -198,8 +198,9 @@ SBModule SBAddress::GetModule() { SBSymbolContext SBAddress::GetSymbolContext(uint32_t resolve_scope) { SBSymbolContext sb_sc; + SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope); if (m_opaque_ap->IsValid()) - m_opaque_ap->CalculateSymbolContext(&sb_sc.ref(), resolve_scope); + m_opaque_ap->CalculateSymbolContext(&sb_sc.ref(), scope); return sb_sc; } diff --git a/source/API/SBAttachInfo.cpp b/source/API/SBAttachInfo.cpp index d6cb212dedf8..a74487a70fe3 100644 --- a/source/API/SBAttachInfo.cpp +++ b/source/API/SBAttachInfo.cpp @@ -26,16 +26,14 @@ SBAttachInfo::SBAttachInfo(lldb::pid_t pid) SBAttachInfo::SBAttachInfo(const char *path, bool wait_for) : m_opaque_sp(new ProcessAttachInfo()) { if (path && path[0]) - m_opaque_sp->GetExecutableFile().SetFile(path, false, - FileSpec::Style::native); + m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native); m_opaque_sp->SetWaitForLaunch(wait_for); } SBAttachInfo::SBAttachInfo(const char *path, bool wait_for, bool async) : m_opaque_sp(new ProcessAttachInfo()) { if (path && path[0]) - m_opaque_sp->GetExecutableFile().SetFile(path, false, - FileSpec::Style::native); + m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native); m_opaque_sp->SetWaitForLaunch(wait_for); m_opaque_sp->SetAsync(async); } @@ -79,8 +77,7 @@ void SBAttachInfo::SetProcessPluginName(const char *plugin_name) { void SBAttachInfo::SetExecutable(const char *path) { if (path && path[0]) - m_opaque_sp->GetExecutableFile().SetFile(path, false, - FileSpec::Style::native); + m_opaque_sp->GetExecutableFile().SetFile(path, FileSpec::Style::native); else m_opaque_sp->GetExecutableFile().Clear(); } diff --git a/source/API/SBBreakpoint.cpp b/source/API/SBBreakpoint.cpp index 6a0ff9536c2c..b6720071e17c 100644 --- a/source/API/SBBreakpoint.cpp +++ b/source/API/SBBreakpoint.cpp @@ -7,10 +7,6 @@ // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/API/SBBreakpoint.h" #include "lldb/API/SBBreakpointLocation.h" #include "lldb/API/SBDebugger.h" @@ -23,6 +19,8 @@ #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointIDList.h" #include "lldb/Breakpoint/BreakpointLocation.h" +#include "lldb/Breakpoint/BreakpointResolver.h" +#include "lldb/Breakpoint/BreakpointResolverScripted.h" #include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Core/Address.h" #include "lldb/Core/Debugger.h" @@ -487,6 +485,40 @@ bool SBBreakpoint::GetDescription(SBStream &s, bool include_locations) { return false; } +SBError +SBBreakpoint::AddLocation(SBAddress &address) { + BreakpointSP bkpt_sp = GetSP(); + SBError error; + + if (!address.IsValid()) { + error.SetErrorString("Can't add an invalid address."); + return error; + } + + if (!bkpt_sp) { + error.SetErrorString("No breakpoint to add a location to."); + return error; + } + + if (!llvm::isa<BreakpointResolverScripted>(bkpt_sp->GetResolver().get())) { + error.SetErrorString("Only a scripted resolver can add locations."); + return error; + } + + if (bkpt_sp->GetSearchFilter()->AddressPasses(address.ref())) + bkpt_sp->AddLocation(address.ref()); + else + { + StreamString s; + address.get()->Dump(&s, &bkpt_sp->GetTarget(), + Address::DumpStyleModuleWithFileAddress); + error.SetErrorStringWithFormat("Address: %s didn't pass the filter.", + s.GetData()); + } + return error; +} + + void SBBreakpoint ::SetCallback(SBBreakpointHitCallback callback, void *baton) { @@ -656,6 +688,13 @@ SBBreakpoint::GetNumBreakpointLocationsFromEvent(const lldb::SBEvent &event) { return num_locations; } +bool SBBreakpoint::IsHardware() const { + BreakpointSP bkpt_sp = GetSP(); + if (bkpt_sp) + return bkpt_sp->IsHardware(); + return false; +} + BreakpointSP SBBreakpoint::GetSP() const { return m_opaque_wp.lock(); } // This is simple collection of breakpoint id's and their target. diff --git a/source/API/SBBreakpointName.cpp b/source/API/SBBreakpointName.cpp index a6742e3b89ec..47bddd752346 100644 --- a/source/API/SBBreakpointName.cpp +++ b/source/API/SBBreakpointName.cpp @@ -7,10 +7,6 @@ // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/API/SBBreakpointName.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBError.h" @@ -168,11 +164,11 @@ const SBBreakpointName &SBBreakpointName::operator=(const SBBreakpointName &rhs) } bool SBBreakpointName::operator==(const lldb::SBBreakpointName &rhs) { - return *m_impl_up.get() == *rhs.m_impl_up.get(); + return *m_impl_up == *rhs.m_impl_up; } bool SBBreakpointName::operator!=(const lldb::SBBreakpointName &rhs) { - return *m_impl_up.get() != *rhs.m_impl_up.get(); + return *m_impl_up != *rhs.m_impl_up; } bool SBBreakpointName::IsValid() const { diff --git a/source/API/SBBreakpointOptionCommon.cpp b/source/API/SBBreakpointOptionCommon.cpp index 569b860a4235..c0618adb238a 100644 --- a/source/API/SBBreakpointOptionCommon.cpp +++ b/source/API/SBBreakpointOptionCommon.cpp @@ -7,10 +7,6 @@ // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/API/SBBreakpointName.h" #include "lldb/API/SBBreakpointLocation.h" #include "lldb/API/SBDebugger.h" diff --git a/source/API/SBBroadcaster.cpp b/source/API/SBBroadcaster.cpp index 278576b5ddcd..7868c38a818a 100644 --- a/source/API/SBBroadcaster.cpp +++ b/source/API/SBBroadcaster.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Core/Broadcaster.h" +#include "lldb/Utility/Broadcaster.h" #include "lldb/Utility/Log.h" #include "lldb/API/SBBroadcaster.h" diff --git a/source/API/SBCommandInterpreter.cpp b/source/API/SBCommandInterpreter.cpp index cbb514abb6fe..2a06e608c0b9 100644 --- a/source/API/SBCommandInterpreter.cpp +++ b/source/API/SBCommandInterpreter.cpp @@ -7,17 +7,13 @@ // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/lldb-types.h" -#include "lldb/Core/Listener.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandObjectMultiword.h" #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Target/Target.h" +#include "lldb/Utility/Listener.h" #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBCommandInterpreter.h" @@ -71,6 +67,14 @@ void SBCommandInterpreterRunOptions::SetEchoCommands(bool echo_commands) { m_opaque_up->SetEchoCommands(echo_commands); } +bool SBCommandInterpreterRunOptions::GetEchoCommentCommands() const { + return m_opaque_up->GetEchoCommentCommands(); +} + +void SBCommandInterpreterRunOptions::SetEchoCommentCommands(bool echo) { + m_opaque_up->SetEchoCommentCommands(echo); +} + bool SBCommandInterpreterRunOptions::GetPrintResults() const { return m_opaque_up->GetPrintResults(); } @@ -94,7 +98,7 @@ SBCommandInterpreterRunOptions::get() const { lldb_private::CommandInterpreterRunOptions & SBCommandInterpreterRunOptions::ref() const { - return *m_opaque_up.get(); + return *m_opaque_up; } class CommandPluginInterfaceImplementation : public CommandObjectParsed { @@ -269,6 +273,16 @@ void SBCommandInterpreter::HandleCommandsFromFile( int SBCommandInterpreter::HandleCompletion( const char *current_line, const char *cursor, const char *last_char, int match_start_point, int max_return_elements, SBStringList &matches) { + SBStringList dummy_descriptions; + return HandleCompletionWithDescriptions( + current_line, cursor, last_char, match_start_point, max_return_elements, + matches, dummy_descriptions); +} + +int SBCommandInterpreter::HandleCompletionWithDescriptions( + const char *current_line, const char *cursor, const char *last_char, + int match_start_point, int max_return_elements, SBStringList &matches, + SBStringList &descriptions) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); int num_completions = 0; @@ -296,13 +310,15 @@ int SBCommandInterpreter::HandleCompletion( match_start_point, max_return_elements); if (IsValid()) { - lldb_private::StringList lldb_matches; + lldb_private::StringList lldb_matches, lldb_descriptions; num_completions = m_opaque_ptr->HandleCompletion( current_line, cursor, last_char, match_start_point, max_return_elements, - lldb_matches); + lldb_matches, lldb_descriptions); - SBStringList temp_list(&lldb_matches); - matches.AppendList(temp_list); + SBStringList temp_matches_list(&lldb_matches); + matches.AppendList(temp_matches_list); + SBStringList temp_descriptions_list(&lldb_descriptions); + descriptions.AppendList(temp_descriptions_list); } if (log) log->Printf( @@ -312,6 +328,17 @@ int SBCommandInterpreter::HandleCompletion( return num_completions; } +int SBCommandInterpreter::HandleCompletionWithDescriptions( + const char *current_line, uint32_t cursor_pos, int match_start_point, + int max_return_elements, SBStringList &matches, + SBStringList &descriptions) { + const char *cursor = current_line + cursor_pos; + const char *last_char = current_line + strlen(current_line); + return HandleCompletionWithDescriptions( + current_line, cursor, last_char, match_start_point, max_return_elements, + matches, descriptions); +} + int SBCommandInterpreter::HandleCompletion(const char *current_line, uint32_t cursor_pos, int match_start_point, diff --git a/source/API/SBCommandReturnObject.cpp b/source/API/SBCommandReturnObject.cpp index 5a8909b98e53..7bc02985a3ec 100644 --- a/source/API/SBCommandReturnObject.cpp +++ b/source/API/SBCommandReturnObject.cpp @@ -7,10 +7,6 @@ // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "lldb/API/SBCommandReturnObject.h" #include "lldb/API/SBError.h" #include "lldb/API/SBStream.h" @@ -52,9 +48,7 @@ operator=(const SBCommandReturnObject &rhs) { return *this; } -bool SBCommandReturnObject::IsValid() const { - return m_opaque_ap.get() != nullptr; -} +bool SBCommandReturnObject::IsValid() const { return m_opaque_ap != nullptr; } const char *SBCommandReturnObject::GetOutput() { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); diff --git a/source/API/SBCompileUnit.cpp b/source/API/SBCompileUnit.cpp index 149d587913e9..4e2fc6af460a 100644 --- a/source/API/SBCompileUnit.cpp +++ b/source/API/SBCompileUnit.cpp @@ -135,17 +135,21 @@ uint32_t SBCompileUnit::GetNumSupportFiles() const { lldb::SBTypeList SBCompileUnit::GetTypes(uint32_t type_mask) { SBTypeList sb_type_list; - if (m_opaque_ptr) { - ModuleSP module_sp(m_opaque_ptr->GetModule()); - if (module_sp) { - SymbolVendor *vendor = module_sp->GetSymbolVendor(); - if (vendor) { - TypeList type_list; - vendor->GetTypes(m_opaque_ptr, type_mask, type_list); - sb_type_list.m_opaque_ap->Append(type_list); - } - } - } + if (!m_opaque_ptr) + return sb_type_list; + + ModuleSP module_sp(m_opaque_ptr->GetModule()); + if (!module_sp) + return sb_type_list; + + SymbolVendor *vendor = module_sp->GetSymbolVendor(); + if (!vendor) + return sb_type_list; + + TypeClass type_class = static_cast<TypeClass>(type_mask); + TypeList type_list; + vendor->GetTypes(m_opaque_ptr, type_class, type_list); + sb_type_list.m_opaque_ap->Append(type_list); return sb_type_list; } diff --git a/source/API/SBData.cpp b/source/API/SBData.cpp index a8ba5808d4f6..a30a778a19d2 100644 --- a/source/API/SBData.cpp +++ b/source/API/SBData.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include <inttypes.h> // PRIu64 +#include <inttypes.h> #include "lldb/API/SBData.h" #include "lldb/API/SBError.h" diff --git a/source/API/SBDebugger.cpp b/source/API/SBDebugger.cpp index a651141003a4..af343233c90e 100644 --- a/source/API/SBDebugger.cpp +++ b/source/API/SBDebugger.cpp @@ -7,10 +7,6 @@ // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "SystemInitializerFull.h" @@ -41,7 +37,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/StructuredDataImpl.h" #include "lldb/DataFormatters/DataVisualization.h" @@ -53,6 +48,7 @@ #include "lldb/Target/Process.h" #include "lldb/Target/TargetList.h" #include "lldb/Utility/Args.h" +#include "lldb/Utility/State.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" @@ -90,7 +86,7 @@ static llvm::sys::DynamicLibrary LoadPlugin(const lldb::DebuggerSP &debugger_sp, "lldb::PluginInitialize(lldb::SBDebugger)"); } } else { - if (spec.Exists()) + if (FileSystem::Instance().Exists(spec)) error.SetErrorString("this file does not represent a loadable dylib"); else error.SetErrorString("no such file"); @@ -129,13 +125,23 @@ SBDebugger &SBDebugger::operator=(const SBDebugger &rhs) { } void SBDebugger::Initialize() { + SBInitializerOptions options; + SBDebugger::Initialize(options); +} + +lldb::SBError SBDebugger::Initialize(SBInitializerOptions &options) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (log) log->Printf("SBDebugger::Initialize ()"); - g_debugger_lifetime->Initialize(llvm::make_unique<SystemInitializerFull>(), - LoadPlugin); + SBError error; + if (auto e = g_debugger_lifetime->Initialize( + llvm::make_unique<SystemInitializerFull>(), *options.m_opaque_up, + LoadPlugin)) { + error.SetError(Status(std::move(e))); + } + return error; } void SBDebugger::Terminate() { g_debugger_lifetime->Terminate(); } @@ -558,7 +564,8 @@ lldb::SBTarget SBDebugger::CreateTarget(const char *filename, platform_options.SetPlatformName(platform_name); sb_error.ref() = m_opaque_sp->GetTargetList().CreateTarget( - *m_opaque_sp, filename, target_triple, add_dependent_modules, + *m_opaque_sp, filename, target_triple, + add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, &platform_options, target_sp); if (sb_error.Success()) @@ -587,7 +594,8 @@ SBDebugger::CreateTargetWithFileAndTargetTriple(const char *filename, if (m_opaque_sp) { const bool add_dependent_modules = true; Status error(m_opaque_sp->GetTargetList().CreateTarget( - *m_opaque_sp, filename, target_triple, add_dependent_modules, nullptr, + *m_opaque_sp, filename, target_triple, + add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, nullptr, target_sp)); sb_target.SetSP(target_sp); } @@ -613,7 +621,8 @@ SBTarget SBDebugger::CreateTargetWithFileAndArch(const char *filename, const bool add_dependent_modules = true; error = m_opaque_sp->GetTargetList().CreateTarget( - *m_opaque_sp, filename, arch_cstr, add_dependent_modules, nullptr, + *m_opaque_sp, filename, arch_cstr, + add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, nullptr, target_sp); if (error.Success()) { @@ -638,7 +647,9 @@ SBTarget SBDebugger::CreateTarget(const char *filename) { Status error; const bool add_dependent_modules = true; error = m_opaque_sp->GetTargetList().CreateTarget( - *m_opaque_sp, filename, "", add_dependent_modules, nullptr, target_sp); + *m_opaque_sp, filename, "", + add_dependent_modules ? eLoadDependentsYes : eLoadDependentsNo, nullptr, + target_sp); if (error.Success()) { m_opaque_sp->GetTargetList().SetSelectedTarget(target_sp.get()); @@ -730,7 +741,7 @@ SBTarget SBDebugger::FindTargetWithFileAndArch(const char *filename, m_opaque_sp->GetPlatformList().GetSelectedPlatform().get(), arch_name); TargetSP target_sp( m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture( - FileSpec(filename, false), arch_name ? &arch : nullptr)); + FileSpec(filename), arch_name ? &arch : nullptr)); sb_target.SetSP(target_sp); } return sb_target; @@ -1050,6 +1061,12 @@ void SBDebugger::SetPrompt(const char *prompt) { m_opaque_sp->SetPrompt(llvm::StringRef::withNullAsEmpty(prompt)); } +const char *SBDebugger::GetReproducerPath() const { + return (m_opaque_sp + ? ConstString(m_opaque_sp->GetReproducerPath()).GetCString() + : nullptr); +} + ScriptLanguage SBDebugger::GetScriptLanguage() const { return (m_opaque_sp ? m_opaque_sp->GetScriptLanguage() : eScriptLanguageNone); } diff --git a/source/API/SBDeclaration.cpp b/source/API/SBDeclaration.cpp index d6e61e32582d..90e4db367d2a 100644 --- a/source/API/SBDeclaration.cpp +++ b/source/API/SBDeclaration.cpp @@ -75,7 +75,7 @@ uint32_t SBDeclaration::GetLine() const { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); uint32_t line = 0; - if (m_opaque_ap.get()) + if (m_opaque_ap) line = m_opaque_ap->GetLine(); if (log) @@ -86,7 +86,7 @@ uint32_t SBDeclaration::GetLine() const { } uint32_t SBDeclaration::GetColumn() const { - if (m_opaque_ap.get()) + if (m_opaque_ap) return m_opaque_ap->GetColumn(); return 0; } @@ -126,7 +126,7 @@ const lldb_private::Declaration *SBDeclaration::operator->() const { } lldb_private::Declaration &SBDeclaration::ref() { - if (m_opaque_ap.get() == NULL) + if (m_opaque_ap == NULL) m_opaque_ap.reset(new lldb_private::Declaration()); return *m_opaque_ap; } @@ -138,7 +138,7 @@ const lldb_private::Declaration &SBDeclaration::ref() const { bool SBDeclaration::GetDescription(SBStream &description) { Stream &strm = description.ref(); - if (m_opaque_ap.get()) { + if (m_opaque_ap) { char file_path[PATH_MAX * 2]; m_opaque_ap->GetFile().GetPath(file_path, sizeof(file_path)); strm.Printf("%s:%u", file_path, GetLine()); diff --git a/source/API/SBError.cpp b/source/API/SBError.cpp index b2811d0ac381..04433bb1aab0 100644 --- a/source/API/SBError.cpp +++ b/source/API/SBError.cpp @@ -28,7 +28,7 @@ SBError::~SBError() {} const SBError &SBError::operator=(const SBError &rhs) { if (rhs.IsValid()) { - if (m_opaque_ap.get()) + if (m_opaque_ap) *m_opaque_ap = *rhs; else m_opaque_ap.reset(new Status(*rhs)); @@ -39,13 +39,13 @@ const SBError &SBError::operator=(const SBError &rhs) { } const char *SBError::GetCString() const { - if (m_opaque_ap.get()) + if (m_opaque_ap) return m_opaque_ap->AsCString(); return NULL; } void SBError::Clear() { - if (m_opaque_ap.get()) + if (m_opaque_ap) m_opaque_ap->Clear(); } @@ -53,7 +53,7 @@ bool SBError::Fail() const { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); bool ret_value = false; - if (m_opaque_ap.get()) + if (m_opaque_ap) ret_value = m_opaque_ap->Fail(); if (log) @@ -66,7 +66,7 @@ bool SBError::Fail() const { bool SBError::Success() const { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); bool ret_value = true; - if (m_opaque_ap.get()) + if (m_opaque_ap) ret_value = m_opaque_ap->Success(); if (log) @@ -80,7 +80,7 @@ uint32_t SBError::GetError() const { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); uint32_t err = 0; - if (m_opaque_ap.get()) + if (m_opaque_ap) err = m_opaque_ap->GetError(); if (log) @@ -93,7 +93,7 @@ uint32_t SBError::GetError() const { ErrorType SBError::GetType() const { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); ErrorType err_type = eErrorTypeInvalid; - if (m_opaque_ap.get()) + if (m_opaque_ap) err_type = m_opaque_ap->GetType(); if (log) @@ -137,10 +137,10 @@ int SBError::SetErrorStringWithFormat(const char *format, ...) { return num_chars; } -bool SBError::IsValid() const { return m_opaque_ap.get() != NULL; } +bool SBError::IsValid() const { return m_opaque_ap != NULL; } void SBError::CreateIfNeeded() { - if (m_opaque_ap.get() == NULL) + if (m_opaque_ap == NULL) m_opaque_ap.reset(new Status()); } @@ -159,7 +159,7 @@ const lldb_private::Status &SBError::operator*() const { } bool SBError::GetDescription(SBStream &description) { - if (m_opaque_ap.get()) { + if (m_opaque_ap) { if (m_opaque_ap->Success()) description.Printf("success"); else { diff --git a/source/API/SBEvent.cpp b/source/API/SBEvent.cpp index 65eb71c09285..0556f50f6544 100644 --- a/source/API/SBEvent.cpp +++ b/source/API/SBEvent.cpp @@ -12,11 +12,11 @@ #include "lldb/API/SBStream.h" #include "lldb/Breakpoint/Breakpoint.h" -#include "lldb/Core/Event.h" #include "lldb/Core/StreamFile.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Target/Process.h" #include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Event.h" #include "lldb/Utility/Stream.h" using namespace lldb; diff --git a/source/API/SBExpressionOptions.cpp b/source/API/SBExpressionOptions.cpp index e26fa11651e5..76cec876a216 100644 --- a/source/API/SBExpressionOptions.cpp +++ b/source/API/SBExpressionOptions.cpp @@ -159,6 +159,15 @@ void SBExpressionOptions::SetTopLevel(bool b) { : m_opaque_ap->default_execution_policy); } +bool SBExpressionOptions::GetAllowJIT() { + return m_opaque_ap->GetExecutionPolicy() != eExecutionPolicyNever; +} + +void SBExpressionOptions::SetAllowJIT(bool allow) { + m_opaque_ap->SetExecutionPolicy(allow ? m_opaque_ap->default_execution_policy + : eExecutionPolicyNever); +} + EvaluateExpressionOptions *SBExpressionOptions::get() const { return m_opaque_ap.get(); } diff --git a/source/API/SBFileSpec.cpp b/source/API/SBFileSpec.cpp index 011b88225ef9..f136409d0b68 100644 --- a/source/API/SBFileSpec.cpp +++ b/source/API/SBFileSpec.cpp @@ -7,11 +7,12 @@ // //===----------------------------------------------------------------------===// -#include <inttypes.h> // PRIu64 +#include <inttypes.h> #include <limits.h> #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBStream.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/PosixApi.h" #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" @@ -31,11 +32,15 @@ SBFileSpec::SBFileSpec(const lldb_private::FileSpec &fspec) : m_opaque_ap(new lldb_private::FileSpec(fspec)) {} // Deprecated!!! -SBFileSpec::SBFileSpec(const char *path) - : m_opaque_ap(new FileSpec(path, true)) {} +SBFileSpec::SBFileSpec(const char *path) : m_opaque_ap(new FileSpec(path)) { + FileSystem::Instance().Resolve(*m_opaque_ap); +} SBFileSpec::SBFileSpec(const char *path, bool resolve) - : m_opaque_ap(new FileSpec(path, resolve)) {} + : m_opaque_ap(new FileSpec(path)) { + if (resolve) + FileSystem::Instance().Resolve(*m_opaque_ap); +} SBFileSpec::~SBFileSpec() {} @@ -50,7 +55,7 @@ bool SBFileSpec::IsValid() const { return m_opaque_ap->operator bool(); } bool SBFileSpec::Exists() const { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - bool result = m_opaque_ap->Exists(); + bool result = FileSystem::Instance().Exists(*m_opaque_ap); if (log) log->Printf("SBFileSpec(%p)::Exists () => %s", @@ -61,13 +66,13 @@ bool SBFileSpec::Exists() const { } bool SBFileSpec::ResolveExecutableLocation() { - return m_opaque_ap->ResolveExecutableLocation(); + return FileSystem::Instance().ResolveExecutableLocation(*m_opaque_ap); } int SBFileSpec::ResolvePath(const char *src_path, char *dst_path, size_t dst_len) { llvm::SmallString<64> result(src_path); - lldb_private::FileSpec::Resolve(result); + FileSystem::Instance().Resolve(result); ::snprintf(dst_path, dst_len, "%s", result.c_str()); return std::min(dst_len - 1, result.size()); } @@ -143,12 +148,10 @@ const lldb_private::FileSpec *SBFileSpec::get() const { } const lldb_private::FileSpec &SBFileSpec::operator*() const { - return *m_opaque_ap.get(); + return *m_opaque_ap; } -const lldb_private::FileSpec &SBFileSpec::ref() const { - return *m_opaque_ap.get(); -} +const lldb_private::FileSpec &SBFileSpec::ref() const { return *m_opaque_ap; } void SBFileSpec::SetFileSpec(const lldb_private::FileSpec &fs) { *m_opaque_ap = fs; diff --git a/source/API/SBFileSpecList.cpp b/source/API/SBFileSpecList.cpp index 67d28dcbe111..439859c3fd85 100644 --- a/source/API/SBFileSpecList.cpp +++ b/source/API/SBFileSpecList.cpp @@ -26,7 +26,7 @@ SBFileSpecList::SBFileSpecList() : m_opaque_ap(new FileSpecList()) {} SBFileSpecList::SBFileSpecList(const SBFileSpecList &rhs) : m_opaque_ap() { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (rhs.m_opaque_ap.get()) + if (rhs.m_opaque_ap) m_opaque_ap.reset(new FileSpecList(*(rhs.get()))); if (log) { @@ -78,17 +78,17 @@ const lldb_private::FileSpecList *SBFileSpecList::get() const { } const lldb_private::FileSpecList &SBFileSpecList::operator*() const { - return *m_opaque_ap.get(); + return *m_opaque_ap; } const lldb_private::FileSpecList &SBFileSpecList::ref() const { - return *m_opaque_ap.get(); + return *m_opaque_ap; } bool SBFileSpecList::GetDescription(SBStream &description) const { Stream &strm = description.ref(); - if (m_opaque_ap.get()) { + if (m_opaque_ap) { uint32_t num_files = m_opaque_ap->GetSize(); strm.Printf("%d files: ", num_files); for (uint32_t i = 0; i < num_files; i++) { diff --git a/source/API/SBFrame.cpp b/source/API/SBFrame.cpp index 5762a75f33d6..44dcfd806be5 100644 --- a/source/API/SBFrame.cpp +++ b/source/API/SBFrame.cpp @@ -7,14 +7,10 @@ // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes #include <algorithm> #include <set> #include <string> -// Other libraries and framework includes -// Project includes #include "lldb/API/SBFrame.h" #include "lldb/lldb-types.h" @@ -36,6 +32,7 @@ #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" #include "lldb/Target/StackFrame.h" +#include "lldb/Target/StackFrameRecognizer.h" #include "lldb/Target/StackID.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" @@ -112,7 +109,7 @@ SBSymbolContext SBFrame::GetSymbolContext(uint32_t resolve_scope) const { SBSymbolContext sb_sym_ctx; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); - + SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope); StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); @@ -121,7 +118,7 @@ SBSymbolContext SBFrame::GetSymbolContext(uint32_t resolve_scope) const { if (stop_locker.TryLock(&process->GetRunLock())) { frame = exe_ctx.GetFramePtr(); if (frame) { - sb_sym_ctx.SetSymbolContext(&frame->GetSymbolContext(resolve_scope)); + sb_sym_ctx.SetSymbolContext(&frame->GetSymbolContext(scope)); } else { if (log) log->Printf("SBFrame::GetVariables () => error: could not " @@ -666,28 +663,10 @@ SBValue SBFrame::FindVariable(const char *name, if (stop_locker.TryLock(&process->GetRunLock())) { frame = exe_ctx.GetFramePtr(); if (frame) { - VariableList variable_list; - SymbolContext sc(frame->GetSymbolContext(eSymbolContextBlock)); - - if (sc.block) { - const bool can_create = true; - const bool get_parent_variables = true; - const bool stop_if_block_is_inlined_function = true; + value_sp = frame->FindVariable(ConstString(name)); - if (sc.block->AppendVariables( - can_create, get_parent_variables, - stop_if_block_is_inlined_function, - [frame](Variable *v) { return v->IsInScope(frame); }, - &variable_list)) { - var_sp = variable_list.FindVariable(ConstString(name)); - } - } - - if (var_sp) { - value_sp = - frame->GetValueObjectForFrameVariable(var_sp, eNoDynamicValues); + if (value_sp) sb_value.SetSP(value_sp, use_dynamic); - } } else { if (log) log->Printf("SBFrame::FindVariable () => error: could not " @@ -978,6 +957,8 @@ SBValueList SBFrame::GetVariables(const lldb::SBVariablesOptions &options) { const bool statics = options.GetIncludeStatics(); const bool arguments = options.GetIncludeArguments(); + const bool recognized_arguments = + options.GetIncludeRecognizedArguments(SBTarget(exe_ctx.GetTargetSP())); const bool locals = options.GetIncludeLocals(); const bool in_scope_only = options.GetInScopeOnly(); const bool include_runtime_support_values = @@ -985,10 +966,11 @@ SBValueList SBFrame::GetVariables(const lldb::SBVariablesOptions &options) { const lldb::DynamicValueType use_dynamic = options.GetUseDynamic(); if (log) - log->Printf("SBFrame::GetVariables (arguments=%i, locals=%i, statics=%i, " - "in_scope_only=%i runtime=%i dynamic=%i)", - arguments, locals, statics, in_scope_only, - include_runtime_support_values, use_dynamic); + log->Printf( + "SBFrame::GetVariables (arguments=%i, recognized_arguments=%i, " + "locals=%i, statics=%i, in_scope_only=%i runtime=%i dynamic=%i)", + arguments, recognized_arguments, locals, statics, in_scope_only, + include_runtime_support_values, use_dynamic); std::set<VariableSP> variable_set; Process *process = exe_ctx.GetProcessPtr(); @@ -1050,6 +1032,20 @@ SBValueList SBFrame::GetVariables(const lldb::SBVariablesOptions &options) { } } } + if (recognized_arguments) { + auto recognized_frame = frame->GetRecognizedFrame(); + if (recognized_frame) { + ValueObjectListSP recognized_arg_list = + recognized_frame->GetRecognizedArguments(); + if (recognized_arg_list) { + for (auto &rec_value_sp : recognized_arg_list->GetObjects()) { + SBValue value_sb; + value_sb.SetSP(rec_value_sp, use_dynamic); + value_list.Append(value_sb); + } + } + } + } } else { if (log) log->Printf("SBFrame::GetVariables () => error: could not " @@ -1366,6 +1362,21 @@ bool SBFrame::IsInlined() const { return false; } +bool SBFrame::IsArtificial() { + return static_cast<const SBFrame *>(this)->IsArtificial(); +} + +bool SBFrame::IsArtificial() const { + std::unique_lock<std::recursive_mutex> lock; + ExecutionContext exe_ctx(m_opaque_sp.get(), lock); + + StackFrame *frame = exe_ctx.GetFramePtr(); + if (frame) + return frame->IsArtificial(); + + return false; +} + const char *SBFrame::GetFunctionName() { return static_cast<const SBFrame *>(this)->GetFunctionName(); } diff --git a/source/API/SBHostOS.cpp b/source/API/SBHostOS.cpp index e56951df43be..ac6ab40bda41 100644 --- a/source/API/SBHostOS.cpp +++ b/source/API/SBHostOS.cpp @@ -11,8 +11,9 @@ #include "Plugins/ScriptInterpreter/Python/lldb-python.h" #endif -#include "lldb/API/SBHostOS.h" #include "lldb/API/SBError.h" +#include "lldb/API/SBHostOS.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/HostNativeThread.h" @@ -86,7 +87,8 @@ SBFileSpec SBHostOS::GetUserHomeDirectory() { llvm::SmallString<64> home_dir_path; llvm::sys::path::home_directory(home_dir_path); - FileSpec homedir(home_dir_path.c_str(), true); + FileSpec homedir(home_dir_path.c_str()); + FileSystem::Instance().Resolve(homedir); sb_fspec.SetFileSpec(homedir); return sb_fspec; diff --git a/source/API/SBInitializerOptions.cpp b/source/API/SBInitializerOptions.cpp new file mode 100644 index 000000000000..8d8ec28190ec --- /dev/null +++ b/source/API/SBInitializerOptions.cpp @@ -0,0 +1,49 @@ +//===-- SBInitializerOptions.cpp --------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/API/SBInitializerOptions.h" +#include "lldb/Initialization/SystemInitializer.h" + +using namespace lldb; +using namespace lldb_private; + +SBInitializerOptions::SBInitializerOptions(const SBInitializerOptions &rhs) { + m_opaque_up.reset(new InitializerOptions()); + *(m_opaque_up.get()) = rhs.ref(); +} + +const SBInitializerOptions &SBInitializerOptions:: +operator=(const SBInitializerOptions &rhs) { + if (this != &rhs) { + this->ref() = rhs.ref(); + } + return *this; +} + +SBInitializerOptions::~SBInitializerOptions() {} + +SBInitializerOptions::SBInitializerOptions() { + m_opaque_up.reset(new InitializerOptions()); +} + +void SBInitializerOptions::SetCaptureReproducer(bool b) { + m_opaque_up->reproducer_capture = b; +} + +void SBInitializerOptions::SetReplayReproducer(bool b) { + m_opaque_up->reproducer_replay = b; +} + +void SBInitializerOptions::SetReproducerPath(const char *path) { + m_opaque_up->reproducer_path = path; +} + +InitializerOptions &SBInitializerOptions::ref() const { + return *(m_opaque_up.get()); +} diff --git a/source/API/SBLaunchInfo.cpp b/source/API/SBLaunchInfo.cpp index aa1759ab3d00..b1bbfa55d5c1 100644 --- a/source/API/SBLaunchInfo.cpp +++ b/source/API/SBLaunchInfo.cpp @@ -128,7 +128,7 @@ const char *SBLaunchInfo::GetWorkingDirectory() const { } void SBLaunchInfo::SetWorkingDirectory(const char *working_dir) { - m_opaque_sp->SetWorkingDirectory(FileSpec{working_dir, false}); + m_opaque_sp->SetWorkingDirectory(FileSpec(working_dir)); } uint32_t SBLaunchInfo::GetLaunchFlags() { @@ -155,7 +155,7 @@ const char *SBLaunchInfo::GetShell() { } void SBLaunchInfo::SetShell(const char *path) { - m_opaque_sp->SetShell(FileSpec(path, false)); + m_opaque_sp->SetShell(FileSpec(path)); } bool SBLaunchInfo::GetShellExpandArguments() { @@ -184,8 +184,7 @@ bool SBLaunchInfo::AddDuplicateFileAction(int fd, int dup_fd) { bool SBLaunchInfo::AddOpenFileAction(int fd, const char *path, bool read, bool write) { - return m_opaque_sp->AppendOpenFileAction(fd, FileSpec{path, false}, read, - write); + return m_opaque_sp->AppendOpenFileAction(fd, FileSpec(path), read, write); } bool SBLaunchInfo::AddSuppressFileAction(int fd, bool read, bool write) { diff --git a/source/API/SBLineEntry.cpp b/source/API/SBLineEntry.cpp index 7341d3603dfe..6f59fe3407e8 100644 --- a/source/API/SBLineEntry.cpp +++ b/source/API/SBLineEntry.cpp @@ -50,7 +50,7 @@ SBLineEntry::~SBLineEntry() {} SBAddress SBLineEntry::GetStartAddress() const { SBAddress sb_address; - if (m_opaque_ap.get()) + if (m_opaque_ap) sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress()); Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); @@ -70,7 +70,7 @@ SBAddress SBLineEntry::GetStartAddress() const { SBAddress SBLineEntry::GetEndAddress() const { SBAddress sb_address; - if (m_opaque_ap.get()) { + if (m_opaque_ap) { sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress()); sb_address.OffsetAddress(m_opaque_ap->range.GetByteSize()); } @@ -114,7 +114,7 @@ uint32_t SBLineEntry::GetLine() const { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); uint32_t line = 0; - if (m_opaque_ap.get()) + if (m_opaque_ap) line = m_opaque_ap->line; if (log) @@ -125,7 +125,7 @@ uint32_t SBLineEntry::GetLine() const { } uint32_t SBLineEntry::GetColumn() const { - if (m_opaque_ap.get()) + if (m_opaque_ap) return m_opaque_ap->column; return 0; } @@ -165,7 +165,7 @@ const lldb_private::LineEntry *SBLineEntry::operator->() const { } lldb_private::LineEntry &SBLineEntry::ref() { - if (m_opaque_ap.get() == NULL) + if (m_opaque_ap == NULL) m_opaque_ap.reset(new lldb_private::LineEntry()); return *m_opaque_ap; } @@ -175,7 +175,7 @@ const lldb_private::LineEntry &SBLineEntry::ref() const { return *m_opaque_ap; } bool SBLineEntry::GetDescription(SBStream &description) { Stream &strm = description.ref(); - if (m_opaque_ap.get()) { + if (m_opaque_ap) { char file_path[PATH_MAX * 2]; m_opaque_ap->file.GetPath(file_path, sizeof(file_path)); strm.Printf("%s:%u", file_path, GetLine()); diff --git a/source/API/SBListener.cpp b/source/API/SBListener.cpp index 50fed4e1ee7b..e671d9f2ce8c 100644 --- a/source/API/SBListener.cpp +++ b/source/API/SBListener.cpp @@ -12,9 +12,9 @@ #include "lldb/API/SBDebugger.h" #include "lldb/API/SBEvent.h" #include "lldb/API/SBStream.h" -#include "lldb/Core/Broadcaster.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/Listener.h" +#include "lldb/Utility/Broadcaster.h" +#include "lldb/Utility/Listener.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" diff --git a/source/API/SBMemoryRegionInfoList.cpp b/source/API/SBMemoryRegionInfoList.cpp index fff4044f73e0..1cefc9dcc044 100644 --- a/source/API/SBMemoryRegionInfoList.cpp +++ b/source/API/SBMemoryRegionInfoList.cpp @@ -32,31 +32,47 @@ public: return *this; } - uint32_t GetSize() { return m_regions.size(); } + size_t GetSize() const { return m_regions.size(); } - void Append(const lldb::SBMemoryRegionInfo &sb_region) { + void Reserve(size_t capacity) { return m_regions.reserve(capacity); } + + void Append(const MemoryRegionInfo &sb_region) { m_regions.push_back(sb_region); } void Append(const MemoryRegionInfoListImpl &list) { - for (auto val : list.m_regions) + Reserve(GetSize() + list.GetSize()); + + for (const auto &val : list.m_regions) Append(val); } void Clear() { m_regions.clear(); } - bool GetMemoryRegionInfoAtIndex(uint32_t index, - SBMemoryRegionInfo ®ion_info) { + bool GetMemoryRegionInfoAtIndex(size_t index, + MemoryRegionInfo ®ion_info) { if (index >= GetSize()) return false; region_info = m_regions[index]; return true; } + MemoryRegionInfos &Ref() { return m_regions; } + + const MemoryRegionInfos &Ref() const { return m_regions; } + private: - std::vector<lldb::SBMemoryRegionInfo> m_regions; + MemoryRegionInfos m_regions; }; +MemoryRegionInfos &SBMemoryRegionInfoList::ref() { + return m_opaque_ap->Ref(); +} + +const MemoryRegionInfos &SBMemoryRegionInfoList::ref() const { + return m_opaque_ap->Ref(); +} + SBMemoryRegionInfoList::SBMemoryRegionInfoList() : m_opaque_ap(new MemoryRegionInfoListImpl()) {} @@ -82,7 +98,7 @@ bool SBMemoryRegionInfoList::GetMemoryRegionAtIndex( uint32_t idx, SBMemoryRegionInfo ®ion_info) { Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - bool result = m_opaque_ap->GetMemoryRegionInfoAtIndex(idx, region_info); + bool result = m_opaque_ap->GetMemoryRegionInfoAtIndex(idx, region_info.ref()); if (log) { SBStream sstr; @@ -100,7 +116,7 @@ bool SBMemoryRegionInfoList::GetMemoryRegionAtIndex( void SBMemoryRegionInfoList::Clear() { m_opaque_ap->Clear(); } void SBMemoryRegionInfoList::Append(SBMemoryRegionInfo &sb_region) { - m_opaque_ap->Append(sb_region); + m_opaque_ap->Append(sb_region.ref()); } void SBMemoryRegionInfoList::Append(SBMemoryRegionInfoList &sb_region_list) { @@ -113,5 +129,5 @@ const MemoryRegionInfoListImpl *SBMemoryRegionInfoList::operator->() const { const MemoryRegionInfoListImpl &SBMemoryRegionInfoList::operator*() const { assert(m_opaque_ap.get()); - return *m_opaque_ap.get(); + return *m_opaque_ap; } diff --git a/source/API/SBModule.cpp b/source/API/SBModule.cpp index 3dd99d5321b4..31980793bce0 100644 --- a/source/API/SBModule.cpp +++ b/source/API/SBModule.cpp @@ -217,9 +217,9 @@ SBModule::ResolveSymbolContextForAddress(const SBAddress &addr, uint32_t resolve_scope) { SBSymbolContext sb_sc; ModuleSP module_sp(GetSP()); + SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope); if (module_sp && addr.IsValid()) - module_sp->ResolveSymbolContextForAddress(addr.ref(), resolve_scope, - *sb_sc); + module_sp->ResolveSymbolContextForAddress(addr.ref(), scope, *sb_sc); return sb_sc; } @@ -365,8 +365,9 @@ lldb::SBSymbolContextList SBModule::FindFunctions(const char *name, const bool append = true; const bool symbols_ok = true; const bool inlines_ok = true; - module_sp->FindFunctions(ConstString(name), NULL, name_type_mask, - symbols_ok, inlines_ok, append, *sb_sc_list); + FunctionNameType type = static_cast<FunctionNameType>(name_type_mask); + module_sp->FindFunctions(ConstString(name), NULL, type, symbols_ok, + inlines_ok, append, *sb_sc_list); } return sb_sc_list; } @@ -439,13 +440,12 @@ lldb::SBTypeList SBModule::FindTypes(const char *type) { ModuleSP module_sp(GetSP()); if (type && module_sp) { - SymbolContext sc; TypeList type_list; const bool exact_match = false; ConstString name(type); llvm::DenseSet<SymbolFile *> searched_symbol_files; const uint32_t num_matches = module_sp->FindTypes( - sc, name, exact_match, UINT32_MAX, searched_symbol_files, type_list); + name, exact_match, UINT32_MAX, searched_symbol_files, type_list); if (num_matches > 0) { for (size_t idx = 0; idx < num_matches; idx++) { @@ -484,14 +484,16 @@ lldb::SBTypeList SBModule::GetTypes(uint32_t type_mask) { SBTypeList sb_type_list; ModuleSP module_sp(GetSP()); - if (module_sp) { - SymbolVendor *vendor = module_sp->GetSymbolVendor(); - if (vendor) { - TypeList type_list; - vendor->GetTypes(NULL, type_mask, type_list); - sb_type_list.m_opaque_ap->Append(type_list); - } - } + if (!module_sp) + return sb_type_list; + SymbolVendor *vendor = module_sp->GetSymbolVendor(); + if (!vendor) + return sb_type_list; + + TypeClass type_class = static_cast<TypeClass>(type_mask); + TypeList type_list; + vendor->GetTypes(NULL, type_class, type_list); + sb_type_list.m_opaque_ap->Append(type_list); return sb_type_list; } @@ -584,7 +586,18 @@ lldb::SBAddress SBModule::GetObjectFileHeaderAddress() const { if (module_sp) { ObjectFile *objfile_ptr = module_sp->GetObjectFile(); if (objfile_ptr) - sb_addr.ref() = objfile_ptr->GetHeaderAddress(); + sb_addr.ref() = objfile_ptr->GetBaseAddress(); + } + return sb_addr; +} + +lldb::SBAddress SBModule::GetObjectFileEntryPointAddress() const { + lldb::SBAddress sb_addr; + ModuleSP module_sp(GetSP()); + if (module_sp) { + ObjectFile *objfile_ptr = module_sp->GetObjectFile(); + if (objfile_ptr) + sb_addr.ref() = objfile_ptr->GetEntryPointAddress(); } return sb_addr; } diff --git a/source/API/SBModuleSpec.cpp b/source/API/SBModuleSpec.cpp index afabd9ace2b9..65492f58b015 100644 --- a/source/API/SBModuleSpec.cpp +++ b/source/API/SBModuleSpec.cpp @@ -114,7 +114,8 @@ SBModuleSpecList::~SBModuleSpecList() {} SBModuleSpecList SBModuleSpecList::GetModuleSpecifications(const char *path) { SBModuleSpecList specs; - FileSpec file_spec(path, true); + FileSpec file_spec(path); + FileSystem::Instance().Resolve(file_spec); Host::ResolveExecutableInBundle(file_spec); ObjectFile::GetModuleSpecifications(file_spec, 0, 0, *specs.m_opaque_ap); return specs; diff --git a/source/API/SBPlatform.cpp b/source/API/SBPlatform.cpp index 5f29f0033988..aedad871cd20 100644 --- a/source/API/SBPlatform.cpp +++ b/source/API/SBPlatform.cpp @@ -244,9 +244,9 @@ bool SBPlatform::SetWorkingDirectory(const char *path) { PlatformSP platform_sp(GetSP()); if (platform_sp) { if (path) - platform_sp->SetWorkingDirectory(FileSpec{path, false}); + platform_sp->SetWorkingDirectory(FileSpec(path)); else - platform_sp->SetWorkingDirectory(FileSpec{}); + platform_sp->SetWorkingDirectory(FileSpec()); return true; } return false; @@ -364,9 +364,9 @@ SBError SBPlatform::Get(SBFileSpec &src, SBFileSpec &dst) { SBError SBPlatform::Put(SBFileSpec &src, SBFileSpec &dst) { return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) { if (src.Exists()) { - uint32_t permissions = src.ref().GetPermissions(); + uint32_t permissions = FileSystem::Instance().GetPermissions(src.ref()); if (permissions == 0) { - if (llvm::sys::fs::is_directory(src.ref().GetPath())) + if (FileSystem::Instance().IsDirectory(src.ref())) permissions = eFilePermissionsDirectoryDefault; else permissions = eFilePermissionsFileDefault; @@ -406,7 +406,7 @@ SBError SBPlatform::Run(SBPlatformShellCommand &shell_command) { if (working_dir) shell_command.SetWorkingDirectory(working_dir); } - return platform_sp->RunShellCommand(command, FileSpec{working_dir, false}, + return platform_sp->RunShellCommand(command, FileSpec(working_dir), &shell_command.m_opaque_ptr->m_status, &shell_command.m_opaque_ptr->m_signo, &shell_command.m_opaque_ptr->m_output, @@ -449,7 +449,7 @@ SBError SBPlatform::MakeDirectory(const char *path, uint32_t file_permissions) { PlatformSP platform_sp(GetSP()); if (platform_sp) { sb_error.ref() = - platform_sp->MakeDirectory(FileSpec{path, false}, file_permissions); + platform_sp->MakeDirectory(FileSpec(path), file_permissions); } else { sb_error.SetErrorString("invalid platform"); } @@ -460,7 +460,7 @@ uint32_t SBPlatform::GetFilePermissions(const char *path) { PlatformSP platform_sp(GetSP()); if (platform_sp) { uint32_t file_permissions = 0; - platform_sp->GetFilePermissions(FileSpec{path, false}, file_permissions); + platform_sp->GetFilePermissions(FileSpec(path), file_permissions); return file_permissions; } return 0; @@ -471,8 +471,8 @@ SBError SBPlatform::SetFilePermissions(const char *path, SBError sb_error; PlatformSP platform_sp(GetSP()); if (platform_sp) { - sb_error.ref() = platform_sp->SetFilePermissions(FileSpec{path, false}, - file_permissions); + sb_error.ref() = + platform_sp->SetFilePermissions(FileSpec(path), file_permissions); } else { sb_error.SetErrorString("invalid platform"); } diff --git a/source/API/SBProcess.cpp b/source/API/SBProcess.cpp index 4d5ddc86ccf9..cb1124607ec0 100644 --- a/source/API/SBProcess.cpp +++ b/source/API/SBProcess.cpp @@ -9,7 +9,6 @@ #include "lldb/API/SBProcess.h" -// C Includes #include <inttypes.h> #include "lldb/lldb-defines.h" @@ -18,7 +17,6 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/Process.h" @@ -28,9 +26,9 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" -// Project includes #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBCommandReturnObject.h" @@ -130,10 +128,9 @@ bool SBProcess::RemoteLaunch(char const **argv, char const **envp, if (process_sp->GetState() == eStateConnected) { if (stop_at_entry) launch_flags |= eLaunchFlagStopAtEntry; - ProcessLaunchInfo launch_info( - FileSpec{stdin_path, false}, FileSpec{stdout_path, false}, - FileSpec{stderr_path, false}, FileSpec{working_directory, false}, - launch_flags); + ProcessLaunchInfo launch_info(FileSpec(stdin_path), FileSpec(stdout_path), + FileSpec(stderr_path), + FileSpec(working_directory), launch_flags); Module *exe_module = process_sp->GetTarget().GetExecutableModulePointer(); if (exe_module) launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true); @@ -1351,7 +1348,7 @@ lldb::SBError SBProcess::SaveCore(const char *file_name) { return error; } - FileSpec core_file(file_name, false); + FileSpec core_file(file_name); error.ref() = PluginManager::SaveCore(process_sp, core_file); return error; } @@ -1361,18 +1358,14 @@ SBProcess::GetMemoryRegionInfo(lldb::addr_t load_addr, SBMemoryRegionInfo &sb_region_info) { lldb::SBError sb_error; ProcessSP process_sp(GetSP()); - MemoryRegionInfoSP region_info_sp = - std::make_shared<lldb_private::MemoryRegionInfo>(); if (process_sp) { Process::StopLocker stop_locker; if (stop_locker.TryLock(&process_sp->GetRunLock())) { std::lock_guard<std::recursive_mutex> guard( process_sp->GetTarget().GetAPIMutex()); + sb_error.ref() = - process_sp->GetMemoryRegionInfo(load_addr, *region_info_sp); - if (sb_error.Success()) { - sb_region_info.ref() = *region_info_sp; - } + process_sp->GetMemoryRegionInfo(load_addr, sb_region_info.ref()); } else { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); if (log) @@ -1388,35 +1381,23 @@ SBProcess::GetMemoryRegionInfo(lldb::addr_t load_addr, } lldb::SBMemoryRegionInfoList SBProcess::GetMemoryRegions() { - lldb::SBError sb_error; lldb::SBMemoryRegionInfoList sb_region_list; + ProcessSP process_sp(GetSP()); - if (process_sp) { - Process::StopLocker stop_locker; - if (stop_locker.TryLock(&process_sp->GetRunLock())) { - std::lock_guard<std::recursive_mutex> guard( - process_sp->GetTarget().GetAPIMutex()); - std::vector<MemoryRegionInfoSP> region_list; - sb_error.ref() = process_sp->GetMemoryRegions(region_list); - if (sb_error.Success()) { - std::vector<MemoryRegionInfoSP>::iterator end = region_list.end(); - for (std::vector<MemoryRegionInfoSP>::iterator it = region_list.begin(); - it != end; it++) { - SBMemoryRegionInfo sb_region_info(it->get()); - sb_region_list.Append(sb_region_info); - } - } - } else { - Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - if (log) - log->Printf( - "SBProcess(%p)::GetMemoryRegionInfo() => error: process is running", - static_cast<void *>(process_sp.get())); - sb_error.SetErrorString("process is running"); - } + Process::StopLocker stop_locker; + if (process_sp && stop_locker.TryLock(&process_sp->GetRunLock())) { + std::lock_guard<std::recursive_mutex> guard( + process_sp->GetTarget().GetAPIMutex()); + + process_sp->GetMemoryRegions(sb_region_list.ref()); } else { - sb_error.SetErrorString("SBProcess is invalid"); + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + if (log) + log->Printf( + "SBProcess(%p)::GetMemoryRegionInfo() => error: process is running", + static_cast<void *>(process_sp.get())); } + return sb_region_list; } diff --git a/source/API/SBProcessInfo.cpp b/source/API/SBProcessInfo.cpp index 38f6c1d1e699..2b3ebfb2465f 100644 --- a/source/API/SBProcessInfo.cpp +++ b/source/API/SBProcessInfo.cpp @@ -36,7 +36,7 @@ SBProcessInfo &SBProcessInfo::operator=(const SBProcessInfo &rhs) { } ProcessInstanceInfo &SBProcessInfo::ref() { - if (m_opaque_ap.get() == nullptr) { + if (m_opaque_ap == nullptr) { m_opaque_ap.reset(new ProcessInstanceInfo()); } return *m_opaque_ap; @@ -46,7 +46,7 @@ void SBProcessInfo::SetProcessInfo(const ProcessInstanceInfo &proc_info_ref) { ref() = proc_info_ref; } -bool SBProcessInfo::IsValid() const { return m_opaque_ap.get() != nullptr; } +bool SBProcessInfo::IsValid() const { return m_opaque_ap != nullptr; } const char *SBProcessInfo::GetName() { const char *name = nullptr; diff --git a/source/API/SBQueue.cpp b/source/API/SBQueue.cpp index 5f852111e077..b4a3cd0c52fb 100644 --- a/source/API/SBQueue.cpp +++ b/source/API/SBQueue.cpp @@ -107,7 +107,7 @@ public: } void FetchThreads() { - if (m_thread_list_fetched == false) { + if (!m_thread_list_fetched) { lldb::QueueSP queue_sp = m_queue_wp.lock(); if (queue_sp) { Process::StopLocker stop_locker; @@ -127,7 +127,7 @@ public: } void FetchItems() { - if (m_pending_items_fetched == false) { + if (!m_pending_items_fetched) { QueueSP queue_sp = m_queue_wp.lock(); if (queue_sp) { Process::StopLocker stop_locker; @@ -178,7 +178,7 @@ public: uint32_t result = 0; QueueSP queue_sp = m_queue_wp.lock(); - if (m_pending_items_fetched == false && queue_sp) { + if (!m_pending_items_fetched && queue_sp) { result = queue_sp->GetNumPendingWorkItems(); } else { result = m_pending_items.size(); diff --git a/source/API/SBSection.cpp b/source/API/SBSection.cpp index 9da5d170da9e..7193857d1281 100644 --- a/source/API/SBSection.cpp +++ b/source/API/SBSection.cpp @@ -14,7 +14,6 @@ #include "lldb/Core/Section.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/DataBuffer.h" -#include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" @@ -166,7 +165,7 @@ SBData SBSection::GetSectionData(uint64_t offset, uint64_t size) { else file_size = 0; } - auto data_buffer_sp = DataBufferLLVM::CreateSliceFromPath( + auto data_buffer_sp = FileSystem::Instance().CreateDataBuffer( objfile->GetFileSpec().GetPath(), file_size, file_offset); if (data_buffer_sp && data_buffer_sp->GetByteSize() > 0) { DataExtractorSP data_extractor_sp( diff --git a/source/API/SBSourceManager.cpp b/source/API/SBSourceManager.cpp index 5804c22bacb8..1d47cc034e35 100644 --- a/source/API/SBSourceManager.cpp +++ b/source/API/SBSourceManager.cpp @@ -107,7 +107,7 @@ size_t SBSourceManager::DisplaySourceLinesWithLineNumbersAndColumn( const SBFileSpec &file, uint32_t line, uint32_t column, uint32_t context_before, uint32_t context_after, const char *current_line_cstr, SBStream &s) { - if (m_opaque_ap.get() == NULL) + if (m_opaque_ap == NULL) return 0; return m_opaque_ap->DisplaySourceLinesWithLineNumbers( diff --git a/source/API/SBStream.cpp b/source/API/SBStream.cpp index d1af77a40fa3..876ef02170d2 100644 --- a/source/API/SBStream.cpp +++ b/source/API/SBStream.cpp @@ -10,6 +10,7 @@ #include "lldb/API/SBStream.h" #include "lldb/Core/StreamFile.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StreamString.h" @@ -24,12 +25,12 @@ SBStream::SBStream(SBStream &&rhs) SBStream::~SBStream() {} -bool SBStream::IsValid() const { return (m_opaque_ap.get() != NULL); } +bool SBStream::IsValid() const { return (m_opaque_ap != NULL); } // If this stream is not redirected to a file, it will maintain a local cache // for the stream data which can be accessed using this accessor. const char *SBStream::GetData() { - if (m_is_file || m_opaque_ap.get() == NULL) + if (m_is_file || m_opaque_ap == NULL) return NULL; return static_cast<StreamString *>(m_opaque_ap.get())->GetData(); @@ -38,7 +39,7 @@ const char *SBStream::GetData() { // If this stream is not redirected to a file, it will maintain a local cache // for the stream output whose length can be accessed using this accessor. size_t SBStream::GetSize() { - if (m_is_file || m_opaque_ap.get() == NULL) + if (m_is_file || m_opaque_ap == NULL) return 0; return static_cast<StreamString *>(m_opaque_ap.get())->GetSize(); @@ -58,7 +59,7 @@ void SBStream::RedirectToFile(const char *path, bool append) { return; std::string local_data; - if (m_opaque_ap.get()) { + if (m_opaque_ap) { // See if we have any locally backed data. If so, copy it so we can then // redirect it to the file so we don't lose the data if (!m_is_file) @@ -70,12 +71,12 @@ void SBStream::RedirectToFile(const char *path, bool append) { open_options |= File::eOpenOptionAppend; else open_options |= File::eOpenOptionTruncate; - stream_file->GetFile().Open(path, open_options, - lldb::eFilePermissionsFileDefault); + FileSystem::Instance().Open(stream_file->GetFile(), FileSpec(path), + open_options); m_opaque_ap.reset(stream_file); - if (m_opaque_ap.get()) { + if (m_opaque_ap) { m_is_file = true; // If we had any data locally in our StreamString, then pass that along to @@ -91,7 +92,7 @@ void SBStream::RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership) { return; std::string local_data; - if (m_opaque_ap.get()) { + if (m_opaque_ap) { // See if we have any locally backed data. If so, copy it so we can then // redirect it to the file so we don't lose the data if (!m_is_file) @@ -99,7 +100,7 @@ void SBStream::RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership) { } m_opaque_ap.reset(new StreamFile(fh, transfer_fh_ownership)); - if (m_opaque_ap.get()) { + if (m_opaque_ap) { m_is_file = true; // If we had any data locally in our StreamString, then pass that along to @@ -112,7 +113,7 @@ void SBStream::RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership) { void SBStream::RedirectToFileDescriptor(int fd, bool transfer_fh_ownership) { std::string local_data; - if (m_opaque_ap.get()) { + if (m_opaque_ap) { // See if we have any locally backed data. If so, copy it so we can then // redirect it to the file so we don't lose the data if (!m_is_file) @@ -120,7 +121,7 @@ void SBStream::RedirectToFileDescriptor(int fd, bool transfer_fh_ownership) { } m_opaque_ap.reset(new StreamFile(::fdopen(fd, "w"), transfer_fh_ownership)); - if (m_opaque_ap.get()) { + if (m_opaque_ap) { m_is_file = true; // If we had any data locally in our StreamString, then pass that along to @@ -136,13 +137,13 @@ lldb_private::Stream *SBStream::operator->() { return m_opaque_ap.get(); } lldb_private::Stream *SBStream::get() { return m_opaque_ap.get(); } lldb_private::Stream &SBStream::ref() { - if (m_opaque_ap.get() == NULL) + if (m_opaque_ap == NULL) m_opaque_ap.reset(new StreamString()); - return *m_opaque_ap.get(); + return *m_opaque_ap; } void SBStream::Clear() { - if (m_opaque_ap.get()) { + if (m_opaque_ap) { // See if we have any locally backed data. If so, copy it so we can then // redirect it to the file so we don't lose the data if (m_is_file) diff --git a/source/API/SBStringList.cpp b/source/API/SBStringList.cpp index 9ac69b15ebb7..6ed4d4b7fb82 100644 --- a/source/API/SBStringList.cpp +++ b/source/API/SBStringList.cpp @@ -47,7 +47,7 @@ const lldb_private::StringList &SBStringList::operator*() const { return *m_opaque_ap; } -bool SBStringList::IsValid() const { return (m_opaque_ap.get() != NULL); } +bool SBStringList::IsValid() const { return (m_opaque_ap != NULL); } void SBStringList::AppendString(const char *str) { if (str != NULL) { diff --git a/source/API/SBStructuredData.cpp b/source/API/SBStructuredData.cpp index d506410f6d80..277193424e99 100644 --- a/source/API/SBStructuredData.cpp +++ b/source/API/SBStructuredData.cpp @@ -10,9 +10,10 @@ #include "lldb/API/SBStructuredData.h" #include "lldb/API/SBStream.h" -#include "lldb/Core/Event.h" +#include "lldb/API/SBStringList.h" #include "lldb/Core/StructuredDataImpl.h" #include "lldb/Target/StructuredDataPlugin.h" +#include "lldb/Utility/Event.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StructuredData.h" @@ -31,6 +32,9 @@ SBStructuredData::SBStructuredData(const lldb::SBStructuredData &rhs) SBStructuredData::SBStructuredData(const lldb::EventSP &event_sp) : m_impl_up(new StructuredDataImpl(event_sp)) {} +SBStructuredData::SBStructuredData(lldb_private::StructuredDataImpl *impl) + : m_impl_up(impl) {} + SBStructuredData::~SBStructuredData() {} SBStructuredData &SBStructuredData:: @@ -76,6 +80,33 @@ size_t SBStructuredData::GetSize() const { return (m_impl_up ? m_impl_up->GetSize() : 0); } +bool SBStructuredData::GetKeys(lldb::SBStringList &keys) const { + if (!m_impl_up) + return false; + + if (GetType() != eStructuredDataTypeDictionary) + return false; + + StructuredData::ObjectSP obj_sp = m_impl_up->GetObjectSP(); + if (!obj_sp) + return false; + + StructuredData::Dictionary *dict = obj_sp->GetAsDictionary(); + // We claimed we were a dictionary, so this can't be null. + assert(dict); + // The return kind of GetKeys is an Array: + StructuredData::ObjectSP array_sp = dict->GetKeys(); + StructuredData::Array *key_arr = array_sp->GetAsArray(); + assert(key_arr); + + key_arr->ForEach([&keys] (StructuredData::Object *object) -> bool { + llvm::StringRef key = object->GetStringValue(""); + keys.AppendString(key.str().c_str()); + return true; + }); + return true; +} + lldb::SBStructuredData SBStructuredData::GetValueForKey(const char *key) const { if (!m_impl_up) return SBStructuredData(); diff --git a/source/API/SBSymbolContext.cpp b/source/API/SBSymbolContext.cpp index 45dfffd916e7..ab70c6f6ca68 100644 --- a/source/API/SBSymbolContext.cpp +++ b/source/API/SBSymbolContext.cpp @@ -27,7 +27,7 @@ SBSymbolContext::SBSymbolContext(const SymbolContext *sc_ptr) : m_opaque_ap() { SBSymbolContext::SBSymbolContext(const SBSymbolContext &rhs) : m_opaque_ap() { if (rhs.IsValid()) { - if (m_opaque_ap.get()) + if (m_opaque_ap) *m_opaque_ap = *rhs.m_opaque_ap; else ref() = *rhs.m_opaque_ap; @@ -39,32 +39,31 @@ SBSymbolContext::~SBSymbolContext() {} const SBSymbolContext &SBSymbolContext::operator=(const SBSymbolContext &rhs) { if (this != &rhs) { if (rhs.IsValid()) - m_opaque_ap.reset( - new lldb_private::SymbolContext(*rhs.m_opaque_ap.get())); + m_opaque_ap.reset(new lldb_private::SymbolContext(*rhs.m_opaque_ap)); } return *this; } void SBSymbolContext::SetSymbolContext(const SymbolContext *sc_ptr) { if (sc_ptr) { - if (m_opaque_ap.get()) + if (m_opaque_ap) *m_opaque_ap = *sc_ptr; else m_opaque_ap.reset(new SymbolContext(*sc_ptr)); } else { - if (m_opaque_ap.get()) + if (m_opaque_ap) m_opaque_ap->Clear(true); } } -bool SBSymbolContext::IsValid() const { return m_opaque_ap.get() != NULL; } +bool SBSymbolContext::IsValid() const { return m_opaque_ap != NULL; } SBModule SBSymbolContext::GetModule() { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); SBModule sb_module; ModuleSP module_sp; - if (m_opaque_ap.get()) { + if (m_opaque_ap) { module_sp = m_opaque_ap->module_sp; sb_module.SetSP(module_sp); } @@ -81,7 +80,7 @@ SBModule SBSymbolContext::GetModule() { } SBCompileUnit SBSymbolContext::GetCompileUnit() { - return SBCompileUnit(m_opaque_ap.get() ? m_opaque_ap->comp_unit : NULL); + return SBCompileUnit(m_opaque_ap ? m_opaque_ap->comp_unit : NULL); } SBFunction SBSymbolContext::GetFunction() { @@ -89,7 +88,7 @@ SBFunction SBSymbolContext::GetFunction() { Function *function = NULL; - if (m_opaque_ap.get()) + if (m_opaque_ap) function = m_opaque_ap->function; SBFunction sb_function(function); @@ -103,14 +102,14 @@ SBFunction SBSymbolContext::GetFunction() { } SBBlock SBSymbolContext::GetBlock() { - return SBBlock(m_opaque_ap.get() ? m_opaque_ap->block : NULL); + return SBBlock(m_opaque_ap ? m_opaque_ap->block : NULL); } SBLineEntry SBSymbolContext::GetLineEntry() { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); SBLineEntry sb_line_entry; - if (m_opaque_ap.get()) + if (m_opaque_ap) sb_line_entry.SetLineEntry(m_opaque_ap->line_entry); if (log) { @@ -127,7 +126,7 @@ SBSymbol SBSymbolContext::GetSymbol() { Symbol *symbol = NULL; - if (m_opaque_ap.get()) + if (m_opaque_ap) symbol = m_opaque_ap->symbol; SBSymbol sb_symbol(symbol); @@ -173,19 +172,19 @@ lldb_private::SymbolContext *SBSymbolContext::operator->() const { const lldb_private::SymbolContext &SBSymbolContext::operator*() const { assert(m_opaque_ap.get()); - return *m_opaque_ap.get(); + return *m_opaque_ap; } lldb_private::SymbolContext &SBSymbolContext::operator*() { - if (m_opaque_ap.get() == NULL) + if (m_opaque_ap == NULL) m_opaque_ap.reset(new SymbolContext); - return *m_opaque_ap.get(); + return *m_opaque_ap; } lldb_private::SymbolContext &SBSymbolContext::ref() { - if (m_opaque_ap.get() == NULL) + if (m_opaque_ap == NULL) m_opaque_ap.reset(new SymbolContext); - return *m_opaque_ap.get(); + return *m_opaque_ap; } lldb_private::SymbolContext *SBSymbolContext::get() const { @@ -195,7 +194,7 @@ lldb_private::SymbolContext *SBSymbolContext::get() const { bool SBSymbolContext::GetDescription(SBStream &description) { Stream &strm = description.ref(); - if (m_opaque_ap.get()) { + if (m_opaque_ap) { m_opaque_ap->GetDescription(&strm, lldb::eDescriptionLevelFull, NULL); } else strm.PutCString("No value"); diff --git a/source/API/SBSymbolContextList.cpp b/source/API/SBSymbolContextList.cpp index 8cc29c3422d0..b07ab2afd554 100644 --- a/source/API/SBSymbolContextList.cpp +++ b/source/API/SBSymbolContextList.cpp @@ -31,14 +31,14 @@ operator=(const SBSymbolContextList &rhs) { } uint32_t SBSymbolContextList::GetSize() const { - if (m_opaque_ap.get()) + if (m_opaque_ap) return m_opaque_ap->GetSize(); return 0; } SBSymbolContext SBSymbolContextList::GetContextAtIndex(uint32_t idx) { SBSymbolContext sb_sc; - if (m_opaque_ap.get()) { + if (m_opaque_ap) { SymbolContext sc; if (m_opaque_ap->GetContextAtIndex(idx, sc)) { sb_sc.SetSymbolContext(&sc); @@ -48,7 +48,7 @@ SBSymbolContext SBSymbolContextList::GetContextAtIndex(uint32_t idx) { } void SBSymbolContextList::Clear() { - if (m_opaque_ap.get()) + if (m_opaque_ap) m_opaque_ap->Clear(); } @@ -62,7 +62,7 @@ void SBSymbolContextList::Append(SBSymbolContextList &sc_list) { m_opaque_ap->Append(*sc_list); } -bool SBSymbolContextList::IsValid() const { return m_opaque_ap.get() != NULL; } +bool SBSymbolContextList::IsValid() const { return m_opaque_ap != NULL; } lldb_private::SymbolContextList *SBSymbolContextList::operator->() const { return m_opaque_ap.get(); @@ -70,12 +70,12 @@ lldb_private::SymbolContextList *SBSymbolContextList::operator->() const { lldb_private::SymbolContextList &SBSymbolContextList::operator*() const { assert(m_opaque_ap.get()); - return *m_opaque_ap.get(); + return *m_opaque_ap; } bool SBSymbolContextList::GetDescription(lldb::SBStream &description) { Stream &strm = description.ref(); - if (m_opaque_ap.get()) + if (m_opaque_ap) m_opaque_ap->GetDescription(&strm, lldb::eDescriptionLevelFull, NULL); return true; } diff --git a/source/API/SBTarget.cpp b/source/API/SBTarget.cpp index 550d336906d3..98587e7d7677 100644 --- a/source/API/SBTarget.cpp +++ b/source/API/SBTarget.cpp @@ -202,6 +202,21 @@ SBStructuredData SBTarget::GetStatistics() { return data; } +void SBTarget::SetCollectingStats(bool v) { + TargetSP target_sp(GetSP()); + if (!target_sp) + return; + return target_sp->SetCollectingStats(v); +} + +bool SBTarget::GetCollectingStats() { + TargetSP target_sp(GetSP()); + if (!target_sp) + return false; + return target_sp->GetCollectingStats(); +} + + SBProcess SBTarget::LoadCore(const char *core_file) { lldb::SBError error; // Ignored return LoadCore(core_file, error); @@ -211,7 +226,8 @@ SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) { SBProcess sb_process; TargetSP target_sp(GetSP()); if (target_sp) { - FileSpec filespec(core_file, true); + FileSpec filespec(core_file); + FileSystem::Instance().Resolve(filespec); ProcessSP process_sp(target_sp->CreateProcess( target_sp->GetDebugger().GetListener(), "", &filespec)); if (process_sp) { @@ -310,10 +326,9 @@ SBProcess SBTarget::Launch(SBListener &listener, char const **argv, if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO")) launch_flags |= eLaunchFlagDisableSTDIO; - ProcessLaunchInfo launch_info( - FileSpec{stdin_path, false}, FileSpec{stdout_path, false}, - FileSpec{stderr_path, false}, FileSpec{working_directory, false}, - launch_flags); + ProcessLaunchInfo launch_info(FileSpec(stdin_path), FileSpec(stdout_path), + FileSpec(stderr_path), + FileSpec(working_directory), launch_flags); Module *exe_module = target_sp->GetExecutableModulePointer(); if (exe_module) @@ -501,8 +516,7 @@ lldb::SBProcess SBTarget::AttachToProcessWithName( if (name && target_sp) { ProcessAttachInfo attach_info; - attach_info.GetExecutableFile().SetFile(name, false, - FileSpec::Style::native); + attach_info.GetExecutableFile().SetFile(name, FileSpec::Style::native); attach_info.SetWaitForLaunch(wait_for); if (listener.IsValid()) attach_info.SetListener(listener.GetSP()); @@ -645,11 +659,12 @@ SBSymbolContext SBTarget::ResolveSymbolContextForAddress(const SBAddress &addr, uint32_t resolve_scope) { SBSymbolContext sc; + SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope); if (addr.IsValid()) { TargetSP target_sp(GetSP()); if (target_sp) - target_sp->GetImages().ResolveSymbolContextForAddress( - addr.ref(), resolve_scope, sc.ref()); + target_sp->GetImages().ResolveSymbolContextForAddress(addr.ref(), scope, + sc.ref()); } return sc; } @@ -693,6 +708,13 @@ SBBreakpoint SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec, uint32_t line, lldb::addr_t offset, SBFileSpecList &sb_module_list) { + return BreakpointCreateByLocation(sb_file_spec, line, 0, offset, + sb_module_list); +} + +SBBreakpoint SBTarget::BreakpointCreateByLocation( + const SBFileSpec &sb_file_spec, uint32_t line, uint32_t column, + lldb::addr_t offset, SBFileSpecList &sb_module_list) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); SBBreakpoint sb_bp; @@ -710,8 +732,8 @@ SBTarget::BreakpointCreateByLocation(const SBFileSpec &sb_file_spec, module_list = sb_module_list.get(); } sb_bp = target_sp->CreateBreakpoint( - module_list, *sb_file_spec, line, offset, check_inlines, skip_prologue, - internal, hardware, move_to_nearest_code); + module_list, *sb_file_spec, line, column, offset, check_inlines, + skip_prologue, internal, hardware, move_to_nearest_code); } if (log) { @@ -743,7 +765,7 @@ SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name, const lldb::addr_t offset = 0; if (module_name && module_name[0]) { FileSpecList module_spec_list; - module_spec_list.Append(FileSpec(module_name, false)); + module_spec_list.Append(FileSpec(module_name)); sb_bp = target_sp->CreateBreakpoint( &module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, offset, skip_prologue, internal, hardware); @@ -767,7 +789,7 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByName(const char *symbol_name, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { - uint32_t name_type_mask = eFunctionNameTypeAuto; + lldb::FunctionNameType name_type_mask = eFunctionNameTypeAuto; return BreakpointCreateByName(symbol_name, name_type_mask, eLanguageTypeUnknown, module_list, comp_unit_list); @@ -794,9 +816,10 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByName( const bool hardware = false; const LazyBool skip_prologue = eLazyBoolCalculate; std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); - sb_bp = target_sp->CreateBreakpoint( - module_list.get(), comp_unit_list.get(), symbol_name, name_type_mask, - symbol_language, 0, skip_prologue, internal, hardware); + FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask); + sb_bp = target_sp->CreateBreakpoint(module_list.get(), comp_unit_list.get(), + symbol_name, mask, symbol_language, 0, + skip_prologue, internal, hardware); } if (log) @@ -837,11 +860,11 @@ lldb::SBBreakpoint SBTarget::BreakpointCreateByNames( std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); const bool internal = false; const bool hardware = false; + FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask); const LazyBool skip_prologue = eLazyBoolCalculate; sb_bp = target_sp->CreateBreakpoint( - module_list.get(), comp_unit_list.get(), symbol_names, num_names, - name_type_mask, symbol_language, offset, skip_prologue, internal, - hardware); + module_list.get(), comp_unit_list.get(), symbol_names, num_names, mask, + symbol_language, offset, skip_prologue, internal, hardware); } if (log) { @@ -870,7 +893,7 @@ SBBreakpoint SBTarget::BreakpointCreateByRegex(const char *symbol_name_regex, SBFileSpecList module_spec_list; SBFileSpecList comp_unit_list; if (module_name && module_name[0]) { - module_spec_list.Append(FileSpec(module_name, false)); + module_spec_list.Append(FileSpec(module_name)); } return BreakpointCreateByRegex(symbol_name_regex, eLanguageTypeUnknown, module_spec_list, comp_unit_list); @@ -971,7 +994,7 @@ SBTarget::BreakpointCreateBySourceRegex(const char *source_regex, SBFileSpecList module_spec_list; if (module_name && module_name[0]) { - module_spec_list.Append(FileSpec(module_name, false)); + module_spec_list.Append(FileSpec(module_name)); } SBFileSpecList source_file_list; @@ -1037,7 +1060,7 @@ SBTarget::BreakpointCreateForException(lldb::LanguageType language, } if (log) - log->Printf("SBTarget(%p)::BreakpointCreateByRegex (Language: %s, catch: " + log->Printf("SBTarget(%p)::BreakpointCreateForException (Language: %s, catch: " "%s throw: %s) => SBBreakpoint(%p)", static_cast<void *>(target_sp.get()), Language::GetNameForLanguageType(language), @@ -1047,6 +1070,42 @@ SBTarget::BreakpointCreateForException(lldb::LanguageType language, return sb_bp; } +lldb::SBBreakpoint +SBTarget::BreakpointCreateFromScript(const char *class_name, + SBStructuredData &extra_args, + const SBFileSpecList &module_list, + const SBFileSpecList &file_list, + bool request_hardware) +{ + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + + SBBreakpoint sb_bp; + TargetSP target_sp(GetSP()); + if (target_sp) { + std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); + Status error; + + StructuredData::ObjectSP obj_sp = extra_args.m_impl_up->GetObjectSP(); + sb_bp = + target_sp->CreateScriptedBreakpoint(class_name, + module_list.get(), + file_list.get(), + false, /* internal */ + request_hardware, + obj_sp, + &error); + } + if (log) + log->Printf("SBTarget(%p)::BreakpointCreateFromScript (class name: %s) " + " => SBBreakpoint(%p)", + static_cast<void *>(target_sp.get()), + class_name, + static_cast<void *>(sb_bp.GetSP().get())); + + return sb_bp; +} + + uint32_t SBTarget::GetNumBreakpoints() const { TargetSP target_sp(GetSP()); if (target_sp) { @@ -1457,6 +1516,26 @@ bool SBTarget::DeleteAllWatchpoints() { return false; } +void SBTarget::AppendImageSearchPath(const char *from, const char *to, + lldb::SBError &error) { + TargetSP target_sp(GetSP()); + if (!target_sp) + return error.SetErrorString("invalid target"); + + const ConstString csFrom(from), csTo(to); + if (!csFrom) + return error.SetErrorString("<from> path can't be empty"); + if (!csTo) + return error.SetErrorString("<to> path can't be empty"); + + Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); + if (log) + log->Printf("SBTarget(%p)::%s: '%s' -> '%s'", + static_cast<void *>(target_sp.get()), __FUNCTION__, + from, to); + target_sp->GetImageSearchPathList().Append(csFrom, csTo, true); +} + lldb::SBModule SBTarget::AddModule(const char *path, const char *triple, const char *uuid_cstr) { return AddModule(path, triple, uuid_cstr, NULL); @@ -1469,7 +1548,7 @@ lldb::SBModule SBTarget::AddModule(const char *path, const char *triple, if (target_sp) { ModuleSpec module_spec; if (path) - module_spec.GetFileSpec().SetFile(path, false, FileSpec::Style::native); + module_spec.GetFileSpec().SetFile(path, FileSpec::Style::native); if (uuid_cstr) module_spec.GetUUID().SetFromStringRef(uuid_cstr); @@ -1481,8 +1560,7 @@ lldb::SBModule SBTarget::AddModule(const char *path, const char *triple, module_spec.GetArchitecture() = target_sp->GetArchitecture(); if (symfile) - module_spec.GetSymbolFileSpec().SetFile(symfile, false, - FileSpec::Style::native); + module_spec.GetSymbolFileSpec().SetFile(symfile, FileSpec::Style::native); sb_module.SetSP(target_sp->GetSharedModule(module_spec)); } @@ -1656,17 +1734,19 @@ bool SBTarget::GetDescription(SBStream &description, lldb::SBSymbolContextList SBTarget::FindFunctions(const char *name, uint32_t name_type_mask) { lldb::SBSymbolContextList sb_sc_list; - if (name && name[0]) { - TargetSP target_sp(GetSP()); - if (target_sp) { - const bool symbols_ok = true; - const bool inlines_ok = true; - const bool append = true; - target_sp->GetImages().FindFunctions(ConstString(name), name_type_mask, - symbols_ok, inlines_ok, append, - *sb_sc_list); - } - } + if (!name | !name[0]) + return sb_sc_list; + + TargetSP target_sp(GetSP()); + if (!target_sp) + return sb_sc_list; + + const bool symbols_ok = true; + const bool inlines_ok = true; + const bool append = true; + FunctionNameType mask = static_cast<FunctionNameType>(name_type_mask); + target_sp->GetImages().FindFunctions(ConstString(name), mask, symbols_ok, + inlines_ok, append, *sb_sc_list); return sb_sc_list; } @@ -1770,11 +1850,10 @@ lldb::SBTypeList SBTarget::FindTypes(const char *typename_cstr) { ModuleList &images = target_sp->GetImages(); ConstString const_typename(typename_cstr); bool exact_match = false; - SymbolContext sc; TypeList type_list; llvm::DenseSet<SymbolFile *> searched_symbol_files; uint32_t num_matches = - images.FindTypes(sc, const_typename, exact_match, UINT32_MAX, + images.FindTypes(nullptr, const_typename, exact_match, UINT32_MAX, searched_symbol_files, type_list); if (num_matches > 0) { diff --git a/source/API/SBThread.cpp b/source/API/SBThread.cpp index 0d25b85f57d2..2c859d5222d6 100644 --- a/source/API/SBThread.cpp +++ b/source/API/SBThread.cpp @@ -14,7 +14,6 @@ #include "lldb/API/SBSymbolContext.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/ValueObject.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -32,6 +31,7 @@ #include "lldb/Target/ThreadPlanStepOut.h" #include "lldb/Target/ThreadPlanStepRange.h" #include "lldb/Target/UnixSignals.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StructuredData.h" @@ -571,7 +571,7 @@ bool SBThread::GetInfoItemByPathAsString(const char *path, SBStream &strm) { success = true; } if (node->GetType() == eStructuredDataTypeBoolean) { - if (node->GetAsBoolean()->GetValue() == true) + if (node->GetAsBoolean()->GetValue()) strm.Printf("true"); else strm.Printf("false"); @@ -657,6 +657,7 @@ void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error) { bool abort_other_plans = false; StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0)); + Status new_plan_status; ThreadPlanSP new_plan_sp; if (frame_sp) { if (frame_sp->HasDebugInformation()) { @@ -664,10 +665,10 @@ void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error) { SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); new_plan_sp = thread->QueueThreadPlanForStepOverRange( abort_other_plans, sc.line_entry, sc, stop_other_threads, - avoid_no_debug); + new_plan_status, avoid_no_debug); } else { new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction( - true, abort_other_plans, stop_other_threads); + true, abort_other_plans, stop_other_threads, new_plan_status); } } error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); @@ -707,6 +708,7 @@ void SBThread::StepInto(const char *target_name, uint32_t end_line, Thread *thread = exe_ctx.GetThreadPtr(); StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0)); ThreadPlanSP new_plan_sp; + Status new_plan_status; if (frame_sp && frame_sp->HasDebugInformation()) { SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); @@ -724,13 +726,17 @@ void SBThread::StepInto(const char *target_name, uint32_t end_line, eLazyBoolCalculate; new_plan_sp = thread->QueueThreadPlanForStepInRange( abort_other_plans, range, sc, target_name, stop_other_threads, - step_in_avoids_code_without_debug_info, + new_plan_status, step_in_avoids_code_without_debug_info, step_out_avoids_code_without_debug_info); } else { new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction( - false, abort_other_plans, stop_other_threads); + false, abort_other_plans, stop_other_threads, new_plan_status); } - error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + + if (new_plan_status.Success()) + error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + else + error.SetErrorString(new_plan_status.AsCString()); } void SBThread::StepOut() { @@ -759,11 +765,15 @@ void SBThread::StepOut(SBError &error) { Thread *thread = exe_ctx.GetThreadPtr(); const LazyBool avoid_no_debug = eLazyBoolCalculate; + Status new_plan_status; ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut( abort_other_plans, NULL, false, stop_other_threads, eVoteYes, - eVoteNoOpinion, 0, avoid_no_debug)); + eVoteNoOpinion, 0, new_plan_status, avoid_no_debug)); - error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + if (new_plan_status.Success()) + error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + else + error.SetErrorString(new_plan_status.AsCString()); } void SBThread::StepOutOfFrame(SBFrame &sb_frame) { @@ -812,11 +822,15 @@ void SBThread::StepOutOfFrame(SBFrame &sb_frame, SBError &error) { return; } + Status new_plan_status; ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut( abort_other_plans, NULL, false, stop_other_threads, eVoteYes, - eVoteNoOpinion, frame_sp->GetFrameIndex())); + eVoteNoOpinion, frame_sp->GetFrameIndex(), new_plan_status)); - error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + if (new_plan_status.Success()) + error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + else + error.SetErrorString(new_plan_status.AsCString()); } void SBThread::StepInstruction(bool step_over) { @@ -840,10 +854,14 @@ void SBThread::StepInstruction(bool step_over, SBError &error) { } Thread *thread = exe_ctx.GetThreadPtr(); - ThreadPlanSP new_plan_sp( - thread->QueueThreadPlanForStepSingleInstruction(step_over, true, true)); + Status new_plan_status; + ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepSingleInstruction( + step_over, true, true, new_plan_status)); - error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + if (new_plan_status.Success()) + error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + else + error.SetErrorString(new_plan_status.AsCString()); } void SBThread::RunToAddress(lldb::addr_t addr) { @@ -873,10 +891,14 @@ void SBThread::RunToAddress(lldb::addr_t addr, SBError &error) { Thread *thread = exe_ctx.GetThreadPtr(); + Status new_plan_status; ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForRunToAddress( - abort_other_plans, target_addr, stop_other_threads)); + abort_other_plans, target_addr, stop_other_threads, new_plan_status)); - error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + if (new_plan_status.Success()) + error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + else + error.SetErrorString(new_plan_status.AsCString()); } SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame, @@ -988,12 +1010,16 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame, } else sb_error.SetErrorString("step until target not in current function"); } else { + Status new_plan_status; ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepUntil( abort_other_plans, &step_over_until_addrs[0], step_over_until_addrs.size(), stop_other_threads, - frame_sp->GetFrameIndex())); + frame_sp->GetFrameIndex(), new_plan_status)); - sb_error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + if (new_plan_status.Success()) + sb_error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + else + sb_error.SetErrorString(new_plan_status.AsCString()); } } else { sb_error.SetErrorString("this SBThread object is invalid"); @@ -1008,7 +1034,7 @@ SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name) { SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name, bool resume_immediately) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API)); - SBError sb_error; + SBError error; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); @@ -1019,37 +1045,29 @@ SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name, } if (!exe_ctx.HasThreadScope()) { - sb_error.SetErrorString("this SBThread object is invalid"); - return sb_error; + error.SetErrorString("this SBThread object is invalid"); + return error; } Thread *thread = exe_ctx.GetThreadPtr(); - ThreadPlanSP thread_plan_sp = - thread->QueueThreadPlanForStepScripted(false, script_class_name, false); + Status new_plan_status; + ThreadPlanSP new_plan_sp = thread->QueueThreadPlanForStepScripted( + false, script_class_name, false, new_plan_status); - if (!thread_plan_sp) { - sb_error.SetErrorStringWithFormat( - "Error queueing thread plan for class: %s", script_class_name); - return sb_error; + if (new_plan_status.Fail()) { + error.SetErrorString(new_plan_status.AsCString()); + return error; } - if (!resume_immediately) { - return sb_error; - } + if (!resume_immediately) + return error; - if (thread_plan_sp) - sb_error = ResumeNewPlan(exe_ctx, thread_plan_sp.get()); - else { - sb_error.SetErrorStringWithFormat( - "Error resuming thread plan for class: %s.", script_class_name); - if (log) - log->Printf("SBThread(%p)::StepUsingScriptedThreadPlan: Error queuing " - "thread plan for class: %s", - static_cast<void *>(exe_ctx.GetThreadPtr()), - script_class_name); - } + if (new_plan_status.Success()) + error = ResumeNewPlan(exe_ctx, new_plan_sp.get()); + else + error.SetErrorString(new_plan_status.AsCString()); - return sb_error; + return error; } SBError SBThread::JumpToLine(lldb::SBFileSpec &file_spec, uint32_t line) { @@ -1452,7 +1470,7 @@ SBThread SBThread::GetExtendedBacktraceThread(const char *type) { } } - if (log && sb_origin_thread.IsValid() == false) + if (log && !sb_origin_thread.IsValid()) log->Printf("SBThread(%p)::GetExtendedBacktraceThread() is not returning a " "Valid thread", static_cast<void *>(exe_ctx.GetThreadPtr())); @@ -1466,6 +1484,20 @@ uint32_t SBThread::GetExtendedBacktraceOriginatingIndexID() { return LLDB_INVALID_INDEX32; } +SBValue SBThread::GetCurrentException() { + ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); + if (!thread_sp) return SBValue(); + + return SBValue(thread_sp->GetCurrentException()); +} + +SBThread SBThread::GetCurrentExceptionBacktrace() { + ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); + if (!thread_sp) return SBThread(); + + return SBThread(thread_sp->GetCurrentExceptionBacktrace()); +} + bool SBThread::SafeToCallFunctions() { ThreadSP thread_sp(m_opaque_sp->GetThreadSP()); if (thread_sp) diff --git a/source/API/SBThreadPlan.cpp b/source/API/SBThreadPlan.cpp index 131f84195908..fc54f5b5f87e 100644 --- a/source/API/SBThreadPlan.cpp +++ b/source/API/SBThreadPlan.cpp @@ -14,7 +14,6 @@ #include "lldb/API/SBSymbolContext.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Debugger.h" -#include "lldb/Core/State.h" #include "lldb/Core/StreamFile.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Symbol/CompileUnit.h" @@ -31,6 +30,7 @@ #include "lldb/Target/ThreadPlanStepInstruction.h" #include "lldb/Target/ThreadPlanStepOut.h" #include "lldb/Target/ThreadPlanStepRange.h" +#include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StructuredData.h" @@ -143,6 +143,12 @@ bool SBThreadPlan::IsValid() { SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange(SBAddress &sb_start_address, lldb::addr_t size) { + SBError error; + return QueueThreadPlanForStepOverRange(sb_start_address, size, error); +} + +SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange( + SBAddress &sb_start_address, lldb::addr_t size, SBError &error) { if (m_opaque_sp) { Address *start_address = sb_start_address.get(); if (!start_address) { @@ -152,9 +158,16 @@ SBThreadPlan::QueueThreadPlanForStepOverRange(SBAddress &sb_start_address, AddressRange range(*start_address, size); SymbolContext sc; start_address->CalculateSymbolContext(&sc); - return SBThreadPlan( - m_opaque_sp->GetThread().QueueThreadPlanForStepOverRange( - false, range, sc, eAllThreads)); + Status plan_status; + + SBThreadPlan plan = + SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepOverRange( + false, range, sc, eAllThreads, plan_status)); + + if (plan_status.Fail()) + error.SetErrorString(plan_status.AsCString()); + + return plan; } else { return SBThreadPlan(); } @@ -163,6 +176,13 @@ SBThreadPlan::QueueThreadPlanForStepOverRange(SBAddress &sb_start_address, SBThreadPlan SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address, lldb::addr_t size) { + SBError error; + return QueueThreadPlanForStepInRange(sb_start_address, size, error); +} + +SBThreadPlan +SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address, + lldb::addr_t size, SBError &error) { if (m_opaque_sp) { Address *start_address = sb_start_address.get(); if (!start_address) { @@ -172,8 +192,16 @@ SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address, AddressRange range(*start_address, size); SymbolContext sc; start_address->CalculateSymbolContext(&sc); - return SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepInRange( - false, range, sc, NULL, eAllThreads)); + + Status plan_status; + SBThreadPlan plan = + SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepInRange( + false, range, sc, NULL, eAllThreads, plan_status)); + + if (plan_status.Fail()) + error.SetErrorString(plan_status.AsCString()); + + return plan; } else { return SBThreadPlan(); } @@ -182,13 +210,28 @@ SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address, SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to, bool first_insn) { + SBError error; + return QueueThreadPlanForStepOut(frame_idx_to_step_to, first_insn, error); +} + +SBThreadPlan +SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to, + bool first_insn, SBError &error) { if (m_opaque_sp) { SymbolContext sc; sc = m_opaque_sp->GetThread().GetStackFrameAtIndex(0)->GetSymbolContext( lldb::eSymbolContextEverything); - return SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepOut( - false, &sc, first_insn, false, eVoteYes, eVoteNoOpinion, - frame_idx_to_step_to)); + + Status plan_status; + SBThreadPlan plan = + SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepOut( + false, &sc, first_insn, false, eVoteYes, eVoteNoOpinion, + frame_idx_to_step_to, plan_status)); + + if (plan_status.Fail()) + error.SetErrorString(plan_status.AsCString()); + + return plan; } else { return SBThreadPlan(); } @@ -196,13 +239,50 @@ SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to, SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address) { + SBError error; + return QueueThreadPlanForRunToAddress(sb_address, error); +} + +SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address, + SBError &error) { if (m_opaque_sp) { Address *address = sb_address.get(); if (!address) return SBThreadPlan(); - return SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForRunToAddress( - false, *address, false)); + Status plan_status; + SBThreadPlan plan = + SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForRunToAddress( + false, *address, false, plan_status)); + + if (plan_status.Fail()) + error.SetErrorString(plan_status.AsCString()); + + return plan; + } else { + return SBThreadPlan(); + } +} + +SBThreadPlan +SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name) { + SBError error; + return QueueThreadPlanForStepScripted(script_class_name, error); +} + +SBThreadPlan +SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name, + SBError &error) { + if (m_opaque_sp) { + Status plan_status; + SBThreadPlan plan = + SBThreadPlan(m_opaque_sp->GetThread().QueueThreadPlanForStepScripted( + false, script_class_name, false, plan_status)); + + if (plan_status.Fail()) + error.SetErrorString(plan_status.AsCString()); + + return plan; } else { return SBThreadPlan(); } diff --git a/source/API/SBType.cpp b/source/API/SBType.cpp index e199b7a33e48..77d7dc654100 100644 --- a/source/API/SBType.cpp +++ b/source/API/SBType.cpp @@ -47,20 +47,20 @@ SBType::SBType(const SBType &rhs) : m_opaque_sp() { //{} // bool SBType::operator==(SBType &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); - if (rhs.IsValid() == false) + if (!rhs.IsValid()) return false; return *m_opaque_sp.get() == *rhs.m_opaque_sp.get(); } bool SBType::operator!=(SBType &rhs) { - if (IsValid() == false) + if (!IsValid()) return rhs.IsValid(); - if (rhs.IsValid() == false) + if (!rhs.IsValid()) return true; return *m_opaque_sp.get() != *rhs.m_opaque_sp.get(); @@ -103,10 +103,11 @@ bool SBType::IsValid() const { } uint64_t SBType::GetByteSize() { - if (!IsValid()) - return 0; - - return m_opaque_sp->GetCompilerType(false).GetByteSize(nullptr); + if (IsValid()) + if (llvm::Optional<uint64_t> size = + m_opaque_sp->GetCompilerType(false).GetByteSize(nullptr)) + return *size; + return 0; } bool SBType::IsPointerType() { @@ -451,7 +452,7 @@ SBTypeList::SBTypeList(const SBTypeList &rhs) Append(const_cast<SBTypeList &>(rhs).GetTypeAtIndex(i)); } -bool SBTypeList::IsValid() { return (m_opaque_ap.get() != NULL); } +bool SBTypeList::IsValid() { return (m_opaque_ap != NULL); } SBTypeList &SBTypeList::operator=(const SBTypeList &rhs) { if (this != &rhs) { @@ -469,7 +470,7 @@ void SBTypeList::Append(SBType type) { } SBType SBTypeList::GetTypeAtIndex(uint32_t index) { - if (m_opaque_ap.get()) + if (m_opaque_ap) return SBType(m_opaque_ap->GetTypeAtIndex(index)); return SBType(); } @@ -500,39 +501,39 @@ lldb::SBTypeMember &SBTypeMember::operator=(const lldb::SBTypeMember &rhs) { bool SBTypeMember::IsValid() const { return m_opaque_ap.get(); } const char *SBTypeMember::GetName() { - if (m_opaque_ap.get()) + if (m_opaque_ap) return m_opaque_ap->GetName().GetCString(); return NULL; } SBType SBTypeMember::GetType() { SBType sb_type; - if (m_opaque_ap.get()) { + if (m_opaque_ap) { sb_type.SetSP(m_opaque_ap->GetTypeImpl()); } return sb_type; } uint64_t SBTypeMember::GetOffsetInBytes() { - if (m_opaque_ap.get()) + if (m_opaque_ap) return m_opaque_ap->GetBitOffset() / 8u; return 0; } uint64_t SBTypeMember::GetOffsetInBits() { - if (m_opaque_ap.get()) + if (m_opaque_ap) return m_opaque_ap->GetBitOffset(); return 0; } bool SBTypeMember::IsBitfield() { - if (m_opaque_ap.get()) + if (m_opaque_ap) return m_opaque_ap->GetIsBitfield(); return false; } uint32_t SBTypeMember::GetBitfieldSizeInBits() { - if (m_opaque_ap.get()) + if (m_opaque_ap) return m_opaque_ap->GetBitfieldBitSize(); return 0; } @@ -541,7 +542,7 @@ bool SBTypeMember::GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level) { Stream &strm = description.ref(); - if (m_opaque_ap.get()) { + if (m_opaque_ap) { const uint32_t bit_offset = m_opaque_ap->GetBitOffset(); const uint32_t byte_offset = bit_offset / 8u; const uint32_t byte_bit_offset = bit_offset % 8u; @@ -571,12 +572,12 @@ void SBTypeMember::reset(TypeMemberImpl *type_member_impl) { } TypeMemberImpl &SBTypeMember::ref() { - if (m_opaque_ap.get() == NULL) + if (m_opaque_ap == NULL) m_opaque_ap.reset(new TypeMemberImpl()); - return *m_opaque_ap.get(); + return *m_opaque_ap; } -const TypeMemberImpl &SBTypeMember::ref() const { return *m_opaque_ap.get(); } +const TypeMemberImpl &SBTypeMember::ref() const { return *m_opaque_ap; } SBTypeMemberFunction::SBTypeMemberFunction() : m_opaque_sp() {} diff --git a/source/API/SBTypeCategory.cpp b/source/API/SBTypeCategory.cpp index 30414bd728cb..7c2a37e7cf21 100644 --- a/source/API/SBTypeCategory.cpp +++ b/source/API/SBTypeCategory.cpp @@ -529,14 +529,14 @@ operator=(const lldb::SBTypeCategory &rhs) { } bool SBTypeCategory::operator==(lldb::SBTypeCategory &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp.get() == rhs.m_opaque_sp.get(); } bool SBTypeCategory::operator!=(lldb::SBTypeCategory &rhs) { - if (IsValid() == false) + if (!IsValid()) return rhs.IsValid(); return m_opaque_sp.get() != rhs.m_opaque_sp.get(); diff --git a/source/API/SBTypeEnumMember.cpp b/source/API/SBTypeEnumMember.cpp index 5ca9db7ce242..87be40e8b141 100644 --- a/source/API/SBTypeEnumMember.cpp +++ b/source/API/SBTypeEnumMember.cpp @@ -94,7 +94,7 @@ SBTypeEnumMemberList::SBTypeEnumMemberList(const SBTypeEnumMemberList &rhs) Append(const_cast<SBTypeEnumMemberList &>(rhs).GetTypeEnumMemberAtIndex(i)); } -bool SBTypeEnumMemberList::IsValid() { return (m_opaque_ap.get() != NULL); } +bool SBTypeEnumMemberList::IsValid() { return (m_opaque_ap != NULL); } SBTypeEnumMemberList &SBTypeEnumMemberList:: operator=(const SBTypeEnumMemberList &rhs) { @@ -116,7 +116,7 @@ void SBTypeEnumMemberList::Append(SBTypeEnumMember enum_member) { SBTypeEnumMember SBTypeEnumMemberList::GetTypeEnumMemberAtIndex(uint32_t index) { - if (m_opaque_ap.get()) + if (m_opaque_ap) return SBTypeEnumMember(m_opaque_ap->GetTypeEnumMemberAtIndex(index)); return SBTypeEnumMember(); } diff --git a/source/API/SBTypeFilter.cpp b/source/API/SBTypeFilter.cpp index 8fa322211384..9709d2e5da10 100644 --- a/source/API/SBTypeFilter.cpp +++ b/source/API/SBTypeFilter.cpp @@ -91,14 +91,14 @@ lldb::SBTypeFilter &SBTypeFilter::operator=(const lldb::SBTypeFilter &rhs) { } bool SBTypeFilter::operator==(lldb::SBTypeFilter &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp == rhs.m_opaque_sp; } bool SBTypeFilter::IsEqualTo(lldb::SBTypeFilter &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); if (GetNumberOfExpressionPaths() != rhs.GetNumberOfExpressionPaths()) @@ -113,7 +113,7 @@ bool SBTypeFilter::IsEqualTo(lldb::SBTypeFilter &rhs) { } bool SBTypeFilter::operator!=(lldb::SBTypeFilter &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp != rhs.m_opaque_sp; diff --git a/source/API/SBTypeFormat.cpp b/source/API/SBTypeFormat.cpp index 6fe7625831d2..66bfd3671736 100644 --- a/source/API/SBTypeFormat.cpp +++ b/source/API/SBTypeFormat.cpp @@ -88,13 +88,13 @@ lldb::SBTypeFormat &SBTypeFormat::operator=(const lldb::SBTypeFormat &rhs) { } bool SBTypeFormat::operator==(lldb::SBTypeFormat &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp == rhs.m_opaque_sp; } bool SBTypeFormat::IsEqualTo(lldb::SBTypeFormat &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); if (GetFormat() == rhs.GetFormat()) @@ -104,7 +104,7 @@ bool SBTypeFormat::IsEqualTo(lldb::SBTypeFormat &rhs) { } bool SBTypeFormat::operator!=(lldb::SBTypeFormat &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp != rhs.m_opaque_sp; } diff --git a/source/API/SBTypeNameSpecifier.cpp b/source/API/SBTypeNameSpecifier.cpp index 2f9deafb68c8..5ffb3d98a0f2 100644 --- a/source/API/SBTypeNameSpecifier.cpp +++ b/source/API/SBTypeNameSpecifier.cpp @@ -80,13 +80,13 @@ operator=(const lldb::SBTypeNameSpecifier &rhs) { } bool SBTypeNameSpecifier::operator==(lldb::SBTypeNameSpecifier &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp == rhs.m_opaque_sp; } bool SBTypeNameSpecifier::IsEqualTo(lldb::SBTypeNameSpecifier &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); if (IsRegex() != rhs.IsRegex()) @@ -98,7 +98,7 @@ bool SBTypeNameSpecifier::IsEqualTo(lldb::SBTypeNameSpecifier &rhs) { } bool SBTypeNameSpecifier::operator!=(lldb::SBTypeNameSpecifier &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp != rhs.m_opaque_sp; } diff --git a/source/API/SBTypeSummary.cpp b/source/API/SBTypeSummary.cpp index cd4edd17f672..76c94ae83444 100644 --- a/source/API/SBTypeSummary.cpp +++ b/source/API/SBTypeSummary.cpp @@ -25,7 +25,7 @@ SBTypeSummaryOptions::SBTypeSummaryOptions() { SBTypeSummaryOptions::SBTypeSummaryOptions( const lldb::SBTypeSummaryOptions &rhs) { if (rhs.m_opaque_ap) - m_opaque_ap.reset(new TypeSummaryOptions(*rhs.m_opaque_ap.get())); + m_opaque_ap.reset(new TypeSummaryOptions(*rhs.m_opaque_ap)); else m_opaque_ap.reset(new TypeSummaryOptions()); } @@ -70,11 +70,11 @@ lldb_private::TypeSummaryOptions *SBTypeSummaryOptions::get() { } lldb_private::TypeSummaryOptions &SBTypeSummaryOptions::ref() { - return *m_opaque_ap.get(); + return *m_opaque_ap; } const lldb_private::TypeSummaryOptions &SBTypeSummaryOptions::ref() const { - return *m_opaque_ap.get(); + return *m_opaque_ap; } SBTypeSummaryOptions::SBTypeSummaryOptions( @@ -261,7 +261,7 @@ lldb::SBTypeSummary &SBTypeSummary::operator=(const lldb::SBTypeSummary &rhs) { } bool SBTypeSummary::operator==(lldb::SBTypeSummary &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp == rhs.m_opaque_sp; } @@ -305,7 +305,7 @@ bool SBTypeSummary::IsEqualTo(lldb::SBTypeSummary &rhs) { } bool SBTypeSummary::operator!=(lldb::SBTypeSummary &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp != rhs.m_opaque_sp; } diff --git a/source/API/SBTypeSynthetic.cpp b/source/API/SBTypeSynthetic.cpp index 37b6086f855a..750d917e67f1 100644 --- a/source/API/SBTypeSynthetic.cpp +++ b/source/API/SBTypeSynthetic.cpp @@ -106,13 +106,13 @@ operator=(const lldb::SBTypeSynthetic &rhs) { } bool SBTypeSynthetic::operator==(lldb::SBTypeSynthetic &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp == rhs.m_opaque_sp; } bool SBTypeSynthetic::IsEqualTo(lldb::SBTypeSynthetic &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); if (m_opaque_sp->IsScripted() != rhs.m_opaque_sp->IsScripted()) @@ -128,7 +128,7 @@ bool SBTypeSynthetic::IsEqualTo(lldb::SBTypeSynthetic &rhs) { } bool SBTypeSynthetic::operator!=(lldb::SBTypeSynthetic &rhs) { - if (IsValid() == false) + if (!IsValid()) return !rhs.IsValid(); return m_opaque_sp != rhs.m_opaque_sp; } diff --git a/source/API/SBValue.cpp b/source/API/SBValue.cpp index a270c0471e9f..a61a2a19a621 100644 --- a/source/API/SBValue.cpp +++ b/source/API/SBValue.cpp @@ -18,7 +18,6 @@ #include "lldb/Breakpoint/Watchpoint.h" #include "lldb/Core/Module.h" -#include "lldb/Core/Scalar.h" #include "lldb/Core/Section.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/Value.h" @@ -38,6 +37,7 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Log.h" +#include "lldb/Utility/Scalar.h" #include "lldb/Utility/Stream.h" #include "lldb/API/SBDebugger.h" @@ -98,10 +98,7 @@ public: // they depend on. So I have no good way to make that check without // tracking that in all the ValueObject subclasses. TargetSP target_sp = m_valobj_sp->GetTargetSP(); - if (target_sp && target_sp->IsValid()) - return true; - else - return false; + return target_sp && target_sp->IsValid(); } } diff --git a/source/API/SBValueList.cpp b/source/API/SBValueList.cpp index 0adf3bb914aa..82b464bab9b9 100644 --- a/source/API/SBValueList.cpp +++ b/source/API/SBValueList.cpp @@ -99,7 +99,7 @@ SBValueList::SBValueList(const ValueListImpl *lldb_object_ptr) : m_opaque_ap() { SBValueList::~SBValueList() {} -bool SBValueList::IsValid() const { return (m_opaque_ap.get() != NULL); } +bool SBValueList::IsValid() const { return (m_opaque_ap != NULL); } void SBValueList::Clear() { m_opaque_ap.reset(); } @@ -150,7 +150,7 @@ SBValue SBValueList::GetValueAtIndex(uint32_t idx) const { // idx); SBValue sb_value; - if (m_opaque_ap.get()) + if (m_opaque_ap) sb_value = m_opaque_ap->GetValueAtIndex(idx); if (log) { @@ -172,7 +172,7 @@ uint32_t SBValueList::GetSize() const { // log->Printf ("SBValueList::GetSize ()"); uint32_t size = 0; - if (m_opaque_ap.get()) + if (m_opaque_ap) size = m_opaque_ap->GetSize(); if (log) @@ -183,20 +183,20 @@ uint32_t SBValueList::GetSize() const { } void SBValueList::CreateIfNeeded() { - if (m_opaque_ap.get() == NULL) + if (m_opaque_ap == NULL) m_opaque_ap.reset(new ValueListImpl()); } SBValue SBValueList::FindValueObjectByUID(lldb::user_id_t uid) { SBValue sb_value; - if (m_opaque_ap.get()) + if (m_opaque_ap) sb_value = m_opaque_ap->FindValueByUID(uid); return sb_value; } SBValue SBValueList::GetFirstValueByName(const char *name) const { SBValue sb_value; - if (m_opaque_ap.get()) + if (m_opaque_ap) sb_value = m_opaque_ap->GetFirstValueByName(name); return sb_value; } @@ -205,5 +205,5 @@ void *SBValueList::opaque_ptr() { return m_opaque_ap.get(); } ValueListImpl &SBValueList::ref() { CreateIfNeeded(); - return *m_opaque_ap.get(); + return *m_opaque_ap; } diff --git a/source/API/SBVariablesOptions.cpp b/source/API/SBVariablesOptions.cpp index e12b9696521c..2651ce11d02a 100644 --- a/source/API/SBVariablesOptions.cpp +++ b/source/API/SBVariablesOptions.cpp @@ -9,6 +9,10 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBVariablesOptions.h" +#include "lldb/API/SBTarget.h" +#include "lldb/Target/Target.h" + +#include "lldb/lldb-private.h" using namespace lldb; using namespace lldb_private; @@ -19,6 +23,7 @@ public: : m_include_arguments(false), m_include_locals(false), m_include_statics(false), m_in_scope_only(false), m_include_runtime_support_values(false), + m_include_recognized_arguments(eLazyBoolCalculate), m_use_dynamic(lldb::eNoDynamicValues) {} VariablesOptionsImpl(const VariablesOptionsImpl &) = default; @@ -31,6 +36,16 @@ public: void SetIncludeArguments(bool b) { m_include_arguments = b; } + bool GetIncludeRecognizedArguments(const lldb::TargetSP &target_sp) const { + if (m_include_recognized_arguments != eLazyBoolCalculate) + return m_include_recognized_arguments; + return target_sp ? target_sp->GetDisplayRecognizedArguments() : false; + } + + void SetIncludeRecognizedArguments(bool b) { + m_include_recognized_arguments = b ? eLazyBoolYes : eLazyBoolNo; + } + bool GetIncludeLocals() const { return m_include_locals; } void SetIncludeLocals(bool b) { m_include_locals = b; } @@ -61,6 +76,7 @@ private: bool m_include_statics : 1; bool m_in_scope_only : 1; bool m_include_runtime_support_values : 1; + LazyBool m_include_recognized_arguments; // can be overridden with a setting lldb::DynamicValueType m_use_dynamic; }; @@ -78,9 +94,7 @@ operator=(const SBVariablesOptions &options) { SBVariablesOptions::~SBVariablesOptions() = default; -bool SBVariablesOptions::IsValid() const { - return m_opaque_ap.get() != nullptr; -} +bool SBVariablesOptions::IsValid() const { return m_opaque_ap != nullptr; } bool SBVariablesOptions::GetIncludeArguments() const { return m_opaque_ap->GetIncludeArguments(); @@ -90,6 +104,15 @@ void SBVariablesOptions::SetIncludeArguments(bool arguments) { m_opaque_ap->SetIncludeArguments(arguments); } +bool SBVariablesOptions::GetIncludeRecognizedArguments( + const lldb::SBTarget &target) const { + return m_opaque_ap->GetIncludeRecognizedArguments(target.GetSP()); +} + +void SBVariablesOptions::SetIncludeRecognizedArguments(bool arguments) { + m_opaque_ap->SetIncludeRecognizedArguments(arguments); +} + bool SBVariablesOptions::GetIncludeLocals() const { return m_opaque_ap->GetIncludeLocals(); } diff --git a/source/API/SystemInitializerFull.cpp b/source/API/SystemInitializerFull.cpp index 18de376183c7..42dea6a01aba 100644 --- a/source/API/SystemInitializerFull.cpp +++ b/source/API/SystemInitializerFull.cpp @@ -24,9 +24,6 @@ #include "lldb/Initialization/SystemInitializerCommon.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Symbol/ClangASTContext.h" -#include "lldb/Symbol/GoASTContext.h" -#include "lldb/Symbol/JavaASTContext.h" -#include "lldb/Symbol/OCamlASTContext.h" #include "lldb/Utility/Timer.h" #include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h" @@ -43,6 +40,7 @@ #include "Plugins/ABI/SysV-s390x/ABISysV_s390x.h" #include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h" #include "Plugins/Architecture/Arm/ArchitectureArm.h" +#include "Plugins/Architecture/Mips/ArchitectureMips.h" #include "Plugins/Architecture/PPC64/ArchitecturePPC64.h" #include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h" #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h" @@ -58,22 +56,17 @@ #include "Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h" #include "Plugins/JITLoader/GDB/JITLoaderGDB.h" #include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h" -#include "Plugins/Language/Go/GoLanguage.h" -#include "Plugins/Language/Java/JavaLanguage.h" -#include "Plugins/Language/OCaml/OCamlLanguage.h" #include "Plugins/Language/ObjC/ObjCLanguage.h" #include "Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h" #include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h" -#include "Plugins/LanguageRuntime/Go/GoLanguageRuntime.h" -#include "Plugins/LanguageRuntime/Java/JavaLanguageRuntime.h" #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h" #include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h" #include "Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h" #include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h" +#include "Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h" #include "Plugins/ObjectFile/ELF/ObjectFileELF.h" #include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h" #include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h" -#include "Plugins/OperatingSystem/Go/OperatingSystemGo.h" #include "Plugins/OperatingSystem/Python/OperatingSystemPython.h" #include "Plugins/Platform/Android/PlatformAndroid.h" #include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h" @@ -90,6 +83,7 @@ #include "Plugins/Process/mach-core/ProcessMachCore.h" #include "Plugins/Process/minidump/ProcessMinidump.h" #include "Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h" +#include "Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h" #include "Plugins/SymbolFile/PDB/SymbolFilePDB.h" @@ -106,6 +100,7 @@ #include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h" #include "Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h" #include "Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h" +#include "Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h" #include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h" #include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h" #include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h" @@ -177,6 +172,18 @@ extern "C" bool LLDBSWIGPythonCallThreadPlan(void *implementor, const char *method_name, Event *event_sp, bool &got_error); +extern "C" void *LLDBSwigPythonCreateScriptedBreakpointResolver( + const char *python_class_name, + const char *session_dictionary_name, + lldb_private::StructuredDataImpl *args, + lldb::BreakpointSP &bkpt_sp); + +extern "C" unsigned int LLDBSwigPythonCallBreakpointResolver( + void *implementor, + const char *method_name, + lldb_private::SymbolContext *sym_ctx +); + extern "C" size_t LLDBSwigPython_CalculateNumChildren(void *implementor, uint32_t max); @@ -222,6 +229,13 @@ LLDBSWIGPythonCreateOSPlugin(const char *python_class_name, const char *session_dictionary_name, const lldb::ProcessSP &process_sp); +extern "C" void *LLDBSWIGPython_CreateFrameRecognizer( + const char *python_class_name, + const char *session_dictionary_name); + +extern "C" void *LLDBSwigPython_GetRecognizedArguments(void *implementor, + const lldb::StackFrameSP& frame_sp); + extern "C" bool LLDBSWIGPythonRunScriptKeywordProcess( const char *python_function_name, const char *session_dictionary_name, lldb::ProcessSP &process, std::string &output); @@ -252,9 +266,12 @@ SystemInitializerFull::SystemInitializerFull() {} SystemInitializerFull::~SystemInitializerFull() {} -void SystemInitializerFull::Initialize() { - SystemInitializerCommon::Initialize(); +llvm::Error +SystemInitializerFull::Initialize(const InitializerOptions &options) { + if (auto e = SystemInitializerCommon::Initialize(options)) + return e; + breakpad::ObjectFileBreakpad::Initialize(); ObjectFileELF::Initialize(); ObjectFileMachO::Initialize(); ObjectFilePECOFF::Initialize(); @@ -264,7 +281,6 @@ void SystemInitializerFull::Initialize() { #ifndef LLDB_DISABLE_PYTHON OperatingSystemPython::Initialize(); #endif - OperatingSystemGo::Initialize(); #if !defined(LLDB_DISABLE_PYTHON) InitializeSWIG(); @@ -296,9 +312,6 @@ void SystemInitializerFull::Initialize() { llvm::InitializeAllDisassemblers(); ClangASTContext::Initialize(); - GoASTContext::Initialize(); - JavaASTContext::Initialize(); - OCamlASTContext::Initialize(); ABIMacOSX_i386::Initialize(); ABIMacOSX_arm::Initialize(); @@ -315,6 +328,7 @@ void SystemInitializerFull::Initialize() { ABISysV_s390x::Initialize(); ArchitectureArm::Initialize(); + ArchitectureMips::Initialize(); ArchitecturePPC64::Initialize(); DisassemblerLLVMC::Initialize(); @@ -330,6 +344,7 @@ void SystemInitializerFull::Initialize() { MainThreadCheckerRuntime::Initialize(); SymbolVendorELF::Initialize(); + breakpad::SymbolFileBreakpad::Initialize(); SymbolFileDWARF::Initialize(); SymbolFilePDB::Initialize(); SymbolFileSymtab::Initialize(); @@ -343,15 +358,10 @@ void SystemInitializerFull::Initialize() { AppleObjCRuntimeV1::Initialize(); SystemRuntimeMacOSX::Initialize(); RenderScriptRuntime::Initialize(); - GoLanguageRuntime::Initialize(); - JavaLanguageRuntime::Initialize(); CPlusPlusLanguage::Initialize(); - GoLanguage::Initialize(); - JavaLanguage::Initialize(); ObjCLanguage::Initialize(); ObjCPlusPlusLanguage::Initialize(); - OCamlLanguage::Initialize(); #if defined(_WIN32) ProcessWindows::Initialize(); @@ -366,6 +376,7 @@ void SystemInitializerFull::Initialize() { PlatformAppleWatchSimulator::Initialize(); PlatformRemoteAppleTV::Initialize(); PlatformRemoteAppleWatch::Initialize(); + PlatformRemoteAppleBridge::Initialize(); DynamicLoaderDarwinKernel::Initialize(); #endif @@ -393,6 +404,8 @@ void SystemInitializerFull::Initialize() { // AFTER PluginManager::Initialize is called. Debugger::SettingsInitialize(); + + return llvm::Error::success(); } void SystemInitializerFull::InitializeSWIG() { @@ -409,11 +422,14 @@ void SystemInitializerFull::InitializeSWIG() { LLDBSwigPython_MightHaveChildrenSynthProviderInstance, LLDBSwigPython_GetValueSynthProviderInstance, LLDBSwigPythonCallCommand, LLDBSwigPythonCallCommandObject, LLDBSwigPythonCallModuleInit, - LLDBSWIGPythonCreateOSPlugin, LLDBSWIGPythonRunScriptKeywordProcess, + LLDBSWIGPythonCreateOSPlugin, LLDBSWIGPython_CreateFrameRecognizer, + LLDBSwigPython_GetRecognizedArguments, + LLDBSWIGPythonRunScriptKeywordProcess, LLDBSWIGPythonRunScriptKeywordThread, LLDBSWIGPythonRunScriptKeywordTarget, LLDBSWIGPythonRunScriptKeywordFrame, LLDBSWIGPythonRunScriptKeywordValue, LLDBSWIGPython_GetDynamicSetting, - LLDBSwigPythonCreateScriptedThreadPlan, LLDBSWIGPythonCallThreadPlan); + LLDBSwigPythonCreateScriptedThreadPlan, LLDBSWIGPythonCallThreadPlan, + LLDBSwigPythonCreateScriptedBreakpointResolver, LLDBSwigPythonCallBreakpointResolver); #endif } @@ -427,9 +443,10 @@ void SystemInitializerFull::Terminate() { PluginManager::Terminate(); ClangASTContext::Terminate(); - GoASTContext::Terminate(); - JavaASTContext::Terminate(); - OCamlASTContext::Terminate(); + + ArchitectureArm::Terminate(); + ArchitectureMips::Terminate(); + ArchitecturePPC64::Terminate(); ABIMacOSX_i386::Terminate(); ABIMacOSX_arm::Terminate(); @@ -456,6 +473,7 @@ void SystemInitializerFull::Terminate() { UndefinedBehaviorSanitizerRuntime::Terminate(); MainThreadCheckerRuntime::Terminate(); SymbolVendorELF::Terminate(); + breakpad::SymbolFileBreakpad::Terminate(); SymbolFileDWARF::Terminate(); SymbolFilePDB::Terminate(); SymbolFileSymtab::Terminate(); @@ -469,14 +487,10 @@ void SystemInitializerFull::Terminate() { AppleObjCRuntimeV1::Terminate(); SystemRuntimeMacOSX::Terminate(); RenderScriptRuntime::Terminate(); - JavaLanguageRuntime::Terminate(); CPlusPlusLanguage::Terminate(); - GoLanguage::Terminate(); - JavaLanguage::Terminate(); ObjCLanguage::Terminate(); ObjCPlusPlusLanguage::Terminate(); - OCamlLanguage::Terminate(); #if defined(__APPLE__) DynamicLoaderDarwinKernel::Terminate(); @@ -486,6 +500,7 @@ void SystemInitializerFull::Terminate() { PlatformAppleWatchSimulator::Terminate(); PlatformRemoteAppleTV::Terminate(); PlatformRemoteAppleWatch::Terminate(); + PlatformRemoteAppleBridge::Terminate(); #endif #if defined(__FreeBSD__) @@ -506,7 +521,6 @@ void SystemInitializerFull::Terminate() { #ifndef LLDB_DISABLE_PYTHON OperatingSystemPython::Terminate(); #endif - OperatingSystemGo::Terminate(); platform_freebsd::PlatformFreeBSD::Terminate(); platform_linux::PlatformLinux::Terminate(); @@ -522,6 +536,7 @@ void SystemInitializerFull::Terminate() { PlatformDarwinKernel::Terminate(); #endif + breakpad::ObjectFileBreakpad::Terminate(); ObjectFileELF::Terminate(); ObjectFileMachO::Terminate(); ObjectFilePECOFF::Terminate(); diff --git a/source/API/SystemInitializerFull.h b/source/API/SystemInitializerFull.h index 9cfc6896da61..b0cf476e9193 100644 --- a/source/API/SystemInitializerFull.h +++ b/source/API/SystemInitializerFull.h @@ -26,7 +26,7 @@ public: SystemInitializerFull(); ~SystemInitializerFull() override; - void Initialize() override; + llvm::Error Initialize(const InitializerOptions &options) override; void Terminate() override; private: |