summaryrefslogtreecommitdiff
path: root/source/API
diff options
context:
space:
mode:
Diffstat (limited to 'source/API')
-rw-r--r--source/API/CMakeLists.txt74
-rw-r--r--source/API/SBAddress.cpp18
-rw-r--r--source/API/SBAttachInfo.cpp9
-rw-r--r--source/API/SBBreakpointName.cpp10
-rw-r--r--source/API/SBCommandInterpreter.cpp21
-rw-r--r--source/API/SBDebugger.cpp70
-rw-r--r--source/API/SBEvent.cpp4
-rw-r--r--source/API/SBFrame.cpp2
-rw-r--r--source/API/SBHostOS.cpp53
-rw-r--r--source/API/SBInstruction.cpp30
-rw-r--r--source/API/SBInstructionList.cpp4
-rw-r--r--source/API/SBLaunchInfo.cpp51
-rw-r--r--source/API/SBModule.cpp63
-rw-r--r--source/API/SBModuleSpec.cpp13
-rw-r--r--source/API/SBPlatform.cpp61
-rw-r--r--source/API/SBProcess.cpp58
-rw-r--r--source/API/SBQueueItem.cpp3
-rw-r--r--source/API/SBStream.cpp9
-rw-r--r--source/API/SBTarget.cpp96
-rw-r--r--source/API/SBThread.cpp252
-rw-r--r--source/API/SBThreadPlan.cpp3
-rw-r--r--source/API/SBType.cpp6
-rw-r--r--source/API/SBTypeCategory.cpp12
-rw-r--r--source/API/SBValue.cpp43
-rw-r--r--source/API/SystemInitializerFull.cpp49
-rw-r--r--source/API/SystemInitializerFull.h38
26 files changed, 649 insertions, 403 deletions
diff --git a/source/API/CMakeLists.txt b/source/API/CMakeLists.txt
index c96e59be5a44a..be9d4115cecc8 100644
--- a/source/API/CMakeLists.txt
+++ b/source/API/CMakeLists.txt
@@ -2,16 +2,6 @@ if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
add_definitions( -DEXPORT_LIBLLDB )
endif()
-option(LLDB_BUILD_FRAMEWORK "Build the Darwin LLDB.framework" Off)
-
-if(LLDB_BUILD_FRAMEWORK AND CMAKE_VERSION VERSION_LESS 3.7)
- message(FATAL_ERROR "LLDB_BUILD_FRAMEWORK is not supported on CMake < 3.7")
-endif()
-
-if (LLDB_BUILD_FRAMEWORK AND NOT APPLE)
- message(FATAL_ERROR "LLDB.framework cannot be generated unless targeting Apple platforms.")
-endif()
-
get_property(LLDB_ALL_PLUGINS GLOBAL PROPERTY LLDB_PLUGINS)
add_lldb_library(liblldb SHARED
@@ -101,13 +91,14 @@ add_lldb_library(liblldb SHARED
Support
)
-if (LLVM_ENABLE_WERROR)
- 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()
+add_dependencies(lldb-suite liblldb)
+
+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()
+
set_source_files_properties(${LLDB_WRAP_PYTHON} PROPERTIES GENERATED 1)
if (CLANG_CL)
set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING
@@ -119,15 +110,10 @@ if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND
PROPERTY COMPILE_FLAGS " -Wno-sequence-point -Wno-cast-qual")
endif ()
-target_link_libraries(liblldb PRIVATE
- lldbPluginScriptInterpreterNone
- lldbPluginScriptInterpreterPython
- )
-
set_target_properties(liblldb
PROPERTIES
VERSION ${LLDB_VERSION}
- )
+)
if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
if (NOT LLDB_EXPORT_ALL_SYMBOLS)
@@ -154,51 +140,9 @@ else()
set_target_properties(liblldb
PROPERTIES
OUTPUT_NAME lldb
- )
+ )
endif()
if (LLDB_WRAP_PYTHON)
add_dependencies(liblldb swig_wrapper)
endif()
-
-if(LLDB_BUILD_FRAMEWORK)
- file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h
- ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h)
- file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h)
- file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h)
- list(REMOVE_ITEM root_public_headers ${root_private_headers})
-
- foreach(header ${public_headers} ${root_public_headers} ${LLDB_SOURCE_DIR}/include/lldb/Utility/SharingPtr.h)
- get_filename_component(basename ${header} NAME)
- add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename}
- DEPENDS ${header}
- COMMAND ${CMAKE_COMMAND} -E copy ${header} ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename})
- list(APPEND framework_headers ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders/${basename})
- endforeach()
-
- add_custom_target(lldb-framework-headers DEPENDS ${framework_headers}
- COMMAND ${LLDB_SOURCE_DIR}/scripts/framework-header-fix.sh ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders ${LLDB_VERSION})
- add_dependencies(liblldb lldb-framework-headers)
-
- set_target_properties(liblldb PROPERTIES
- OUTPUT_NAME LLDB
- FRAMEWORK On
- FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION}
- LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR}
- PUBLIC_HEADER "${framework_headers}")
-
- if(NOT IOS)
- add_custom_command(TARGET liblldb POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders $<TARGET_FILE_DIR:liblldb>/Headers
- COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/Headers ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Headers
- COMMAND ${CMAKE_COMMAND} -E create_symlink ${LLDB_FRAMEWORK_VERSION} ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Versions/Current
- COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/clang/${LLDB_VERSION} $<TARGET_FILE_DIR:liblldb>/Resources/Clang
- )
- else()
- add_custom_command(TARGET liblldb POST_BUILD
- COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_BINARY_DIR}/FrameworkHeaders $<TARGET_FILE_DIR:liblldb>/Headers
- )
- endif()
-
-endif()
-
diff --git a/source/API/SBAddress.cpp b/source/API/SBAddress.cpp
index a3493d7c743f9..d12197e66ddd0 100644
--- a/source/API/SBAddress.cpp
+++ b/source/API/SBAddress.cpp
@@ -120,10 +120,9 @@ void SBAddress::SetLoadAddress(lldb::addr_t load_addr, lldb::SBTarget &target) {
else
m_opaque_ap->Clear();
- // Check if we weren't were able to resolve a section offset address.
- // If we weren't it is ok, the load address might be a location on the
- // stack or heap, so we should just have an address with no section and
- // a valid offset
+ // Check if we weren't were able to resolve a section offset address. If we
+ // weren't it is ok, the load address might be a location on the stack or
+ // heap, so we should just have an address with no section and a valid offset
if (!m_opaque_ap->IsValid())
m_opaque_ap->SetOffset(load_addr);
}
@@ -163,9 +162,8 @@ Address &SBAddress::ref() {
}
const Address &SBAddress::ref() const {
- // This object should already have checked with "IsValid()"
- // prior to calling this function. In case you didn't we will assert
- // and die to let you know.
+ // This object should already have checked with "IsValid()" prior to calling
+ // this function. In case you didn't we will assert and die to let you know.
assert(m_opaque_ap.get());
return *m_opaque_ap;
}
@@ -242,9 +240,3 @@ SBLineEntry SBAddress::GetLineEntry() {
}
return sb_line_entry;
}
-
-AddressClass SBAddress::GetAddressClass() {
- if (m_opaque_ap->IsValid())
- return m_opaque_ap->GetAddressClass();
- return eAddressClassInvalid;
-}
diff --git a/source/API/SBAttachInfo.cpp b/source/API/SBAttachInfo.cpp
index e6500c468ec5d..d6cb212dedf83 100644
--- a/source/API/SBAttachInfo.cpp
+++ b/source/API/SBAttachInfo.cpp
@@ -26,14 +26,16 @@ 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);
+ m_opaque_sp->GetExecutableFile().SetFile(path, false,
+ 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);
+ m_opaque_sp->GetExecutableFile().SetFile(path, false,
+ FileSpec::Style::native);
m_opaque_sp->SetWaitForLaunch(wait_for);
m_opaque_sp->SetAsync(async);
}
@@ -77,7 +79,8 @@ void SBAttachInfo::SetProcessPluginName(const char *plugin_name) {
void SBAttachInfo::SetExecutable(const char *path) {
if (path && path[0])
- m_opaque_sp->GetExecutableFile().SetFile(path, false);
+ m_opaque_sp->GetExecutableFile().SetFile(path, false,
+ FileSpec::Style::native);
else
m_opaque_sp->GetExecutableFile().Clear();
}
diff --git a/source/API/SBBreakpointName.cpp b/source/API/SBBreakpointName.cpp
index 2205280b9e5f2..a6742e3b89ec9 100644
--- a/source/API/SBBreakpointName.cpp
+++ b/source/API/SBBreakpointName.cpp
@@ -52,8 +52,8 @@ public:
bool operator==(const SBBreakpointNameImpl &rhs);
bool operator!=(const SBBreakpointNameImpl &rhs);
- // For now we take a simple approach and only keep the name, and relook
- // up the location when we need it.
+ // For now we take a simple approach and only keep the name, and relook up
+ // the location when we need it.
TargetSP GetTarget() const {
return m_target_wp.lock();
@@ -115,8 +115,7 @@ SBBreakpointName::SBBreakpointName() {}
SBBreakpointName::SBBreakpointName(SBTarget &sb_target, const char *name)
{
m_impl_up.reset(new SBBreakpointNameImpl(sb_target, name));
- // Call FindBreakpointName here to make sure the name is valid, reset if
- // not:
+ // Call FindBreakpointName here to make sure the name is valid, reset if not:
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name)
m_impl_up.reset();
@@ -133,8 +132,7 @@ SBBreakpointName::SBBreakpointName(SBBreakpoint &sb_bkpt, const char *name)
m_impl_up.reset(new SBBreakpointNameImpl(target.shared_from_this(), name));
- // Call FindBreakpointName here to make sure the name is valid, reset if
- // not:
+ // Call FindBreakpointName here to make sure the name is valid, reset if not:
BreakpointName *bp_name = GetBreakpointName();
if (!bp_name) {
m_impl_up.reset();
diff --git a/source/API/SBCommandInterpreter.cpp b/source/API/SBCommandInterpreter.cpp
index c9bb8f65fa2e9..cbb514abb6fe0 100644
--- a/source/API/SBCommandInterpreter.cpp
+++ b/source/API/SBCommandInterpreter.cpp
@@ -272,8 +272,8 @@ int SBCommandInterpreter::HandleCompletion(
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
int num_completions = 0;
- // Sanity check the arguments that are passed in:
- // cursor & last_char have to be within the current_line.
+ // Sanity check the arguments that are passed in: cursor & last_char have to
+ // be within the current_line.
if (current_line == nullptr || cursor == nullptr || last_char == nullptr)
return 0;
@@ -379,6 +379,23 @@ void SBCommandInterpreter::SetPromptOnQuit(bool b) {
m_opaque_ptr->SetPromptOnQuit(b);
}
+void SBCommandInterpreter::AllowExitCodeOnQuit(bool allow) {
+ if (m_opaque_ptr)
+ m_opaque_ptr->AllowExitCodeOnQuit(allow);
+}
+
+bool SBCommandInterpreter::HasCustomQuitExitCode() {
+ bool exited = false;
+ if (m_opaque_ptr)
+ m_opaque_ptr->GetQuitExitCode(exited);
+ return exited;
+}
+
+int SBCommandInterpreter::GetQuitStatus() {
+ bool exited = false;
+ return (m_opaque_ptr ? m_opaque_ptr->GetQuitExitCode(exited) : 0);
+}
+
void SBCommandInterpreter::ResolveCommand(const char *command_line,
SBCommandReturnObject &result) {
result.Clear();
diff --git a/source/API/SBDebugger.cpp b/source/API/SBDebugger.cpp
index d3294dab582de..a651141003a44 100644
--- a/source/API/SBDebugger.cpp
+++ b/source/API/SBDebugger.cpp
@@ -11,6 +11,9 @@
// C++ Includes
// Other libraries and framework includes
// Project includes
+
+#include "SystemInitializerFull.h"
+
#include "lldb/API/SBDebugger.h"
#include "lldb/lldb-private.h"
@@ -35,7 +38,6 @@
#include "lldb/API/SBTypeNameSpecifier.h"
#include "lldb/API/SBTypeSummary.h"
#include "lldb/API/SBTypeSynthetic.h"
-#include "lldb/API/SystemInitializerFull.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/PluginManager.h"
@@ -43,12 +45,14 @@
#include "lldb/Core/StreamFile.h"
#include "lldb/Core/StructuredDataImpl.h"
#include "lldb/DataFormatters/DataVisualization.h"
+#include "lldb/Host/XML.h"
#include "lldb/Initialization/SystemLifetimeManager.h"
-#include "lldb/Interpreter/Args.h"
#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/OptionArgParser.h"
#include "lldb/Interpreter/OptionGroupPlatform.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/TargetList.h"
+#include "lldb/Utility/Args.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
@@ -166,14 +170,10 @@ SBDebugger SBDebugger::Create(bool source_init_files,
SBDebugger debugger;
// Currently we have issues if this function is called simultaneously on two
- // different
- // threads. The issues mainly revolve around the fact that the
- // lldb_private::FormatManager
- // uses global collections and having two threads parsing the .lldbinit files
- // can cause
- // mayhem. So to get around this for now we need to use a mutex to prevent bad
- // things
- // from happening.
+ // different threads. The issues mainly revolve around the fact that the
+ // lldb_private::FormatManager uses global collections and having two threads
+ // parsing the .lldbinit files can cause mayhem. So to get around this for
+ // now we need to use a mutex to prevent bad things from happening.
static std::recursive_mutex g_mutex;
std::lock_guard<std::recursive_mutex> guard(g_mutex);
@@ -218,10 +218,10 @@ void SBDebugger::Destroy(SBDebugger &debugger) {
}
void SBDebugger::MemoryPressureDetected() {
- // Since this function can be call asynchronously, we allow it to be
- // non-mandatory. We have seen deadlocks with this function when called
- // so we need to safeguard against this until we can determine what is
- // causing the deadlocks.
+ // Since this function can be call asynchronously, we allow it to be non-
+ // mandatory. We have seen deadlocks with this function when called so we
+ // need to safeguard against this until we can determine what is causing the
+ // deadlocks.
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
const bool mandatory = false;
@@ -254,9 +254,9 @@ void SBDebugger::SkipAppInitFiles(bool b) {
m_opaque_sp->GetCommandInterpreter().SkipAppInitFiles(b);
}
-// Shouldn't really be settable after initialization as this could cause lots of
-// problems; don't want users
-// trying to switch modes in the middle of a debugging session.
+// Shouldn't really be settable after initialization as this could cause lots
+// of problems; don't want users trying to switch modes in the middle of a
+// debugging session.
void SBDebugger::SetInputFileHandle(FILE *fh, bool transfer_ownership) {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
@@ -479,8 +479,8 @@ bool SBDebugger::SetDefaultArchitecture(const char *arch_name) {
ScriptLanguage
SBDebugger::GetScriptingLanguage(const char *script_language_name) {
if (!script_language_name) return eScriptLanguageDefault;
- return Args::StringToScriptLanguage(llvm::StringRef(script_language_name),
- eScriptLanguageDefault, nullptr);
+ return OptionArgParser::ToScriptLanguage(
+ llvm::StringRef(script_language_name), eScriptLanguageDefault, nullptr);
}
const char *SBDebugger::GetVersionString() {
@@ -491,6 +491,38 @@ const char *SBDebugger::StateAsCString(StateType state) {
return lldb_private::StateAsCString(state);
}
+static void AddBoolConfigEntry(StructuredData::Dictionary &dict,
+ llvm::StringRef name, bool value,
+ llvm::StringRef description) {
+ auto entry_up = llvm::make_unique<StructuredData::Dictionary>();
+ entry_up->AddBooleanItem("value", value);
+ entry_up->AddStringItem("description", description);
+ dict.AddItem(name, std::move(entry_up));
+}
+
+static void AddLLVMTargets(StructuredData::Dictionary &dict) {
+ auto array_up = llvm::make_unique<StructuredData::Array>();
+#define LLVM_TARGET(target) \
+ array_up->AddItem(llvm::make_unique<StructuredData::String>(#target));
+#include "llvm/Config/Targets.def"
+ auto entry_up = llvm::make_unique<StructuredData::Dictionary>();
+ entry_up->AddItem("value", std::move(array_up));
+ entry_up->AddStringItem("description", "A list of configured LLVM targets.");
+ dict.AddItem("targets", std::move(entry_up));
+}
+
+SBStructuredData SBDebugger::GetBuildConfiguration() {
+ auto config_up = llvm::make_unique<StructuredData::Dictionary>();
+ AddBoolConfigEntry(
+ *config_up, "xml", XMLDocument::XMLEnabled(),
+ "A boolean value that indicates if XML support is enabled in LLDB");
+ AddLLVMTargets(*config_up);
+
+ SBStructuredData data;
+ data.m_impl_up->SetObjectSP(std::move(config_up));
+ return data;
+}
+
bool SBDebugger::StateIsRunningState(StateType state) {
Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
diff --git a/source/API/SBEvent.cpp b/source/API/SBEvent.cpp
index 17a16ffd04812..65eb71c09285e 100644
--- a/source/API/SBEvent.cpp
+++ b/source/API/SBEvent.cpp
@@ -146,8 +146,8 @@ void SBEvent::reset(Event *event_ptr) {
}
bool SBEvent::IsValid() const {
- // Do NOT use m_opaque_ptr directly!!! Must use the SBEvent::get()
- // accessor. See comments in SBEvent::get()....
+ // Do NOT use m_opaque_ptr directly!!! Must use the SBEvent::get() accessor.
+ // See comments in SBEvent::get()....
return SBEvent::get() != NULL;
}
diff --git a/source/API/SBFrame.cpp b/source/API/SBFrame.cpp
index 684a707dda94b..5762a75f33d6a 100644
--- a/source/API/SBFrame.cpp
+++ b/source/API/SBFrame.cpp
@@ -419,7 +419,7 @@ addr_t SBFrame::GetPC() const {
frame = exe_ctx.GetFramePtr();
if (frame) {
addr = frame->GetFrameCodeAddress().GetOpcodeLoadAddress(
- target, eAddressClassCode);
+ target, AddressClass::eCode);
} else {
if (log)
log->Printf("SBFrame::GetPC () => error: could not reconstruct frame "
diff --git a/source/API/SBHostOS.cpp b/source/API/SBHostOS.cpp
index 90b75a6ecd7b7..e56951df43be7 100644
--- a/source/API/SBHostOS.cpp
+++ b/source/API/SBHostOS.cpp
@@ -7,6 +7,10 @@
//
//===----------------------------------------------------------------------===//
+#ifndef LLDB_DISABLE_PYTHON
+#include "Plugins/ScriptInterpreter/Python/lldb-python.h"
+#endif
+
#include "lldb/API/SBHostOS.h"
#include "lldb/API/SBError.h"
#include "lldb/Host/Host.h"
@@ -17,6 +21,11 @@
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Log.h"
+#include "Plugins/ExpressionParser/Clang/ClangHost.h"
+#ifndef LLDB_DISABLE_PYTHON
+#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h"
+#endif
+
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Path.h"
@@ -30,19 +39,45 @@ SBFileSpec SBHostOS::GetProgramFileSpec() {
}
SBFileSpec SBHostOS::GetLLDBPythonPath() {
- SBFileSpec sb_lldb_python_filespec;
- FileSpec lldb_python_spec;
- if (HostInfo::GetLLDBPath(ePathTypePythonDir, lldb_python_spec)) {
- sb_lldb_python_filespec.SetFileSpec(lldb_python_spec);
- }
- return sb_lldb_python_filespec;
+ return GetLLDBPath(ePathTypePythonDir);
}
SBFileSpec SBHostOS::GetLLDBPath(lldb::PathType path_type) {
- SBFileSpec sb_fspec;
FileSpec fspec;
- if (HostInfo::GetLLDBPath(path_type, fspec))
- sb_fspec.SetFileSpec(fspec);
+ switch (path_type) {
+ case ePathTypeLLDBShlibDir:
+ fspec = HostInfo::GetShlibDir();
+ break;
+ case ePathTypeSupportExecutableDir:
+ fspec = HostInfo::GetSupportExeDir();
+ break;
+ case ePathTypeHeaderDir:
+ fspec = HostInfo::GetHeaderDir();
+ break;
+ case ePathTypePythonDir:
+#ifndef LLDB_DISABLE_PYTHON
+ fspec = ScriptInterpreterPython::GetPythonDir();
+#endif
+ break;
+ case ePathTypeLLDBSystemPlugins:
+ fspec = HostInfo::GetSystemPluginDir();
+ break;
+ case ePathTypeLLDBUserPlugins:
+ fspec = HostInfo::GetUserPluginDir();
+ break;
+ case ePathTypeLLDBTempSystemDir:
+ fspec = HostInfo::GetProcessTempDir();
+ break;
+ case ePathTypeGlobalLLDBTempSystemDir:
+ fspec = HostInfo::GetGlobalTempDir();
+ break;
+ case ePathTypeClangDir:
+ fspec = GetClangResourceDir();
+ break;
+ }
+
+ SBFileSpec sb_fspec;
+ sb_fspec.SetFileSpec(fspec);
return sb_fspec;
}
diff --git a/source/API/SBInstruction.cpp b/source/API/SBInstruction.cpp
index 1cca8db2afe8d..462f082880920 100644
--- a/source/API/SBInstruction.cpp
+++ b/source/API/SBInstruction.cpp
@@ -27,12 +27,11 @@
#include "lldb/Utility/DataExtractor.h"
//----------------------------------------------------------------------
-// We recently fixed a leak in one of the Instruction subclasses where
-// the instruction will only hold a weak reference to the disassembler
-// to avoid a cycle that was keeping both objects alive (leak) and we
-// need the InstructionImpl class to make sure our public API behaves
-// as users would expect. Calls in our public API allow clients to do
-// things like:
+// We recently fixed a leak in one of the Instruction subclasses where the
+// instruction will only hold a weak reference to the disassembler to avoid a
+// cycle that was keeping both objects alive (leak) and we need the
+// InstructionImpl class to make sure our public API behaves as users would
+// expect. Calls in our public API allow clients to do things like:
//
// 1 lldb::SBInstruction inst;
// 2 inst = target.ReadInstructions(pc, 1).GetInstructionAtIndex(0)
@@ -40,12 +39,12 @@
// 4 ...
//
// There was a temporary lldb::DisassemblerSP object created in the
-// SBInstructionList that was returned by lldb.target.ReadInstructions()
-// that will go away after line 2 but the "inst" object should be able
-// to still answer questions about itself. So we make sure that any
-// SBInstruction objects that are given out have a strong reference to
-// the disassembler and the instruction so that the object can live and
-// successfully respond to all queries.
+// SBInstructionList that was returned by lldb.target.ReadInstructions() that
+// will go away after line 2 but the "inst" object should be able to still
+// answer questions about itself. So we make sure that any SBInstruction
+// objects that are given out have a strong reference to the disassembler and
+// the instruction so that the object can live and successfully respond to all
+// queries.
//----------------------------------------------------------------------
class InstructionImpl {
public:
@@ -275,10 +274,3 @@ bool SBInstruction::TestEmulation(lldb::SBStream &output_stream,
return inst_sp->TestEmulation(output_stream.get(), test_file);
return false;
}
-
-lldb::AddressClass SBInstruction::GetAddressClass() {
- lldb::InstructionSP inst_sp(GetOpaque());
- if (inst_sp)
- return inst_sp->GetAddressClass();
- return eAddressClassInvalid;
-}
diff --git a/source/API/SBInstructionList.cpp b/source/API/SBInstructionList.cpp
index 3edb9eae98c10..29e0c96075fd0 100644
--- a/source/API/SBInstructionList.cpp
+++ b/source/API/SBInstructionList.cpp
@@ -92,8 +92,8 @@ bool SBInstructionList::GetDescription(lldb::SBStream &description) {
if (m_opaque_sp) {
size_t num_instructions = GetSize();
if (num_instructions) {
- // Call the ref() to make sure a stream is created if one deesn't
- // exist already inside description...
+ // Call the ref() to make sure a stream is created if one deesn't exist
+ // already inside description...
Stream &sref = description.ref();
const uint32_t max_opcode_byte_size =
m_opaque_sp->GetInstructionList().GetMaxOpcocdeByteSize();
diff --git a/source/API/SBLaunchInfo.cpp b/source/API/SBLaunchInfo.cpp
index 5f5afccee6808..aa1759ab3d002 100644
--- a/source/API/SBLaunchInfo.cpp
+++ b/source/API/SBLaunchInfo.cpp
@@ -16,8 +16,26 @@
using namespace lldb;
using namespace lldb_private;
+class lldb_private::SBLaunchInfoImpl : public ProcessLaunchInfo {
+public:
+ SBLaunchInfoImpl()
+ : ProcessLaunchInfo(), m_envp(GetEnvironment().getEnvp()) {}
+
+ const char *const *GetEnvp() const { return m_envp; }
+ void RegenerateEnvp() { m_envp = GetEnvironment().getEnvp(); }
+
+ SBLaunchInfoImpl &operator=(const ProcessLaunchInfo &rhs) {
+ ProcessLaunchInfo::operator=(rhs);
+ RegenerateEnvp();
+ return *this;
+ }
+
+private:
+ Environment::Envp m_envp;
+};
+
SBLaunchInfo::SBLaunchInfo(const char **argv)
- : m_opaque_sp(new ProcessLaunchInfo()) {
+ : m_opaque_sp(new SBLaunchInfoImpl()) {
m_opaque_sp->GetFlags().Reset(eLaunchFlagDebug | eLaunchFlagDisableASLR);
if (argv && argv[0])
m_opaque_sp->GetArguments().SetArguments(argv);
@@ -25,12 +43,14 @@ SBLaunchInfo::SBLaunchInfo(const char **argv)
SBLaunchInfo::~SBLaunchInfo() {}
-lldb_private::ProcessLaunchInfo &SBLaunchInfo::ref() { return *m_opaque_sp; }
-
const lldb_private::ProcessLaunchInfo &SBLaunchInfo::ref() const {
return *m_opaque_sp;
}
+void SBLaunchInfo::set_ref(const ProcessLaunchInfo &info) {
+ *m_opaque_sp = info;
+}
+
lldb::pid_t SBLaunchInfo::GetProcessID() { return m_opaque_sp->GetProcessID(); }
uint32_t SBLaunchInfo::GetUserID() { return m_opaque_sp->GetUserID(); }
@@ -83,23 +103,22 @@ void SBLaunchInfo::SetArguments(const char **argv, bool append) {
}
uint32_t SBLaunchInfo::GetNumEnvironmentEntries() {
- return m_opaque_sp->GetEnvironmentEntries().GetArgumentCount();
+ return m_opaque_sp->GetEnvironment().size();
}
const char *SBLaunchInfo::GetEnvironmentEntryAtIndex(uint32_t idx) {
- return m_opaque_sp->GetEnvironmentEntries().GetArgumentAtIndex(idx);
+ if (idx > GetNumEnvironmentEntries())
+ return nullptr;
+ return m_opaque_sp->GetEnvp()[idx];
}
void SBLaunchInfo::SetEnvironmentEntries(const char **envp, bool append) {
- if (append) {
- if (envp)
- m_opaque_sp->GetEnvironmentEntries().AppendArguments(envp);
- } else {
- if (envp)
- m_opaque_sp->GetEnvironmentEntries().SetArguments(envp);
- else
- m_opaque_sp->GetEnvironmentEntries().Clear();
- }
+ Environment env(envp);
+ if (append)
+ m_opaque_sp->GetEnvironment().insert(env.begin(), env.end());
+ else
+ m_opaque_sp->GetEnvironment() = env;
+ m_opaque_sp->RegenerateEnvp();
}
void SBLaunchInfo::Clear() { m_opaque_sp->Clear(); }
@@ -129,8 +148,8 @@ void SBLaunchInfo::SetProcessPluginName(const char *plugin_name) {
}
const char *SBLaunchInfo::GetShell() {
- // Constify this string so that it is saved in the string pool. Otherwise
- // it would be freed when this function goes out of scope.
+ // Constify this string so that it is saved in the string pool. Otherwise it
+ // would be freed when this function goes out of scope.
ConstString shell(m_opaque_sp->GetShell().GetPath().c_str());
return shell.AsCString();
}
diff --git a/source/API/SBModule.cpp b/source/API/SBModule.cpp
index 17f3dcc5656dc..3dd99d5321b45 100644
--- a/source/API/SBModule.cpp
+++ b/source/API/SBModule.cpp
@@ -144,7 +144,7 @@ const uint8_t *SBModule::GetUUIDBytes() const {
const uint8_t *uuid_bytes = NULL;
ModuleSP module_sp(GetSP());
if (module_sp)
- uuid_bytes = (const uint8_t *)module_sp->GetUUID().GetBytes();
+ uuid_bytes = module_sp->GetUUID().GetBytes().data();
if (log) {
if (uuid_bytes) {
@@ -165,11 +165,10 @@ const char *SBModule::GetUUIDString() const {
const char *uuid_cstr = NULL;
ModuleSP module_sp(GetSP());
if (module_sp) {
- // We are going to return a "const char *" value through the public
- // API, so we need to constify it so it gets added permanently the
- // string pool and then we don't need to worry about the lifetime of the
- // string as it will never go away once it has been put into the ConstString
- // string pool
+ // We are going to return a "const char *" value through the public API, so
+ // we need to constify it so it gets added permanently the string pool and
+ // then we don't need to worry about the lifetime of the string as it will
+ // never go away once it has been put into the ConstString string pool
uuid_cstr = ConstString(module_sp->GetUUID().GetAsString()).GetCString();
}
@@ -254,6 +253,17 @@ SBCompileUnit SBModule::GetCompileUnitAtIndex(uint32_t index) {
return sb_cu;
}
+SBSymbolContextList
+SBModule::FindCompileUnits(const SBFileSpec &sb_file_spec) {
+ SBSymbolContextList sb_sc_list;
+ const ModuleSP module_sp(GetSP());
+ if (sb_file_spec.IsValid() && module_sp) {
+ const bool append = true;
+ module_sp->FindCompileUnits(*sb_file_spec, append, *sb_sc_list);
+ }
+ return sb_sc_list;
+}
+
static Symtab *GetUnifiedSymbolTable(const lldb::ModuleSP &module_sp) {
if (module_sp) {
SymbolVendor *symbols = module_sp->GetSymbolVendor();
@@ -368,7 +378,7 @@ SBValueList SBModule::FindGlobalVariables(SBTarget &target, const char *name,
if (name && module_sp) {
VariableList variable_list;
const uint32_t match_count = module_sp->FindGlobalVariables(
- ConstString(name), NULL, false, max_matches, variable_list);
+ ConstString(name), NULL, max_matches, variable_list);
if (match_count > 0) {
for (uint32_t i = 0; i < match_count; ++i) {
@@ -515,9 +525,9 @@ const char *SBModule::GetTriple() {
ModuleSP module_sp(GetSP());
if (module_sp) {
std::string triple(module_sp->GetArchitecture().GetTriple().str());
- // Unique the string so we don't run into ownership issues since
- // the const strings put the string into the string pool once and
- // the strings never comes out
+ // Unique the string so we don't run into ownership issues since the const
+ // strings put the string into the string pool once and the strings never
+ // comes out
ConstString const_triple(triple.c_str());
return const_triple.GetCString();
}
@@ -532,16 +542,29 @@ uint32_t SBModule::GetAddressByteSize() {
}
uint32_t SBModule::GetVersion(uint32_t *versions, uint32_t num_versions) {
- ModuleSP module_sp(GetSP());
- if (module_sp)
- return module_sp->GetVersion(versions, num_versions);
- else {
- if (versions && num_versions) {
- for (uint32_t i = 0; i < num_versions; ++i)
- versions[i] = UINT32_MAX;
- }
- return 0;
- }
+ llvm::VersionTuple version;
+ if (ModuleSP module_sp = GetSP())
+ version = module_sp->GetVersion();
+ uint32_t result = 0;
+ if (!version.empty())
+ ++result;
+ if (version.getMinor())
+ ++result;
+ if(version.getSubminor())
+ ++result;
+
+ if (!versions)
+ return result;
+
+ if (num_versions > 0)
+ versions[0] = version.empty() ? UINT32_MAX : version.getMajor();
+ if (num_versions > 1)
+ versions[1] = version.getMinor().getValueOr(UINT32_MAX);
+ if (num_versions > 2)
+ versions[2] = version.getSubminor().getValueOr(UINT32_MAX);
+ for (uint32_t i = 3; i < num_versions; ++i)
+ versions[i] = UINT32_MAX;
+ return result;
}
lldb::SBFileSpec SBModule::GetSymbolFileSpec() const {
diff --git a/source/API/SBModuleSpec.cpp b/source/API/SBModuleSpec.cpp
index a1c08865c6a4f..afabd9ace2b95 100644
--- a/source/API/SBModuleSpec.cpp
+++ b/source/API/SBModuleSpec.cpp
@@ -70,9 +70,9 @@ void SBModuleSpec::SetObjectName(const char *name) {
const char *SBModuleSpec::GetTriple() {
std::string triple(m_opaque_ap->GetArchitecture().GetTriple().str());
- // Unique the string so we don't run into ownership issues since
- // the const strings put the string into the string pool once and
- // the strings never comes out
+ // Unique the string so we don't run into ownership issues since the const
+ // strings put the string into the string pool once and the strings never
+ // comes out
ConstString const_triple(triple.c_str());
return const_triple.GetCString();
}
@@ -82,15 +82,16 @@ void SBModuleSpec::SetTriple(const char *triple) {
}
const uint8_t *SBModuleSpec::GetUUIDBytes() {
- return (const uint8_t *)m_opaque_ap->GetUUID().GetBytes();
+ return m_opaque_ap->GetUUID().GetBytes().data();
}
size_t SBModuleSpec::GetUUIDLength() {
- return m_opaque_ap->GetUUID().GetByteSize();
+ return m_opaque_ap->GetUUID().GetBytes().size();
}
bool SBModuleSpec::SetUUIDBytes(const uint8_t *uuid, size_t uuid_len) {
- return m_opaque_ap->GetUUID().SetBytes(uuid, uuid_len);
+ m_opaque_ap->GetUUID() = UUID::fromOptionalData(uuid, uuid_len);
+ return m_opaque_ap->GetUUID().IsValid();
}
bool SBModuleSpec::GetDescription(lldb::SBStream &description) {
diff --git a/source/API/SBPlatform.cpp b/source/API/SBPlatform.cpp
index 7ec43f13021f3..5f29f0033988a 100644
--- a/source/API/SBPlatform.cpp
+++ b/source/API/SBPlatform.cpp
@@ -13,10 +13,10 @@
#include "lldb/API/SBLaunchInfo.h"
#include "lldb/API/SBUnixSignals.h"
#include "lldb/Host/File.h"
-#include "lldb/Interpreter/Args.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Target.h"
#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/Args.h"
#include "lldb/Utility/Status.h"
#include "llvm/Support/FileSystem.h"
@@ -53,8 +53,7 @@ struct PlatformConnectOptions {
//----------------------------------------------------------------------
struct PlatformShellCommand {
PlatformShellCommand(const char *shell_command = NULL)
- : m_command(), m_working_dir(), m_status(0), m_signo(0),
- m_timeout_sec(UINT32_MAX) {
+ : m_command(), m_working_dir(), m_status(0), m_signo(0) {
if (shell_command && shell_command[0])
m_command = shell_command;
}
@@ -66,7 +65,7 @@ struct PlatformShellCommand {
std::string m_output;
int m_status;
int m_signo;
- uint32_t m_timeout_sec;
+ Timeout<std::ratio<1>> m_timeout = llvm::None;
};
//----------------------------------------------------------------------
// SBPlatformConnectOptions
@@ -182,11 +181,16 @@ void SBPlatformShellCommand::SetWorkingDirectory(const char *path) {
}
uint32_t SBPlatformShellCommand::GetTimeoutSeconds() {
- return m_opaque_ptr->m_timeout_sec;
+ if (m_opaque_ptr->m_timeout)
+ return m_opaque_ptr->m_timeout->count();
+ return UINT32_MAX;
}
void SBPlatformShellCommand::SetTimeoutSeconds(uint32_t sec) {
- m_opaque_ptr->m_timeout_sec = sec;
+ if (sec == UINT32_MAX)
+ m_opaque_ptr->m_timeout = llvm::None;
+ else
+ m_opaque_ptr->m_timeout = std::chrono::seconds(sec);
}
int SBPlatformShellCommand::GetSignal() { return m_opaque_ptr->m_signo; }
@@ -271,7 +275,7 @@ void SBPlatform::DisconnectRemote() {
bool SBPlatform::IsConnected() {
PlatformSP platform_sp(GetSP());
if (platform_sp)
- platform_sp->IsConnected();
+ return platform_sp->IsConnected();
return false;
}
@@ -326,27 +330,24 @@ const char *SBPlatform::GetHostname() {
}
uint32_t SBPlatform::GetOSMajorVersion() {
- uint32_t major, minor, update;
- PlatformSP platform_sp(GetSP());
- if (platform_sp && platform_sp->GetOSVersion(major, minor, update))
- return major;
- return UINT32_MAX;
+ llvm::VersionTuple version;
+ if (PlatformSP platform_sp = GetSP())
+ version = platform_sp->GetOSVersion();
+ return version.empty() ? UINT32_MAX : version.getMajor();
}
uint32_t SBPlatform::GetOSMinorVersion() {
- uint32_t major, minor, update;
- PlatformSP platform_sp(GetSP());
- if (platform_sp && platform_sp->GetOSVersion(major, minor, update))
- return minor;
- return UINT32_MAX;
+ llvm::VersionTuple version;
+ if (PlatformSP platform_sp = GetSP())
+ version = platform_sp->GetOSVersion();
+ return version.getMinor().getValueOr(UINT32_MAX);
}
uint32_t SBPlatform::GetOSUpdateVersion() {
- uint32_t major, minor, update;
- PlatformSP platform_sp(GetSP());
- if (platform_sp && platform_sp->GetOSVersion(major, minor, update))
- return update;
- return UINT32_MAX;
+ llvm::VersionTuple version;
+ if (PlatformSP platform_sp = GetSP())
+ version = platform_sp->GetOSVersion();
+ return version.getSubminor().getValueOr(UINT32_MAX);
}
SBError SBPlatform::Get(SBFileSpec &src, SBFileSpec &dst) {
@@ -405,18 +406,20 @@ SBError SBPlatform::Run(SBPlatformShellCommand &shell_command) {
if (working_dir)
shell_command.SetWorkingDirectory(working_dir);
}
- return platform_sp->RunShellCommand(
- command, FileSpec{working_dir, false},
- &shell_command.m_opaque_ptr->m_status,
- &shell_command.m_opaque_ptr->m_signo,
- &shell_command.m_opaque_ptr->m_output,
- shell_command.m_opaque_ptr->m_timeout_sec);
+ return platform_sp->RunShellCommand(command, FileSpec{working_dir, false},
+ &shell_command.m_opaque_ptr->m_status,
+ &shell_command.m_opaque_ptr->m_signo,
+ &shell_command.m_opaque_ptr->m_output,
+ shell_command.m_opaque_ptr->m_timeout);
});
}
SBError SBPlatform::Launch(SBLaunchInfo &launch_info) {
return ExecuteConnected([&](const lldb::PlatformSP &platform_sp) {
- return platform_sp->LaunchProcess(launch_info.ref());
+ ProcessLaunchInfo info = launch_info.ref();
+ Status error = platform_sp->LaunchProcess(info);
+ launch_info.set_ref(info);
+ return error;
});
}
diff --git a/source/API/SBProcess.cpp b/source/API/SBProcess.cpp
index e08a7f4b08e0b..4d5ddc86ccf97 100644
--- a/source/API/SBProcess.cpp
+++ b/source/API/SBProcess.cpp
@@ -20,13 +20,13 @@
#include "lldb/Core/PluginManager.h"
#include "lldb/Core/State.h"
#include "lldb/Core/StreamFile.h"
-#include "lldb/Interpreter/Args.h"
#include "lldb/Target/MemoryRegionInfo.h"
#include "lldb/Target/Process.h"
#include "lldb/Target/RegisterContext.h"
#include "lldb/Target/SystemRuntime.h"
#include "lldb/Target/Target.h"
#include "lldb/Target/Thread.h"
+#include "lldb/Utility/Args.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/Stream.h"
@@ -140,7 +140,7 @@ bool SBProcess::RemoteLaunch(char const **argv, char const **envp,
if (argv)
launch_info.GetArguments().AppendArguments(argv);
if (envp)
- launch_info.GetEnvironmentEntries().SetArguments(envp);
+ launch_info.GetEnvironment() = Environment(envp);
error.SetError(process_sp->Launch(launch_info));
} else {
error.SetErrorString("must be in eStateConnected to call RemoteLaunch");
@@ -896,8 +896,7 @@ SBProcess SBProcess::GetProcessFromEvent(const SBEvent &event) {
ProcessSP process_sp =
Process::ProcessEventData::GetProcessFromEvent(event.get());
if (!process_sp) {
- // StructuredData events also know the process they come from.
- // Try that.
+ // StructuredData events also know the process they come from. Try that.
process_sp = EventDataStructuredData::GetProcessFromEvent(event.get());
}
@@ -1188,6 +1187,57 @@ uint32_t SBProcess::LoadImage(const lldb::SBFileSpec &sb_local_image_spec,
return LLDB_INVALID_IMAGE_TOKEN;
}
+uint32_t SBProcess::LoadImageUsingPaths(const lldb::SBFileSpec &image_spec,
+ SBStringList &paths,
+ lldb::SBFileSpec &loaded_path,
+ lldb::SBError &error) {
+ Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
+ ProcessSP process_sp(GetSP());
+ if (process_sp) {
+ Process::StopLocker stop_locker;
+ if (stop_locker.TryLock(&process_sp->GetRunLock())) {
+ if (log)
+ log->Printf("SBProcess(%p)::LoadImageUsingPaths() => "
+ "calling Platform::LoadImageUsingPaths for: %s",
+ static_cast<void *>(process_sp.get()),
+ image_spec.GetFilename());
+
+ std::lock_guard<std::recursive_mutex> guard(
+ process_sp->GetTarget().GetAPIMutex());
+ PlatformSP platform_sp = process_sp->GetTarget().GetPlatform();
+ size_t num_paths = paths.GetSize();
+ std::vector<std::string> paths_vec;
+ paths_vec.reserve(num_paths);
+ for (size_t i = 0; i < num_paths; i++)
+ paths_vec.push_back(paths.GetStringAtIndex(i));
+ FileSpec loaded_spec;
+
+ uint32_t token = platform_sp->LoadImageUsingPaths(process_sp.get(),
+ *image_spec,
+ paths_vec,
+ error.ref(),
+ &loaded_spec);
+ if (token != LLDB_INVALID_IMAGE_TOKEN)
+ loaded_path = loaded_spec;
+ return token;
+ } else {
+ if (log)
+ log->Printf("SBProcess(%p)::LoadImageUsingPaths() => error: "
+ "process is running",
+ static_cast<void *>(process_sp.get()));
+ error.SetErrorString("process is running");
+ }
+ } else {
+ if (log)
+ log->Printf("SBProcess(%p)::LoadImageUsingPaths() => error: "
+ "called with invalid process",
+ static_cast<void *>(process_sp.get()));
+ error.SetErrorString("process is invalid");
+ }
+
+ return LLDB_INVALID_IMAGE_TOKEN;
+}
+
lldb::SBError SBProcess::UnloadImage(uint32_t image_token) {
lldb::SBError sb_error;
ProcessSP process_sp(GetSP());
diff --git a/source/API/SBQueueItem.cpp b/source/API/SBQueueItem.cpp
index 87ba73f9e6d38..aac5844240fba 100644
--- a/source/API/SBQueueItem.cpp
+++ b/source/API/SBQueueItem.cpp
@@ -112,8 +112,7 @@ SBThread SBQueueItem::GetExtendedBacktraceThread(const char *type) {
thread_sp = m_queue_item_sp->GetExtendedBacktraceThread(type_const);
if (thread_sp) {
// Save this in the Process' ExtendedThreadList so a strong pointer
- // retains the
- // object
+ // retains the object
process_sp->GetExtendedThreadList().AddThread(thread_sp);
result.SetThread(thread_sp);
if (log) {
diff --git a/source/API/SBStream.cpp b/source/API/SBStream.cpp
index 159ec07e4e023..d1af77a40fa34 100644
--- a/source/API/SBStream.cpp
+++ b/source/API/SBStream.cpp
@@ -26,8 +26,8 @@ SBStream::~SBStream() {}
bool SBStream::IsValid() const { return (m_opaque_ap.get() != 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.
+// 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)
return NULL;
@@ -35,9 +35,8 @@ const char *SBStream::GetData() {
return static_cast<StreamString *>(m_opaque_ap.get())->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.
+// 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)
return 0;
diff --git a/source/API/SBTarget.cpp b/source/API/SBTarget.cpp
index 2c1c6bcac71b6..550d336906d3f 100644
--- a/source/API/SBTarget.cpp
+++ b/source/API/SBTarget.cpp
@@ -23,6 +23,7 @@
#include "lldb/API/SBSourceManager.h"
#include "lldb/API/SBStream.h"
#include "lldb/API/SBStringList.h"
+#include "lldb/API/SBStructuredData.h"
#include "lldb/API/SBSymbolContextList.h"
#include "lldb/Breakpoint/BreakpointID.h"
#include "lldb/Breakpoint/BreakpointIDList.h"
@@ -38,11 +39,11 @@
#include "lldb/Core/STLUtils.h"
#include "lldb/Core/SearchFilter.h"
#include "lldb/Core/Section.h"
+#include "lldb/Core/StructuredDataImpl.h"
#include "lldb/Core/ValueObjectConstResult.h"
#include "lldb/Core/ValueObjectList.h"
#include "lldb/Core/ValueObjectVariable.h"
#include "lldb/Host/Host.h"
-#include "lldb/Interpreter/Args.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/DeclVendor.h"
#include "lldb/Symbol/ObjectFile.h"
@@ -58,11 +59,12 @@
#include "lldb/Target/Target.h"
#include "lldb/Target/TargetList.h"
#include "lldb/Utility/ArchSpec.h"
+#include "lldb/Utility/Args.h"
#include "lldb/Utility/FileSpec.h"
#include "lldb/Utility/Log.h"
#include "lldb/Utility/RegularExpression.h"
-#include "../source/Commands/CommandObjectBreakpoint.h"
+#include "Commands/CommandObjectBreakpoint.h"
#include "lldb/Interpreter/CommandReturnObject.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Regex.h"
@@ -82,8 +84,8 @@ Status AttachToProcess(ProcessAttachInfo &attach_info, Target &target) {
const auto state = process_sp->GetState();
if (process_sp->IsAlive() && state == eStateConnected) {
// If we are already connected, then we have already specified the
- // listener, so if a valid listener is supplied, we need to error out
- // to let the client know.
+ // listener, so if a valid listener is supplied, we need to error out to
+ // let the client know.
if (attach_info.GetListener())
return Status("process is connected and already has a listener, pass "
"empty listener");
@@ -181,7 +183,31 @@ SBDebugger SBTarget::GetDebugger() const {
return debugger;
}
+SBStructuredData SBTarget::GetStatistics() {
+ SBStructuredData data;
+ TargetSP target_sp(GetSP());
+ if (!target_sp)
+ return data;
+
+ auto stats_up = llvm::make_unique<StructuredData::Dictionary>();
+ int i = 0;
+ for (auto &Entry : target_sp->GetStatistics()) {
+ std::string Desc = lldb_private::GetStatDescription(
+ static_cast<lldb_private::StatisticKind>(i));
+ stats_up->AddIntegerItem(Desc, Entry);
+ i += 1;
+ }
+
+ data.m_impl_up->SetObjectSP(std::move(stats_up));
+ return data;
+}
+
SBProcess SBTarget::LoadCore(const char *core_file) {
+ lldb::SBError error; // Ignored
+ return LoadCore(core_file, error);
+}
+
+SBProcess SBTarget::LoadCore(const char *core_file, lldb::SBError &error) {
SBProcess sb_process;
TargetSP target_sp(GetSP());
if (target_sp) {
@@ -189,9 +215,14 @@ SBProcess SBTarget::LoadCore(const char *core_file) {
ProcessSP process_sp(target_sp->CreateProcess(
target_sp->GetDebugger().GetListener(), "", &filespec));
if (process_sp) {
- process_sp->LoadCore();
- sb_process.SetSP(process_sp);
+ error.SetError(process_sp->LoadCore());
+ if (error.Success())
+ sb_process.SetSP(process_sp);
+ } else {
+ error.SetErrorString("Failed to create the process");
}
+ } else {
+ error.SetErrorString("SBTarget is invalid");
}
return sb_process;
}
@@ -267,8 +298,8 @@ SBProcess SBTarget::Launch(SBListener &listener, char const **argv,
if (state == eStateConnected) {
// If we are already connected, then we have already specified the
- // listener, so if a valid listener is supplied, we need to error out
- // to let the client know.
+ // listener, so if a valid listener is supplied, we need to error out to
+ // let the client know.
if (listener.IsValid()) {
error.SetErrorString("process is connected and already has a listener, "
"pass empty listener");
@@ -290,7 +321,7 @@ SBProcess SBTarget::Launch(SBListener &listener, char const **argv,
if (argv)
launch_info.GetArguments().AppendArguments(argv);
if (envp)
- launch_info.GetEnvironmentEntries().SetArguments(envp);
+ launch_info.GetEnvironment() = Environment(envp);
if (listener.IsValid())
launch_info.SetListener(listener.GetSP());
@@ -340,7 +371,7 @@ SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, SBError &error) {
}
}
- lldb_private::ProcessLaunchInfo &launch_info = sb_launch_info.ref();
+ lldb_private::ProcessLaunchInfo launch_info = sb_launch_info.ref();
if (!launch_info.GetExecutableFile()) {
Module *exe_module = target_sp->GetExecutableModulePointer();
@@ -353,6 +384,7 @@ SBProcess SBTarget::Launch(SBLaunchInfo &sb_launch_info, SBError &error) {
launch_info.GetArchitecture() = arch_spec;
error.SetError(target_sp->Launch(launch_info, NULL));
+ sb_launch_info.set_ref(launch_info);
sb_process.SetSP(target_sp->GetProcessSP());
} else {
error.SetErrorString("SBTarget is invalid");
@@ -469,7 +501,8 @@ lldb::SBProcess SBTarget::AttachToProcessWithName(
if (name && target_sp) {
ProcessAttachInfo attach_info;
- attach_info.GetExecutableFile().SetFile(name, false);
+ attach_info.GetExecutableFile().SetFile(name, false,
+ FileSpec::Style::native);
attach_info.SetWaitForLaunch(wait_for);
if (listener.IsValid())
attach_info.SetListener(listener.GetSP());
@@ -1436,10 +1469,10 @@ lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
if (target_sp) {
ModuleSpec module_spec;
if (path)
- module_spec.GetFileSpec().SetFile(path, false);
+ module_spec.GetFileSpec().SetFile(path, false, FileSpec::Style::native);
if (uuid_cstr)
- module_spec.GetUUID().SetFromCString(uuid_cstr);
+ module_spec.GetUUID().SetFromStringRef(uuid_cstr);
if (triple)
module_spec.GetArchitecture() = Platform::GetAugmentedArchSpec(
@@ -1448,7 +1481,8 @@ lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
module_spec.GetArchitecture() = target_sp->GetArchitecture();
if (symfile)
- module_spec.GetSymbolFileSpec().SetFile(symfile, false);
+ module_spec.GetSymbolFileSpec().SetFile(symfile, false,
+ FileSpec::Style::native);
sb_module.SetSP(target_sp->GetSharedModule(module_spec));
}
@@ -1510,6 +1544,18 @@ SBModule SBTarget::FindModule(const SBFileSpec &sb_file_spec) {
return sb_module;
}
+SBSymbolContextList
+SBTarget::FindCompileUnits(const SBFileSpec &sb_file_spec) {
+ SBSymbolContextList sb_sc_list;
+ const TargetSP target_sp(GetSP());
+ if (target_sp && sb_file_spec.IsValid()) {
+ const bool append = true;
+ target_sp->GetImages().FindCompileUnits(*sb_file_spec,
+ append, *sb_sc_list);
+ }
+ return sb_sc_list;
+}
+
lldb::ByteOrder SBTarget::GetByteOrder() {
TargetSP target_sp(GetSP());
if (target_sp)
@@ -1521,9 +1567,9 @@ const char *SBTarget::GetTriple() {
TargetSP target_sp(GetSP());
if (target_sp) {
std::string triple(target_sp->GetArchitecture().GetTriple().str());
- // Unique the string so we don't run into ownership issues since
- // the const strings put the string into the string pool once and
- // the strings never comes out
+ // Unique the string so we don't run into ownership issues since the const
+ // strings put the string into the string pool once and the strings never
+ // comes out
ConstString const_triple(triple.c_str());
return const_triple.GetCString();
}
@@ -1673,8 +1719,8 @@ lldb::SBType SBTarget::FindFirstType(const char *typename_cstr) {
}
}
- // Didn't find the type in the symbols; try the Objective-C runtime
- // if one is installed
+ // Didn't find the type in the symbols; try the Objective-C runtime if one
+ // is installed
ProcessSP process_sp(target_sp->GetProcessSP());
@@ -1782,9 +1828,8 @@ SBValueList SBTarget::FindGlobalVariables(const char *name,
TargetSP target_sp(GetSP());
if (name && target_sp) {
VariableList variable_list;
- const bool append = true;
const uint32_t match_count = target_sp->GetImages().FindGlobalVariables(
- ConstString(name), append, max_matches, variable_list);
+ ConstString(name), max_matches, variable_list);
if (match_count > 0) {
ExecutionContextScope *exe_scope = target_sp->GetProcessSP().get();
@@ -1811,23 +1856,22 @@ SBValueList SBTarget::FindGlobalVariables(const char *name,
if (name && target_sp) {
llvm::StringRef name_ref(name);
VariableList variable_list;
- const bool append = true;
std::string regexstr;
uint32_t match_count;
switch (matchtype) {
case eMatchTypeNormal:
match_count = target_sp->GetImages().FindGlobalVariables(
- ConstString(name), append, max_matches, variable_list);
+ ConstString(name), max_matches, variable_list);
break;
case eMatchTypeRegex:
match_count = target_sp->GetImages().FindGlobalVariables(
- RegularExpression(name_ref), append, max_matches, variable_list);
+ RegularExpression(name_ref), max_matches, variable_list);
break;
case eMatchTypeStartsWith:
regexstr = llvm::Regex::escape(name) + ".*";
match_count = target_sp->GetImages().FindGlobalVariables(
- RegularExpression(regexstr), append, max_matches, variable_list);
+ RegularExpression(regexstr), max_matches, variable_list);
break;
}
@@ -2195,7 +2239,7 @@ lldb::SBLaunchInfo SBTarget::GetLaunchInfo() const {
lldb::SBLaunchInfo launch_info(NULL);
TargetSP target_sp(GetSP());
if (target_sp)
- launch_info.ref() = m_opaque_sp->GetProcessLaunchInfo();
+ launch_info.set_ref(m_opaque_sp->GetProcessLaunchInfo());
return launch_info;
}
diff --git a/source/API/SBThread.cpp b/source/API/SBThread.cpp
index b34489603c8ac..0d25b85f57d23 100644
--- a/source/API/SBThread.cpp
+++ b/source/API/SBThread.cpp
@@ -615,8 +615,7 @@ SBError SBThread::ResumeNewPlan(ExecutionContext &exe_ctx,
}
// User level plans should be Master Plans so they can be interrupted, other
- // plans executed, and
- // then a "continue" will resume the plan.
+ // plans executed, and then a "continue" will resume the plan.
if (new_plan != NULL) {
new_plan->SetIsMasterPlan(true);
new_plan->SetOkayToDiscard(false);
@@ -634,6 +633,11 @@ SBError SBThread::ResumeNewPlan(ExecutionContext &exe_ctx,
}
void SBThread::StepOver(lldb::RunMode stop_other_threads) {
+ SBError error; // Ignored
+ StepOver(stop_other_threads, error);
+}
+
+void SBThread::StepOver(lldb::RunMode stop_other_threads, SBError &error) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
std::unique_lock<std::recursive_mutex> lock;
@@ -644,28 +648,29 @@ void SBThread::StepOver(lldb::RunMode stop_other_threads) {
static_cast<void *>(exe_ctx.GetThreadPtr()),
Thread::RunModeAsCString(stop_other_threads));
- if (exe_ctx.HasThreadScope()) {
- Thread *thread = exe_ctx.GetThreadPtr();
- bool abort_other_plans = false;
- StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
-
- ThreadPlanSP new_plan_sp;
- if (frame_sp) {
- if (frame_sp->HasDebugInformation()) {
- const LazyBool avoid_no_debug = eLazyBoolCalculate;
- SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
- new_plan_sp = thread->QueueThreadPlanForStepOverRange(
- abort_other_plans, sc.line_entry, sc, stop_other_threads,
- avoid_no_debug);
- } else {
- new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
- true, abort_other_plans, stop_other_threads);
- }
- }
+ if (!exe_ctx.HasThreadScope()) {
+ error.SetErrorString("this SBThread object is invalid");
+ return;
+ }
+
+ Thread *thread = exe_ctx.GetThreadPtr();
+ bool abort_other_plans = false;
+ StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
- // This returns an error, we should use it!
- ResumeNewPlan(exe_ctx, new_plan_sp.get());
+ ThreadPlanSP new_plan_sp;
+ if (frame_sp) {
+ if (frame_sp->HasDebugInformation()) {
+ const LazyBool avoid_no_debug = eLazyBoolCalculate;
+ SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
+ new_plan_sp = thread->QueueThreadPlanForStepOverRange(
+ abort_other_plans, sc.line_entry, sc, stop_other_threads,
+ avoid_no_debug);
+ } else {
+ new_plan_sp = thread->QueueThreadPlanForStepSingleInstruction(
+ true, abort_other_plans, stop_other_threads);
+ }
}
+ error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
}
void SBThread::StepInto(lldb::RunMode stop_other_threads) {
@@ -674,7 +679,7 @@ void SBThread::StepInto(lldb::RunMode stop_other_threads) {
void SBThread::StepInto(const char *target_name,
lldb::RunMode stop_other_threads) {
- SBError error;
+ SBError error; // Ignored
StepInto(target_name, LLDB_INVALID_LINE_NUMBER, error, stop_other_threads);
}
@@ -692,41 +697,48 @@ void SBThread::StepInto(const char *target_name, uint32_t end_line,
target_name ? target_name : "<NULL>",
Thread::RunModeAsCString(stop_other_threads));
- if (exe_ctx.HasThreadScope()) {
- bool abort_other_plans = false;
+ if (!exe_ctx.HasThreadScope()) {
+ error.SetErrorString("this SBThread object is invalid");
+ return;
+ }
- Thread *thread = exe_ctx.GetThreadPtr();
- StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
- ThreadPlanSP new_plan_sp;
+ bool abort_other_plans = false;
- if (frame_sp && frame_sp->HasDebugInformation()) {
- SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
- AddressRange range;
- if (end_line == LLDB_INVALID_LINE_NUMBER)
- range = sc.line_entry.range;
- else {
- if (!sc.GetAddressRangeFromHereToEndLine(end_line, range, error.ref()))
- return;
- }
-
- const LazyBool step_out_avoids_code_without_debug_info =
- eLazyBoolCalculate;
- const LazyBool step_in_avoids_code_without_debug_info =
- eLazyBoolCalculate;
- new_plan_sp = thread->QueueThreadPlanForStepInRange(
- abort_other_plans, range, sc, target_name, stop_other_threads,
- 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);
+ Thread *thread = exe_ctx.GetThreadPtr();
+ StackFrameSP frame_sp(thread->GetStackFrameAtIndex(0));
+ ThreadPlanSP new_plan_sp;
+
+ if (frame_sp && frame_sp->HasDebugInformation()) {
+ SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything));
+ AddressRange range;
+ if (end_line == LLDB_INVALID_LINE_NUMBER)
+ range = sc.line_entry.range;
+ else {
+ if (!sc.GetAddressRangeFromHereToEndLine(end_line, range, error.ref()))
+ return;
}
- error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
+ const LazyBool step_out_avoids_code_without_debug_info =
+ eLazyBoolCalculate;
+ const LazyBool step_in_avoids_code_without_debug_info =
+ eLazyBoolCalculate;
+ new_plan_sp = thread->QueueThreadPlanForStepInRange(
+ abort_other_plans, range, sc, target_name, stop_other_threads,
+ 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);
}
+ error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
}
void SBThread::StepOut() {
+ SBError error; // Ignored
+ StepOut(error);
+}
+
+void SBThread::StepOut(SBError &error) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
std::unique_lock<std::recursive_mutex> lock;
@@ -736,23 +748,30 @@ void SBThread::StepOut() {
log->Printf("SBThread(%p)::StepOut ()",
static_cast<void *>(exe_ctx.GetThreadPtr()));
- if (exe_ctx.HasThreadScope()) {
- bool abort_other_plans = false;
- bool stop_other_threads = false;
+ if (!exe_ctx.HasThreadScope()) {
+ error.SetErrorString("this SBThread object is invalid");
+ return;
+ }
- Thread *thread = exe_ctx.GetThreadPtr();
+ bool abort_other_plans = false;
+ bool stop_other_threads = false;
+
+ Thread *thread = exe_ctx.GetThreadPtr();
- const LazyBool avoid_no_debug = eLazyBoolCalculate;
- ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
- abort_other_plans, NULL, false, stop_other_threads, eVoteYes,
- eVoteNoOpinion, 0, avoid_no_debug));
+ const LazyBool avoid_no_debug = eLazyBoolCalculate;
+ ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
+ abort_other_plans, NULL, false, stop_other_threads, eVoteYes,
+ eVoteNoOpinion, 0, avoid_no_debug));
- // This returns an error, we should use it!
- ResumeNewPlan(exe_ctx, new_plan_sp.get());
- }
+ error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
}
-void SBThread::StepOutOfFrame(lldb::SBFrame &sb_frame) {
+void SBThread::StepOutOfFrame(SBFrame &sb_frame) {
+ SBError error; // Ignored
+ StepOutOfFrame(sb_frame, error);
+}
+
+void SBThread::StepOutOfFrame(SBFrame &sb_frame, SBError &error) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
std::unique_lock<std::recursive_mutex> lock;
@@ -763,6 +782,7 @@ void SBThread::StepOutOfFrame(lldb::SBFrame &sb_frame) {
log->Printf(
"SBThread(%p)::StepOutOfFrame passed an invalid frame, returning.",
static_cast<void *>(exe_ctx.GetThreadPtr()));
+ error.SetErrorString("passed invalid SBFrame object");
return;
}
@@ -775,27 +795,36 @@ void SBThread::StepOutOfFrame(lldb::SBFrame &sb_frame) {
static_cast<void *>(frame_sp.get()), frame_desc_strm.GetData());
}
- if (exe_ctx.HasThreadScope()) {
- bool abort_other_plans = false;
- bool stop_other_threads = false;
- Thread *thread = exe_ctx.GetThreadPtr();
- if (sb_frame.GetThread().GetThreadID() != thread->GetID()) {
- log->Printf("SBThread(%p)::StepOutOfFrame passed a frame from another "
- "thread (0x%" PRIx64 " vrs. 0x%" PRIx64 ", returning.",
- static_cast<void *>(exe_ctx.GetThreadPtr()),
- sb_frame.GetThread().GetThreadID(), thread->GetID());
- }
-
- ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
- abort_other_plans, NULL, false, stop_other_threads, eVoteYes,
- eVoteNoOpinion, frame_sp->GetFrameIndex()));
+ if (!exe_ctx.HasThreadScope()) {
+ error.SetErrorString("this SBThread object is invalid");
+ return;
+ }
- // This returns an error, we should use it!
- ResumeNewPlan(exe_ctx, new_plan_sp.get());
+ bool abort_other_plans = false;
+ bool stop_other_threads = false;
+ Thread *thread = exe_ctx.GetThreadPtr();
+ if (sb_frame.GetThread().GetThreadID() != thread->GetID()) {
+ log->Printf("SBThread(%p)::StepOutOfFrame passed a frame from another "
+ "thread (0x%" PRIx64 " vrs. 0x%" PRIx64 ", returning.",
+ static_cast<void *>(exe_ctx.GetThreadPtr()),
+ sb_frame.GetThread().GetThreadID(), thread->GetID());
+ error.SetErrorString("passed a frame from another thread");
+ return;
}
+
+ ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut(
+ abort_other_plans, NULL, false, stop_other_threads, eVoteYes,
+ eVoteNoOpinion, frame_sp->GetFrameIndex()));
+
+ error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
}
void SBThread::StepInstruction(bool step_over) {
+ SBError error; // Ignored
+ StepInstruction(step_over, error);
+}
+
+void SBThread::StepInstruction(bool step_over, SBError &error) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
std::unique_lock<std::recursive_mutex> lock;
@@ -805,17 +834,24 @@ void SBThread::StepInstruction(bool step_over) {
log->Printf("SBThread(%p)::StepInstruction (step_over=%i)",
static_cast<void *>(exe_ctx.GetThreadPtr()), step_over);
- if (exe_ctx.HasThreadScope()) {
- Thread *thread = exe_ctx.GetThreadPtr();
- ThreadPlanSP new_plan_sp(
- thread->QueueThreadPlanForStepSingleInstruction(step_over, true, true));
-
- // This returns an error, we should use it!
- ResumeNewPlan(exe_ctx, new_plan_sp.get());
+ if (!exe_ctx.HasThreadScope()) {
+ error.SetErrorString("this SBThread object is invalid");
+ return;
}
+
+ Thread *thread = exe_ctx.GetThreadPtr();
+ ThreadPlanSP new_plan_sp(
+ thread->QueueThreadPlanForStepSingleInstruction(step_over, true, true));
+
+ error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
}
void SBThread::RunToAddress(lldb::addr_t addr) {
+ SBError error; // Ignored
+ RunToAddress(addr, error);
+}
+
+void SBThread::RunToAddress(lldb::addr_t addr, SBError &error) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
std::unique_lock<std::recursive_mutex> lock;
@@ -825,20 +861,22 @@ void SBThread::RunToAddress(lldb::addr_t addr) {
log->Printf("SBThread(%p)::RunToAddress (addr=0x%" PRIx64 ")",
static_cast<void *>(exe_ctx.GetThreadPtr()), addr);
- if (exe_ctx.HasThreadScope()) {
- bool abort_other_plans = false;
- bool stop_other_threads = true;
+ if (!exe_ctx.HasThreadScope()) {
+ error.SetErrorString("this SBThread object is invalid");
+ return;
+ }
- Address target_addr(addr);
+ bool abort_other_plans = false;
+ bool stop_other_threads = true;
- Thread *thread = exe_ctx.GetThreadPtr();
+ Address target_addr(addr);
+
+ Thread *thread = exe_ctx.GetThreadPtr();
- ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForRunToAddress(
- abort_other_plans, target_addr, stop_other_threads));
+ ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForRunToAddress(
+ abort_other_plans, target_addr, stop_other_threads));
- // This returns an error, we should use it!
- ResumeNewPlan(exe_ctx, new_plan_sp.get());
- }
+ error = ResumeNewPlan(exe_ctx, new_plan_sp.get());
}
SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame,
@@ -911,8 +949,7 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame,
// Grab the current function, then we will make sure the "until" address is
// within the function. We discard addresses that are out of the current
// function, and then if there are no addresses remaining, give an
- // appropriate
- // error message.
+ // appropriate error message.
bool all_in_function = true;
AddressRange fun_range = frame_sc.function->GetAddressRange();
@@ -1084,6 +1121,11 @@ SBError SBThread::UnwindInnermostExpression() {
}
bool SBThread::Suspend() {
+ SBError error; // Ignored
+ return Suspend(error);
+}
+
+bool SBThread::Suspend(SBError &error) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -1095,11 +1137,13 @@ bool SBThread::Suspend() {
exe_ctx.GetThreadPtr()->SetResumeState(eStateSuspended);
result = true;
} else {
+ error.SetErrorString("process is running");
if (log)
log->Printf("SBThread(%p)::Suspend() => error: process is running",
static_cast<void *>(exe_ctx.GetThreadPtr()));
}
- }
+ } else
+ error.SetErrorString("this SBThread object is invalid");
if (log)
log->Printf("SBThread(%p)::Suspend() => %i",
static_cast<void *>(exe_ctx.GetThreadPtr()), result);
@@ -1107,6 +1151,11 @@ bool SBThread::Suspend() {
}
bool SBThread::Resume() {
+ SBError error; // Ignored
+ return Resume(error);
+}
+
+bool SBThread::Resume(SBError &error) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_API));
std::unique_lock<std::recursive_mutex> lock;
ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
@@ -1119,11 +1168,13 @@ bool SBThread::Resume() {
exe_ctx.GetThreadPtr()->SetResumeState(eStateRunning, override_suspend);
result = true;
} else {
+ error.SetErrorString("process is running");
if (log)
log->Printf("SBThread(%p)::Resume() => error: process is running",
static_cast<void *>(exe_ctx.GetThreadPtr()));
}
- }
+ } else
+ error.SetErrorString("this SBThread object is invalid");
if (log)
log->Printf("SBThread(%p)::Resume() => %i",
static_cast<void *>(exe_ctx.GetThreadPtr()), result);
@@ -1374,8 +1425,7 @@ SBThread SBThread::GetExtendedBacktraceThread(const char *type) {
runtime->GetExtendedBacktraceThread(real_thread, type_const));
if (new_thread_sp) {
// Save this in the Process' ExtendedThreadList so a strong
- // pointer retains the
- // object.
+ // pointer retains the object.
process->GetExtendedThreadList().AddThread(new_thread_sp);
sb_origin_thread.SetThread(new_thread_sp);
if (log) {
diff --git a/source/API/SBThreadPlan.cpp b/source/API/SBThreadPlan.cpp
index a19023f66de23..131f84195908e 100644
--- a/source/API/SBThreadPlan.cpp
+++ b/source/API/SBThreadPlan.cpp
@@ -138,8 +138,7 @@ bool SBThreadPlan::IsValid() {
// plans...
//
// FIXME, you should only be able to queue thread plans from inside the methods
-// of a
-// Scripted Thread Plan. Need a way to enforce that.
+// of a Scripted Thread Plan. Need a way to enforce that.
SBThreadPlan
SBThreadPlan::QueueThreadPlanForStepOverRange(SBAddress &sb_start_address,
diff --git a/source/API/SBType.cpp b/source/API/SBType.cpp
index 80d48754c89b2..e199b7a33e48c 100644
--- a/source/API/SBType.cpp
+++ b/source/API/SBType.cpp
@@ -88,9 +88,9 @@ TypeImpl &SBType::ref() {
}
const TypeImpl &SBType::ref() const {
- // "const SBAddress &addr" should already have checked "addr.IsValid()"
- // prior to calling this function. In case you didn't we will assert
- // and die to let you know.
+ // "const SBAddress &addr" should already have checked "addr.IsValid()" prior
+ // to calling this function. In case you didn't we will assert and die to let
+ // you know.
assert(m_opaque_sp.get());
return *m_opaque_sp;
}
diff --git a/source/API/SBTypeCategory.cpp b/source/API/SBTypeCategory.cpp
index 38e7cca35dfda..30414bd728cba 100644
--- a/source/API/SBTypeCategory.cpp
+++ b/source/API/SBTypeCategory.cpp
@@ -341,9 +341,9 @@ bool SBTypeCategory::AddTypeSummary(SBTypeNameSpecifier type_name,
// FIXME: we need to iterate over all the Debugger objects and have each of
// them contain a copy of the function
// since we currently have formatters live in a global space, while Python
- // code lives in a specific Debugger-related environment
- // this should eventually be fixed by deciding a final location in the LLDB
- // object space for formatters
+ // code lives in a specific Debugger-related environment this should
+ // eventually be fixed by deciding a final location in the LLDB object space
+ // for formatters
if (summary.IsFunctionCode()) {
const void *name_token =
(const void *)ConstString(type_name.GetName()).GetCString();
@@ -453,9 +453,9 @@ bool SBTypeCategory::AddTypeSynthetic(SBTypeNameSpecifier type_name,
// FIXME: we need to iterate over all the Debugger objects and have each of
// them contain a copy of the function
// since we currently have formatters live in a global space, while Python
- // code lives in a specific Debugger-related environment
- // this should eventually be fixed by deciding a final location in the LLDB
- // object space for formatters
+ // code lives in a specific Debugger-related environment this should
+ // eventually be fixed by deciding a final location in the LLDB object space
+ // for formatters
if (synth.IsClassCode()) {
const void *name_token =
(const void *)ConstString(type_name.GetName()).GetCString();
diff --git a/source/API/SBValue.cpp b/source/API/SBValue.cpp
index b6f044c61a789..a270c0471e9f5 100644
--- a/source/API/SBValue.cpp
+++ b/source/API/SBValue.cpp
@@ -89,16 +89,13 @@ public:
// FIXME: This check is necessary but not sufficient. We for sure don't
// want to touch SBValues whose owning
// targets have gone away. This check is a little weak in that it
- // enforces that restriction when you call
- // IsValid, but since IsValid doesn't lock the target, you have no
- // guarantee that the SBValue won't go
- // invalid after you call this...
- // Also, an SBValue could depend on data from one of the modules in the
- // target, and those could go away
- // independently of the target, for instance if a module is unloaded. But
- // right now, neither SBValues
- // nor ValueObjects know which modules they depend on. So I have no good
- // way to make that check without
+ // enforces that restriction when you call IsValid, but since IsValid
+ // doesn't lock the target, you have no guarantee that the SBValue won't
+ // go invalid after you call this... Also, an SBValue could depend on
+ // data from one of the modules in the target, and those could go away
+ // independently of the target, for instance if a module is unloaded.
+ // But right now, neither SBValues nor ValueObjects know which modules
+ // 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())
@@ -129,9 +126,9 @@ public:
ProcessSP process_sp(value_sp->GetProcessSP());
if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock())) {
- // We don't allow people to play around with ValueObject if the process is
- // running.
- // If you want to look at values, pause the process, then look.
+ // We don't allow people to play around with ValueObject if the process
+ // is running. If you want to look at values, pause the process, then
+ // look.
if (log)
log->Printf("SBValue(%p)::GetSP() => error: process is running",
static_cast<void *>(value_sp.get()));
@@ -171,10 +168,8 @@ public:
// All the derived values that we would make from the m_valobj_sp will share
// the ExecutionContext with m_valobj_sp, so we don't need to do the
- // calculations
- // in GetSP to return the Target, Process, Thread or Frame. It is convenient
- // to
- // provide simple accessors for these, which I do here.
+ // calculations in GetSP to return the Target, Process, Thread or Frame. It
+ // is convenient to provide simple accessors for these, which I do here.
TargetSP GetTargetSP() {
if (m_valobj_sp)
return m_valobj_sp->GetTargetSP();
@@ -242,9 +237,9 @@ SBValue &SBValue::operator=(const SBValue &rhs) {
SBValue::~SBValue() {}
bool SBValue::IsValid() {
- // If this function ever changes to anything that does more than just
- // check if the opaque shared pointer is non NULL, then we need to update
- // all "if (m_opaque_sp)" code in this file.
+ // If this function ever changes to anything that does more than just check
+ // if the opaque shared pointer is non NULL, then we need to update all "if
+ // (m_opaque_sp)" code in this file.
return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid() &&
m_opaque_sp->GetRootSP().get() != NULL;
}
@@ -1397,11 +1392,9 @@ lldb::SBAddress SBValue::GetAddress() {
if (module_sp)
module_sp->ResolveFileAddress(value, addr);
} else if (addr_type == eAddressTypeLoad) {
- // no need to check the return value on this.. if it can actually do the
- // resolve
- // addr will be in the form (section,offset), otherwise it will simply
- // be returned
- // as (NULL, value)
+ // no need to check the return value on this.. if it can actually do
+ // the resolve addr will be in the form (section,offset), otherwise it
+ // will simply be returned as (NULL, value)
addr.SetLoadAddress(value, target_sp.get());
}
}
diff --git a/source/API/SystemInitializerFull.cpp b/source/API/SystemInitializerFull.cpp
index 977ebe62353ec..18de376183c7d 100644
--- a/source/API/SystemInitializerFull.cpp
+++ b/source/API/SystemInitializerFull.cpp
@@ -11,7 +11,7 @@
#include "Plugins/ScriptInterpreter/Python/lldb-python.h"
#endif
-#include "lldb/API/SystemInitializerFull.h"
+#include "SystemInitializerFull.h"
#include "lldb/API/SBCommandInterpreter.h"
@@ -43,6 +43,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/PPC64/ArchitecturePPC64.h"
#include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h"
#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h"
#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
@@ -50,6 +51,7 @@
#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h"
#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h"
#include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h"
+#include "Plugins/Instruction/PPC64/EmulateInstructionPPC64.h"
#include "Plugins/InstrumentationRuntime/ASan/ASanRuntime.h"
#include "Plugins/InstrumentationRuntime/MainThreadChecker/MainThreadCheckerRuntime.h"
#include "Plugins/InstrumentationRuntime/TSan/TSanRuntime.h"
@@ -68,6 +70,9 @@
#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h"
#include "Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h"
#include "Plugins/MemoryHistory/asan/MemoryHistoryASan.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"
@@ -82,6 +87,7 @@
#include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h"
#include "Plugins/Process/elf-core/ProcessElfCore.h"
#include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
+#include "Plugins/Process/mach-core/ProcessMachCore.h"
#include "Plugins/Process/minidump/ProcessMinidump.h"
#include "Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h"
#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h"
@@ -102,7 +108,6 @@
#include "Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h"
#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h"
#include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h"
-#include "Plugins/Process/mach-core/ProcessMachCore.h"
#include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h"
#endif
#include "Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h"
@@ -136,11 +141,10 @@ extern "C" void init_lldb(void);
#define LLDBSwigPyInit init_lldb
#endif
-// these are the Pythonic implementations of the required callbacks
-// these are scripting-language specific, which is why they belong here
-// we still need to use function pointers to them instead of relying
-// on linkage-time resolution because the SWIG stuff and this file
-// get built at different times
+// these are the Pythonic implementations of the required callbacks these are
+// scripting-language specific, which is why they belong here we still need to
+// use function pointers to them instead of relying on linkage-time resolution
+// because the SWIG stuff and this file get built at different times
extern "C" bool LLDBSwigPythonBreakpointCallbackFunction(
const char *python_function_name, const char *session_dictionary_name,
const lldb::StackFrameSP &sb_frame,
@@ -250,6 +254,11 @@ SystemInitializerFull::~SystemInitializerFull() {}
void SystemInitializerFull::Initialize() {
SystemInitializerCommon::Initialize();
+
+ ObjectFileELF::Initialize();
+ ObjectFileMachO::Initialize();
+ ObjectFilePECOFF::Initialize();
+
ScriptInterpreterNone::Initialize();
#ifndef LLDB_DISABLE_PYTHON
@@ -260,10 +269,9 @@ void SystemInitializerFull::Initialize() {
#if !defined(LLDB_DISABLE_PYTHON)
InitializeSWIG();
- // ScriptInterpreterPython::Initialize() depends on things like HostInfo being
- // initialized
- // so it can compute the python directory etc, so we need to do this after
- // SystemInitializerCommon::Initialize().
+ // ScriptInterpreterPython::Initialize() depends on things like HostInfo
+ // being initialized so it can compute the python directory etc, so we need
+ // to do this after SystemInitializerCommon::Initialize().
ScriptInterpreterPython::Initialize();
#endif
@@ -307,11 +315,13 @@ void SystemInitializerFull::Initialize() {
ABISysV_s390x::Initialize();
ArchitectureArm::Initialize();
+ ArchitecturePPC64::Initialize();
DisassemblerLLVMC::Initialize();
JITLoaderGDB::Initialize();
ProcessElfCore::Initialize();
+ ProcessMachCore::Initialize();
minidump::ProcessMinidump::Initialize();
MemoryHistoryASan::Initialize();
AddressSanitizerRuntime::Initialize();
@@ -326,6 +336,7 @@ void SystemInitializerFull::Initialize() {
UnwindAssemblyInstEmulation::Initialize();
UnwindAssembly_x86::Initialize();
EmulateInstructionARM64::Initialize();
+ EmulateInstructionPPC64::Initialize();
SymbolFileDWARFDebugMap::Initialize();
ItaniumABILanguageRuntime::Initialize();
AppleObjCRuntimeV2::Initialize();
@@ -351,7 +362,6 @@ void SystemInitializerFull::Initialize() {
#if defined(__APPLE__)
SymbolVendorMacOSX::Initialize();
ProcessKDP::Initialize();
- ProcessMachCore::Initialize();
PlatformAppleTVSimulator::Initialize();
PlatformAppleWatchSimulator::Initialize();
PlatformRemoteAppleTV::Initialize();
@@ -359,8 +369,8 @@ void SystemInitializerFull::Initialize() {
DynamicLoaderDarwinKernel::Initialize();
#endif
- // This plugin is valid on any host that talks to a Darwin remote.
- // It shouldn't be limited to __APPLE__.
+ // This plugin is valid on any host that talks to a Darwin remote. It
+ // shouldn't be limited to __APPLE__.
StructuredDataDarwinLog::Initialize();
//----------------------------------------------------------------------
@@ -378,8 +388,8 @@ void SystemInitializerFull::Initialize() {
// Scan for any system or user LLDB plug-ins
PluginManager::Initialize();
- // The process settings need to know about installed plug-ins, so the Settings
- // must be initialized
+ // The process settings need to know about installed plug-ins, so the
+ // Settings must be initialized
// AFTER PluginManager::Initialize is called.
Debugger::SettingsInitialize();
@@ -438,6 +448,7 @@ void SystemInitializerFull::Terminate() {
JITLoaderGDB::Terminate();
ProcessElfCore::Terminate();
+ ProcessMachCore::Terminate();
minidump::ProcessMinidump::Terminate();
MemoryHistoryASan::Terminate();
AddressSanitizerRuntime::Terminate();
@@ -451,6 +462,7 @@ void SystemInitializerFull::Terminate() {
UnwindAssembly_x86::Terminate();
UnwindAssemblyInstEmulation::Terminate();
EmulateInstructionARM64::Terminate();
+ EmulateInstructionPPC64::Terminate();
SymbolFileDWARFDebugMap::Terminate();
ItaniumABILanguageRuntime::Terminate();
AppleObjCRuntimeV2::Terminate();
@@ -468,7 +480,6 @@ void SystemInitializerFull::Terminate() {
#if defined(__APPLE__)
DynamicLoaderDarwinKernel::Terminate();
- ProcessMachCore::Terminate();
ProcessKDP::Terminate();
SymbolVendorMacOSX::Terminate();
PlatformAppleTVSimulator::Terminate();
@@ -511,6 +522,10 @@ void SystemInitializerFull::Terminate() {
PlatformDarwinKernel::Terminate();
#endif
+ ObjectFileELF::Terminate();
+ ObjectFileMachO::Terminate();
+ ObjectFilePECOFF::Terminate();
+
// Now shutdown the common parts, in reverse order.
SystemInitializerCommon::Terminate();
}
diff --git a/source/API/SystemInitializerFull.h b/source/API/SystemInitializerFull.h
new file mode 100644
index 0000000000000..9cfc6896da61e
--- /dev/null
+++ b/source/API/SystemInitializerFull.h
@@ -0,0 +1,38 @@
+//===-- SystemInitializerFull.h ---------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLDB_API_SYSTEM_INITIALIZER_FULL_H
+#define LLDB_API_SYSTEM_INITIALIZER_FULL_H
+
+#include "lldb/Initialization/SystemInitializerCommon.h"
+
+namespace lldb_private {
+//------------------------------------------------------------------
+/// Initializes lldb.
+///
+/// This class is responsible for initializing all of lldb system
+/// services needed to use the full LLDB application. This class is
+/// not intended to be used externally, but is instead used
+/// internally by SBDebugger to initialize the system.
+//------------------------------------------------------------------
+class SystemInitializerFull : public SystemInitializerCommon {
+public:
+ SystemInitializerFull();
+ ~SystemInitializerFull() override;
+
+ void Initialize() override;
+ void Terminate() override;
+
+private:
+ void InitializeSWIG();
+};
+
+} // namespace lldb_private
+
+#endif // LLDB_API_SYSTEM_INITIALIZER_FULL_H