diff options
Diffstat (limited to 'lldb/source/API')
38 files changed, 483 insertions, 425 deletions
diff --git a/lldb/source/API/SBBlock.cpp b/lldb/source/API/SBBlock.cpp index a5fee445d5c6..5c49053dd972 100644 --- a/lldb/source/API/SBBlock.cpp +++ b/lldb/source/API/SBBlock.cpp @@ -25,9 +25,7 @@ using namespace lldb; using namespace lldb_private; -SBBlock::SBBlock() : m_opaque_ptr(nullptr) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBlock); -} +SBBlock::SBBlock() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBlock); } SBBlock::SBBlock(lldb_private::Block *lldb_object_ptr) : m_opaque_ptr(lldb_object_ptr) {} diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp index 96ae305ffce5..0f0a93519993 100644 --- a/lldb/source/API/SBBreakpoint.cpp +++ b/lldb/source/API/SBBreakpoint.cpp @@ -384,7 +384,7 @@ void SBBreakpoint::SetThreadIndex(uint32_t index) { if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( bkpt_sp->GetTarget().GetAPIMutex()); - bkpt_sp->GetOptions()->GetThreadSpec()->SetIndex(index); + bkpt_sp->GetOptions().GetThreadSpec()->SetIndex(index); } } @@ -397,7 +397,7 @@ uint32_t SBBreakpoint::GetThreadIndex() const { std::lock_guard<std::recursive_mutex> guard( bkpt_sp->GetTarget().GetAPIMutex()); const ThreadSpec *thread_spec = - bkpt_sp->GetOptions()->GetThreadSpecNoCreate(); + bkpt_sp->GetOptions().GetThreadSpecNoCreate(); if (thread_spec != nullptr) thread_idx = thread_spec->GetIndex(); } @@ -414,7 +414,7 @@ void SBBreakpoint::SetThreadName(const char *thread_name) { if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( bkpt_sp->GetTarget().GetAPIMutex()); - bkpt_sp->GetOptions()->GetThreadSpec()->SetName(thread_name); + bkpt_sp->GetOptions().GetThreadSpec()->SetName(thread_name); } } @@ -427,7 +427,7 @@ const char *SBBreakpoint::GetThreadName() const { std::lock_guard<std::recursive_mutex> guard( bkpt_sp->GetTarget().GetAPIMutex()); const ThreadSpec *thread_spec = - bkpt_sp->GetOptions()->GetThreadSpecNoCreate(); + bkpt_sp->GetOptions().GetThreadSpecNoCreate(); if (thread_spec != nullptr) name = thread_spec->GetName(); } @@ -443,7 +443,7 @@ void SBBreakpoint::SetQueueName(const char *queue_name) { if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( bkpt_sp->GetTarget().GetAPIMutex()); - bkpt_sp->GetOptions()->GetThreadSpec()->SetQueueName(queue_name); + bkpt_sp->GetOptions().GetThreadSpec()->SetQueueName(queue_name); } } @@ -456,7 +456,7 @@ const char *SBBreakpoint::GetQueueName() const { std::lock_guard<std::recursive_mutex> guard( bkpt_sp->GetTarget().GetAPIMutex()); const ThreadSpec *thread_spec = - bkpt_sp->GetOptions()->GetThreadSpecNoCreate(); + bkpt_sp->GetOptions().GetThreadSpecNoCreate(); if (thread_spec) name = thread_spec->GetQueueName(); } @@ -506,7 +506,7 @@ void SBBreakpoint::SetCommandLineCommands(SBStringList &commands) { std::unique_ptr<BreakpointOptions::CommandData> cmd_data_up( new BreakpointOptions::CommandData(*commands, eScriptLanguageNone)); - bkpt_sp->GetOptions()->SetCommandDataCallback(cmd_data_up); + bkpt_sp->GetOptions().SetCommandDataCallback(cmd_data_up); } bool SBBreakpoint::GetCommandLineCommands(SBStringList &commands) { @@ -518,7 +518,7 @@ bool SBBreakpoint::GetCommandLineCommands(SBStringList &commands) { return false; StringList command_list; bool has_commands = - bkpt_sp->GetOptions()->GetCommandLineCallbacks(command_list); + bkpt_sp->GetOptions().GetCommandLineCallbacks(command_list); if (has_commands) commands.AppendList(command_list); return has_commands; @@ -636,7 +636,7 @@ SBError SBBreakpoint::SetScriptCallbackFunction( Status error; std::lock_guard<std::recursive_mutex> guard( bkpt_sp->GetTarget().GetAPIMutex()); - BreakpointOptions *bp_options = bkpt_sp->GetOptions(); + BreakpointOptions &bp_options = bkpt_sp->GetOptions(); error = bkpt_sp->GetTarget() .GetDebugger() .GetScriptInterpreter() @@ -661,7 +661,7 @@ SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) { if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( bkpt_sp->GetTarget().GetAPIMutex()); - BreakpointOptions *bp_options = bkpt_sp->GetOptions(); + BreakpointOptions &bp_options = bkpt_sp->GetOptions(); Status error = bkpt_sp->GetTarget() .GetDebugger() diff --git a/lldb/source/API/SBBreakpointLocation.cpp b/lldb/source/API/SBBreakpointLocation.cpp index d6bbb5faf041..175120429925 100644 --- a/lldb/source/API/SBBreakpointLocation.cpp +++ b/lldb/source/API/SBBreakpointLocation.cpp @@ -227,7 +227,7 @@ SBError SBBreakpointLocation::SetScriptCallbackFunction( Status error; std::lock_guard<std::recursive_mutex> guard( loc_sp->GetTarget().GetAPIMutex()); - BreakpointOptions *bp_options = loc_sp->GetLocationOptions(); + BreakpointOptions &bp_options = loc_sp->GetLocationOptions(); error = loc_sp->GetBreakpoint() .GetTarget() .GetDebugger() @@ -254,7 +254,7 @@ SBBreakpointLocation::SetScriptCallbackBody(const char *callback_body_text) { if (loc_sp) { std::lock_guard<std::recursive_mutex> guard( loc_sp->GetTarget().GetAPIMutex()); - BreakpointOptions *bp_options = loc_sp->GetLocationOptions(); + BreakpointOptions &bp_options = loc_sp->GetLocationOptions(); Status error = loc_sp->GetBreakpoint() .GetTarget() @@ -283,7 +283,7 @@ void SBBreakpointLocation::SetCommandLineCommands(SBStringList &commands) { std::unique_ptr<BreakpointOptions::CommandData> cmd_data_up( new BreakpointOptions::CommandData(*commands, eScriptLanguageNone)); - loc_sp->GetLocationOptions()->SetCommandDataCallback(cmd_data_up); + loc_sp->GetLocationOptions().SetCommandDataCallback(cmd_data_up); } bool SBBreakpointLocation::GetCommandLineCommands(SBStringList &commands) { @@ -295,7 +295,7 @@ bool SBBreakpointLocation::GetCommandLineCommands(SBStringList &commands) { return false; StringList command_list; bool has_commands = - loc_sp->GetLocationOptions()->GetCommandLineCallbacks(command_list); + loc_sp->GetLocationOptions().GetCommandLineCallbacks(command_list); if (has_commands) commands.AppendList(command_list); return has_commands; diff --git a/lldb/source/API/SBBreakpointName.cpp b/lldb/source/API/SBBreakpointName.cpp index 3995defcf97c..b5c700c78bbb 100644 --- a/lldb/source/API/SBBreakpointName.cpp +++ b/lldb/source/API/SBBreakpointName.cpp @@ -144,7 +144,7 @@ SBBreakpointName::SBBreakpointName(SBBreakpoint &sb_bkpt, const char *name) { } // Now copy over the breakpoint's options: - target.ConfigureBreakpointName(*bp_name, *bkpt_sp->GetOptions(), + target.ConfigureBreakpointName(*bp_name, bkpt_sp->GetOptions(), BreakpointName::Permissions()); } @@ -594,12 +594,11 @@ SBError SBBreakpointName::SetScriptCallbackFunction( BreakpointOptions &bp_options = bp_name->GetOptions(); Status error; error = m_impl_up->GetTarget() - ->GetDebugger() - .GetScriptInterpreter() - ->SetBreakpointCommandCallbackFunction(&bp_options, - callback_function_name, - extra_args.m_impl_up - ->GetObjectSP()); + ->GetDebugger() + .GetScriptInterpreter() + ->SetBreakpointCommandCallbackFunction( + bp_options, callback_function_name, + extra_args.m_impl_up->GetObjectSP()); sb_error.SetError(error); UpdateName(*bp_name); return LLDB_RECORD_RESULT(sb_error); @@ -623,7 +622,7 @@ SBBreakpointName::SetScriptCallbackBody(const char *callback_body_text) { m_impl_up->GetTarget() ->GetDebugger() .GetScriptInterpreter() - ->SetBreakpointCommandCallback(&bp_options, callback_body_text); + ->SetBreakpointCommandCallback(bp_options, callback_body_text); sb_error.SetError(error); if (!sb_error.Fail()) UpdateName(*bp_name); diff --git a/lldb/source/API/SBBroadcaster.cpp b/lldb/source/API/SBBroadcaster.cpp index d42d7ce2a536..2e6d837f102b 100644 --- a/lldb/source/API/SBBroadcaster.cpp +++ b/lldb/source/API/SBBroadcaster.cpp @@ -16,7 +16,7 @@ using namespace lldb; using namespace lldb_private; -SBBroadcaster::SBBroadcaster() : m_opaque_sp(), m_opaque_ptr(nullptr) { +SBBroadcaster::SBBroadcaster() : m_opaque_sp() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBBroadcaster); } diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp index 31e7da8323b8..b4a69c3e972a 100644 --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -171,27 +171,22 @@ lldb::ReturnStatus SBCommandInterpreter::HandleCommand( lldb::SBCommandReturnObject &, bool), command_line, override_context, result, add_to_history); - - ExecutionContext ctx, *ctx_ptr; - if (override_context.get()) { - ctx = override_context.get()->Lock(true); - ctx_ptr = &ctx; - } else - ctx_ptr = nullptr; - result.Clear(); if (command_line && IsValid()) { result.ref().SetInteractive(false); - m_opaque_ptr->HandleCommand(command_line, - add_to_history ? eLazyBoolYes : eLazyBoolNo, - result.ref(), ctx_ptr); + auto do_add_to_history = add_to_history ? eLazyBoolYes : eLazyBoolNo; + if (override_context.get()) + m_opaque_ptr->HandleCommand(command_line, do_add_to_history, + override_context.get()->Lock(true), + result.ref()); + else + m_opaque_ptr->HandleCommand(command_line, do_add_to_history, + result.ref()); } else { result->AppendError( "SBCommandInterpreter or the command line is not valid"); - result->SetStatus(eReturnStatusFailed); } - return result.GetStatus(); } @@ -207,7 +202,6 @@ void SBCommandInterpreter::HandleCommandsFromFile( if (!IsValid()) { result->AppendError("SBCommandInterpreter is not valid."); - result->SetStatus(eReturnStatusFailed); return; } @@ -215,19 +209,17 @@ void SBCommandInterpreter::HandleCommandsFromFile( SBStream s; file.GetDescription(s); result->AppendErrorWithFormat("File is not valid: %s.", s.GetData()); - result->SetStatus(eReturnStatusFailed); } FileSpec tmp_spec = file.ref(); - ExecutionContext ctx, *ctx_ptr; - if (override_context.get()) { - ctx = override_context.get()->Lock(true); - ctx_ptr = &ctx; - } else - ctx_ptr = nullptr; + if (override_context.get()) + m_opaque_ptr->HandleCommandsFromFile(tmp_spec, + override_context.get()->Lock(true), + options.ref(), + result.ref()); - m_opaque_ptr->HandleCommandsFromFile(tmp_spec, ctx_ptr, options.ref(), - result.ref()); + else + m_opaque_ptr->HandleCommandsFromFile(tmp_spec, options.ref(), result.ref()); } int SBCommandInterpreter::HandleCompletion( @@ -444,7 +436,6 @@ void SBCommandInterpreter::ResolveCommand(const char *command_line, } else { result->AppendError( "SBCommandInterpreter or the command line is not valid"); - result->SetStatus(eReturnStatusFailed); } } @@ -474,7 +465,6 @@ void SBCommandInterpreter::SourceInitFileInHomeDirectory( m_opaque_ptr->SourceInitFileHome(result.ref()); } else { result->AppendError("SBCommandInterpreter is not valid"); - result->SetStatus(eReturnStatusFailed); } } @@ -492,7 +482,6 @@ void SBCommandInterpreter::SourceInitFileInHomeDirectory( m_opaque_ptr->SourceInitFileHome(result.ref(), is_repl); } else { result->AppendError("SBCommandInterpreter is not valid"); - result->SetStatus(eReturnStatusFailed); } } @@ -511,7 +500,6 @@ void SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory( m_opaque_ptr->SourceInitFileCwd(result.ref()); } else { result->AppendError("SBCommandInterpreter is not valid"); - result->SetStatus(eReturnStatusFailed); } } diff --git a/lldb/source/API/SBCommandInterpreterRunOptions.cpp b/lldb/source/API/SBCommandInterpreterRunOptions.cpp index da800e8b7804..317ec6d37127 100644 --- a/lldb/source/API/SBCommandInterpreterRunOptions.cpp +++ b/lldb/source/API/SBCommandInterpreterRunOptions.cpp @@ -131,6 +131,20 @@ void SBCommandInterpreterRunOptions::SetPrintResults(bool print_results) { m_opaque_up->SetPrintResults(print_results); } +bool SBCommandInterpreterRunOptions::GetPrintErrors() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, + GetPrintErrors); + + return m_opaque_up->GetPrintErrors(); +} + +void SBCommandInterpreterRunOptions::SetPrintErrors(bool print_errors) { + LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetPrintErrors, + (bool), print_errors); + + m_opaque_up->SetPrintErrors(print_errors); +} + bool SBCommandInterpreterRunOptions::GetAddToHistory() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, GetAddToHistory); @@ -270,6 +284,10 @@ template <> void RegisterMethods<SBCommandInterpreterRunOptions>(Registry &R) { LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetPrintResults, (bool)); LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, + GetPrintErrors, ()); + LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetPrintErrors, + (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, GetAddToHistory, ()); LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetAddToHistory, (bool)); diff --git a/lldb/source/API/SBCommandReturnObject.cpp b/lldb/source/API/SBCommandReturnObject.cpp index fddf90b66481..00150d198fca 100644 --- a/lldb/source/API/SBCommandReturnObject.cpp +++ b/lldb/source/API/SBCommandReturnObject.cpp @@ -21,8 +21,7 @@ using namespace lldb_private; class lldb_private::SBCommandReturnObjectImpl { public: - SBCommandReturnObjectImpl() - : m_ptr(new CommandReturnObject(false)), m_owned(true) {} + SBCommandReturnObjectImpl() : m_ptr(new CommandReturnObject(false)) {} SBCommandReturnObjectImpl(CommandReturnObject &ref) : m_ptr(&ref), m_owned(false) {} SBCommandReturnObjectImpl(const SBCommandReturnObjectImpl &rhs) @@ -42,7 +41,7 @@ public: private: CommandReturnObject *m_ptr; - bool m_owned; + bool m_owned = true; }; SBCommandReturnObject::SBCommandReturnObject() @@ -364,7 +363,7 @@ void SBCommandReturnObject::SetError(const char *error_cstr) { error_cstr); if (error_cstr) - ref().SetError(error_cstr); + ref().AppendError(error_cstr); } namespace lldb_private { diff --git a/lldb/source/API/SBCommunication.cpp b/lldb/source/API/SBCommunication.cpp index d55ecd35b557..9a2ab89d5e4e 100644 --- a/lldb/source/API/SBCommunication.cpp +++ b/lldb/source/API/SBCommunication.cpp @@ -16,7 +16,7 @@ using namespace lldb; using namespace lldb_private; -SBCommunication::SBCommunication() : m_opaque(nullptr), m_opaque_owned(false) { +SBCommunication::SBCommunication() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommunication); } diff --git a/lldb/source/API/SBCompileUnit.cpp b/lldb/source/API/SBCompileUnit.cpp index 765957d680c9..a44d3b897110 100644 --- a/lldb/source/API/SBCompileUnit.cpp +++ b/lldb/source/API/SBCompileUnit.cpp @@ -21,7 +21,7 @@ using namespace lldb; using namespace lldb_private; -SBCompileUnit::SBCompileUnit() : m_opaque_ptr(nullptr) { +SBCompileUnit::SBCompileUnit() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCompileUnit); } @@ -108,9 +108,10 @@ uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line, else file_spec = m_opaque_ptr->GetPrimaryFile(); + LineEntry line_entry; index = m_opaque_ptr->FindLineEntry( start_idx, line, inline_file_spec ? inline_file_spec->get() : nullptr, - exact, nullptr); + exact, &line_entry); } return index; diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 6245b3a83565..a854c22bb214 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -38,6 +38,7 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/Progress.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/StructuredDataImpl.h" #include "lldb/DataFormatters/DataVisualization.h" @@ -149,6 +150,41 @@ SBDebugger &SBDebugger::operator=(const SBDebugger &rhs) { return LLDB_RECORD_RESULT(*this); } +const char *SBDebugger::GetBroadcasterClass() { + LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBDebugger, + GetBroadcasterClass); + + return Debugger::GetStaticBroadcasterClass().AsCString(); +} + +const char *SBDebugger::GetProgressFromEvent(const lldb::SBEvent &event, + uint64_t &progress_id, + uint64_t &completed, + uint64_t &total, + bool &is_debugger_specific) { + const Debugger::ProgressEventData *progress_data = + Debugger::ProgressEventData::GetEventDataFromEvent(event.get()); + if (progress_data == nullptr) + return nullptr; + progress_id = progress_data->GetID(); + completed = progress_data->GetCompleted(); + total = progress_data->GetTotal(); + is_debugger_specific = progress_data->IsDebuggerSpecific(); + // We must record the static method _after_ the out parameters have been + // filled in. + LLDB_RECORD_STATIC_METHOD( + const char *, SBDebugger, GetProgressFromEvent, + (const lldb::SBEvent &, uint64_t &, uint64_t &, uint64_t &, bool &), + event, progress_id, completed, total, is_debugger_specific); + return LLDB_RECORD_RESULT(progress_data->GetMessage().c_str()) +} + +SBBroadcaster SBDebugger::GetBroadcaster() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBBroadcaster, SBDebugger, GetBroadcaster); + SBBroadcaster broadcaster(&m_opaque_sp->GetBroadcaster(), false); + return LLDB_RECORD_RESULT(broadcaster); +} + void SBDebugger::Initialize() { LLDB_RECORD_STATIC_METHOD_NO_ARGS(void, SBDebugger, Initialize); SBError ignored = SBDebugger::InitializeWithErrorHandling(); @@ -824,7 +860,7 @@ SBTarget SBDebugger::CreateTargetWithFileAndArch(const char *filename, if (error.Success()) sb_target.SetSP(target_sp); } - + LLDB_LOGF(log, "SBDebugger(%p)::CreateTargetWithFileAndArch (filename=\"%s\", " "arch=%s) => SBTarget(%p)", @@ -1298,7 +1334,6 @@ SBDebugger::GetInternalVariableValue(const char *var_name, lldb::SBStringList, SBDebugger, GetInternalVariableValue, (const char *, const char *), var_name, debugger_instance_name); - SBStringList ret_value; DebuggerSP debugger_sp(Debugger::FindDebuggerWithInstanceName( ConstString(debugger_instance_name))); Status error; @@ -1351,7 +1386,7 @@ void SBDebugger::SetPrompt(const char *prompt) { LLDB_RECORD_METHOD(void, SBDebugger, SetPrompt, (const char *), prompt); if (m_opaque_sp) - m_opaque_sp->SetPrompt(llvm::StringRef::withNullAsEmpty(prompt)); + m_opaque_sp->SetPrompt(llvm::StringRef(prompt)); } const char *SBDebugger::GetReproducerPath() const { @@ -1711,6 +1746,12 @@ template <> void RegisterMethods<SBDebugger>(Registry &R) { LLDB_REGISTER_METHOD(void, SBDebugger, Clear, ()); LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, ()); LLDB_REGISTER_STATIC_METHOD(lldb::SBDebugger, SBDebugger, Create, (bool)); + LLDB_REGISTER_STATIC_METHOD( + const char *, SBDebugger, GetProgressFromEvent, + (const lldb::SBEvent &, uint64_t &, uint64_t &, uint64_t &, bool &)); + LLDB_REGISTER_STATIC_METHOD(const char *, SBDebugger, GetBroadcasterClass, + ()); + LLDB_REGISTER_METHOD(SBBroadcaster, SBDebugger, GetBroadcaster, ()); LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, Destroy, (lldb::SBDebugger &)); LLDB_REGISTER_STATIC_METHOD(void, SBDebugger, MemoryPressureDetected, ()); LLDB_REGISTER_METHOD_CONST(bool, SBDebugger, IsValid, ()); diff --git a/lldb/source/API/SBDeclaration.cpp b/lldb/source/API/SBDeclaration.cpp index f1066d63c06a..1496096e46d1 100644 --- a/lldb/source/API/SBDeclaration.cpp +++ b/lldb/source/API/SBDeclaration.cpp @@ -10,11 +10,11 @@ #include "SBReproducerPrivate.h" #include "Utils.h" #include "lldb/API/SBStream.h" +#include "lldb/Core/Declaration.h" #include "lldb/Host/PosixApi.h" -#include "lldb/Symbol/Declaration.h" #include "lldb/Utility/Stream.h" -#include <limits.h> +#include <climits> using namespace lldb; using namespace lldb_private; diff --git a/lldb/source/API/SBError.cpp b/lldb/source/API/SBError.cpp index f979572778e0..89b5f26fd80c 100644 --- a/lldb/source/API/SBError.cpp +++ b/lldb/source/API/SBError.cpp @@ -12,7 +12,7 @@ #include "lldb/API/SBStream.h" #include "lldb/Utility/Status.h" -#include <stdarg.h> +#include <cstdarg> using namespace lldb; using namespace lldb_private; diff --git a/lldb/source/API/SBEvent.cpp b/lldb/source/API/SBEvent.cpp index 2776ec49c092..a0b606e3812e 100644 --- a/lldb/source/API/SBEvent.cpp +++ b/lldb/source/API/SBEvent.cpp @@ -22,9 +22,7 @@ using namespace lldb; using namespace lldb_private; -SBEvent::SBEvent() : m_event_sp(), m_opaque_ptr(nullptr) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBEvent); -} +SBEvent::SBEvent() : m_event_sp() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBEvent); } SBEvent::SBEvent(uint32_t event_type, const char *cstr, uint32_t cstr_len) : m_event_sp(new Event(event_type, new EventDataBytes(cstr, cstr_len))), diff --git a/lldb/source/API/SBFileSpec.cpp b/lldb/source/API/SBFileSpec.cpp index 7bfb665df4fb..0a6b63bb460c 100644 --- a/lldb/source/API/SBFileSpec.cpp +++ b/lldb/source/API/SBFileSpec.cpp @@ -17,8 +17,8 @@ #include "llvm/ADT/SmallString.h" -#include <inttypes.h> -#include <limits.h> +#include <cinttypes> +#include <climits> using namespace lldb; using namespace lldb_private; diff --git a/lldb/source/API/SBFileSpecList.cpp b/lldb/source/API/SBFileSpecList.cpp index 7afa34363271..768ff0affd15 100644 --- a/lldb/source/API/SBFileSpecList.cpp +++ b/lldb/source/API/SBFileSpecList.cpp @@ -16,7 +16,7 @@ #include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Stream.h" -#include <limits.h> +#include <climits> using namespace lldb; using namespace lldb_private; diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp index 9f3cf817fc8c..2d0cb239de75 100644 --- a/lldb/source/API/SBFunction.cpp +++ b/lldb/source/API/SBFunction.cpp @@ -22,9 +22,7 @@ using namespace lldb; using namespace lldb_private; -SBFunction::SBFunction() : m_opaque_ptr(nullptr) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFunction); -} +SBFunction::SBFunction() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFunction); } SBFunction::SBFunction(lldb_private::Function *lldb_object_ptr) : m_opaque_ptr(lldb_object_ptr) {} @@ -132,10 +130,10 @@ SBInstructionList SBFunction::GetInstructions(SBTarget target, m_opaque_ptr->GetAddressRange().GetBaseAddress().GetModule()); if (target_sp && module_sp) { lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex()); - const bool prefer_file_cache = false; + const bool force_live_memory = true; sb_instructions.SetDisassembler(Disassembler::DisassembleRange( module_sp->GetArchitecture(), nullptr, flavor, *target_sp, - m_opaque_ptr->GetAddressRange(), prefer_file_cache)); + m_opaque_ptr->GetAddressRange(), force_live_memory)); } } return LLDB_RECORD_RESULT(sb_instructions); diff --git a/lldb/source/API/SBLanguageRuntime.cpp b/lldb/source/API/SBLanguageRuntime.cpp index 33c900d20c31..e65b58270517 100644 --- a/lldb/source/API/SBLanguageRuntime.cpp +++ b/lldb/source/API/SBLanguageRuntime.cpp @@ -18,8 +18,7 @@ SBLanguageRuntime::GetLanguageTypeFromString(const char *string) { LLDB_RECORD_STATIC_METHOD(lldb::LanguageType, SBLanguageRuntime, GetLanguageTypeFromString, (const char *), string); - return Language::GetLanguageTypeFromString( - llvm::StringRef::withNullAsEmpty(string)); + return Language::GetLanguageTypeFromString(llvm::StringRef(string)); } const char * diff --git a/lldb/source/API/SBLaunchInfo.cpp b/lldb/source/API/SBLaunchInfo.cpp index cda8134c9853..70cd1c6ecf74 100644 --- a/lldb/source/API/SBLaunchInfo.cpp +++ b/lldb/source/API/SBLaunchInfo.cpp @@ -10,8 +10,12 @@ #include "SBReproducerPrivate.h" #include "lldb/API/SBEnvironment.h" +#include "lldb/API/SBError.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBListener.h" +#include "lldb/API/SBStream.h" +#include "lldb/API/SBStructuredData.h" +#include "lldb/Core/StructuredDataImpl.h" #include "lldb/Host/ProcessLaunchInfo.h" using namespace lldb; @@ -343,6 +347,53 @@ bool SBLaunchInfo::GetDetachOnError() const { return m_opaque_sp->GetDetachOnError(); } +const char *SBLaunchInfo::GetScriptedProcessClassName() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(const char *, SBLaunchInfo, + GetScriptedProcessClassName); + + // 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 class_name(m_opaque_sp->GetScriptedProcessClassName().c_str()); + return class_name.AsCString(); +} + +void SBLaunchInfo::SetScriptedProcessClassName(const char *class_name) { + LLDB_RECORD_METHOD(void, SBLaunchInfo, SetScriptedProcessClassName, + (const char *), class_name); + + m_opaque_sp->SetScriptedProcessClassName(class_name); +} + +lldb::SBStructuredData SBLaunchInfo::GetScriptedProcessDictionary() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBStructuredData, SBLaunchInfo, + GetScriptedProcessDictionary); + + lldb_private::StructuredData::DictionarySP dict_sp = + m_opaque_sp->GetScriptedProcessDictionarySP(); + + SBStructuredData data; + data.m_impl_up->SetObjectSP(dict_sp); + + return LLDB_RECORD_RESULT(data); +} + +void SBLaunchInfo::SetScriptedProcessDictionary(lldb::SBStructuredData dict) { + LLDB_RECORD_METHOD(void, SBLaunchInfo, SetScriptedProcessDictionary, + (lldb::SBStructuredData), dict); + + SBStream stream; + SBError error = dict.GetAsJSON(stream); + + if (error.Fail()) + return; + + StructuredData::DictionarySP dict_sp; + llvm::json::OStream s(stream.ref().AsRawOstream()); + dict_sp->Serialize(s); + + m_opaque_sp->SetScriptedProcessDictionarySP(dict_sp); +} + namespace lldb_private { namespace repro { @@ -403,6 +454,14 @@ void RegisterMethods<SBLaunchInfo>(Registry &R) { ()); LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetDetachOnError, (bool)); LLDB_REGISTER_METHOD_CONST(bool, SBLaunchInfo, GetDetachOnError, ()); + LLDB_REGISTER_METHOD_CONST(const char *, SBLaunchInfo, + GetScriptedProcessClassName, ()); + LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetScriptedProcessClassName, + (const char *)); + LLDB_REGISTER_METHOD_CONST(lldb::SBStructuredData, SBLaunchInfo, + GetScriptedProcessDictionary, ()); + LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetScriptedProcessDictionary, + (lldb::SBStructuredData)); LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetEnvironment, (const lldb::SBEnvironment &, bool)); LLDB_REGISTER_METHOD(lldb::SBEnvironment, SBLaunchInfo, GetEnvironment, ()); diff --git a/lldb/source/API/SBLineEntry.cpp b/lldb/source/API/SBLineEntry.cpp index 9866acbcbec3..29ffda9b0471 100644 --- a/lldb/source/API/SBLineEntry.cpp +++ b/lldb/source/API/SBLineEntry.cpp @@ -14,7 +14,7 @@ #include "lldb/Symbol/LineEntry.h" #include "lldb/Utility/StreamString.h" -#include <limits.h> +#include <climits> using namespace lldb; using namespace lldb_private; diff --git a/lldb/source/API/SBListener.cpp b/lldb/source/API/SBListener.cpp index f3463268b3b5..6e5e15de7b3d 100644 --- a/lldb/source/API/SBListener.cpp +++ b/lldb/source/API/SBListener.cpp @@ -20,7 +20,7 @@ using namespace lldb; using namespace lldb_private; -SBListener::SBListener() : m_opaque_sp(), m_unused_ptr(nullptr) { +SBListener::SBListener() : m_opaque_sp() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBListener); } diff --git a/lldb/source/API/SBMemoryRegionInfo.cpp b/lldb/source/API/SBMemoryRegionInfo.cpp index 2a28b99c72d7..ab74d559387f 100644 --- a/lldb/source/API/SBMemoryRegionInfo.cpp +++ b/lldb/source/API/SBMemoryRegionInfo.cpp @@ -116,6 +116,42 @@ const char *SBMemoryRegionInfo::GetName() { return m_opaque_up->GetName().AsCString(); } +bool SBMemoryRegionInfo::HasDirtyMemoryPageList() { + LLDB_RECORD_METHOD_NO_ARGS(bool, SBMemoryRegionInfo, HasDirtyMemoryPageList); + + return m_opaque_up->GetDirtyPageList().hasValue(); +} + +uint32_t SBMemoryRegionInfo::GetNumDirtyPages() { + LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBMemoryRegionInfo, GetNumDirtyPages); + + uint32_t num_dirty_pages = 0; + llvm::Optional<std::vector<addr_t>> dirty_page_list = + m_opaque_up->GetDirtyPageList(); + if (dirty_page_list.hasValue()) + num_dirty_pages = dirty_page_list.getValue().size(); + + return num_dirty_pages; +} + +addr_t SBMemoryRegionInfo::GetDirtyPageAddressAtIndex(uint32_t idx) { + LLDB_RECORD_METHOD(addr_t, SBMemoryRegionInfo, GetDirtyPageAddressAtIndex, + (uint32_t), idx); + + addr_t dirty_page_addr = LLDB_INVALID_ADDRESS; + const llvm::Optional<std::vector<addr_t>> &dirty_page_list = + m_opaque_up->GetDirtyPageList(); + if (dirty_page_list.hasValue() && idx < dirty_page_list.getValue().size()) + dirty_page_addr = dirty_page_list.getValue()[idx]; + + return dirty_page_addr; +} + +int SBMemoryRegionInfo::GetPageSize() { + LLDB_RECORD_METHOD_NO_ARGS(int, SBMemoryRegionInfo, GetPageSize); + return m_opaque_up->GetPageSize(); +} + bool SBMemoryRegionInfo::GetDescription(SBStream &description) { LLDB_RECORD_METHOD(bool, SBMemoryRegionInfo, GetDescription, (lldb::SBStream &), description); diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp index f118048156b9..496c40a0678f 100644 --- a/lldb/source/API/SBPlatform.cpp +++ b/lldb/source/API/SBPlatform.cpp @@ -32,7 +32,7 @@ using namespace lldb_private; struct PlatformConnectOptions { PlatformConnectOptions(const char *url = nullptr) : m_url(), m_rsync_options(), m_rsync_remote_path_prefix(), - m_rsync_enabled(false), m_rsync_omit_hostname_from_remote_path(false), + m_local_cache_directory() { if (url && url[0]) m_url = url; @@ -43,8 +43,8 @@ struct PlatformConnectOptions { std::string m_url; std::string m_rsync_options; std::string m_rsync_remote_path_prefix; - bool m_rsync_enabled; - bool m_rsync_omit_hostname_from_remote_path; + bool m_rsync_enabled = false; + bool m_rsync_omit_hostname_from_remote_path = false; ConstString m_local_cache_directory; }; @@ -61,7 +61,7 @@ struct PlatformShellCommand { } PlatformShellCommand(llvm::StringRef shell_command = llvm::StringRef()) - : m_shell(), m_command(), m_working_dir(), m_status(0), m_signo(0) { + : m_shell(), m_command(), m_working_dir() { if (!shell_command.empty()) m_command = shell_command.str(); } @@ -72,8 +72,8 @@ struct PlatformShellCommand { std::string m_command; std::string m_working_dir; std::string m_output; - int m_status; - int m_signo; + int m_status = 0; + int m_signo = 0; Timeout<std::ratio<1>> m_timeout = llvm::None; }; // SBPlatformConnectOptions @@ -413,8 +413,7 @@ SBError SBPlatform::ConnectRemote(SBPlatformConnectOptions &connect_options) { PlatformSP platform_sp(GetSP()); if (platform_sp && connect_options.GetURL()) { Args args; - args.AppendArgument( - llvm::StringRef::withNullAsEmpty(connect_options.GetURL())); + args.AppendArgument(connect_options.GetURL()); sb_error.ref() = platform_sp->ConnectRemote(args); } else { sb_error.SetErrorString("invalid platform"); diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index d7b7fd7cacad..47c35a23b078 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -9,7 +9,7 @@ #include "lldb/API/SBProcess.h" #include "SBReproducerPrivate.h" -#include <inttypes.h> +#include <cinttypes> #include "lldb/lldb-defines.h" #include "lldb/lldb-types.h" @@ -44,7 +44,6 @@ #include "lldb/API/SBThread.h" #include "lldb/API/SBThreadCollection.h" #include "lldb/API/SBTrace.h" -#include "lldb/API/SBTraceOptions.h" #include "lldb/API/SBUnixSignals.h" using namespace lldb; @@ -312,26 +311,6 @@ size_t SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const { return bytes_read; } -lldb::SBTrace SBProcess::StartTrace(SBTraceOptions &options, - lldb::SBError &error) { - LLDB_RECORD_METHOD(lldb::SBTrace, SBProcess, StartTrace, - (lldb::SBTraceOptions &, lldb::SBError &), options, error); - - ProcessSP process_sp(GetSP()); - error.Clear(); - SBTrace trace_instance; - trace_instance.SetSP(process_sp); - lldb::user_id_t uid = LLDB_INVALID_UID; - - if (!process_sp) { - error.SetErrorString("invalid process"); - } else { - uid = process_sp->StartTrace(*(options.m_traceoptions_sp), error.ref()); - trace_instance.SetTraceUID(uid); - } - return LLDB_RECORD_RESULT(trace_instance); -} - void SBProcess::ReportEventState(const SBEvent &event, SBFile out) const { LLDB_RECORD_METHOD_CONST(void, SBProcess, ReportEventState, (const SBEvent &, SBFile), event, out); @@ -1248,7 +1227,8 @@ lldb::SBError SBProcess::SaveCore(const char *file_name) { } FileSpec core_file(file_name); - error.ref() = PluginManager::SaveCore(process_sp, core_file); + SaveCoreStyle core_style = SaveCoreStyle::eSaveCoreFull; + error.ref() = PluginManager::SaveCore(process_sp, core_file, core_style); return LLDB_RECORD_RESULT(error); } @@ -1308,6 +1288,51 @@ lldb::SBProcessInfo SBProcess::GetProcessInfo() { return LLDB_RECORD_RESULT(sb_proc_info); } +lldb::addr_t SBProcess::AllocateMemory(size_t size, uint32_t permissions, + lldb::SBError &sb_error) { + LLDB_RECORD_METHOD(lldb::addr_t, SBProcess, AllocateMemory, + (size_t, uint32_t, lldb::SBError &), size, permissions, + sb_error); + + lldb::addr_t addr = LLDB_INVALID_ADDRESS; + 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()); + addr = process_sp->AllocateMemory(size, permissions, sb_error.ref()); + } else { + sb_error.SetErrorString("process is running"); + } + } else { + sb_error.SetErrorString("SBProcess is invalid"); + } + return addr; +} + +lldb::SBError SBProcess::DeallocateMemory(lldb::addr_t ptr) { + LLDB_RECORD_METHOD(lldb::SBError, SBProcess, DeallocateMemory, (lldb::addr_t), + ptr); + + lldb::SBError sb_error; + 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()); + Status error = process_sp->DeallocateMemory(ptr); + sb_error.SetError(error); + } else { + sb_error.SetErrorString("process is running"); + } + } else { + sb_error.SetErrorString("SBProcess is invalid"); + } + return sb_error; +} + namespace lldb_private { namespace repro { @@ -1338,8 +1363,6 @@ void RegisterMethods<SBProcess>(Registry &R) { (lldb::tid_t, lldb::addr_t)); LLDB_REGISTER_METHOD_CONST(lldb::SBTarget, SBProcess, GetTarget, ()); LLDB_REGISTER_METHOD(size_t, SBProcess, PutSTDIN, (const char *, size_t)); - LLDB_REGISTER_METHOD(lldb::SBTrace, SBProcess, StartTrace, - (lldb::SBTraceOptions &, lldb::SBError &)); LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState, (const lldb::SBEvent &, FILE *)); LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState, @@ -1439,6 +1462,10 @@ void RegisterMethods<SBProcess>(Registry &R) { LLDB_REGISTER_METHOD(lldb::SBMemoryRegionInfoList, SBProcess, GetMemoryRegions, ()); LLDB_REGISTER_METHOD(lldb::SBProcessInfo, SBProcess, GetProcessInfo, ()); + LLDB_REGISTER_METHOD(lldb::addr_t, SBProcess, AllocateMemory, + (size_t, uint32_t, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::SBError, SBProcess, DeallocateMemory, + (lldb::addr_t)); LLDB_REGISTER_CHAR_PTR_METHOD_CONST(size_t, SBProcess, GetSTDOUT); LLDB_REGISTER_CHAR_PTR_METHOD_CONST(size_t, SBProcess, GetSTDERR); diff --git a/lldb/source/API/SBProcessInfo.cpp b/lldb/source/API/SBProcessInfo.cpp index 29a9c7b24b5a..cba3bdc179f3 100644 --- a/lldb/source/API/SBProcessInfo.cpp +++ b/lldb/source/API/SBProcessInfo.cpp @@ -179,6 +179,21 @@ lldb::pid_t SBProcessInfo::GetParentProcessID() { return proc_id; } +const char *SBProcessInfo::GetTriple() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBProcessInfo, GetTriple); + + const char *triple = nullptr; + if (m_opaque_up) { + const auto &arch = m_opaque_up->GetArchitecture(); + if (arch.IsValid()) { + // Const-ify the string so we don't need to worry about the lifetime of + // the string + triple = ConstString(arch.GetTriple().getTriple().c_str()).GetCString(); + } + } + return triple; +} + namespace lldb_private { namespace repro { @@ -204,6 +219,7 @@ void RegisterMethods<SBProcessInfo>(Registry &R) { LLDB_REGISTER_METHOD(bool, SBProcessInfo, EffectiveUserIDIsValid, ()); LLDB_REGISTER_METHOD(bool, SBProcessInfo, EffectiveGroupIDIsValid, ()); LLDB_REGISTER_METHOD(lldb::pid_t, SBProcessInfo, GetParentProcessID, ()); + LLDB_REGISTER_METHOD(const char *, SBProcessInfo, GetTriple, ()); } } diff --git a/lldb/source/API/SBQueue.cpp b/lldb/source/API/SBQueue.cpp index 2e6571392ea1..746df9e79d61 100644 --- a/lldb/source/API/SBQueue.cpp +++ b/lldb/source/API/SBQueue.cpp @@ -6,7 +6,7 @@ // //===----------------------------------------------------------------------===// -#include <inttypes.h> +#include <cinttypes> #include "SBReproducerPrivate.h" #include "lldb/API/SBQueue.h" @@ -27,9 +27,7 @@ namespace lldb_private { class QueueImpl { public: - QueueImpl() - : m_queue_wp(), m_threads(), m_thread_list_fetched(false), - m_pending_items(), m_pending_items_fetched(false) {} + QueueImpl() : m_queue_wp(), m_threads(), m_pending_items() {} QueueImpl(const lldb::QueueSP &queue_sp) : m_queue_wp(), m_threads(), m_thread_list_fetched(false), @@ -210,10 +208,11 @@ private: lldb::QueueWP m_queue_wp; std::vector<lldb::ThreadWP> m_threads; // threads currently executing this queue's items - bool - m_thread_list_fetched; // have we tried to fetch the threads list already? + bool m_thread_list_fetched = + false; // have we tried to fetch the threads list already? std::vector<lldb::QueueItemSP> m_pending_items; // items currently enqueued - bool m_pending_items_fetched; // have we tried to fetch the item list already? + bool m_pending_items_fetched = + false; // have we tried to fetch the item list already? }; } diff --git a/lldb/source/API/SBReproducer.cpp b/lldb/source/API/SBReproducer.cpp index 4d25fcc4a8f6..68e632da1bde 100644 --- a/lldb/source/API/SBReproducer.cpp +++ b/lldb/source/API/SBReproducer.cpp @@ -117,7 +117,6 @@ SBRegistry::SBRegistry() { RegisterMethods<SBThreadCollection>(R); RegisterMethods<SBThreadPlan>(R); RegisterMethods<SBTrace>(R); - RegisterMethods<SBTraceOptions>(R); RegisterMethods<SBType>(R); RegisterMethods<SBTypeCategory>(R); RegisterMethods<SBTypeEnumMember>(R); diff --git a/lldb/source/API/SBStream.cpp b/lldb/source/API/SBStream.cpp index eb81153084e8..66172d248bf3 100644 --- a/lldb/source/API/SBStream.cpp +++ b/lldb/source/API/SBStream.cpp @@ -19,7 +19,7 @@ using namespace lldb; using namespace lldb_private; -SBStream::SBStream() : m_opaque_up(new StreamString()), m_is_file(false) { +SBStream::SBStream() : m_opaque_up(new StreamString()) { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBStream); } diff --git a/lldb/source/API/SBStructuredData.cpp b/lldb/source/API/SBStructuredData.cpp index 2ae3005fd8d1..97a9eadcaf07 100644 --- a/lldb/source/API/SBStructuredData.cpp +++ b/lldb/source/API/SBStructuredData.cpp @@ -29,7 +29,7 @@ SBStructuredData::SBStructuredData() : m_impl_up(new StructuredDataImpl()) { } SBStructuredData::SBStructuredData(const lldb::SBStructuredData &rhs) - : m_impl_up(new StructuredDataImpl(*rhs.m_impl_up.get())) { + : m_impl_up(new StructuredDataImpl(*rhs.m_impl_up)) { LLDB_RECORD_CONSTRUCTOR(SBStructuredData, (const lldb::SBStructuredData &), rhs); } @@ -40,7 +40,7 @@ SBStructuredData::SBStructuredData(const lldb::EventSP &event_sp) } SBStructuredData::SBStructuredData(lldb_private::StructuredDataImpl *impl) - : m_impl_up(impl) { + : m_impl_up(impl ? impl : new StructuredDataImpl()) { LLDB_RECORD_CONSTRUCTOR(SBStructuredData, (lldb_private::StructuredDataImpl *), impl); } @@ -72,10 +72,19 @@ lldb::SBError SBStructuredData::SetFromJSON(lldb::SBStream &stream) { return LLDB_RECORD_RESULT(error); } +lldb::SBError SBStructuredData::SetFromJSON(const char *json) { + LLDB_RECORD_METHOD(lldb::SBError, SBStructuredData, SetFromJSON, + (const char *), json); + lldb::SBStream s; + s.Print(json); + return LLDB_RECORD_RESULT(SetFromJSON(s)); +} + bool SBStructuredData::IsValid() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStructuredData, IsValid); return this->operator bool(); } + SBStructuredData::operator bool() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStructuredData, operator bool); @@ -111,22 +120,19 @@ StructuredDataType SBStructuredData::GetType() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::StructuredDataType, SBStructuredData, GetType); - return (m_impl_up ? m_impl_up->GetType() : eStructuredDataTypeInvalid); + return m_impl_up->GetType(); } size_t SBStructuredData::GetSize() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBStructuredData, GetSize); - return (m_impl_up ? m_impl_up->GetSize() : 0); + return m_impl_up->GetSize(); } bool SBStructuredData::GetKeys(lldb::SBStringList &keys) const { LLDB_RECORD_METHOD_CONST(bool, SBStructuredData, GetKeys, (lldb::SBStringList &), keys); - if (!m_impl_up) - return false; - if (GetType() != eStructuredDataTypeDictionary) return false; @@ -154,9 +160,6 @@ lldb::SBStructuredData SBStructuredData::GetValueForKey(const char *key) const { LLDB_RECORD_METHOD_CONST(lldb::SBStructuredData, SBStructuredData, GetValueForKey, (const char *), key); - if (!m_impl_up) - return LLDB_RECORD_RESULT(SBStructuredData()); - SBStructuredData result; result.m_impl_up->SetObjectSP(m_impl_up->GetValueForKey(key)); return LLDB_RECORD_RESULT(result); @@ -166,9 +169,6 @@ lldb::SBStructuredData SBStructuredData::GetItemAtIndex(size_t idx) const { LLDB_RECORD_METHOD_CONST(lldb::SBStructuredData, SBStructuredData, GetItemAtIndex, (size_t), idx); - if (!m_impl_up) - return LLDB_RECORD_RESULT(SBStructuredData()); - SBStructuredData result; result.m_impl_up->SetObjectSP(m_impl_up->GetItemAtIndex(idx)); return LLDB_RECORD_RESULT(result); @@ -178,28 +178,28 @@ uint64_t SBStructuredData::GetIntegerValue(uint64_t fail_value) const { LLDB_RECORD_METHOD_CONST(uint64_t, SBStructuredData, GetIntegerValue, (uint64_t), fail_value); - return (m_impl_up ? m_impl_up->GetIntegerValue(fail_value) : fail_value); + return m_impl_up->GetIntegerValue(fail_value); } double SBStructuredData::GetFloatValue(double fail_value) const { LLDB_RECORD_METHOD_CONST(double, SBStructuredData, GetFloatValue, (double), fail_value); - return (m_impl_up ? m_impl_up->GetFloatValue(fail_value) : fail_value); + return m_impl_up->GetFloatValue(fail_value); } bool SBStructuredData::GetBooleanValue(bool fail_value) const { LLDB_RECORD_METHOD_CONST(bool, SBStructuredData, GetBooleanValue, (bool), fail_value); - return (m_impl_up ? m_impl_up->GetBooleanValue(fail_value) : fail_value); + return m_impl_up->GetBooleanValue(fail_value); } size_t SBStructuredData::GetStringValue(char *dst, size_t dst_len) const { LLDB_RECORD_CHAR_PTR_METHOD_CONST(size_t, SBStructuredData, GetStringValue, (char *, size_t), dst, "", dst_len); - return (m_impl_up ? m_impl_up->GetStringValue(dst, dst_len) : 0); + return m_impl_up->GetStringValue(dst, dst_len); } namespace lldb_private { @@ -216,6 +216,8 @@ template <> void RegisterMethods<SBStructuredData>(Registry &R) { SBStructuredData, operator=,(const lldb::SBStructuredData &)); LLDB_REGISTER_METHOD(lldb::SBError, SBStructuredData, SetFromJSON, (lldb::SBStream &)); + LLDB_REGISTER_METHOD(lldb::SBError, SBStructuredData, SetFromJSON, + (const char *)); LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, IsValid, ()); LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, operator bool, ()); LLDB_REGISTER_METHOD(void, SBStructuredData, Clear, ()); diff --git a/lldb/source/API/SBSymbol.cpp b/lldb/source/API/SBSymbol.cpp index eafc3e630bcd..d3abc13675f5 100644 --- a/lldb/source/API/SBSymbol.cpp +++ b/lldb/source/API/SBSymbol.cpp @@ -18,9 +18,7 @@ using namespace lldb; using namespace lldb_private; -SBSymbol::SBSymbol() : m_opaque_ptr(nullptr) { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBSymbol); -} +SBSymbol::SBSymbol() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBSymbol); } SBSymbol::SBSymbol(lldb_private::Symbol *lldb_object_ptr) : m_opaque_ptr(lldb_object_ptr) {} @@ -132,10 +130,10 @@ SBInstructionList SBSymbol::GetInstructions(SBTarget target, ModuleSP module_sp = symbol_addr.GetModule(); if (module_sp) { AddressRange symbol_range(symbol_addr, m_opaque_ptr->GetByteSize()); - const bool prefer_file_cache = false; + const bool force_live_memory = true; sb_instructions.SetDisassembler(Disassembler::DisassembleRange( module_sp->GetArchitecture(), nullptr, flavor_string, *target_sp, - symbol_range, prefer_file_cache)); + symbol_range, force_live_memory)); } } } diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 6128c04de32b..6f0633288a2b 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -26,13 +26,13 @@ #include "lldb/API/SBStringList.h" #include "lldb/API/SBStructuredData.h" #include "lldb/API/SBSymbolContextList.h" +#include "lldb/API/SBTrace.h" #include "lldb/Breakpoint/BreakpointID.h" #include "lldb/Breakpoint/BreakpointIDList.h" #include "lldb/Breakpoint/BreakpointList.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Address.h" #include "lldb/Core/AddressResolver.h" -#include "lldb/Core/AddressResolverName.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Disassembler.h" #include "lldb/Core/Module.h" @@ -706,7 +706,7 @@ size_t SBTarget::ReadMemory(const SBAddress addr, void *buf, size_t size, if (target_sp) { std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex()); bytes_read = - target_sp->ReadMemory(addr.ref(), false, buf, size, sb_error.ref()); + target_sp->ReadMemory(addr.ref(), buf, size, sb_error.ref(), true); } else { sb_error.SetErrorString("invalid target"); } @@ -2086,12 +2086,12 @@ lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr, if (addr_ptr) { DataBufferHeap data( target_sp->GetArchitecture().GetMaximumOpcodeByteSize() * count, 0); - bool prefer_file_cache = false; + bool force_live_memory = true; lldb_private::Status error; lldb::addr_t load_addr = LLDB_INVALID_ADDRESS; const size_t bytes_read = - target_sp->ReadMemory(*addr_ptr, prefer_file_cache, data.GetBytes(), - data.GetByteSize(), error, &load_addr); + target_sp->ReadMemory(*addr_ptr, data.GetBytes(), data.GetByteSize(), + error, force_live_memory, &load_addr); const bool data_from_file = load_addr == LLDB_INVALID_ADDRESS; sb_instructions.SetDisassembler(Disassembler::DisassembleBytes( target_sp->GetArchitecture(), nullptr, flavor_string, *addr_ptr, @@ -2410,6 +2410,21 @@ lldb::addr_t SBTarget::GetStackRedZoneSize() { return 0; } +bool SBTarget::IsLoaded(const SBModule &module) const { + LLDB_RECORD_METHOD_CONST(bool, SBTarget, IsLoaded, (const lldb::SBModule &), + module); + + TargetSP target_sp(GetSP()); + if (!target_sp) + return false; + + ModuleSP module_sp(module.GetSP()); + if (!module_sp) + return false; + + return module_sp->IsLoadedInTarget(target_sp.get()); +} + lldb::SBLaunchInfo SBTarget::GetLaunchInfo() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo); @@ -2440,6 +2455,34 @@ SBEnvironment SBTarget::GetEnvironment() { return LLDB_RECORD_RESULT(SBEnvironment()); } +lldb::SBTrace SBTarget::GetTrace() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTrace, SBTarget, GetTrace); + TargetSP target_sp(GetSP()); + + if (target_sp) + return LLDB_RECORD_RESULT(SBTrace(target_sp->GetTrace())); + + return LLDB_RECORD_RESULT(SBTrace()); +} + +lldb::SBTrace SBTarget::CreateTrace(lldb::SBError &error) { + LLDB_RECORD_METHOD(lldb::SBTrace, SBTarget, CreateTrace, (lldb::SBError &), + error); + TargetSP target_sp(GetSP()); + error.Clear(); + + if (target_sp) { + if (llvm::Expected<lldb::TraceSP> trace_sp = target_sp->CreateTrace()) { + return LLDB_RECORD_RESULT(SBTrace(*trace_sp)); + } else { + error.SetErrorString(llvm::toString(trace_sp.takeError()).c_str()); + } + } else { + error.SetErrorString("missing target"); + } + return LLDB_RECORD_RESULT(SBTrace()); +} + namespace lldb_private { namespace repro { @@ -2682,6 +2725,8 @@ void RegisterMethods<SBTarget>(Registry &R) { LLDB_REGISTER_METHOD(lldb::SBValue, SBTarget, EvaluateExpression, (const char *, const lldb::SBExpressionOptions &)); LLDB_REGISTER_METHOD(lldb::addr_t, SBTarget, GetStackRedZoneSize, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBTarget, IsLoaded, + (const lldb::SBModule &)); LLDB_REGISTER_METHOD_CONST(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo, ()); LLDB_REGISTER_METHOD(void, SBTarget, SetLaunchInfo, (const lldb::SBLaunchInfo &)); @@ -2699,6 +2744,8 @@ void RegisterMethods<SBTarget>(Registry &R) { GetInstructionsWithFlavor, (lldb::addr_t, const char *, const void *, size_t)); LLDB_REGISTER_METHOD(lldb::SBEnvironment, SBTarget, GetEnvironment, ()); + LLDB_REGISTER_METHOD(lldb::SBTrace, SBTarget, GetTrace, ()); + LLDB_REGISTER_METHOD(lldb::SBTrace, SBTarget, CreateTrace, (lldb::SBError &)); } } diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index 0d50aceee5e4..e0ab8b2e9fa8 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -172,6 +172,8 @@ size_t SBThread::GetStopReasonDataCount() { case eStopReasonPlanComplete: case eStopReasonThreadExiting: case eStopReasonInstrumentation: + case eStopReasonProcessorTrace: + case eStopReasonVForkDone: // There is no data for these stop reasons. return 0; @@ -194,6 +196,12 @@ size_t SBThread::GetStopReasonDataCount() { case eStopReasonException: return 1; + + case eStopReasonFork: + return 1; + + case eStopReasonVFork: + return 1; } } } @@ -223,6 +231,8 @@ uint64_t SBThread::GetStopReasonDataAtIndex(uint32_t idx) { case eStopReasonPlanComplete: case eStopReasonThreadExiting: case eStopReasonInstrumentation: + case eStopReasonProcessorTrace: + case eStopReasonVForkDone: // There is no data for these stop reasons. return 0; @@ -256,6 +266,12 @@ uint64_t SBThread::GetStopReasonDataAtIndex(uint32_t idx) { case eStopReasonException: return stop_info_sp->GetValue(); + + case eStopReasonFork: + return stop_info_sp->GetValue(); + + case eStopReasonVFork: + return stop_info_sp->GetValue(); } } } @@ -841,12 +857,13 @@ SBError SBThread::StepOverUntil(lldb::SBFrame &sb_frame, std::vector<addr_t> step_over_until_addrs; const bool abort_other_plans = false; const bool stop_other_threads = false; - const bool check_inlines = true; - const bool exact = false; + // TODO: Handle SourceLocationSpec column information + SourceLocationSpec location_spec( + step_file_spec, line, /*column=*/llvm::None, /*check_inlines=*/true, + /*exact_match=*/false); SymbolContextList sc_list; - frame_sc.comp_unit->ResolveSymbolContext(step_file_spec, line, - check_inlines, exact, + frame_sc.comp_unit->ResolveSymbolContext(location_spec, eSymbolContextLineEntry, sc_list); const uint32_t num_matches = sc_list.GetSize(); if (num_matches > 0) { diff --git a/lldb/source/API/SBTrace.cpp b/lldb/source/API/SBTrace.cpp index 3fdabaa29ac2..079c33a562c0 100644 --- a/lldb/source/API/SBTrace.cpp +++ b/lldb/source/API/SBTrace.cpp @@ -9,123 +9,88 @@ #include "SBReproducerPrivate.h" #include "lldb/Target/Process.h" +#include "lldb/API/SBStructuredData.h" +#include "lldb/API/SBThread.h" #include "lldb/API/SBTrace.h" -#include "lldb/API/SBTraceOptions.h" + +#include "lldb/Core/StructuredDataImpl.h" #include <memory> using namespace lldb; using namespace lldb_private; -class TraceImpl { -public: - lldb::user_id_t uid; -}; - -lldb::ProcessSP SBTrace::GetSP() const { return m_opaque_wp.lock(); } - -size_t SBTrace::GetTraceData(SBError &error, void *buf, size_t size, - size_t offset, lldb::tid_t thread_id) { - LLDB_RECORD_DUMMY(size_t, SBTrace, GetTraceData, - (lldb::SBError &, void *, size_t, size_t, lldb::tid_t), - error, buf, size, offset, thread_id); +SBTrace::SBTrace() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTrace); } - ProcessSP process_sp(GetSP()); - llvm::MutableArrayRef<uint8_t> buffer(static_cast<uint8_t *>(buf), size); - error.Clear(); - - if (!process_sp) { - error.SetErrorString("invalid process"); - } else { - error.SetError( - process_sp->GetData(GetTraceUID(), thread_id, buffer, offset)); - } - return buffer.size(); +SBTrace::SBTrace(const lldb::TraceSP &trace_sp) : m_opaque_sp(trace_sp) { + LLDB_RECORD_CONSTRUCTOR(SBTrace, (const lldb::TraceSP &), trace_sp); } -size_t SBTrace::GetMetaData(SBError &error, void *buf, size_t size, - size_t offset, lldb::tid_t thread_id) { - LLDB_RECORD_DUMMY(size_t, SBTrace, GetMetaData, - (lldb::SBError &, void *, size_t, size_t, lldb::tid_t), - error, buf, size, offset, thread_id); - - ProcessSP process_sp(GetSP()); - llvm::MutableArrayRef<uint8_t> buffer(static_cast<uint8_t *>(buf), size); - error.Clear(); - - if (!process_sp) { - error.SetErrorString("invalid process"); - } else { - error.SetError( - process_sp->GetMetaData(GetTraceUID(), thread_id, buffer, offset)); - } - return buffer.size(); +const char *SBTrace::GetStartConfigurationHelp() { + LLDB_RECORD_METHOD_NO_ARGS(const char *, SBTrace, GetStartConfigurationHelp); + return LLDB_RECORD_RESULT( + m_opaque_sp ? m_opaque_sp->GetStartConfigurationHelp() : nullptr); } -void SBTrace::StopTrace(SBError &error, lldb::tid_t thread_id) { - LLDB_RECORD_METHOD(void, SBTrace, StopTrace, (lldb::SBError &, lldb::tid_t), - error, thread_id); - - ProcessSP process_sp(GetSP()); - error.Clear(); - - if (!process_sp) { - error.SetErrorString("invalid process"); - return; - } - error.SetError(process_sp->StopTrace(GetTraceUID(), thread_id)); +SBError SBTrace::Start(const SBStructuredData &configuration) { + LLDB_RECORD_METHOD(SBError, SBTrace, Start, (const SBStructuredData &), + configuration); + SBError error; + if (!m_opaque_sp) + error.SetErrorString("error: invalid trace"); + else if (llvm::Error err = + m_opaque_sp->Start(configuration.m_impl_up->GetObjectSP())) + error.SetErrorString(llvm::toString(std::move(err)).c_str()); + return LLDB_RECORD_RESULT(error); } -void SBTrace::GetTraceConfig(SBTraceOptions &options, SBError &error) { - LLDB_RECORD_METHOD(void, SBTrace, GetTraceConfig, - (lldb::SBTraceOptions &, lldb::SBError &), options, error); - - ProcessSP process_sp(GetSP()); - error.Clear(); +SBError SBTrace::Start(const SBThread &thread, + const SBStructuredData &configuration) { + LLDB_RECORD_METHOD(SBError, SBTrace, Start, + (const SBThread &, const SBStructuredData &), thread, + configuration); - if (!process_sp) { - error.SetErrorString("invalid process"); - } else { - error.SetError(process_sp->GetTraceConfig(GetTraceUID(), - *(options.m_traceoptions_sp))); + SBError error; + if (!m_opaque_sp) + error.SetErrorString("error: invalid trace"); + else { + if (llvm::Error err = + m_opaque_sp->Start(std::vector<lldb::tid_t>{thread.GetThreadID()}, + configuration.m_impl_up->GetObjectSP())) + error.SetErrorString(llvm::toString(std::move(err)).c_str()); } -} - -lldb::user_id_t SBTrace::GetTraceUID() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::user_id_t, SBTrace, GetTraceUID); - if (m_trace_impl_sp) - return m_trace_impl_sp->uid; - return LLDB_INVALID_UID; + return LLDB_RECORD_RESULT(error); } -void SBTrace::SetTraceUID(lldb::user_id_t uid) { - if (m_trace_impl_sp) - m_trace_impl_sp->uid = uid; +SBError SBTrace::Stop() { + LLDB_RECORD_METHOD_NO_ARGS(SBError, SBTrace, Stop); + SBError error; + if (!m_opaque_sp) + error.SetErrorString("error: invalid trace"); + else if (llvm::Error err = m_opaque_sp->Stop()) + error.SetErrorString(llvm::toString(std::move(err)).c_str()); + return LLDB_RECORD_RESULT(error); } -SBTrace::SBTrace() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTrace); - - m_trace_impl_sp = std::make_shared<TraceImpl>(); - if (m_trace_impl_sp) - m_trace_impl_sp->uid = LLDB_INVALID_UID; +SBError SBTrace::Stop(const SBThread &thread) { + LLDB_RECORD_METHOD(SBError, SBTrace, Stop, (const SBThread &), thread); + SBError error; + if (!m_opaque_sp) + error.SetErrorString("error: invalid trace"); + else if (llvm::Error err = m_opaque_sp->Stop({thread.GetThreadID()})) + error.SetErrorString(llvm::toString(std::move(err)).c_str()); + return LLDB_RECORD_RESULT(error); } -void SBTrace::SetSP(const ProcessSP &process_sp) { m_opaque_wp = process_sp; } - bool SBTrace::IsValid() { LLDB_RECORD_METHOD_NO_ARGS(bool, SBTrace, IsValid); return this->operator bool(); } + SBTrace::operator bool() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTrace, operator bool); - - if (!m_trace_impl_sp) - return false; - if (!GetSP()) - return false; - return true; + return (bool)m_opaque_sp; } namespace lldb_private { @@ -133,13 +98,15 @@ namespace repro { template <> void RegisterMethods<SBTrace>(Registry &R) { - LLDB_REGISTER_METHOD(void, SBTrace, StopTrace, - (lldb::SBError &, lldb::tid_t)); - LLDB_REGISTER_METHOD(void, SBTrace, GetTraceConfig, - (lldb::SBTraceOptions &, lldb::SBError &)); - LLDB_REGISTER_METHOD(lldb::user_id_t, SBTrace, GetTraceUID, ()); LLDB_REGISTER_CONSTRUCTOR(SBTrace, ()); + LLDB_REGISTER_CONSTRUCTOR(SBTrace, (const lldb::TraceSP &)); + LLDB_REGISTER_METHOD(SBError, SBTrace, Start, (const SBStructuredData &)); + LLDB_REGISTER_METHOD(SBError, SBTrace, Start, + (const SBThread &, const SBStructuredData &)); + LLDB_REGISTER_METHOD(SBError, SBTrace, Stop, (const SBThread &)); + LLDB_REGISTER_METHOD(SBError, SBTrace, Stop, ()); LLDB_REGISTER_METHOD(bool, SBTrace, IsValid, ()); + LLDB_REGISTER_METHOD(const char *, SBTrace, GetStartConfigurationHelp, ()); LLDB_REGISTER_METHOD_CONST(bool, SBTrace, operator bool, ()); } diff --git a/lldb/source/API/SBTraceOptions.cpp b/lldb/source/API/SBTraceOptions.cpp deleted file mode 100644 index f1f5a63edf06..000000000000 --- a/lldb/source/API/SBTraceOptions.cpp +++ /dev/null @@ -1,159 +0,0 @@ -//===-- SBTraceOptions.cpp ------------------------------------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include "lldb/API/SBTraceOptions.h" -#include "SBReproducerPrivate.h" -#include "lldb/API/SBError.h" -#include "lldb/API/SBStructuredData.h" -#include "lldb/Core/StructuredDataImpl.h" -#include "lldb/Utility/Log.h" -#include "lldb/Utility/TraceOptions.h" - -#include <memory> - -using namespace lldb; -using namespace lldb_private; - -SBTraceOptions::SBTraceOptions() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTraceOptions); - - m_traceoptions_sp = std::make_shared<TraceOptions>(); -} - -lldb::TraceType SBTraceOptions::getType() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::TraceType, SBTraceOptions, getType); - - if (m_traceoptions_sp) - return m_traceoptions_sp->getType(); - return lldb::TraceType::eTraceTypeNone; -} - -uint64_t SBTraceOptions::getTraceBufferSize() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint64_t, SBTraceOptions, - getTraceBufferSize); - - if (m_traceoptions_sp) - return m_traceoptions_sp->getTraceBufferSize(); - return 0; -} - -lldb::SBStructuredData SBTraceOptions::getTraceParams(lldb::SBError &error) { - LLDB_RECORD_METHOD(lldb::SBStructuredData, SBTraceOptions, getTraceParams, - (lldb::SBError &), error); - - error.Clear(); - const lldb_private::StructuredData::DictionarySP dict_obj = - m_traceoptions_sp->getTraceParams(); - lldb::SBStructuredData structData; - if (dict_obj && structData.m_impl_up) - structData.m_impl_up->SetObjectSP(dict_obj->shared_from_this()); - else - error.SetErrorString("Empty trace params"); - return LLDB_RECORD_RESULT(structData); -} - -uint64_t SBTraceOptions::getMetaDataBufferSize() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(uint64_t, SBTraceOptions, - getMetaDataBufferSize); - - if (m_traceoptions_sp) - return m_traceoptions_sp->getTraceBufferSize(); - return 0; -} - -void SBTraceOptions::setTraceParams(lldb::SBStructuredData ¶ms) { - LLDB_RECORD_METHOD(void, SBTraceOptions, setTraceParams, - (lldb::SBStructuredData &), params); - - if (m_traceoptions_sp && params.m_impl_up) { - StructuredData::ObjectSP obj_sp = params.m_impl_up->GetObjectSP(); - if (obj_sp && obj_sp->GetAsDictionary() != nullptr) - m_traceoptions_sp->setTraceParams( - std::static_pointer_cast<StructuredData::Dictionary>(obj_sp)); - } - return; -} - -void SBTraceOptions::setType(lldb::TraceType type) { - LLDB_RECORD_METHOD(void, SBTraceOptions, setType, (lldb::TraceType), type); - - if (m_traceoptions_sp) - m_traceoptions_sp->setType(type); -} - -void SBTraceOptions::setTraceBufferSize(uint64_t size) { - LLDB_RECORD_METHOD(void, SBTraceOptions, setTraceBufferSize, (uint64_t), - size); - - if (m_traceoptions_sp) - m_traceoptions_sp->setTraceBufferSize(size); -} - -void SBTraceOptions::setMetaDataBufferSize(uint64_t size) { - LLDB_RECORD_METHOD(void, SBTraceOptions, setMetaDataBufferSize, (uint64_t), - size); - - if (m_traceoptions_sp) - m_traceoptions_sp->setMetaDataBufferSize(size); -} - -bool SBTraceOptions::IsValid() { - LLDB_RECORD_METHOD_NO_ARGS(bool, SBTraceOptions, IsValid); - return this->operator bool(); -} -SBTraceOptions::operator bool() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTraceOptions, operator bool); - - if (m_traceoptions_sp) - return true; - return false; -} - -void SBTraceOptions::setThreadID(lldb::tid_t thread_id) { - LLDB_RECORD_METHOD(void, SBTraceOptions, setThreadID, (lldb::tid_t), - thread_id); - - if (m_traceoptions_sp) - m_traceoptions_sp->setThreadID(thread_id); -} - -lldb::tid_t SBTraceOptions::getThreadID() { - LLDB_RECORD_METHOD_NO_ARGS(lldb::tid_t, SBTraceOptions, getThreadID); - - if (m_traceoptions_sp) - return m_traceoptions_sp->getThreadID(); - return LLDB_INVALID_THREAD_ID; -} - -namespace lldb_private { -namespace repro { - -template <> -void RegisterMethods<SBTraceOptions>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBTraceOptions, ()); - LLDB_REGISTER_METHOD_CONST(lldb::TraceType, SBTraceOptions, getType, ()); - LLDB_REGISTER_METHOD_CONST(uint64_t, SBTraceOptions, getTraceBufferSize, - ()); - LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBTraceOptions, getTraceParams, - (lldb::SBError &)); - LLDB_REGISTER_METHOD_CONST(uint64_t, SBTraceOptions, getMetaDataBufferSize, - ()); - LLDB_REGISTER_METHOD(void, SBTraceOptions, setTraceParams, - (lldb::SBStructuredData &)); - LLDB_REGISTER_METHOD(void, SBTraceOptions, setType, (lldb::TraceType)); - LLDB_REGISTER_METHOD(void, SBTraceOptions, setTraceBufferSize, (uint64_t)); - LLDB_REGISTER_METHOD(void, SBTraceOptions, setMetaDataBufferSize, - (uint64_t)); - LLDB_REGISTER_METHOD(bool, SBTraceOptions, IsValid, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBTraceOptions, operator bool, ()); - LLDB_REGISTER_METHOD(void, SBTraceOptions, setThreadID, (lldb::tid_t)); - LLDB_REGISTER_METHOD(lldb::tid_t, SBTraceOptions, getThreadID, ()); -} - -} -} diff --git a/lldb/source/API/SBTypeCategory.cpp b/lldb/source/API/SBTypeCategory.cpp index 9ce1a57ec4f7..e7432959b260 100644 --- a/lldb/source/API/SBTypeCategory.cpp +++ b/lldb/source/API/SBTypeCategory.cpp @@ -363,9 +363,7 @@ bool SBTypeCategory::AddTypeFormat(SBTypeNameSpecifier type_name, if (type_name.IsRegex()) m_opaque_sp->GetRegexTypeFormatsContainer()->Add( - RegularExpression( - llvm::StringRef::withNullAsEmpty(type_name.GetName())), - format.GetSP()); + RegularExpression(type_name.GetName()), format.GetSP()); else m_opaque_sp->GetTypeFormatsContainer()->Add( ConstString(type_name.GetName()), format.GetSP()); @@ -442,9 +440,7 @@ bool SBTypeCategory::AddTypeSummary(SBTypeNameSpecifier type_name, if (type_name.IsRegex()) m_opaque_sp->GetRegexTypeSummariesContainer()->Add( - RegularExpression( - llvm::StringRef::withNullAsEmpty(type_name.GetName())), - summary.GetSP()); + RegularExpression(type_name.GetName()), summary.GetSP()); else m_opaque_sp->GetTypeSummariesContainer()->Add( ConstString(type_name.GetName()), summary.GetSP()); @@ -487,9 +483,7 @@ bool SBTypeCategory::AddTypeFilter(SBTypeNameSpecifier type_name, if (type_name.IsRegex()) m_opaque_sp->GetRegexTypeFiltersContainer()->Add( - RegularExpression( - llvm::StringRef::withNullAsEmpty(type_name.GetName())), - filter.GetSP()); + RegularExpression(type_name.GetName()), filter.GetSP()); else m_opaque_sp->GetTypeFiltersContainer()->Add( ConstString(type_name.GetName()), filter.GetSP()); @@ -566,9 +560,7 @@ bool SBTypeCategory::AddTypeSynthetic(SBTypeNameSpecifier type_name, if (type_name.IsRegex()) m_opaque_sp->GetRegexTypeSyntheticsContainer()->Add( - RegularExpression( - llvm::StringRef::withNullAsEmpty(type_name.GetName())), - synth.GetSP()); + RegularExpression(type_name.GetName()), synth.GetSP()); else m_opaque_sp->GetTypeSyntheticsContainer()->Add( ConstString(type_name.GetName()), synth.GetSP()); diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 0a95cf41263d..9faee102c5e3 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -17,6 +17,7 @@ #include "lldb/API/SBTypeSynthetic.h" #include "lldb/Breakpoint/Watchpoint.h" +#include "lldb/Core/Declaration.h" #include "lldb/Core/Module.h" #include "lldb/Core/Section.h" #include "lldb/Core/StreamFile.h" @@ -25,7 +26,6 @@ #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/DataFormatters/DataVisualization.h" #include "lldb/Symbol/Block.h" -#include "lldb/Symbol/Declaration.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Type.h" #include "lldb/Symbol/Variable.h" diff --git a/lldb/source/API/SBVariablesOptions.cpp b/lldb/source/API/SBVariablesOptions.cpp index 4ef16364e628..1af582a0c3d7 100644 --- a/lldb/source/API/SBVariablesOptions.cpp +++ b/lldb/source/API/SBVariablesOptions.cpp @@ -21,9 +21,7 @@ public: VariablesOptionsImpl() : 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) {} + m_include_runtime_support_values(false) {} VariablesOptionsImpl(const VariablesOptionsImpl &) = default; @@ -75,8 +73,9 @@ 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; + LazyBool m_include_recognized_arguments = + eLazyBoolCalculate; // can be overridden with a setting + lldb::DynamicValueType m_use_dynamic = lldb::eNoDynamicValues; }; SBVariablesOptions::SBVariablesOptions() diff --git a/lldb/source/API/SystemInitializerFull.cpp b/lldb/source/API/SystemInitializerFull.cpp index 0530f94580b3..cc6cb6925bd0 100644 --- a/lldb/source/API/SystemInitializerFull.cpp +++ b/lldb/source/API/SystemInitializerFull.cpp @@ -17,6 +17,7 @@ #include "lldb/Target/ProcessTrace.h" #include "lldb/Utility/Reproducer.h" #include "lldb/Utility/Timer.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/TargetSelect.h" #pragma clang diagnostic push @@ -29,9 +30,22 @@ #define LLDB_PLUGIN(p) LLDB_PLUGIN_DECLARE(p) #include "Plugins/Plugins.def" +#if LLDB_ENABLE_PYTHON +#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h" + +constexpr lldb_private::HostInfo::SharedLibraryDirectoryHelper + *g_shlib_dir_helper = + lldb_private::ScriptInterpreterPython::SharedLibraryDirectoryHelper; + +#else +constexpr lldb_private::HostInfo::SharedLibraryDirectoryHelper + *g_shlib_dir_helper = 0; +#endif + using namespace lldb_private; -SystemInitializerFull::SystemInitializerFull() = default; +SystemInitializerFull::SystemInitializerFull() + : SystemInitializerCommon(g_shlib_dir_helper) {} SystemInitializerFull::~SystemInitializerFull() = default; llvm::Error SystemInitializerFull::Initialize() { @@ -51,6 +65,13 @@ llvm::Error SystemInitializerFull::Initialize() { llvm::InitializeAllAsmPrinters(); llvm::InitializeAllTargetMCs(); llvm::InitializeAllDisassemblers(); + // Initialize the command line parser in LLVM. This usually isn't necessary + // as we aren't dealing with command line options here, but otherwise some + // other code in Clang/LLVM might be tempted to call this function from a + // different thread later on which won't work (as the function isn't + // thread-safe). + const char *arg0 = "lldb"; + llvm::cl::ParseCommandLineOptions(1, &arg0); #define LLDB_PLUGIN(p) LLDB_PLUGIN_INITIALIZE(p); #include "Plugins/Plugins.def" |
