diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 |
commit | cfca06d7963fa0909f90483b42a6d7d194d01e08 (patch) | |
tree | 209fb2a2d68f8f277793fc8df46c753d31bc853b /lldb/source/API | |
parent | 706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff) |
Notes
Diffstat (limited to 'lldb/source/API')
75 files changed, 1186 insertions, 1003 deletions
diff --git a/lldb/source/API/SBAddress.cpp b/lldb/source/API/SBAddress.cpp index dcde25b779172..6444a006c0ff4 100644 --- a/lldb/source/API/SBAddress.cpp +++ b/lldb/source/API/SBAddress.cpp @@ -1,4 +1,4 @@ -//===-- SBAddress.cpp -------------------------------------------*- C++ -*-===// +//===-- SBAddress.cpp -----------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -52,7 +52,7 @@ SBAddress::SBAddress(lldb::addr_t load_addr, lldb::SBTarget &target) SetLoadAddress(load_addr, target); } -SBAddress::~SBAddress() {} +SBAddress::~SBAddress() = default; const SBAddress &SBAddress::operator=(const SBAddress &rhs) { LLDB_RECORD_METHOD(const lldb::SBAddress &, @@ -89,7 +89,7 @@ SBAddress::operator bool() const { void SBAddress::Clear() { LLDB_RECORD_METHOD_NO_ARGS(void, SBAddress, Clear); - m_opaque_up.reset(new Address()); + m_opaque_up = std::make_unique<Address>(); } void SBAddress::SetAddress(lldb::SBSection section, lldb::addr_t offset) { @@ -105,7 +105,7 @@ void SBAddress::SetAddress(const Address *lldb_object_ptr) { if (lldb_object_ptr) ref() = *lldb_object_ptr; else - m_opaque_up.reset(new Address()); + m_opaque_up = std::make_unique<Address>(); } lldb::addr_t SBAddress::GetFileAddress() const { @@ -187,7 +187,7 @@ const Address *SBAddress::operator->() const { return m_opaque_up.get(); } Address &SBAddress::ref() { if (m_opaque_up == nullptr) - m_opaque_up.reset(new Address()); + m_opaque_up = std::make_unique<Address>(); return *m_opaque_up; } diff --git a/lldb/source/API/SBAttachInfo.cpp b/lldb/source/API/SBAttachInfo.cpp index 838385c104ae6..b21589cf27081 100644 --- a/lldb/source/API/SBAttachInfo.cpp +++ b/lldb/source/API/SBAttachInfo.cpp @@ -1,4 +1,4 @@ -//===-- SBAttachInfo.cpp ----------------------------------------*- C++ -*-===// +//===-- SBAttachInfo.cpp --------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -54,7 +54,7 @@ SBAttachInfo::SBAttachInfo(const SBAttachInfo &rhs) m_opaque_sp = clone(rhs.m_opaque_sp); } -SBAttachInfo::~SBAttachInfo() {} +SBAttachInfo::~SBAttachInfo() = default; lldb_private::ProcessAttachInfo &SBAttachInfo::ref() { return *m_opaque_sp; } diff --git a/lldb/source/API/SBBlock.cpp b/lldb/source/API/SBBlock.cpp index f333d1d7b5f32..a5fee445d5c6a 100644 --- a/lldb/source/API/SBBlock.cpp +++ b/lldb/source/API/SBBlock.cpp @@ -1,4 +1,4 @@ -//===-- SBBlock.cpp ---------------------------------------------*- C++ -*-===// +//===-- SBBlock.cpp -------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -71,13 +71,7 @@ const char *SBBlock::GetInlinedName() const { const InlineFunctionInfo *inlined_info = m_opaque_ptr->GetInlinedFunctionInfo(); if (inlined_info) { - Function *function = m_opaque_ptr->CalculateSymbolContextFunction(); - LanguageType language; - if (function) - language = function->GetLanguage(); - else - language = lldb::eLanguageTypeUnknown; - return inlined_info->GetName(language).AsCString(nullptr); + return inlined_info->GetName().AsCString(nullptr); } } return nullptr; diff --git a/lldb/source/API/SBBreakpoint.cpp b/lldb/source/API/SBBreakpoint.cpp index 8159b851d58cc..eb75bf8b33f43 100644 --- a/lldb/source/API/SBBreakpoint.cpp +++ b/lldb/source/API/SBBreakpoint.cpp @@ -1,4 +1,4 @@ -//===-- SBBreakpoint.cpp ----------------------------------------*- C++ -*-===// +//===-- SBBreakpoint.cpp --------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -652,19 +652,28 @@ SBError SBBreakpoint::SetScriptCallbackBody(const char *callback_body_text) { bool SBBreakpoint::AddName(const char *new_name) { LLDB_RECORD_METHOD(bool, SBBreakpoint, AddName, (const char *), new_name); + SBError status = AddNameWithErrorHandling(new_name); + return status.Success(); +} + +SBError SBBreakpoint::AddNameWithErrorHandling(const char *new_name) { + LLDB_RECORD_METHOD(SBError, SBBreakpoint, AddNameWithErrorHandling, + (const char *), new_name); + BreakpointSP bkpt_sp = GetSP(); + SBError status; if (bkpt_sp) { std::lock_guard<std::recursive_mutex> guard( bkpt_sp->GetTarget().GetAPIMutex()); - Status error; // Think I'm just going to swallow the error here, it's - // probably more annoying to have to provide it. + Status error; bkpt_sp->GetTarget().AddNameToBreakpoint(bkpt_sp, new_name, error); - if (error.Fail()) - return false; + status.SetError(error); + } else { + status.SetErrorString("invalid breakpoint"); } - return true; + return LLDB_RECORD_RESULT(status); } void SBBreakpoint::RemoveName(const char *name_to_remove) { @@ -873,7 +882,7 @@ SBBreakpointList::SBBreakpointList(SBTarget &target) LLDB_RECORD_CONSTRUCTOR(SBBreakpointList, (lldb::SBTarget &), target); } -SBBreakpointList::~SBBreakpointList() {} +SBBreakpointList::~SBBreakpointList() = default; size_t SBBreakpointList::GetSize() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBBreakpointList, GetSize); @@ -1015,6 +1024,8 @@ void RegisterMethods<SBBreakpoint>(Registry &R) { LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, SetScriptCallbackBody, (const char *)); LLDB_REGISTER_METHOD(bool, SBBreakpoint, AddName, (const char *)); + LLDB_REGISTER_METHOD(lldb::SBError, SBBreakpoint, AddNameWithErrorHandling, + (const char *)); LLDB_REGISTER_METHOD(void, SBBreakpoint, RemoveName, (const char *)); LLDB_REGISTER_METHOD(bool, SBBreakpoint, MatchesName, (const char *)); LLDB_REGISTER_METHOD(void, SBBreakpoint, GetNames, (lldb::SBStringList &)); diff --git a/lldb/source/API/SBBreakpointLocation.cpp b/lldb/source/API/SBBreakpointLocation.cpp index 2b62a69a21ef4..e29f3fd9c50e2 100644 --- a/lldb/source/API/SBBreakpointLocation.cpp +++ b/lldb/source/API/SBBreakpointLocation.cpp @@ -1,4 +1,4 @@ -//===-- SBBreakpointLocation.cpp --------------------------------*- C++ -*-===// +//===-- SBBreakpointLocation.cpp ------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -59,7 +59,7 @@ operator=(const SBBreakpointLocation &rhs) { return LLDB_RECORD_RESULT(*this); } -SBBreakpointLocation::~SBBreakpointLocation() {} +SBBreakpointLocation::~SBBreakpointLocation() = default; BreakpointLocationSP SBBreakpointLocation::GetSP() const { return m_opaque_wp.lock(); diff --git a/lldb/source/API/SBBreakpointName.cpp b/lldb/source/API/SBBreakpointName.cpp index 5bd7732ebb60b..3995defcf97c2 100644 --- a/lldb/source/API/SBBreakpointName.cpp +++ b/lldb/source/API/SBBreakpointName.cpp @@ -1,4 +1,4 @@ -//===-- SBBreakpointName.cpp ----------------------------------------*- C++ -*-===// +//===-- SBBreakpointName.cpp ----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -115,7 +115,7 @@ SBBreakpointName::SBBreakpointName(SBTarget &sb_target, const char *name) { LLDB_RECORD_CONSTRUCTOR(SBBreakpointName, (lldb::SBTarget &, const char *), sb_target, name); - m_impl_up.reset(new SBBreakpointNameImpl(sb_target, name)); + m_impl_up = std::make_unique<SBBreakpointNameImpl>(sb_target, name); // Call FindBreakpointName here to make sure the name is valid, reset if not: BreakpointName *bp_name = GetBreakpointName(); if (!bp_name) @@ -133,7 +133,8 @@ SBBreakpointName::SBBreakpointName(SBBreakpoint &sb_bkpt, const char *name) { BreakpointSP bkpt_sp = sb_bkpt.GetSP(); Target &target = bkpt_sp->GetTarget(); - m_impl_up.reset(new SBBreakpointNameImpl(target.shared_from_this(), name)); + m_impl_up = + std::make_unique<SBBreakpointNameImpl>(target.shared_from_this(), name); // Call FindBreakpointName here to make sure the name is valid, reset if not: BreakpointName *bp_name = GetBreakpointName(); @@ -154,8 +155,8 @@ SBBreakpointName::SBBreakpointName(const SBBreakpointName &rhs) { if (!rhs.m_impl_up) return; else - m_impl_up.reset(new SBBreakpointNameImpl(rhs.m_impl_up->GetTarget(), - rhs.m_impl_up->GetName())); + m_impl_up = std::make_unique<SBBreakpointNameImpl>( + rhs.m_impl_up->GetTarget(), rhs.m_impl_up->GetName()); } SBBreakpointName::~SBBreakpointName() = default; @@ -171,8 +172,8 @@ operator=(const SBBreakpointName &rhs) { return LLDB_RECORD_RESULT(*this); } - m_impl_up.reset(new SBBreakpointNameImpl(rhs.m_impl_up->GetTarget(), - rhs.m_impl_up->GetName())); + m_impl_up = std::make_unique<SBBreakpointNameImpl>(rhs.m_impl_up->GetTarget(), + rhs.m_impl_up->GetName()); return LLDB_RECORD_RESULT(*this); } diff --git a/lldb/source/API/SBBreakpointOptionCommon.cpp b/lldb/source/API/SBBreakpointOptionCommon.cpp index 870b4b941ada6..2ee47ff7795c6 100644 --- a/lldb/source/API/SBBreakpointOptionCommon.cpp +++ b/lldb/source/API/SBBreakpointOptionCommon.cpp @@ -1,4 +1,4 @@ -//===-- SBBreakpointOptionCommon.cpp --------------------------------*- C++ -*-===// +//===-- SBBreakpointOptionCommon.cpp --------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/lldb/source/API/SBBreakpointOptionCommon.h b/lldb/source/API/SBBreakpointOptionCommon.h index 52049e4e7588c..0ceb90290de53 100644 --- a/lldb/source/API/SBBreakpointOptionCommon.h +++ b/lldb/source/API/SBBreakpointOptionCommon.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_SBBreakpointOptionCommons_h_ -#define LLDB_SBBreakpointOptionCommons_h_ +#ifndef LLDB_SOURCE_API_SBBREAKPOINTOPTIONCOMMON_H +#define LLDB_SOURCE_API_SBBREAKPOINTOPTIONCOMMON_H #include "lldb/API/SBDefines.h" #include "lldb/Utility/Baton.h" @@ -33,4 +33,4 @@ public: }; } // namespace lldb -#endif // LLDB_SBBreakpointOptionCommons_h_ +#endif // LLDB_SOURCE_API_SBBREAKPOINTOPTIONCOMMON_H diff --git a/lldb/source/API/SBBroadcaster.cpp b/lldb/source/API/SBBroadcaster.cpp index e1efdf7baf61f..d42d7ce2a536a 100644 --- a/lldb/source/API/SBBroadcaster.cpp +++ b/lldb/source/API/SBBroadcaster.cpp @@ -1,4 +1,4 @@ -//===-- SBBroadcaster.cpp ---------------------------------------*- C++ -*-===// +//===-- SBBroadcaster.cpp -------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/lldb/source/API/SBCommandInterpreter.cpp b/lldb/source/API/SBCommandInterpreter.cpp index 6e5ebe6a7ded7..f4f19577b36c5 100644 --- a/lldb/source/API/SBCommandInterpreter.cpp +++ b/lldb/source/API/SBCommandInterpreter.cpp @@ -1,4 +1,4 @@ -//===-- SBCommandInterpreter.cpp --------------------------------*- C++ -*-===// +//===-- SBCommandInterpreter.cpp ------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -17,6 +17,7 @@ #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBCommandInterpreter.h" +#include "lldb/API/SBCommandInterpreterRunOptions.h" #include "lldb/API/SBCommandReturnObject.h" #include "lldb/API/SBEvent.h" #include "lldb/API/SBExecutionContext.h" @@ -31,122 +32,6 @@ using namespace lldb; using namespace lldb_private; -SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions() { - LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommandInterpreterRunOptions); - - m_opaque_up.reset(new CommandInterpreterRunOptions()); -} - -SBCommandInterpreterRunOptions::~SBCommandInterpreterRunOptions() = default; - -bool SBCommandInterpreterRunOptions::GetStopOnContinue() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, - GetStopOnContinue); - - return m_opaque_up->GetStopOnContinue(); -} - -void SBCommandInterpreterRunOptions::SetStopOnContinue(bool stop_on_continue) { - LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnContinue, - (bool), stop_on_continue); - - m_opaque_up->SetStopOnContinue(stop_on_continue); -} - -bool SBCommandInterpreterRunOptions::GetStopOnError() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, - GetStopOnError); - - return m_opaque_up->GetStopOnError(); -} - -void SBCommandInterpreterRunOptions::SetStopOnError(bool stop_on_error) { - LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnError, - (bool), stop_on_error); - - m_opaque_up->SetStopOnError(stop_on_error); -} - -bool SBCommandInterpreterRunOptions::GetStopOnCrash() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, - GetStopOnCrash); - - return m_opaque_up->GetStopOnCrash(); -} - -void SBCommandInterpreterRunOptions::SetStopOnCrash(bool stop_on_crash) { - LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnCrash, - (bool), stop_on_crash); - - m_opaque_up->SetStopOnCrash(stop_on_crash); -} - -bool SBCommandInterpreterRunOptions::GetEchoCommands() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, - GetEchoCommands); - - return m_opaque_up->GetEchoCommands(); -} - -void SBCommandInterpreterRunOptions::SetEchoCommands(bool echo_commands) { - LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetEchoCommands, - (bool), echo_commands); - - m_opaque_up->SetEchoCommands(echo_commands); -} - -bool SBCommandInterpreterRunOptions::GetEchoCommentCommands() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, - GetEchoCommentCommands); - - return m_opaque_up->GetEchoCommentCommands(); -} - -void SBCommandInterpreterRunOptions::SetEchoCommentCommands(bool echo) { - LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, - SetEchoCommentCommands, (bool), echo); - - m_opaque_up->SetEchoCommentCommands(echo); -} - -bool SBCommandInterpreterRunOptions::GetPrintResults() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, - GetPrintResults); - - return m_opaque_up->GetPrintResults(); -} - -void SBCommandInterpreterRunOptions::SetPrintResults(bool print_results) { - LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetPrintResults, - (bool), print_results); - - m_opaque_up->SetPrintResults(print_results); -} - -bool SBCommandInterpreterRunOptions::GetAddToHistory() const { - LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, - GetAddToHistory); - - return m_opaque_up->GetAddToHistory(); -} - -void SBCommandInterpreterRunOptions::SetAddToHistory(bool add_to_history) { - LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetAddToHistory, - (bool), add_to_history); - - m_opaque_up->SetAddToHistory(add_to_history); -} - -lldb_private::CommandInterpreterRunOptions * -SBCommandInterpreterRunOptions::get() const { - return m_opaque_up.get(); -} - -lldb_private::CommandInterpreterRunOptions & -SBCommandInterpreterRunOptions::ref() const { - return *m_opaque_up; -} - class CommandPluginInterfaceImplementation : public CommandObjectParsed { public: CommandPluginInterfaceImplementation(CommandInterpreter &interpreter, @@ -154,22 +39,41 @@ public: lldb::SBCommandPluginInterface *backend, const char *help = nullptr, const char *syntax = nullptr, - uint32_t flags = 0) + uint32_t flags = 0, + const char *auto_repeat_command = "") : CommandObjectParsed(interpreter, name, help, syntax, flags), - m_backend(backend) {} + m_backend(backend) { + m_auto_repeat_command = + auto_repeat_command == nullptr + ? llvm::None + : llvm::Optional<std::string>(auto_repeat_command); + } bool IsRemovable() const override { return true; } + /// More documentation is available in lldb::CommandObject::GetRepeatCommand, + /// but in short, if nullptr is returned, the previous command will be + /// repeated, and if an empty string is returned, no commands will be + /// executed. + const char *GetRepeatCommand(Args ¤t_command_args, + uint32_t index) override { + if (!m_auto_repeat_command) + return nullptr; + else + return m_auto_repeat_command->c_str(); + } + protected: bool DoExecute(Args &command, CommandReturnObject &result) override { SBCommandReturnObject sb_return(result); SBCommandInterpreter sb_interpreter(&m_interpreter); SBDebugger debugger_sb(m_interpreter.GetDebugger().shared_from_this()); bool ret = m_backend->DoExecute( - debugger_sb, (char **)command.GetArgumentVector(), sb_return); + debugger_sb, command.GetArgumentVector(), sb_return); return ret; } std::shared_ptr<lldb::SBCommandPluginInterface> m_backend; + llvm::Optional<std::string> m_auto_repeat_command; }; SBCommandInterpreter::SBCommandInterpreter(CommandInterpreter *interpreter) @@ -681,14 +585,8 @@ lldb::SBCommand SBCommandInterpreter::AddCommand( (const char *, lldb::SBCommandPluginInterface *, const char *), name, impl, help); - lldb::CommandObjectSP new_command_sp; - new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>( - *m_opaque_ptr, name, impl, help); - - if (new_command_sp && - m_opaque_ptr->AddUserCommand(name, new_command_sp, true)) - return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp)); - return LLDB_RECORD_RESULT(lldb::SBCommand()); + return LLDB_RECORD_RESULT(AddCommand(name, impl, help, /*syntax=*/nullptr, + /*auto_repeat_command=*/"")) } lldb::SBCommand @@ -699,10 +597,22 @@ SBCommandInterpreter::AddCommand(const char *name, (const char *, lldb::SBCommandPluginInterface *, const char *, const char *), name, impl, help, syntax); + return LLDB_RECORD_RESULT( + AddCommand(name, impl, help, syntax, /*auto_repeat_command=*/"")) +} + +lldb::SBCommand SBCommandInterpreter::AddCommand( + const char *name, lldb::SBCommandPluginInterface *impl, const char *help, + const char *syntax, const char *auto_repeat_command) { + LLDB_RECORD_METHOD(lldb::SBCommand, SBCommandInterpreter, AddCommand, + (const char *, lldb::SBCommandPluginInterface *, + const char *, const char *, const char *), + name, impl, help, syntax, auto_repeat_command); lldb::CommandObjectSP new_command_sp; new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>( - *m_opaque_ptr, name, impl, help, syntax); + *m_opaque_ptr, name, impl, help, syntax, /*flags=*/0, + auto_repeat_command); if (new_command_sp && m_opaque_ptr->AddUserCommand(name, new_command_sp, true)) @@ -783,17 +693,8 @@ lldb::SBCommand SBCommand::AddCommand(const char *name, lldb::SBCommand, SBCommand, AddCommand, (const char *, lldb::SBCommandPluginInterface *, const char *), name, impl, help); - - if (!IsValid()) - return LLDB_RECORD_RESULT(lldb::SBCommand()); - if (!m_opaque_sp->IsMultiwordObject()) - return LLDB_RECORD_RESULT(lldb::SBCommand()); - lldb::CommandObjectSP new_command_sp; - new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>( - m_opaque_sp->GetCommandInterpreter(), name, impl, help); - if (new_command_sp && m_opaque_sp->LoadSubCommand(name, new_command_sp)) - return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp)); - return LLDB_RECORD_RESULT(lldb::SBCommand()); + return LLDB_RECORD_RESULT(AddCommand(name, impl, help, /*syntax=*/nullptr, + /*auto_repeat_command=*/"")) } lldb::SBCommand SBCommand::AddCommand(const char *name, @@ -803,6 +704,18 @@ lldb::SBCommand SBCommand::AddCommand(const char *name, (const char *, lldb::SBCommandPluginInterface *, const char *, const char *), name, impl, help, syntax); + return LLDB_RECORD_RESULT( + AddCommand(name, impl, help, syntax, /*auto_repeat_command=*/"")) +} + +lldb::SBCommand SBCommand::AddCommand(const char *name, + lldb::SBCommandPluginInterface *impl, + const char *help, const char *syntax, + const char *auto_repeat_command) { + LLDB_RECORD_METHOD(lldb::SBCommand, SBCommand, AddCommand, + (const char *, lldb::SBCommandPluginInterface *, + const char *, const char *, const char *), + name, impl, help, syntax, auto_repeat_command); if (!IsValid()) return LLDB_RECORD_RESULT(lldb::SBCommand()); @@ -810,7 +723,8 @@ lldb::SBCommand SBCommand::AddCommand(const char *name, return LLDB_RECORD_RESULT(lldb::SBCommand()); lldb::CommandObjectSP new_command_sp; new_command_sp = std::make_shared<CommandPluginInterfaceImplementation>( - m_opaque_sp->GetCommandInterpreter(), name, impl, help, syntax); + m_opaque_sp->GetCommandInterpreter(), name, impl, help, syntax, + /*flags=*/0, auto_repeat_command); if (new_command_sp && m_opaque_sp->LoadSubCommand(name, new_command_sp)) return LLDB_RECORD_RESULT(lldb::SBCommand(new_command_sp)); return LLDB_RECORD_RESULT(lldb::SBCommand()); @@ -832,37 +746,7 @@ void SBCommand::SetFlags(uint32_t flags) { namespace lldb_private { namespace repro { -template <> -void RegisterMethods<SBCommandInterpreterRunOptions>(Registry &R) { - LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunOptions, ()); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, - GetStopOnContinue, ()); - LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, - SetStopOnContinue, (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, - GetStopOnError, ()); - LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnError, - (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, - GetStopOnCrash, ()); - LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnCrash, - (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, - GetEchoCommands, ()); - LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetEchoCommands, - (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, - GetEchoCommentCommands, ()); - LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, - SetEchoCommentCommands, (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, - GetPrintResults, ()); - LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetPrintResults, - (bool)); - LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, - GetAddToHistory, ()); - LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetAddToHistory, - (bool)); +template <> void RegisterMethods<SBCommandInterpreter>(Registry &R) { LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreter, (lldb_private::CommandInterpreter *)); LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreter, @@ -946,6 +830,9 @@ void RegisterMethods<SBCommandInterpreterRunOptions>(Registry &R) { LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommandInterpreter, AddCommand, (const char *, lldb::SBCommandPluginInterface *, const char *, const char *)); + LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommandInterpreter, AddCommand, + (const char *, lldb::SBCommandPluginInterface *, + const char *, const char *, const char *)); LLDB_REGISTER_CONSTRUCTOR(SBCommand, ()); LLDB_REGISTER_METHOD(bool, SBCommand, IsValid, ()); LLDB_REGISTER_METHOD_CONST(bool, SBCommand, operator bool, ()); @@ -962,9 +849,11 @@ void RegisterMethods<SBCommandInterpreterRunOptions>(Registry &R) { LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommand, AddCommand, (const char *, lldb::SBCommandPluginInterface *, const char *, const char *)); + LLDB_REGISTER_METHOD(lldb::SBCommand, SBCommand, AddCommand, + (const char *, lldb::SBCommandPluginInterface *, + const char *, const char *, const char *)); LLDB_REGISTER_METHOD(uint32_t, SBCommand, GetFlags, ()); LLDB_REGISTER_METHOD(void, SBCommand, SetFlags, (uint32_t)); } - } } diff --git a/lldb/source/API/SBCommandInterpreterRunOptions.cpp b/lldb/source/API/SBCommandInterpreterRunOptions.cpp new file mode 100644 index 0000000000000..fcfbf5e5401ae --- /dev/null +++ b/lldb/source/API/SBCommandInterpreterRunOptions.cpp @@ -0,0 +1,272 @@ +//===-- SBCommandInterpreterRunOptions.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/lldb-types.h" + +#include "SBReproducerPrivate.h" + +#include "lldb/API/SBCommandInterpreterRunOptions.h" +#include "lldb/Interpreter/CommandInterpreter.h" + +#include <memory> + +using namespace lldb; +using namespace lldb_private; + +SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions() { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommandInterpreterRunOptions); + + m_opaque_up = std::make_unique<CommandInterpreterRunOptions>(); +} + +SBCommandInterpreterRunOptions::~SBCommandInterpreterRunOptions() = default; + +bool SBCommandInterpreterRunOptions::GetStopOnContinue() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, + GetStopOnContinue); + + return m_opaque_up->GetStopOnContinue(); +} + +void SBCommandInterpreterRunOptions::SetStopOnContinue(bool stop_on_continue) { + LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnContinue, + (bool), stop_on_continue); + + m_opaque_up->SetStopOnContinue(stop_on_continue); +} + +bool SBCommandInterpreterRunOptions::GetStopOnError() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, + GetStopOnError); + + return m_opaque_up->GetStopOnError(); +} + +void SBCommandInterpreterRunOptions::SetStopOnError(bool stop_on_error) { + LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnError, + (bool), stop_on_error); + + m_opaque_up->SetStopOnError(stop_on_error); +} + +bool SBCommandInterpreterRunOptions::GetStopOnCrash() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, + GetStopOnCrash); + + return m_opaque_up->GetStopOnCrash(); +} + +void SBCommandInterpreterRunOptions::SetStopOnCrash(bool stop_on_crash) { + LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnCrash, + (bool), stop_on_crash); + + m_opaque_up->SetStopOnCrash(stop_on_crash); +} + +bool SBCommandInterpreterRunOptions::GetEchoCommands() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, + GetEchoCommands); + + return m_opaque_up->GetEchoCommands(); +} + +void SBCommandInterpreterRunOptions::SetEchoCommands(bool echo_commands) { + LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetEchoCommands, + (bool), echo_commands); + + m_opaque_up->SetEchoCommands(echo_commands); +} + +bool SBCommandInterpreterRunOptions::GetEchoCommentCommands() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, + GetEchoCommentCommands); + + return m_opaque_up->GetEchoCommentCommands(); +} + +void SBCommandInterpreterRunOptions::SetEchoCommentCommands(bool echo) { + LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, + SetEchoCommentCommands, (bool), echo); + + m_opaque_up->SetEchoCommentCommands(echo); +} + +bool SBCommandInterpreterRunOptions::GetPrintResults() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, + GetPrintResults); + + return m_opaque_up->GetPrintResults(); +} + +void SBCommandInterpreterRunOptions::SetPrintResults(bool print_results) { + LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetPrintResults, + (bool), print_results); + + m_opaque_up->SetPrintResults(print_results); +} + +bool SBCommandInterpreterRunOptions::GetAddToHistory() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, + GetAddToHistory); + + return m_opaque_up->GetAddToHistory(); +} + +void SBCommandInterpreterRunOptions::SetAddToHistory(bool add_to_history) { + LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetAddToHistory, + (bool), add_to_history); + + m_opaque_up->SetAddToHistory(add_to_history); +} + +bool SBCommandInterpreterRunOptions::GetAutoHandleEvents() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, + GetAutoHandleEvents); + + return m_opaque_up->GetAutoHandleEvents(); +} + +void SBCommandInterpreterRunOptions::SetAutoHandleEvents( + bool auto_handle_events) { + LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetAutoHandleEvents, + (bool), auto_handle_events); + + m_opaque_up->SetAutoHandleEvents(auto_handle_events); +} + +bool SBCommandInterpreterRunOptions::GetSpawnThread() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBCommandInterpreterRunOptions, + GetSpawnThread); + + return m_opaque_up->GetSpawnThread(); +} + +void SBCommandInterpreterRunOptions::SetSpawnThread(bool spawn_thread) { + LLDB_RECORD_METHOD(void, SBCommandInterpreterRunOptions, SetSpawnThread, + (bool), spawn_thread); + + m_opaque_up->SetSpawnThread(spawn_thread); +} + +lldb_private::CommandInterpreterRunOptions * +SBCommandInterpreterRunOptions::get() const { + return m_opaque_up.get(); +} + +lldb_private::CommandInterpreterRunOptions & +SBCommandInterpreterRunOptions::ref() const { + return *m_opaque_up; +} + +SBCommandInterpreterRunResult::SBCommandInterpreterRunResult() + : m_opaque_up(new CommandInterpreterRunResult()) + +{ + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommandInterpreterRunResult); +} + +SBCommandInterpreterRunResult::SBCommandInterpreterRunResult( + const SBCommandInterpreterRunResult &rhs) + : m_opaque_up(new CommandInterpreterRunResult()) { + LLDB_RECORD_CONSTRUCTOR(SBCommandInterpreterRunResult, + (const lldb::SBCommandInterpreterRunResult &), rhs); + + *m_opaque_up = *rhs.m_opaque_up; +} + +SBCommandInterpreterRunResult::SBCommandInterpreterRunResult( + const CommandInterpreterRunResult &rhs) + : m_opaque_up() { + m_opaque_up = std::make_unique<CommandInterpreterRunResult>(rhs); +} + +SBCommandInterpreterRunResult::~SBCommandInterpreterRunResult() = default; + +SBCommandInterpreterRunResult &SBCommandInterpreterRunResult::operator=( + const SBCommandInterpreterRunResult &rhs) { + LLDB_RECORD_METHOD(lldb::SBCommandInterpreterRunResult &, + SBCommandInterpreterRunResult, + operator=,(const lldb::SBCommandInterpreterRunResult &), + rhs); + + if (this == &rhs) + return *this; + *m_opaque_up = *rhs.m_opaque_up; + return LLDB_RECORD_RESULT(*this); +} + +int SBCommandInterpreterRunResult::GetNumberOfErrors() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(int, SBCommandInterpreterRunResult, + GetNumberOfErrors); + + return m_opaque_up->GetNumErrors(); +} + +lldb::CommandInterpreterResult +SBCommandInterpreterRunResult::GetResult() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::CommandInterpreterResult, + SBCommandInterpreterRunResult, GetResult); + + return m_opaque_up->GetResult(); +} + +namespace lldb_private { +namespace repro { + +template <> void RegisterMethods<SBCommandInterpreterRunOptions>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunOptions, ()); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, + GetStopOnContinue, ()); + LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnContinue, + (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, + GetStopOnError, ()); + LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnError, + (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, + GetStopOnCrash, ()); + LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetStopOnCrash, + (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, + GetEchoCommands, ()); + LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetEchoCommands, + (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, + GetEchoCommentCommands, ()); + LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, + SetEchoCommentCommands, (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, + GetPrintResults, ()); + LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetPrintResults, + (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, + GetAddToHistory, ()); + LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetAddToHistory, + (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, + GetAutoHandleEvents, ()); + LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, + SetAutoHandleEvents, (bool)); + LLDB_REGISTER_METHOD_CONST(bool, SBCommandInterpreterRunOptions, + GetSpawnThread, ()); + LLDB_REGISTER_METHOD(void, SBCommandInterpreterRunOptions, SetSpawnThread, + (bool)); + LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunResult, ()); + LLDB_REGISTER_CONSTRUCTOR(SBCommandInterpreterRunResult, + (const lldb::SBCommandInterpreterRunResult &)); + LLDB_REGISTER_METHOD(lldb::SBCommandInterpreterRunResult &, + SBCommandInterpreterRunResult, + operator=,(const lldb::SBCommandInterpreterRunResult &)); + LLDB_REGISTER_METHOD_CONST(int, SBCommandInterpreterRunResult, + GetNumberOfErrors, ()); + LLDB_REGISTER_METHOD_CONST(lldb::CommandInterpreterResult, + SBCommandInterpreterRunResult, GetResult, ()); +} + +} // namespace repro +} // namespace lldb_private diff --git a/lldb/source/API/SBCommandReturnObject.cpp b/lldb/source/API/SBCommandReturnObject.cpp index eec1383df8759..fddf90b664814 100644 --- a/lldb/source/API/SBCommandReturnObject.cpp +++ b/lldb/source/API/SBCommandReturnObject.cpp @@ -1,4 +1,4 @@ -//===-- SBCommandReturnObject.cpp -------------------------------*- C++ -*-===// +//===-- SBCommandReturnObject.cpp -----------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -22,7 +22,7 @@ using namespace lldb_private; class lldb_private::SBCommandReturnObjectImpl { public: SBCommandReturnObjectImpl() - : m_ptr(new CommandReturnObject()), m_owned(true) {} + : m_ptr(new CommandReturnObject(false)), m_owned(true) {} SBCommandReturnObjectImpl(CommandReturnObject &ref) : m_ptr(&ref), m_owned(false) {} SBCommandReturnObjectImpl(const SBCommandReturnObjectImpl &rhs) diff --git a/lldb/source/API/SBCommunication.cpp b/lldb/source/API/SBCommunication.cpp index 90df70bde72f1..d55ecd35b5570 100644 --- a/lldb/source/API/SBCommunication.cpp +++ b/lldb/source/API/SBCommunication.cpp @@ -1,4 +1,4 @@ -//===-- SBCommunication.cpp -------------------------------------*- C++ -*-===// +//===-- SBCommunication.cpp -----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -63,7 +63,7 @@ ConnectionStatus SBCommunication::Connect(const char *url) { if (m_opaque) { if (!m_opaque->HasConnection()) - m_opaque->SetConnection(Host::CreateDefaultConnection(url).release()); + m_opaque->SetConnection(Host::CreateDefaultConnection(url)); return m_opaque->Connect(url, nullptr); } return eConnectionStatusNoConnection; @@ -79,7 +79,8 @@ ConnectionStatus SBCommunication::AdoptFileDesriptor(int fd, bool owns_fd) { if (m_opaque->IsConnected()) m_opaque->Disconnect(); } - m_opaque->SetConnection(new ConnectionFileDescriptor(fd, owns_fd)); + m_opaque->SetConnection( + std::make_unique<ConnectionFileDescriptor>(fd, owns_fd)); if (m_opaque->IsConnected()) status = eConnectionStatusSuccess; else diff --git a/lldb/source/API/SBCompileUnit.cpp b/lldb/source/API/SBCompileUnit.cpp index d52040d850a95..765957d680c9c 100644 --- a/lldb/source/API/SBCompileUnit.cpp +++ b/lldb/source/API/SBCompileUnit.cpp @@ -1,4 +1,4 @@ -//===-- SBCompileUnit.cpp ---------------------------------------*- C++ -*-===// +//===-- SBCompileUnit.cpp -------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/lldb/source/API/SBData.cpp b/lldb/source/API/SBData.cpp index 528cd8d43ecce..daf313ad55c99 100644 --- a/lldb/source/API/SBData.cpp +++ b/lldb/source/API/SBData.cpp @@ -1,4 +1,4 @@ -//===-- SBData.cpp ----------------------------------------------*- C++ -*-===// +//===-- SBData.cpp --------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -41,7 +41,7 @@ const SBData &SBData::operator=(const SBData &rhs) { return LLDB_RECORD_RESULT(*this); } -SBData::~SBData() {} +SBData::~SBData() = default; void SBData::SetOpaque(const lldb::DataExtractorSP &data_sp) { m_opaque_sp = data_sp; diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index b7ac8047f8e5d..5f62987f37dad 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -1,4 +1,4 @@ -//===-- SBDebugger.cpp ------------------------------------------*- C++ -*-===// +//===-- SBDebugger.cpp ----------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -15,6 +15,7 @@ #include "lldb/API/SBBroadcaster.h" #include "lldb/API/SBCommandInterpreter.h" +#include "lldb/API/SBCommandInterpreterRunOptions.h" #include "lldb/API/SBCommandReturnObject.h" #include "lldb/API/SBError.h" #include "lldb/API/SBEvent.h" @@ -312,7 +313,7 @@ SBError SBDebugger::SetInputFile(SBFile file) { repro::DataRecorder *recorder = nullptr; if (repro::Generator *g = repro::Reproducer::Instance().GetGenerator()) - recorder = g->GetOrCreate<repro::CommandProvider>().GetNewDataRecorder(); + recorder = g->GetOrCreate<repro::CommandProvider>().GetNewRecorder(); FileSP file_sp = file.m_opaque_sp; @@ -596,8 +597,9 @@ SBSourceManager SBDebugger::GetSourceManager() { } bool SBDebugger::GetDefaultArchitecture(char *arch_name, size_t arch_name_len) { - LLDB_RECORD_STATIC_METHOD(bool, SBDebugger, GetDefaultArchitecture, - (char *, size_t), "", arch_name_len); + LLDB_RECORD_CHAR_PTR_STATIC_METHOD(bool, SBDebugger, GetDefaultArchitecture, + (char *, size_t), arch_name, "", + arch_name_len); if (arch_name && arch_name_len) { ArchSpec default_arch = Target::GetDefaultArchitecture(); @@ -1165,9 +1167,9 @@ void SBDebugger::RunCommandInterpreter(bool auto_handle_events, if (m_opaque_sp) { CommandInterpreterRunOptions options; - - m_opaque_sp->GetCommandInterpreter().RunCommandInterpreter( - auto_handle_events, spawn_thread, options); + options.SetAutoHandleEvents(auto_handle_events); + options.SetSpawnThread(spawn_thread); + m_opaque_sp->GetCommandInterpreter().RunCommandInterpreter(options); } } @@ -1185,15 +1187,35 @@ void SBDebugger::RunCommandInterpreter(bool auto_handle_events, quit_requested, stopped_for_crash); if (m_opaque_sp) { + options.SetAutoHandleEvents(auto_handle_events); + options.SetSpawnThread(spawn_thread); CommandInterpreter &interp = m_opaque_sp->GetCommandInterpreter(); - interp.RunCommandInterpreter(auto_handle_events, spawn_thread, - options.ref()); - num_errors = interp.GetNumErrors(); - quit_requested = interp.GetQuitRequested(); - stopped_for_crash = interp.GetStoppedForCrash(); + CommandInterpreterRunResult result = + interp.RunCommandInterpreter(options.ref()); + num_errors = result.GetNumErrors(); + quit_requested = + result.IsResult(lldb::eCommandInterpreterResultQuitRequested); + stopped_for_crash = + result.IsResult(lldb::eCommandInterpreterResultInferiorCrash); } } +SBCommandInterpreterRunResult SBDebugger::RunCommandInterpreter( + const SBCommandInterpreterRunOptions &options) { + LLDB_RECORD_METHOD(lldb::SBCommandInterpreterRunResult, SBDebugger, + RunCommandInterpreter, + (const lldb::SBCommandInterpreterRunOptions &), options); + + if (!m_opaque_sp) + return LLDB_RECORD_RESULT(SBCommandInterpreterRunResult()); + + CommandInterpreter &interp = m_opaque_sp->GetCommandInterpreter(); + CommandInterpreterRunResult result = + interp.RunCommandInterpreter(options.ref()); + + return LLDB_RECORD_RESULT(SBCommandInterpreterRunResult(result)); +} + SBError SBDebugger::RunREPL(lldb::LanguageType language, const char *repl_options) { LLDB_RECORD_METHOD(lldb::SBError, SBDebugger, RunREPL, @@ -1282,7 +1304,7 @@ SBDebugger::GetInternalVariableValue(const char *var_name, if (value_sp) { StreamString value_strm; value_sp->DumpValue(&exe_ctx, value_strm, OptionValue::eDumpOptionValue); - const std::string &value_str = value_strm.GetString(); + const std::string &value_str = std::string(value_strm.GetString()); if (!value_str.empty()) { StringList string_list; string_list.SplitIntoLines(value_str); @@ -1374,6 +1396,18 @@ bool SBDebugger::GetUseColor() const { return (m_opaque_sp ? m_opaque_sp->GetUseColor() : false); } +bool SBDebugger::SetUseSourceCache(bool value) { + LLDB_RECORD_METHOD(bool, SBDebugger, SetUseSourceCache, (bool), value); + + return (m_opaque_sp ? m_opaque_sp->SetUseSourceCache(value) : false); +} + +bool SBDebugger::GetUseSourceCache() const { + LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDebugger, GetUseSourceCache); + + return (m_opaque_sp ? m_opaque_sp->GetUseSourceCache() : false); +} + bool SBDebugger::GetDescription(SBStream &description) { LLDB_RECORD_METHOD(bool, SBDebugger, GetDescription, (lldb::SBStream &), description); @@ -1627,46 +1661,38 @@ static SBError SetFileRedirect(SBDebugger *, SBFile file) { return SBError(); } static SBError SetFileRedirect(SBDebugger *, FileSP file) { return SBError(); } -static bool GetDefaultArchitectureRedirect(char *arch_name, - size_t arch_name_len) { - // The function is writing to its argument. Without the redirect it would - // write into the replay buffer. - char buffer[1024]; - return SBDebugger::GetDefaultArchitecture(buffer, arch_name_len); -} - template <> void RegisterMethods<SBDebugger>(Registry &R) { // Custom implementation. - R.Register(&invoke<void (SBDebugger::*)( - FILE *, bool)>::method<&SBDebugger::SetErrorFileHandle>::doit, + R.Register(&invoke<void (SBDebugger::*)(FILE *, bool)>::method< + &SBDebugger::SetErrorFileHandle>::record, &SetFileHandleRedirect); - R.Register(&invoke<void (SBDebugger::*)( - FILE *, bool)>::method<&SBDebugger::SetOutputFileHandle>::doit, + R.Register(&invoke<void (SBDebugger::*)(FILE *, bool)>::method< + &SBDebugger::SetOutputFileHandle>::record, &SetFileHandleRedirect); - R.Register<bool(char *, size_t)>(static_cast<bool (*)(char *, size_t)>( - &SBDebugger::GetDefaultArchitecture), - &GetDefaultArchitectureRedirect); R.Register(&invoke<SBError (SBDebugger::*)( - SBFile)>::method<&SBDebugger::SetInputFile>::doit, + SBFile)>::method<&SBDebugger::SetInputFile>::record, &SetFileRedirect); R.Register(&invoke<SBError (SBDebugger::*)( - SBFile)>::method<&SBDebugger::SetOutputFile>::doit, + SBFile)>::method<&SBDebugger::SetOutputFile>::record, &SetFileRedirect); R.Register(&invoke<SBError (SBDebugger::*)( - SBFile)>::method<&SBDebugger::SetErrorFile>::doit, + SBFile)>::method<&SBDebugger::SetErrorFile>::record, &SetFileRedirect); R.Register(&invoke<SBError (SBDebugger::*)( - FileSP)>::method<&SBDebugger::SetInputFile>::doit, + FileSP)>::method<&SBDebugger::SetInputFile>::record, &SetFileRedirect); R.Register(&invoke<SBError (SBDebugger::*)( - FileSP)>::method<&SBDebugger::SetOutputFile>::doit, + FileSP)>::method<&SBDebugger::SetOutputFile>::record, &SetFileRedirect); R.Register(&invoke<SBError (SBDebugger::*)( - FileSP)>::method<&SBDebugger::SetErrorFile>::doit, + FileSP)>::method<&SBDebugger::SetErrorFile>::record, &SetFileRedirect); + LLDB_REGISTER_CHAR_PTR_METHOD_STATIC(bool, SBDebugger, + GetDefaultArchitecture); + LLDB_REGISTER_CONSTRUCTOR(SBDebugger, ()); LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::DebuggerSP &)); LLDB_REGISTER_CONSTRUCTOR(SBDebugger, (const lldb::SBDebugger &)); @@ -1816,6 +1842,9 @@ template <> void RegisterMethods<SBDebugger>(Registry &R) { (lldb::SBTypeNameSpecifier)); LLDB_REGISTER_METHOD(bool, SBDebugger, EnableLog, (const char *, const char **)); + LLDB_REGISTER_METHOD(lldb::SBCommandInterpreterRunResult, SBDebugger, + RunCommandInterpreter, + (const lldb::SBCommandInterpreterRunOptions &)); } } // namespace repro diff --git a/lldb/source/API/SBDeclaration.cpp b/lldb/source/API/SBDeclaration.cpp index 50db1770c612c..f1066d63c06ab 100644 --- a/lldb/source/API/SBDeclaration.cpp +++ b/lldb/source/API/SBDeclaration.cpp @@ -1,4 +1,4 @@ -//===-- SBDeclaration.cpp ----------------------------------------*- C++-*-===// +//===-- SBDeclaration.cpp -------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -50,7 +50,7 @@ void SBDeclaration::SetDeclaration( ref() = lldb_object_ref; } -SBDeclaration::~SBDeclaration() {} +SBDeclaration::~SBDeclaration() = default; bool SBDeclaration::IsValid() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBDeclaration, IsValid); @@ -148,7 +148,7 @@ const lldb_private::Declaration *SBDeclaration::operator->() const { lldb_private::Declaration &SBDeclaration::ref() { if (m_opaque_up == nullptr) - m_opaque_up.reset(new lldb_private::Declaration()); + m_opaque_up = std::make_unique<lldb_private::Declaration>(); return *m_opaque_up; } diff --git a/lldb/source/API/SBEnvironment.cpp b/lldb/source/API/SBEnvironment.cpp new file mode 100644 index 0000000000000..d4de89c325675 --- /dev/null +++ b/lldb/source/API/SBEnvironment.cpp @@ -0,0 +1,155 @@ +//===-- SBEnvironment.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/SBEnvironment.h" +#include "SBReproducerPrivate.h" +#include "Utils.h" +#include "lldb/API/SBStringList.h" +#include "lldb/Utility/ConstString.h" +#include "lldb/Utility/Environment.h" + +using namespace lldb; +using namespace lldb_private; + +SBEnvironment::SBEnvironment() : m_opaque_up(new Environment()) { + LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBEnvironment); +} + +SBEnvironment::SBEnvironment(const SBEnvironment &rhs) + : m_opaque_up(clone(rhs.m_opaque_up)) { + LLDB_RECORD_CONSTRUCTOR(SBEnvironment, (const lldb::SBEnvironment &), rhs); +} + +SBEnvironment::SBEnvironment(Environment rhs) + : m_opaque_up(new Environment(std::move(rhs))) {} + +SBEnvironment::~SBEnvironment() = default; + +const SBEnvironment &SBEnvironment::operator=(const SBEnvironment &rhs) { + LLDB_RECORD_METHOD(const lldb::SBEnvironment &, + SBEnvironment, operator=,(const lldb::SBEnvironment &), + rhs); + + if (this != &rhs) + m_opaque_up = clone(rhs.m_opaque_up); + return LLDB_RECORD_RESULT(*this); +} + +size_t SBEnvironment::GetNumValues() { + LLDB_RECORD_METHOD_NO_ARGS(size_t, SBEnvironment, GetNumValues); + + return m_opaque_up->size(); +} + +const char *SBEnvironment::Get(const char *name) { + LLDB_RECORD_METHOD(const char *, SBEnvironment, Get, (const char *), name); + + auto entry = m_opaque_up->find(name); + if (entry == m_opaque_up->end()) { + return nullptr; + } + return ConstString(entry->second).AsCString(""); +} + +const char *SBEnvironment::GetNameAtIndex(size_t index) { + LLDB_RECORD_METHOD(const char *, SBEnvironment, GetNameAtIndex, (size_t), + index); + + if (index >= GetNumValues()) + return nullptr; + return ConstString(std::next(m_opaque_up->begin(), index)->first()) + .AsCString(""); +} + +const char *SBEnvironment::GetValueAtIndex(size_t index) { + LLDB_RECORD_METHOD(const char *, SBEnvironment, GetValueAtIndex, (size_t), + index); + + if (index >= GetNumValues()) + return nullptr; + return ConstString(std::next(m_opaque_up->begin(), index)->second) + .AsCString(""); +} + +bool SBEnvironment::Set(const char *name, const char *value, bool overwrite) { + LLDB_RECORD_METHOD(bool, SBEnvironment, Set, + (const char *, const char *, bool), name, value, + overwrite); + + if (overwrite) { + m_opaque_up->insert_or_assign(name, std::string(value)); + return true; + } + return m_opaque_up->try_emplace(name, std::string(value)).second; +} + +bool SBEnvironment::Unset(const char *name) { + LLDB_RECORD_METHOD(bool, SBEnvironment, Unset, (const char *), name); + + return m_opaque_up->erase(name); +} + +SBStringList SBEnvironment::GetEntries() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBStringList, SBEnvironment, GetEntries); + + SBStringList entries; + for (const auto &KV : *m_opaque_up) { + entries.AppendString(Environment::compose(KV).c_str()); + } + return LLDB_RECORD_RESULT(entries); +} + +void SBEnvironment::PutEntry(const char *name_and_value) { + LLDB_RECORD_METHOD(void, SBEnvironment, PutEntry, (const char *), + name_and_value); + + auto split = llvm::StringRef(name_and_value).split('='); + m_opaque_up->insert_or_assign(split.first.str(), split.second.str()); +} + +void SBEnvironment::SetEntries(const SBStringList &entries, bool append) { + LLDB_RECORD_METHOD(void, SBEnvironment, SetEntries, + (const lldb::SBStringList &, bool), entries, append); + + if (!append) + m_opaque_up->clear(); + for (size_t i = 0; i < entries.GetSize(); i++) { + PutEntry(entries.GetStringAtIndex(i)); + } +} + +void SBEnvironment::Clear() { + LLDB_RECORD_METHOD_NO_ARGS(void, SBEnvironment, Clear); + + m_opaque_up->clear(); +} + +Environment &SBEnvironment::ref() const { return *m_opaque_up; } + +namespace lldb_private { +namespace repro { +template <> void RegisterMethods<SBEnvironment>(Registry &R) { + LLDB_REGISTER_CONSTRUCTOR(SBEnvironment, ()); + LLDB_REGISTER_CONSTRUCTOR(SBEnvironment, (const lldb::SBEnvironment &)); + LLDB_REGISTER_METHOD(const lldb::SBEnvironment &, + SBEnvironment, operator=,(const lldb::SBEnvironment &)); + LLDB_REGISTER_METHOD(size_t, SBEnvironment, GetNumValues, ()); + LLDB_REGISTER_METHOD(const char *, SBEnvironment, Get, (const char *)); + LLDB_REGISTER_METHOD(const char *, SBEnvironment, GetNameAtIndex, (size_t)); + LLDB_REGISTER_METHOD(const char *, SBEnvironment, GetValueAtIndex, (size_t)); + LLDB_REGISTER_METHOD(bool, SBEnvironment, Set, + (const char *, const char *, bool)); + LLDB_REGISTER_METHOD(bool, SBEnvironment, Unset, (const char *)); + LLDB_REGISTER_METHOD(lldb::SBStringList, SBEnvironment, GetEntries, ()); + LLDB_REGISTER_METHOD(void, SBEnvironment, PutEntry, (const char *)); + LLDB_REGISTER_METHOD(void, SBEnvironment, SetEntries, + (const lldb::SBStringList &, bool)); + LLDB_REGISTER_METHOD(void, SBEnvironment, Clear, ()); +} +} // namespace repro +} // namespace lldb_private diff --git a/lldb/source/API/SBError.cpp b/lldb/source/API/SBError.cpp index 7256e8e55de94..67c7663d35831 100644 --- a/lldb/source/API/SBError.cpp +++ b/lldb/source/API/SBError.cpp @@ -1,4 +1,4 @@ -//===-- SBError.cpp ---------------------------------------------*- C++ -*-===// +//===-- SBError.cpp -------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -25,7 +25,7 @@ SBError::SBError(const SBError &rhs) : m_opaque_up() { m_opaque_up = clone(rhs.m_opaque_up); } -SBError::~SBError() {} +SBError::~SBError() = default; const SBError &SBError::operator=(const SBError &rhs) { LLDB_RECORD_METHOD(const lldb::SBError &, @@ -149,7 +149,7 @@ SBError::operator bool() const { void SBError::CreateIfNeeded() { if (m_opaque_up == nullptr) - m_opaque_up.reset(new Status()); + m_opaque_up = std::make_unique<Status>(); } lldb_private::Status *SBError::operator->() { return m_opaque_up.get(); } diff --git a/lldb/source/API/SBEvent.cpp b/lldb/source/API/SBEvent.cpp index fb2ad10ddcf92..2776ec49c0924 100644 --- a/lldb/source/API/SBEvent.cpp +++ b/lldb/source/API/SBEvent.cpp @@ -1,4 +1,4 @@ -//===-- SBEvent.cpp ---------------------------------------------*- C++ -*-===// +//===-- SBEvent.cpp -------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -58,7 +58,7 @@ const SBEvent &SBEvent::operator=(const SBEvent &rhs) { return LLDB_RECORD_RESULT(*this); } -SBEvent::~SBEvent() {} +SBEvent::~SBEvent() = default; const char *SBEvent::GetDataFlavor() { LLDB_RECORD_METHOD_NO_ARGS(const char *, SBEvent, GetDataFlavor); diff --git a/lldb/source/API/SBExecutionContext.cpp b/lldb/source/API/SBExecutionContext.cpp index 1224c2abe989b..caf02b4164ea0 100644 --- a/lldb/source/API/SBExecutionContext.cpp +++ b/lldb/source/API/SBExecutionContext.cpp @@ -1,5 +1,4 @@ -//===-- SBExecutionContext.cpp ------------------------------------*- C++ -//-*-===// +//===-- SBExecutionContext.cpp --------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -66,7 +65,7 @@ SBExecutionContext::SBExecutionContext(const lldb::SBFrame &frame) m_exe_ctx_sp->SetFrameSP(frame.GetFrameSP()); } -SBExecutionContext::~SBExecutionContext() {} +SBExecutionContext::~SBExecutionContext() = default; const SBExecutionContext &SBExecutionContext:: operator=(const lldb::SBExecutionContext &rhs) { diff --git a/lldb/source/API/SBExpressionOptions.cpp b/lldb/source/API/SBExpressionOptions.cpp index 8c34194abf1e2..217e8ad5c21b3 100644 --- a/lldb/source/API/SBExpressionOptions.cpp +++ b/lldb/source/API/SBExpressionOptions.cpp @@ -1,5 +1,4 @@ -//===-- SBExpressionOptions.cpp ---------------------------------------------*- -//C++ -*-===// +//===-- SBExpressionOptions.cpp -------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -40,7 +39,7 @@ operator=(const SBExpressionOptions &rhs) { return LLDB_RECORD_RESULT(*this); } -SBExpressionOptions::~SBExpressionOptions() {} +SBExpressionOptions::~SBExpressionOptions() = default; bool SBExpressionOptions::GetCoerceResultToId() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBExpressionOptions, @@ -238,6 +237,20 @@ void SBExpressionOptions::SetAutoApplyFixIts(bool b) { return m_opaque_up->SetAutoApplyFixIts(b); } +uint64_t SBExpressionOptions::GetRetriesWithFixIts() { + LLDB_RECORD_METHOD_NO_ARGS(uint64_t, SBExpressionOptions, + GetRetriesWithFixIts); + + return m_opaque_up->GetRetriesWithFixIts(); +} + +void SBExpressionOptions::SetRetriesWithFixIts(uint64_t retries) { + LLDB_RECORD_METHOD(void, SBExpressionOptions, SetRetriesWithFixIts, + (uint64_t), retries); + + return m_opaque_up->SetRetriesWithFixIts(retries); +} + bool SBExpressionOptions::GetTopLevel() { LLDB_RECORD_METHOD_NO_ARGS(bool, SBExpressionOptions, GetTopLevel); @@ -330,6 +343,9 @@ void RegisterMethods<SBExpressionOptions>(Registry &R) { LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetTopLevel, (bool)); LLDB_REGISTER_METHOD(bool, SBExpressionOptions, GetAllowJIT, ()); LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetAllowJIT, (bool)); + LLDB_REGISTER_METHOD(uint64_t, SBExpressionOptions, GetRetriesWithFixIts, ()); + LLDB_REGISTER_METHOD(void, SBExpressionOptions, SetRetriesWithFixIts, + (uint64_t)); } } diff --git a/lldb/source/API/SBFile.cpp b/lldb/source/API/SBFile.cpp index 277402f31abf7..41ccdbe76b91a 100644 --- a/lldb/source/API/SBFile.cpp +++ b/lldb/source/API/SBFile.cpp @@ -1,4 +1,4 @@ -//===-- SBFile.cpp ------------------------------------------*- C++ -*-===// +//===-- SBFile.cpp --------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -14,22 +14,39 @@ using namespace lldb; using namespace lldb_private; -SBFile::~SBFile() {} +SBFile::~SBFile() = default; SBFile::SBFile(FileSP file_sp) : m_opaque_sp(file_sp) { - LLDB_RECORD_DUMMY(void, SBfile, SBFile, (FileSP), file_sp); + // We have no way to capture the incoming FileSP as the class isn't + // instrumented, so pretend that it's always null. + LLDB_RECORD_CONSTRUCTOR(SBFile, (lldb::FileSP), nullptr); +} + +SBFile::SBFile(const SBFile &rhs) : m_opaque_sp(rhs.m_opaque_sp) { + LLDB_RECORD_CONSTRUCTOR(SBFile, (const lldb::SBFile&), rhs); +} + +SBFile &SBFile ::operator=(const SBFile &rhs) { + LLDB_RECORD_METHOD(lldb::SBFile &, + SBFile, operator=,(const lldb::SBFile &), rhs); + + if (this != &rhs) + m_opaque_sp = rhs.m_opaque_sp; + return LLDB_RECORD_RESULT(*this); } SBFile::SBFile() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBFile); } SBFile::SBFile(FILE *file, bool transfer_ownership) { - LLDB_RECORD_DUMMY(void, SBFile, (FILE *, bool), file, transfer_ownership); + LLDB_RECORD_CONSTRUCTOR(SBFile, (FILE *, bool), file, transfer_ownership); + m_opaque_sp = std::make_shared<NativeFile>(file, transfer_ownership); } SBFile::SBFile(int fd, const char *mode, bool transfer_owndership) { - LLDB_RECORD_DUMMY(void, SBFile, (int, const char *, bool), fd, mode, - transfer_owndership); + LLDB_RECORD_CONSTRUCTOR(SBFile, (int, const char *, bool), fd, mode, + transfer_owndership); + auto options = File::GetOptionsFromMode(mode); if (!options) { llvm::consumeError(options.takeError()); @@ -40,8 +57,9 @@ SBFile::SBFile(int fd, const char *mode, bool transfer_owndership) { } SBError SBFile::Read(uint8_t *buf, size_t num_bytes, size_t *bytes_read) { - LLDB_RECORD_DUMMY(lldb::SBError, SBFile, Read, (uint8_t *, size_t, size_t *), - buf, num_bytes, bytes_read); + LLDB_RECORD_METHOD(lldb::SBError, SBFile, Read, (uint8_t *, size_t, size_t *), + buf, num_bytes, bytes_read); + SBError error; if (!m_opaque_sp) { error.SetErrorString("invalid SBFile"); @@ -56,9 +74,10 @@ SBError SBFile::Read(uint8_t *buf, size_t num_bytes, size_t *bytes_read) { SBError SBFile::Write(const uint8_t *buf, size_t num_bytes, size_t *bytes_written) { - LLDB_RECORD_DUMMY(lldb::SBError, SBFile, Write, - (const uint8_t *, size_t, size_t *), buf, num_bytes, - bytes_written); + LLDB_RECORD_METHOD(lldb::SBError, SBFile, Write, + (const uint8_t *, size_t, size_t *), buf, num_bytes, + bytes_written); + SBError error; if (!m_opaque_sp) { error.SetErrorString("invalid SBFile"); @@ -73,6 +92,7 @@ SBError SBFile::Write(const uint8_t *buf, size_t num_bytes, SBError SBFile::Flush() { LLDB_RECORD_METHOD_NO_ARGS(lldb::SBError, SBFile, Flush); + SBError error; if (!m_opaque_sp) { error.SetErrorString("invalid SBFile"); @@ -119,9 +139,15 @@ namespace repro { template <> void RegisterMethods<SBFile>(Registry &R) { LLDB_REGISTER_CONSTRUCTOR(SBFile, ()); LLDB_REGISTER_CONSTRUCTOR(SBFile, (FileSP)); + LLDB_REGISTER_CONSTRUCTOR(SBFile, (const SBFile&)); LLDB_REGISTER_CONSTRUCTOR(SBFile, (FILE *, bool)); LLDB_REGISTER_CONSTRUCTOR(SBFile, (int, const char *, bool)); + LLDB_REGISTER_METHOD(SBFile&, SBFile, operator=,(const SBFile&)); LLDB_REGISTER_METHOD(lldb::SBError, SBFile, Flush, ()); + LLDB_REGISTER_METHOD(lldb::SBError, SBFile, Read, + (uint8_t *, size_t, size_t *)); + LLDB_REGISTER_METHOD(lldb::SBError, SBFile, Write, + (const uint8_t *, size_t, size_t *)); LLDB_REGISTER_METHOD_CONST(bool, SBFile, IsValid, ()); LLDB_REGISTER_METHOD_CONST(bool, SBFile, operator bool,()); LLDB_REGISTER_METHOD_CONST(bool, SBFile, operator!,()); diff --git a/lldb/source/API/SBFileSpec.cpp b/lldb/source/API/SBFileSpec.cpp index 2e7eba42bc909..7bfb665df4fba 100644 --- a/lldb/source/API/SBFileSpec.cpp +++ b/lldb/source/API/SBFileSpec.cpp @@ -1,4 +1,4 @@ -//===-- SBFileSpec.cpp ------------------------------------------*- C++ -*-===// +//===-- SBFileSpec.cpp ----------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -51,7 +51,7 @@ SBFileSpec::SBFileSpec(const char *path, bool resolve) FileSystem::Instance().Resolve(*m_opaque_up); } -SBFileSpec::~SBFileSpec() {} +SBFileSpec::~SBFileSpec() = default; const SBFileSpec &SBFileSpec::operator=(const SBFileSpec &rhs) { LLDB_RECORD_METHOD(const lldb::SBFileSpec &, @@ -143,8 +143,8 @@ void SBFileSpec::SetDirectory(const char *directory) { } uint32_t SBFileSpec::GetPath(char *dst_path, size_t dst_len) const { - LLDB_RECORD_DUMMY(uint32_t, SBFileSpec, GetPath, (char *, size_t), - dst_path, dst_len); + LLDB_RECORD_CHAR_PTR_METHOD_CONST(uint32_t, SBFileSpec, GetPath, + (char *, size_t), dst_path, "", dst_len); uint32_t result = m_opaque_up->GetPath(dst_path, dst_len); @@ -213,10 +213,10 @@ void RegisterMethods<SBFileSpec>(Registry &R) { LLDB_REGISTER_METHOD_CONST(const char *, SBFileSpec, GetDirectory, ()); LLDB_REGISTER_METHOD(void, SBFileSpec, SetFilename, (const char *)); LLDB_REGISTER_METHOD(void, SBFileSpec, SetDirectory, (const char *)); - LLDB_REGISTER_METHOD_CONST(uint32_t, SBFileSpec, GetPath, (char *, size_t)); LLDB_REGISTER_METHOD_CONST(bool, SBFileSpec, GetDescription, (lldb::SBStream &)); LLDB_REGISTER_METHOD(void, SBFileSpec, AppendPathComponent, (const char *)); + LLDB_REGISTER_CHAR_PTR_METHOD_CONST(uint32_t, SBFileSpec, GetPath); } } diff --git a/lldb/source/API/SBFileSpecList.cpp b/lldb/source/API/SBFileSpecList.cpp index 3143964b38cbe..7afa343632719 100644 --- a/lldb/source/API/SBFileSpecList.cpp +++ b/lldb/source/API/SBFileSpecList.cpp @@ -1,4 +1,4 @@ -//===-- SBFileSpecList.cpp --------------------------------------*- C++ -*-===// +//===-- SBFileSpecList.cpp ------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -32,7 +32,7 @@ SBFileSpecList::SBFileSpecList(const SBFileSpecList &rhs) : m_opaque_up() { m_opaque_up = clone(rhs.m_opaque_up); } -SBFileSpecList::~SBFileSpecList() {} +SBFileSpecList::~SBFileSpecList() = default; const SBFileSpecList &SBFileSpecList::operator=(const SBFileSpecList &rhs) { LLDB_RECORD_METHOD(const lldb::SBFileSpecList &, diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index af42be9ac75e5..81782dbf838f3 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -1,4 +1,4 @@ -//===-- SBFrame.cpp ---------------------------------------------*- C++ -*-===// +//===-- SBFrame.cpp -------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -354,15 +354,15 @@ bool SBFrame::SetPC(addr_t new_pc) { std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); - StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) { Process::StopLocker stop_locker; if (stop_locker.TryLock(&process->GetRunLock())) { - frame = exe_ctx.GetFramePtr(); - if (frame) { - ret_val = frame->GetRegisterContext()->SetPC(new_pc); + if (StackFrame *frame = exe_ctx.GetFramePtr()) { + if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext()) { + ret_val = reg_ctx_sp->SetPC(new_pc); + } } } } @@ -377,15 +377,15 @@ addr_t SBFrame::GetSP() const { std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); - StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) { Process::StopLocker stop_locker; if (stop_locker.TryLock(&process->GetRunLock())) { - frame = exe_ctx.GetFramePtr(); - if (frame) { - addr = frame->GetRegisterContext()->GetSP(); + if (StackFrame *frame = exe_ctx.GetFramePtr()) { + if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext()) { + addr = reg_ctx_sp->GetSP(); + } } } } @@ -400,15 +400,16 @@ addr_t SBFrame::GetFP() const { std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); - StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) { Process::StopLocker stop_locker; if (stop_locker.TryLock(&process->GetRunLock())) { - frame = exe_ctx.GetFramePtr(); - if (frame) - addr = frame->GetRegisterContext()->GetFP(); + if (StackFrame *frame = exe_ctx.GetFramePtr()) { + if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext()) { + addr = reg_ctx_sp->GetFP(); + } + } } } @@ -1225,8 +1226,7 @@ const char *SBFrame::GetFunctionName() const { if (inlined_block) { const InlineFunctionInfo *inlined_info = inlined_block->GetInlinedFunctionInfo(); - name = - inlined_info->GetName(sc.function->GetLanguage()).AsCString(); + name = inlined_info->GetName().AsCString(); } } @@ -1269,8 +1269,7 @@ const char *SBFrame::GetDisplayFunctionName() { if (inlined_block) { const InlineFunctionInfo *inlined_info = inlined_block->GetInlinedFunctionInfo(); - name = inlined_info->GetDisplayName(sc.function->GetLanguage()) - .AsCString(); + name = inlined_info->GetDisplayName().AsCString(); } } diff --git a/lldb/source/API/SBFunction.cpp b/lldb/source/API/SBFunction.cpp index 1770bede2f428..e49513bd0da55 100644 --- a/lldb/source/API/SBFunction.cpp +++ b/lldb/source/API/SBFunction.cpp @@ -1,4 +1,4 @@ -//===-- SBFunction.cpp ------------------------------------------*- C++ -*-===// +//===-- SBFunction.cpp ----------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -69,9 +69,7 @@ const char *SBFunction::GetDisplayName() const { const char *cstr = nullptr; if (m_opaque_ptr) - cstr = m_opaque_ptr->GetMangled() - .GetDisplayDemangledName(m_opaque_ptr->GetLanguage()) - .AsCString(); + cstr = m_opaque_ptr->GetMangled().GetDisplayDemangledName().AsCString(); return cstr; } @@ -128,20 +126,15 @@ SBInstructionList SBFunction::GetInstructions(SBTarget target, SBInstructionList sb_instructions; if (m_opaque_ptr) { - ExecutionContext exe_ctx; TargetSP target_sp(target.GetSP()); std::unique_lock<std::recursive_mutex> lock; - if (target_sp) { - lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex()); - target_sp->CalculateExecutionContext(exe_ctx); - exe_ctx.SetProcessSP(target_sp->GetProcessSP()); - } ModuleSP module_sp( m_opaque_ptr->GetAddressRange().GetBaseAddress().GetModule()); - if (module_sp) { + if (target_sp && module_sp) { + lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex()); const bool prefer_file_cache = false; sb_instructions.SetDisassembler(Disassembler::DisassembleRange( - module_sp->GetArchitecture(), nullptr, flavor, exe_ctx, + module_sp->GetArchitecture(), nullptr, flavor, *target_sp, m_opaque_ptr->GetAddressRange(), prefer_file_cache)); } } diff --git a/lldb/source/API/SBHostOS.cpp b/lldb/source/API/SBHostOS.cpp index 6ac8717237e71..9d3d119e4c2a4 100644 --- a/lldb/source/API/SBHostOS.cpp +++ b/lldb/source/API/SBHostOS.cpp @@ -1,4 +1,4 @@ -//===-- SBHostOS.cpp --------------------------------------------*- C++ -*-===// +//===-- SBHostOS.cpp ------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/lldb/source/API/SBInstruction.cpp b/lldb/source/API/SBInstruction.cpp index a9ef9fb59d248..207e81272e50d 100644 --- a/lldb/source/API/SBInstruction.cpp +++ b/lldb/source/API/SBInstruction.cpp @@ -1,4 +1,4 @@ -//===-- SBInstruction.cpp ---------------------------------------*- C++ -*-===// +//===-- SBInstruction.cpp -------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -89,7 +89,7 @@ const SBInstruction &SBInstruction::operator=(const SBInstruction &rhs) { return LLDB_RECORD_RESULT(*this); } -SBInstruction::~SBInstruction() {} +SBInstruction::~SBInstruction() = default; bool SBInstruction::IsValid() { LLDB_RECORD_METHOD_NO_ARGS(bool, SBInstruction, IsValid); diff --git a/lldb/source/API/SBInstructionList.cpp b/lldb/source/API/SBInstructionList.cpp index 8b3855c0883b5..a0c6fbe7e3387 100644 --- a/lldb/source/API/SBInstructionList.cpp +++ b/lldb/source/API/SBInstructionList.cpp @@ -1,4 +1,4 @@ -//===-- SBInstructionList.cpp -----------------------------------*- C++ -*-===// +//===-- SBInstructionList.cpp ---------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -42,7 +42,7 @@ operator=(const SBInstructionList &rhs) { return LLDB_RECORD_RESULT(*this); } -SBInstructionList::~SBInstructionList() {} +SBInstructionList::~SBInstructionList() = default; bool SBInstructionList::IsValid() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBInstructionList, IsValid); diff --git a/lldb/source/API/SBLanguageRuntime.cpp b/lldb/source/API/SBLanguageRuntime.cpp index 04bd08fb739e0..33c900d20c31a 100644 --- a/lldb/source/API/SBLanguageRuntime.cpp +++ b/lldb/source/API/SBLanguageRuntime.cpp @@ -1,4 +1,4 @@ -//===-- SBLanguageRuntime.cpp -----------------------------------*- C++ -*-===// +//===-- SBLanguageRuntime.cpp ---------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/lldb/source/API/SBLaunchInfo.cpp b/lldb/source/API/SBLaunchInfo.cpp index 5c5e69704c7cf..ba13072e8f9bc 100644 --- a/lldb/source/API/SBLaunchInfo.cpp +++ b/lldb/source/API/SBLaunchInfo.cpp @@ -1,4 +1,4 @@ -//===-- SBLaunchInfo.cpp ----------------------------------------*- C++ -*-===// +//===-- SBLaunchInfo.cpp --------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -9,6 +9,7 @@ #include "lldb/API/SBLaunchInfo.h" #include "SBReproducerPrivate.h" +#include "lldb/API/SBEnvironment.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBListener.h" #include "lldb/Host/ProcessLaunchInfo.h" @@ -43,7 +44,21 @@ SBLaunchInfo::SBLaunchInfo(const char **argv) m_opaque_sp->GetArguments().SetArguments(argv); } -SBLaunchInfo::~SBLaunchInfo() {} +SBLaunchInfo::SBLaunchInfo(const SBLaunchInfo &rhs) { + LLDB_RECORD_CONSTRUCTOR(SBLaunchInfo, (const lldb::SBLaunchInfo &), rhs); + + m_opaque_sp = rhs.m_opaque_sp; +} + +SBLaunchInfo &SBLaunchInfo::operator=(const SBLaunchInfo &rhs) { + LLDB_RECORD_METHOD(SBLaunchInfo &, + SBLaunchInfo, operator=,(const lldb::SBLaunchInfo &), rhs); + + m_opaque_sp = rhs.m_opaque_sp; + return LLDB_RECORD_RESULT(*this); +} + +SBLaunchInfo::~SBLaunchInfo() = default; const lldb_private::ProcessLaunchInfo &SBLaunchInfo::ref() const { return *m_opaque_sp; @@ -168,15 +183,26 @@ const char *SBLaunchInfo::GetEnvironmentEntryAtIndex(uint32_t idx) { void SBLaunchInfo::SetEnvironmentEntries(const char **envp, bool append) { LLDB_RECORD_METHOD(void, SBLaunchInfo, SetEnvironmentEntries, (const char **, bool), envp, append); + SetEnvironment(SBEnvironment(Environment(envp)), append); +} - Environment env(envp); +void SBLaunchInfo::SetEnvironment(const SBEnvironment &env, bool append) { + LLDB_RECORD_METHOD(void, SBLaunchInfo, SetEnvironment, + (const lldb::SBEnvironment &, bool), env, append); + Environment &refEnv = env.ref(); if (append) - m_opaque_sp->GetEnvironment().insert(env.begin(), env.end()); + m_opaque_sp->GetEnvironment().insert(refEnv.begin(), refEnv.end()); else - m_opaque_sp->GetEnvironment() = env; + m_opaque_sp->GetEnvironment() = refEnv; m_opaque_sp->RegenerateEnvp(); } +SBEnvironment SBLaunchInfo::GetEnvironment() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBEnvironment, SBLaunchInfo, GetEnvironment); + return LLDB_RECORD_RESULT( + SBEnvironment(Environment(m_opaque_sp->GetEnvironment()))); +} + void SBLaunchInfo::Clear() { LLDB_RECORD_METHOD_NO_ARGS(void, SBLaunchInfo, Clear); @@ -322,6 +348,9 @@ namespace repro { template <> void RegisterMethods<SBLaunchInfo>(Registry &R) { LLDB_REGISTER_CONSTRUCTOR(SBLaunchInfo, (const char **)); + LLDB_REGISTER_CONSTRUCTOR(SBLaunchInfo, (const lldb::SBLaunchInfo &)); + LLDB_REGISTER_METHOD(SBLaunchInfo &, + SBLaunchInfo, operator=,(const lldb::SBLaunchInfo &)); LLDB_REGISTER_METHOD(lldb::pid_t, SBLaunchInfo, GetProcessID, ()); LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetUserID, ()); LLDB_REGISTER_METHOD(uint32_t, SBLaunchInfo, GetGroupID, ()); @@ -373,6 +402,9 @@ void RegisterMethods<SBLaunchInfo>(Registry &R) { ()); LLDB_REGISTER_METHOD(void, SBLaunchInfo, SetDetachOnError, (bool)); LLDB_REGISTER_METHOD_CONST(bool, SBLaunchInfo, GetDetachOnError, ()); + 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 66884f7633989..cefbe3ee1a1eb 100644 --- a/lldb/source/API/SBLineEntry.cpp +++ b/lldb/source/API/SBLineEntry.cpp @@ -1,4 +1,4 @@ -//===-- SBLineEntry.cpp -----------------------------------------*- C++ -*-===// +//===-- SBLineEntry.cpp ---------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -48,7 +48,7 @@ void SBLineEntry::SetLineEntry(const lldb_private::LineEntry &lldb_object_ref) { m_opaque_up = std::make_unique<LineEntry>(lldb_object_ref); } -SBLineEntry::~SBLineEntry() {} +SBLineEntry::~SBLineEntry() = default; SBAddress SBLineEntry::GetStartAddress() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBAddress, SBLineEntry, @@ -163,7 +163,7 @@ const lldb_private::LineEntry *SBLineEntry::operator->() const { lldb_private::LineEntry &SBLineEntry::ref() { if (m_opaque_up == nullptr) - m_opaque_up.reset(new lldb_private::LineEntry()); + m_opaque_up = std::make_unique<lldb_private::LineEntry>(); return *m_opaque_up; } diff --git a/lldb/source/API/SBListener.cpp b/lldb/source/API/SBListener.cpp index 4fe90f6f68620..f3463268b3b5e 100644 --- a/lldb/source/API/SBListener.cpp +++ b/lldb/source/API/SBListener.cpp @@ -1,4 +1,4 @@ -//===-- SBListener.cpp ------------------------------------------*- C++ -*-===// +//===-- SBListener.cpp ----------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -48,7 +48,7 @@ const lldb::SBListener &SBListener::operator=(const lldb::SBListener &rhs) { SBListener::SBListener(const lldb::ListenerSP &listener_sp) : m_opaque_sp(listener_sp), m_unused_ptr(nullptr) {} -SBListener::~SBListener() {} +SBListener::~SBListener() = default; bool SBListener::IsValid() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBListener, IsValid); diff --git a/lldb/source/API/SBMemoryRegionInfo.cpp b/lldb/source/API/SBMemoryRegionInfo.cpp index d25570f51ce54..2a28b99c72d73 100644 --- a/lldb/source/API/SBMemoryRegionInfo.cpp +++ b/lldb/source/API/SBMemoryRegionInfo.cpp @@ -1,4 +1,4 @@ -//===-- SBMemoryRegionInfo.cpp ----------------------------------*- C++ -*-===// +//===-- SBMemoryRegionInfo.cpp --------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -46,7 +46,7 @@ operator=(const SBMemoryRegionInfo &rhs) { return LLDB_RECORD_RESULT(*this); } -SBMemoryRegionInfo::~SBMemoryRegionInfo() {} +SBMemoryRegionInfo::~SBMemoryRegionInfo() = default; void SBMemoryRegionInfo::Clear() { LLDB_RECORD_METHOD_NO_ARGS(void, SBMemoryRegionInfo, Clear); diff --git a/lldb/source/API/SBMemoryRegionInfoList.cpp b/lldb/source/API/SBMemoryRegionInfoList.cpp index 32a3afb84af0e..0f3f9c1b8177f 100644 --- a/lldb/source/API/SBMemoryRegionInfoList.cpp +++ b/lldb/source/API/SBMemoryRegionInfoList.cpp @@ -1,4 +1,4 @@ -//===-- SBMemoryRegionInfoList.cpp ------------------------------*- C++ -*-===// +//===-- SBMemoryRegionInfoList.cpp ----------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -82,7 +82,7 @@ SBMemoryRegionInfoList::SBMemoryRegionInfoList( (const lldb::SBMemoryRegionInfoList &), rhs); } -SBMemoryRegionInfoList::~SBMemoryRegionInfoList() {} +SBMemoryRegionInfoList::~SBMemoryRegionInfoList() = default; const SBMemoryRegionInfoList &SBMemoryRegionInfoList:: operator=(const SBMemoryRegionInfoList &rhs) { diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index 4e9dfb0c1e62e..c30529b37eb1e 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -1,4 +1,4 @@ -//===-- SBModule.cpp --------------------------------------------*- C++ -*-===// +//===-- SBModule.cpp ------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -75,7 +75,7 @@ const SBModule &SBModule::operator=(const SBModule &rhs) { return LLDB_RECORD_RESULT(*this); } -SBModule::~SBModule() {} +SBModule::~SBModule() = default; bool SBModule::IsValid() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModule, IsValid); @@ -401,8 +401,8 @@ lldb::SBSymbolContextList SBModule::FindFunctions(const char *name, const bool symbols_ok = true; const bool inlines_ok = true; FunctionNameType type = static_cast<FunctionNameType>(name_type_mask); - module_sp->FindFunctions(ConstString(name), nullptr, type, symbols_ok, - inlines_ok, *sb_sc_list); + module_sp->FindFunctions(ConstString(name), CompilerDeclContext(), type, + symbols_ok, inlines_ok, *sb_sc_list); } return LLDB_RECORD_RESULT(sb_sc_list); } @@ -417,8 +417,8 @@ SBValueList SBModule::FindGlobalVariables(SBTarget &target, const char *name, ModuleSP module_sp(GetSP()); if (name && module_sp) { VariableList variable_list; - module_sp->FindGlobalVariables(ConstString(name), nullptr, max_matches, - variable_list); + module_sp->FindGlobalVariables(ConstString(name), CompilerDeclContext(), + max_matches, variable_list); for (const VariableSP &var_sp : variable_list) { lldb::ValueObjectSP valobj_sp; TargetSP target_sp(target.GetSP()); @@ -683,6 +683,13 @@ lldb::SBAddress SBModule::GetObjectFileEntryPointAddress() const { return LLDB_RECORD_RESULT(sb_addr); } +uint32_t SBModule::GetNumberAllocatedModules() { + LLDB_RECORD_STATIC_METHOD_NO_ARGS(uint32_t, SBModule, + GetNumberAllocatedModules); + + return Module::GetNumberAllocatedModules(); +} + namespace lldb_private { namespace repro { @@ -757,6 +764,8 @@ void RegisterMethods<SBModule>(Registry &R) { GetObjectFileHeaderAddress, ()); LLDB_REGISTER_METHOD_CONST(lldb::SBAddress, SBModule, GetObjectFileEntryPointAddress, ()); + LLDB_REGISTER_STATIC_METHOD(uint32_t, SBModule, GetNumberAllocatedModules, + ()); } } diff --git a/lldb/source/API/SBModuleSpec.cpp b/lldb/source/API/SBModuleSpec.cpp index a5e9ad26fac12..5d88272a399b6 100644 --- a/lldb/source/API/SBModuleSpec.cpp +++ b/lldb/source/API/SBModuleSpec.cpp @@ -1,4 +1,4 @@ -//===-- SBModuleSpec.cpp ----------------------------------------*- C++ -*-===// +//===-- SBModuleSpec.cpp --------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -38,7 +38,7 @@ const SBModuleSpec &SBModuleSpec::operator=(const SBModuleSpec &rhs) { return LLDB_RECORD_RESULT(*this); } -SBModuleSpec::~SBModuleSpec() {} +SBModuleSpec::~SBModuleSpec() = default; bool SBModuleSpec::IsValid() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBModuleSpec, IsValid); @@ -169,7 +169,7 @@ SBModuleSpecList &SBModuleSpecList::operator=(const SBModuleSpecList &rhs) { return LLDB_RECORD_RESULT(*this); } -SBModuleSpecList::~SBModuleSpecList() {} +SBModuleSpecList::~SBModuleSpecList() = default; SBModuleSpecList SBModuleSpecList::GetModuleSpecifications(const char *path) { LLDB_RECORD_STATIC_METHOD(lldb::SBModuleSpecList, SBModuleSpecList, diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp index f3708d8e084f3..7ac852488ffbb 100644 --- a/lldb/source/API/SBPlatform.cpp +++ b/lldb/source/API/SBPlatform.cpp @@ -1,4 +1,4 @@ -//===-- SBPlatform.cpp ------------------------------------------*- C++ -*-===// +//===-- SBPlatform.cpp ----------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -8,9 +8,11 @@ #include "lldb/API/SBPlatform.h" #include "SBReproducerPrivate.h" +#include "lldb/API/SBEnvironment.h" #include "lldb/API/SBError.h" #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBLaunchInfo.h" +#include "lldb/API/SBPlatform.h" #include "lldb/API/SBUnixSignals.h" #include "lldb/Host/File.h" #include "lldb/Target/Platform.h" @@ -36,7 +38,7 @@ struct PlatformConnectOptions { m_url = url; } - ~PlatformConnectOptions() {} + ~PlatformConnectOptions() = default; std::string m_url; std::string m_rsync_options; @@ -54,7 +56,7 @@ struct PlatformShellCommand { m_command = shell_command; } - ~PlatformShellCommand() {} + ~PlatformShellCommand() = default; std::string m_command; std::string m_working_dir; @@ -80,14 +82,16 @@ SBPlatformConnectOptions::SBPlatformConnectOptions( SBPlatformConnectOptions::~SBPlatformConnectOptions() { delete m_opaque_ptr; } -void SBPlatformConnectOptions::operator=(const SBPlatformConnectOptions &rhs) { +SBPlatformConnectOptions &SBPlatformConnectOptions:: +operator=(const SBPlatformConnectOptions &rhs) { LLDB_RECORD_METHOD( - void, + SBPlatformConnectOptions &, SBPlatformConnectOptions, operator=,( const lldb::SBPlatformConnectOptions &), rhs); *m_opaque_ptr = *rhs.m_opaque_ptr; + return LLDB_RECORD_RESULT(*this); } const char *SBPlatformConnectOptions::GetURL() { @@ -174,6 +178,18 @@ SBPlatformShellCommand::SBPlatformShellCommand( *m_opaque_ptr = *rhs.m_opaque_ptr; } +SBPlatformShellCommand &SBPlatformShellCommand:: +operator=(const SBPlatformShellCommand &rhs) { + + LLDB_RECORD_METHOD( + SBPlatformShellCommand &, + SBPlatformShellCommand, operator=,(const lldb::SBPlatformShellCommand &), + rhs); + + *m_opaque_ptr = *rhs.m_opaque_ptr; + return LLDB_RECORD_RESULT(*this); +} + SBPlatformShellCommand::~SBPlatformShellCommand() { delete m_opaque_ptr; } void SBPlatformShellCommand::Clear() { @@ -273,7 +289,30 @@ SBPlatform::SBPlatform(const char *platform_name) : m_opaque_sp() { m_opaque_sp = Platform::Create(ConstString(platform_name), error); } -SBPlatform::~SBPlatform() {} +SBPlatform::SBPlatform(const SBPlatform &rhs) { + LLDB_RECORD_CONSTRUCTOR(SBPlatform, (const lldb::SBPlatform &), rhs); + + m_opaque_sp = rhs.m_opaque_sp; +} + +SBPlatform &SBPlatform::operator=(const SBPlatform &rhs) { + LLDB_RECORD_METHOD(SBPlatform &, + SBPlatform, operator=,(const lldb::SBPlatform &), rhs); + + m_opaque_sp = rhs.m_opaque_sp; + return LLDB_RECORD_RESULT(*this); +} + +SBPlatform::~SBPlatform() = default; + +SBPlatform SBPlatform::GetHostPlatform() { + LLDB_RECORD_STATIC_METHOD_NO_ARGS(lldb::SBPlatform, SBPlatform, + GetHostPlatform); + + SBPlatform host_platform; + host_platform.m_opaque_sp = Platform::GetHostPlatform(); + return LLDB_RECORD_RESULT(host_platform); +} bool SBPlatform::IsValid() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBPlatform, IsValid); @@ -615,6 +654,17 @@ SBUnixSignals SBPlatform::GetUnixSignals() const { return LLDB_RECORD_RESULT(SBUnixSignals()); } +SBEnvironment SBPlatform::GetEnvironment() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBEnvironment, SBPlatform, GetEnvironment); + PlatformSP platform_sp(GetSP()); + + if (platform_sp) { + return LLDB_RECORD_RESULT(SBEnvironment(platform_sp->GetEnvironment())); + } + + return LLDB_RECORD_RESULT(SBEnvironment()); +} + namespace lldb_private { namespace repro { @@ -624,7 +674,7 @@ void RegisterMethods<SBPlatformConnectOptions>(Registry &R) { LLDB_REGISTER_CONSTRUCTOR(SBPlatformConnectOptions, (const lldb::SBPlatformConnectOptions &)); LLDB_REGISTER_METHOD( - void, + SBPlatformConnectOptions &, SBPlatformConnectOptions, operator=,( const lldb::SBPlatformConnectOptions &)); LLDB_REGISTER_METHOD(const char *, SBPlatformConnectOptions, GetURL, ()); @@ -645,6 +695,9 @@ void RegisterMethods<SBPlatformShellCommand>(Registry &R) { LLDB_REGISTER_CONSTRUCTOR(SBPlatformShellCommand, (const char *)); LLDB_REGISTER_CONSTRUCTOR(SBPlatformShellCommand, (const lldb::SBPlatformShellCommand &)); + LLDB_REGISTER_METHOD( + SBPlatformShellCommand &, + SBPlatformShellCommand, operator=,(const lldb::SBPlatformShellCommand &)); LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, Clear, ()); LLDB_REGISTER_METHOD(const char *, SBPlatformShellCommand, GetCommand, ()); LLDB_REGISTER_METHOD(void, SBPlatformShellCommand, SetCommand, @@ -666,6 +719,9 @@ template <> void RegisterMethods<SBPlatform>(Registry &R) { LLDB_REGISTER_CONSTRUCTOR(SBPlatform, ()); LLDB_REGISTER_CONSTRUCTOR(SBPlatform, (const char *)); + LLDB_REGISTER_CONSTRUCTOR(SBPlatform, (const lldb::SBPlatform &)); + LLDB_REGISTER_METHOD(SBPlatform &, + SBPlatform, operator=,(const lldb::SBPlatform &)); LLDB_REGISTER_METHOD_CONST(bool, SBPlatform, IsValid, ()); LLDB_REGISTER_METHOD_CONST(bool, SBPlatform, operator bool, ()); LLDB_REGISTER_METHOD(void, SBPlatform, Clear, ()); @@ -700,8 +756,11 @@ void RegisterMethods<SBPlatform>(Registry &R) { (const char *)); LLDB_REGISTER_METHOD(lldb::SBError, SBPlatform, SetFilePermissions, (const char *, uint32_t)); + LLDB_REGISTER_METHOD(lldb::SBEnvironment, SBPlatform, GetEnvironment, ()); LLDB_REGISTER_METHOD_CONST(lldb::SBUnixSignals, SBPlatform, GetUnixSignals, ()); + LLDB_REGISTER_STATIC_METHOD(lldb::SBPlatform, SBPlatform, GetHostPlatform, + ()); } } diff --git a/lldb/source/API/SBProcess.cpp b/lldb/source/API/SBProcess.cpp index 45aaa0bd2d8a1..d7b7fd7cacadf 100644 --- a/lldb/source/API/SBProcess.cpp +++ b/lldb/source/API/SBProcess.cpp @@ -1,4 +1,4 @@ -//===-- SBProcess.cpp -------------------------------------------*- C++ -*-===// +//===-- SBProcess.cpp -----------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -18,6 +18,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/StreamFile.h" +#include "lldb/Core/StructuredDataImpl.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" @@ -74,7 +75,7 @@ const SBProcess &SBProcess::operator=(const SBProcess &rhs) { } // Destructor -SBProcess::~SBProcess() {} +SBProcess::~SBProcess() = default; const char *SBProcess::GetBroadcasterClassName() { LLDB_RECORD_STATIC_METHOD_NO_ARGS(const char *, SBProcess, @@ -270,8 +271,8 @@ size_t SBProcess::PutSTDIN(const char *src, size_t src_len) { } size_t SBProcess::GetSTDOUT(char *dst, size_t dst_len) const { - LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetSTDOUT, (char *, size_t), dst, - dst_len); + LLDB_RECORD_CHAR_PTR_METHOD_CONST(size_t, SBProcess, GetSTDOUT, + (char *, size_t), dst, "", dst_len); size_t bytes_read = 0; ProcessSP process_sp(GetSP()); @@ -284,8 +285,8 @@ size_t SBProcess::GetSTDOUT(char *dst, size_t dst_len) const { } size_t SBProcess::GetSTDERR(char *dst, size_t dst_len) const { - LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetSTDERR, (char *, size_t), dst, - dst_len); + LLDB_RECORD_CHAR_PTR_METHOD_CONST(size_t, SBProcess, GetSTDERR, + (char *, size_t), dst, "", dst_len); size_t bytes_read = 0; ProcessSP process_sp(GetSP()); @@ -298,8 +299,8 @@ size_t SBProcess::GetSTDERR(char *dst, size_t dst_len) const { } size_t SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const { - LLDB_RECORD_METHOD_CONST(size_t, SBProcess, GetAsyncProfileData, - (char *, size_t), dst, dst_len); + LLDB_RECORD_CHAR_PTR_METHOD_CONST(size_t, SBProcess, GetAsyncProfileData, + (char *, size_t), dst, "", dst_len); size_t bytes_read = 0; ProcessSP process_sp(GetSP()); @@ -1010,6 +1011,30 @@ bool SBProcess::GetDescription(SBStream &description) { return true; } +SBStructuredData SBProcess::GetExtendedCrashInformation() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBStructuredData, SBProcess, + GetExtendedCrashInformation); + SBStructuredData data; + ProcessSP process_sp(GetSP()); + if (!process_sp) + return LLDB_RECORD_RESULT(data); + + PlatformSP platform_sp = process_sp->GetTarget().GetPlatform(); + + if (!platform_sp) + return LLDB_RECORD_RESULT(data); + + auto expected_data = + platform_sp->FetchExtendedCrashInformation(*process_sp.get()); + + if (!expected_data) + return LLDB_RECORD_RESULT(data); + + StructuredData::ObjectSP fetched_data = *expected_data; + data.m_impl_up->SetObjectSP(fetched_data); + return LLDB_RECORD_RESULT(data); +} + uint32_t SBProcess::GetNumSupportedHardwareWatchpoints(lldb::SBError &sb_error) const { LLDB_RECORD_METHOD_CONST(uint32_t, SBProcess, @@ -1313,10 +1338,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_CONST(size_t, SBProcess, GetSTDOUT, (char *, size_t)); - LLDB_REGISTER_METHOD_CONST(size_t, SBProcess, GetSTDERR, (char *, size_t)); - LLDB_REGISTER_METHOD_CONST(size_t, SBProcess, GetAsyncProfileData, - (char *, size_t)); LLDB_REGISTER_METHOD(lldb::SBTrace, SBProcess, StartTrace, (lldb::SBTraceOptions &, lldb::SBError &)); LLDB_REGISTER_METHOD_CONST(void, SBProcess, ReportEventState, @@ -1389,6 +1410,8 @@ void RegisterMethods<SBProcess>(Registry &R) { LLDB_REGISTER_METHOD(lldb::addr_t, SBProcess, ReadPointerFromMemory, (lldb::addr_t, lldb::SBError &)); LLDB_REGISTER_METHOD(bool, SBProcess, GetDescription, (lldb::SBStream &)); + LLDB_REGISTER_METHOD(lldb::SBStructuredData, SBProcess, + GetExtendedCrashInformation, ()); LLDB_REGISTER_METHOD_CONST(uint32_t, SBProcess, GetNumSupportedHardwareWatchpoints, (lldb::SBError &)); @@ -1416,6 +1439,10 @@ void RegisterMethods<SBProcess>(Registry &R) { LLDB_REGISTER_METHOD(lldb::SBMemoryRegionInfoList, SBProcess, GetMemoryRegions, ()); LLDB_REGISTER_METHOD(lldb::SBProcessInfo, SBProcess, GetProcessInfo, ()); + + LLDB_REGISTER_CHAR_PTR_METHOD_CONST(size_t, SBProcess, GetSTDOUT); + LLDB_REGISTER_CHAR_PTR_METHOD_CONST(size_t, SBProcess, GetSTDERR); + LLDB_REGISTER_CHAR_PTR_METHOD_CONST(size_t, SBProcess, GetAsyncProfileData); } } diff --git a/lldb/source/API/SBProcessInfo.cpp b/lldb/source/API/SBProcessInfo.cpp index be242ec5872d9..29a9c7b24b5a7 100644 --- a/lldb/source/API/SBProcessInfo.cpp +++ b/lldb/source/API/SBProcessInfo.cpp @@ -1,4 +1,4 @@ -//===-- SBProcessInfo.cpp ---------------------------------------*- C++ -*-===// +//===-- SBProcessInfo.cpp -------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -25,7 +25,7 @@ SBProcessInfo::SBProcessInfo(const SBProcessInfo &rhs) : m_opaque_up() { m_opaque_up = clone(rhs.m_opaque_up); } -SBProcessInfo::~SBProcessInfo() {} +SBProcessInfo::~SBProcessInfo() = default; SBProcessInfo &SBProcessInfo::operator=(const SBProcessInfo &rhs) { LLDB_RECORD_METHOD(lldb::SBProcessInfo &, @@ -39,7 +39,7 @@ SBProcessInfo &SBProcessInfo::operator=(const SBProcessInfo &rhs) { ProcessInstanceInfo &SBProcessInfo::ref() { if (m_opaque_up == nullptr) { - m_opaque_up.reset(new ProcessInstanceInfo()); + m_opaque_up = std::make_unique<ProcessInstanceInfo>(); } return *m_opaque_up; } diff --git a/lldb/source/API/SBQueue.cpp b/lldb/source/API/SBQueue.cpp index 7d1581c42f60a..2e6571392ea16 100644 --- a/lldb/source/API/SBQueue.cpp +++ b/lldb/source/API/SBQueue.cpp @@ -1,4 +1,4 @@ -//===-- SBQueue.cpp ---------------------------------------------*- C++ -*-===// +//===-- SBQueue.cpp -------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -47,7 +47,7 @@ public: m_pending_items_fetched = rhs.m_pending_items_fetched; } - ~QueueImpl() {} + ~QueueImpl() = default; bool IsValid() { return m_queue_wp.lock() != nullptr; } @@ -243,7 +243,7 @@ const lldb::SBQueue &SBQueue::operator=(const lldb::SBQueue &rhs) { return LLDB_RECORD_RESULT(*this); } -SBQueue::~SBQueue() {} +SBQueue::~SBQueue() = default; bool SBQueue::IsValid() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBQueue, IsValid); diff --git a/lldb/source/API/SBQueueItem.cpp b/lldb/source/API/SBQueueItem.cpp index 5f2cbd1bdbfb9..0f92e2e041261 100644 --- a/lldb/source/API/SBQueueItem.cpp +++ b/lldb/source/API/SBQueueItem.cpp @@ -1,4 +1,4 @@ -//===-- SBQueueItem.cpp -----------------------------------------*- C++ -*-===// +//===-- SBQueueItem.cpp ---------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/lldb/source/API/SBReproducer.cpp b/lldb/source/API/SBReproducer.cpp index 3d2de07274448..0eb3429c4fefc 100644 --- a/lldb/source/API/SBReproducer.cpp +++ b/lldb/source/API/SBReproducer.cpp @@ -1,4 +1,4 @@ -//===-- SBReproducer.cpp ----------------------------------------*- C++ -*-===// +//===-- SBReproducer.cpp --------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -15,6 +15,7 @@ #include "lldb/API/SBBlock.h" #include "lldb/API/SBBreakpoint.h" #include "lldb/API/SBCommandInterpreter.h" +#include "lldb/API/SBCommandInterpreterRunOptions.h" #include "lldb/API/SBData.h" #include "lldb/API/SBDebugger.h" #include "lldb/API/SBDeclaration.h" @@ -40,14 +41,15 @@ SBRegistry::SBRegistry() { RegisterMethods<SBBreakpointLocation>(R); RegisterMethods<SBBreakpointName>(R); RegisterMethods<SBBroadcaster>(R); + RegisterMethods<SBCommandInterpreter>(R); RegisterMethods<SBCommandInterpreterRunOptions>(R); RegisterMethods<SBCommandReturnObject>(R); RegisterMethods<SBCommunication>(R); RegisterMethods<SBCompileUnit>(R); RegisterMethods<SBData>(R); - RegisterMethods<SBInputReader>(R); RegisterMethods<SBDebugger>(R); RegisterMethods<SBDeclaration>(R); + RegisterMethods<SBEnvironment>(R); RegisterMethods<SBError>(R); RegisterMethods<SBEvent>(R); RegisterMethods<SBExecutionContext>(R); @@ -58,6 +60,7 @@ SBRegistry::SBRegistry() { RegisterMethods<SBFrame>(R); RegisterMethods<SBFunction>(R); RegisterMethods<SBHostOS>(R); + RegisterMethods<SBInputReader>(R); RegisterMethods<SBInstruction>(R); RegisterMethods<SBInstructionList>(R); RegisterMethods<SBLanguageRuntime>(R); @@ -68,9 +71,9 @@ SBRegistry::SBRegistry() { RegisterMethods<SBMemoryRegionInfoList>(R); RegisterMethods<SBModule>(R); RegisterMethods<SBModuleSpec>(R); + RegisterMethods<SBPlatform>(R); RegisterMethods<SBPlatformConnectOptions>(R); RegisterMethods<SBPlatformShellCommand>(R); - RegisterMethods<SBPlatform>(R); RegisterMethods<SBProcess>(R); RegisterMethods<SBProcessInfo>(R); RegisterMethods<SBQueue>(R); @@ -95,8 +98,8 @@ SBRegistry::SBRegistry() { RegisterMethods<SBTypeFilter>(R); RegisterMethods<SBTypeFormat>(R); RegisterMethods<SBTypeNameSpecifier>(R); - RegisterMethods<SBTypeSummaryOptions>(R); RegisterMethods<SBTypeSummary>(R); + RegisterMethods<SBTypeSummaryOptions>(R); RegisterMethods<SBTypeSynthetic>(R); RegisterMethods<SBUnixSignals>(R); RegisterMethods<SBValue>(R); @@ -111,6 +114,12 @@ const char *SBReproducer::Capture() { error = llvm::toString(std::move(e)); return error.c_str(); } + + if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) { + auto &p = g->GetOrCreate<SBProvider>(); + InstrumentationData::Initialize(p.GetSerializer(), p.GetRegistry()); + } + return nullptr; } @@ -121,6 +130,35 @@ const char *SBReproducer::Capture(const char *path) { error = llvm::toString(std::move(e)); return error.c_str(); } + + if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) { + auto &p = g->GetOrCreate<SBProvider>(); + InstrumentationData::Initialize(p.GetSerializer(), p.GetRegistry()); + } + + return nullptr; +} + +const char *SBReproducer::PassiveReplay(const char *path) { + static std::string error; + if (auto e = Reproducer::Initialize(ReproducerMode::PassiveReplay, + FileSpec(path))) { + error = llvm::toString(std::move(e)); + return error.c_str(); + } + + if (auto *l = lldb_private::repro::Reproducer::Instance().GetLoader()) { + FileSpec file = l->GetFile<SBProvider::Info>(); + auto error_or_file = llvm::MemoryBuffer::getFile(file.GetPath()); + if (!error_or_file) { + error = + "unable to read SB API data: " + error_or_file.getError().message(); + return error.c_str(); + } + static ReplayData r(std::move(*error_or_file)); + InstrumentationData::Initialize(r.GetDeserializer(), r.GetRegistry()); + } + return nullptr; } @@ -178,6 +216,15 @@ bool SBReproducer::Generate() { return false; } +bool SBReproducer::SetAutoGenerate(bool b) { + auto &r = Reproducer::Instance(); + if (auto generator = r.GetGenerator()) { + generator->SetAutoGenerate(b); + return true; + } + return false; +} + const char *SBReproducer::GetPath() { static std::string path; auto &r = Reproducer::Instance(); @@ -185,6 +232,12 @@ const char *SBReproducer::GetPath() { return path.c_str(); } +void SBReproducer::SetWorkingDirectory(const char *path) { + if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) { + g->GetOrCreate<WorkingDirectoryProvider>().Update(path); + } +} + char lldb_private::repro::SBProvider::ID = 0; const char *SBProvider::Info::name = "sbapi"; const char *SBProvider::Info::file = "sbapi.bin"; diff --git a/lldb/source/API/SBReproducerPrivate.h b/lldb/source/API/SBReproducerPrivate.h index edd06941398f6..a4c6eb94627ba 100644 --- a/lldb/source/API/SBReproducerPrivate.h +++ b/lldb/source/API/SBReproducerPrivate.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_API_SBREPRODUCER_PRIVATE_H -#define LLDB_API_SBREPRODUCER_PRIVATE_H +#ifndef LLDB_SOURCE_API_SBREPRODUCERPRIVATE_H +#define LLDB_SOURCE_API_SBREPRODUCERPRIVATE_H #include "lldb/API/SBReproducer.h" @@ -20,7 +20,7 @@ #include "llvm/ADT/DenseMap.h" #define LLDB_GET_INSTRUMENTATION_DATA() \ - lldb_private::repro::GetInstrumentationData() + lldb_private::repro::InstrumentationData::Instance() namespace lldb_private { namespace repro { @@ -55,17 +55,19 @@ private: SBRegistry m_registry; }; -inline InstrumentationData GetInstrumentationData() { - if (!lldb_private::repro::Reproducer::Initialized()) - return {}; - - if (auto *g = lldb_private::repro::Reproducer::Instance().GetGenerator()) { - auto &p = g->GetOrCreate<SBProvider>(); - return {p.GetSerializer(), p.GetRegistry()}; - } +class ReplayData { +public: + ReplayData(std::unique_ptr<llvm::MemoryBuffer> memory_buffer) + : m_memory_buffer(std::move(memory_buffer)), m_registry(), + m_deserializer(m_memory_buffer->getBuffer()) {} + Deserializer &GetDeserializer() { return m_deserializer; } + Registry &GetRegistry() { return m_registry; } - return {}; -} +private: + std::unique_ptr<llvm::MemoryBuffer> m_memory_buffer; + SBRegistry m_registry; + Deserializer m_deserializer; +}; template <typename T> void RegisterMethods(Registry &R); diff --git a/lldb/source/API/SBSection.cpp b/lldb/source/API/SBSection.cpp index 14e1e14f59aa1..bb56fa18d9cab 100644 --- a/lldb/source/API/SBSection.cpp +++ b/lldb/source/API/SBSection.cpp @@ -1,4 +1,4 @@ -//===-- SBSection.cpp -------------------------------------------*- C++ -*-===// +//===-- SBSection.cpp -----------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -44,7 +44,7 @@ const SBSection &SBSection::operator=(const SBSection &rhs) { return LLDB_RECORD_RESULT(*this); } -SBSection::~SBSection() {} +SBSection::~SBSection() = default; bool SBSection::IsValid() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBSection, IsValid); @@ -281,7 +281,7 @@ bool SBSection::GetDescription(SBStream &description) { const addr_t file_addr = section_sp->GetFileAddress(); strm.Printf("[0x%16.16" PRIx64 "-0x%16.16" PRIx64 ") ", file_addr, file_addr + section_sp->GetByteSize()); - section_sp->DumpName(&strm); + section_sp->DumpName(strm.AsRawOstream()); } else { strm.PutCString("No value"); } diff --git a/lldb/source/API/SBSourceManager.cpp b/lldb/source/API/SBSourceManager.cpp index 9c4ce3c7f4e3a..43c3443672f73 100644 --- a/lldb/source/API/SBSourceManager.cpp +++ b/lldb/source/API/SBSourceManager.cpp @@ -1,4 +1,4 @@ -//===-- SBSourceManager.cpp -------------------------------------*- C++ -*-===// +//===-- SBSourceManager.cpp -----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -75,13 +75,13 @@ SBSourceManager::SBSourceManager(const SBDebugger &debugger) { LLDB_RECORD_CONSTRUCTOR(SBSourceManager, (const lldb::SBDebugger &), debugger); - m_opaque_up.reset(new SourceManagerImpl(debugger.get_sp())); + m_opaque_up = std::make_unique<SourceManagerImpl>(debugger.get_sp()); } SBSourceManager::SBSourceManager(const SBTarget &target) { LLDB_RECORD_CONSTRUCTOR(SBSourceManager, (const lldb::SBTarget &), target); - m_opaque_up.reset(new SourceManagerImpl(target.GetSP())); + m_opaque_up = std::make_unique<SourceManagerImpl>(target.GetSP()); } SBSourceManager::SBSourceManager(const SBSourceManager &rhs) { @@ -91,7 +91,7 @@ SBSourceManager::SBSourceManager(const SBSourceManager &rhs) { if (&rhs == this) return; - m_opaque_up.reset(new SourceManagerImpl(*(rhs.m_opaque_up.get()))); + m_opaque_up = std::make_unique<SourceManagerImpl>(*(rhs.m_opaque_up.get())); } const lldb::SBSourceManager &SBSourceManager:: @@ -100,11 +100,11 @@ operator=(const lldb::SBSourceManager &rhs) { SBSourceManager, operator=,(const lldb::SBSourceManager &), rhs); - m_opaque_up.reset(new SourceManagerImpl(*(rhs.m_opaque_up.get()))); + m_opaque_up = std::make_unique<SourceManagerImpl>(*(rhs.m_opaque_up.get())); return LLDB_RECORD_RESULT(*this); } -SBSourceManager::~SBSourceManager() {} +SBSourceManager::~SBSourceManager() = default; size_t SBSourceManager::DisplaySourceLinesWithLineNumbers( const SBFileSpec &file, uint32_t line, uint32_t context_before, diff --git a/lldb/source/API/SBStream.cpp b/lldb/source/API/SBStream.cpp index d57634d2947cd..eb81153084e8c 100644 --- a/lldb/source/API/SBStream.cpp +++ b/lldb/source/API/SBStream.cpp @@ -1,4 +1,4 @@ -//===-- SBStream.cpp ----------------------------------------*- C++ -*-===// +//===-- SBStream.cpp ------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -26,7 +26,7 @@ SBStream::SBStream() : m_opaque_up(new StreamString()), m_is_file(false) { SBStream::SBStream(SBStream &&rhs) : m_opaque_up(std::move(rhs.m_opaque_up)), m_is_file(rhs.m_is_file) {} -SBStream::~SBStream() {} +SBStream::~SBStream() = default; bool SBStream::IsValid() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBStream, IsValid); @@ -60,6 +60,12 @@ size_t SBStream::GetSize() { return static_cast<StreamString *>(m_opaque_up.get())->GetSize(); } +void SBStream::Print(const char *str) { + LLDB_RECORD_METHOD(void, SBStream, Print, (const char *), str); + + Printf("%s", str); +} + void SBStream::Printf(const char *format, ...) { if (!format) return; @@ -81,7 +87,8 @@ void SBStream::RedirectToFile(const char *path, bool append) { // See if we have any locally backed data. If so, copy it so we can then // redirect it to the file so we don't lose the data if (!m_is_file) - local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString(); + local_data = std::string( + static_cast<StreamString *>(m_opaque_up.get())->GetString()); } auto open_options = File::eOpenOptionWrite | File::eOpenOptionCanCreate; if (append) @@ -129,7 +136,8 @@ void SBStream::RedirectToFile(FileSP file_sp) { // See if we have any locally backed data. If so, copy it so we can then // redirect it to the file so we don't lose the data if (!m_is_file) - local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString(); + local_data = std::string( + static_cast<StreamString *>(m_opaque_up.get())->GetString()); } m_opaque_up = std::make_unique<StreamFile>(file_sp); @@ -150,7 +158,8 @@ void SBStream::RedirectToFileDescriptor(int fd, bool transfer_fh_ownership) { // See if we have any locally backed data. If so, copy it so we can then // redirect it to the file so we don't lose the data if (!m_is_file) - local_data = static_cast<StreamString *>(m_opaque_up.get())->GetString(); + local_data = std::string( + static_cast<StreamString *>(m_opaque_up.get())->GetString()); } m_opaque_up = std::make_unique<StreamFile>(fd, transfer_fh_ownership); @@ -168,7 +177,7 @@ lldb_private::Stream *SBStream::get() { return m_opaque_up.get(); } lldb_private::Stream &SBStream::ref() { if (m_opaque_up == nullptr) - m_opaque_up.reset(new StreamString()); + m_opaque_up = std::make_unique<StreamString>(); return *m_opaque_up; } @@ -201,6 +210,7 @@ void RegisterMethods<SBStream>(Registry &R) { LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileHandle, (FILE *, bool)); LLDB_REGISTER_METHOD(void, SBStream, RedirectToFileDescriptor, (int, bool)); LLDB_REGISTER_METHOD(void, SBStream, Clear, ()); + LLDB_REGISTER_METHOD(void, SBStream, Print, (const char *)); } } diff --git a/lldb/source/API/SBStringList.cpp b/lldb/source/API/SBStringList.cpp index ac07b8faac4df..d9b03692ec0e4 100644 --- a/lldb/source/API/SBStringList.cpp +++ b/lldb/source/API/SBStringList.cpp @@ -1,4 +1,4 @@ -//===-- SBStringList.cpp ----------------------------------------*- C++ -*-===// +//===-- SBStringList.cpp --------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -39,7 +39,7 @@ const SBStringList &SBStringList::operator=(const SBStringList &rhs) { return LLDB_RECORD_RESULT(*this); } -SBStringList::~SBStringList() {} +SBStringList::~SBStringList() = default; const lldb_private::StringList *SBStringList::operator->() const { return m_opaque_up.get(); @@ -66,7 +66,7 @@ void SBStringList::AppendString(const char *str) { if (IsValid()) m_opaque_up->AppendString(str); else - m_opaque_up.reset(new lldb_private::StringList(str)); + m_opaque_up = std::make_unique<lldb_private::StringList>(str); } } @@ -78,7 +78,7 @@ void SBStringList::AppendList(const char **strv, int strc) { if (IsValid()) m_opaque_up->AppendList(strv, strc); else - m_opaque_up.reset(new lldb_private::StringList(strv, strc)); + m_opaque_up = std::make_unique<lldb_private::StringList>(strv, strc); } } @@ -88,14 +88,14 @@ void SBStringList::AppendList(const SBStringList &strings) { if (strings.IsValid()) { if (!IsValid()) - m_opaque_up.reset(new lldb_private::StringList()); + m_opaque_up = std::make_unique<lldb_private::StringList>(); m_opaque_up->AppendList(*(strings.m_opaque_up)); } } void SBStringList::AppendList(const StringList &strings) { if (!IsValid()) - m_opaque_up.reset(new lldb_private::StringList()); + m_opaque_up = std::make_unique<lldb_private::StringList>(); m_opaque_up->AppendList(strings); } diff --git a/lldb/source/API/SBStructuredData.cpp b/lldb/source/API/SBStructuredData.cpp index 6b973e82c858b..2ae3005fd8d11 100644 --- a/lldb/source/API/SBStructuredData.cpp +++ b/lldb/source/API/SBStructuredData.cpp @@ -1,4 +1,4 @@ -//===-- SBStructuredData.cpp ------------------------------------*- C++ -*-===// +//===-- SBStructuredData.cpp ----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -45,7 +45,7 @@ SBStructuredData::SBStructuredData(lldb_private::StructuredDataImpl *impl) (lldb_private::StructuredDataImpl *), impl); } -SBStructuredData::~SBStructuredData() {} +SBStructuredData::~SBStructuredData() = default; SBStructuredData &SBStructuredData:: operator=(const lldb::SBStructuredData &rhs) { @@ -126,10 +126,10 @@ bool SBStructuredData::GetKeys(lldb::SBStringList &keys) const { if (!m_impl_up) return false; - + if (GetType() != eStructuredDataTypeDictionary) return false; - + StructuredData::ObjectSP obj_sp = m_impl_up->GetObjectSP(); if (!obj_sp) return false; @@ -141,7 +141,7 @@ bool SBStructuredData::GetKeys(lldb::SBStringList &keys) const { StructuredData::ObjectSP array_sp = dict->GetKeys(); StructuredData::Array *key_arr = array_sp->GetAsArray(); assert(key_arr); - + key_arr->ForEach([&keys] (StructuredData::Object *object) -> bool { llvm::StringRef key = object->GetStringValue(""); keys.AppendString(key.str().c_str()); @@ -196,8 +196,8 @@ bool SBStructuredData::GetBooleanValue(bool fail_value) const { } size_t SBStructuredData::GetStringValue(char *dst, size_t dst_len) const { - LLDB_RECORD_METHOD_CONST(size_t, SBStructuredData, GetStringValue, - (char *, size_t), dst, dst_len); + 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); } @@ -205,11 +205,9 @@ size_t SBStructuredData::GetStringValue(char *dst, size_t dst_len) const { namespace lldb_private { namespace repro { -template <> -void RegisterMethods<SBStructuredData>(Registry &R) { +template <> void RegisterMethods<SBStructuredData>(Registry &R) { LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, ()); - LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, - (const lldb::SBStructuredData &)); + LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, (const lldb::SBStructuredData &)); LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, (const lldb::EventSP &)); LLDB_REGISTER_CONSTRUCTOR(SBStructuredData, (lldb_private::StructuredDataImpl *)); @@ -236,12 +234,10 @@ void RegisterMethods<SBStructuredData>(Registry &R) { GetItemAtIndex, (size_t)); LLDB_REGISTER_METHOD_CONST(uint64_t, SBStructuredData, GetIntegerValue, (uint64_t)); - LLDB_REGISTER_METHOD_CONST(double, SBStructuredData, GetFloatValue, - (double)); + LLDB_REGISTER_METHOD_CONST(double, SBStructuredData, GetFloatValue, (double)); LLDB_REGISTER_METHOD_CONST(bool, SBStructuredData, GetBooleanValue, (bool)); - LLDB_REGISTER_METHOD_CONST(size_t, SBStructuredData, GetStringValue, - (char *, size_t)); + LLDB_REGISTER_CHAR_PTR_METHOD_CONST(size_t, SBStructuredData, GetStringValue); } -} -} +} // namespace repro +} // namespace lldb_private diff --git a/lldb/source/API/SBSymbol.cpp b/lldb/source/API/SBSymbol.cpp index 6cc90e0ee368b..e4f2f3518270b 100644 --- a/lldb/source/API/SBSymbol.cpp +++ b/lldb/source/API/SBSymbol.cpp @@ -1,4 +1,4 @@ -//===-- SBSymbol.cpp --------------------------------------------*- C++ -*-===// +//===-- SBSymbol.cpp ------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -68,9 +68,7 @@ const char *SBSymbol::GetDisplayName() const { const char *name = nullptr; if (m_opaque_ptr) - name = m_opaque_ptr->GetMangled() - .GetDisplayDemangledName(m_opaque_ptr->GetLanguage()) - .AsCString(); + name = m_opaque_ptr->GetMangled().GetDisplayDemangledName().AsCString(); return name; } @@ -126,22 +124,17 @@ SBInstructionList SBSymbol::GetInstructions(SBTarget target, SBInstructionList sb_instructions; if (m_opaque_ptr) { - ExecutionContext exe_ctx; TargetSP target_sp(target.GetSP()); std::unique_lock<std::recursive_mutex> lock; - if (target_sp) { + if (target_sp && m_opaque_ptr->ValueIsAddress()) { lock = std::unique_lock<std::recursive_mutex>(target_sp->GetAPIMutex()); - - target_sp->CalculateExecutionContext(exe_ctx); - } - if (m_opaque_ptr->ValueIsAddress()) { const Address &symbol_addr = m_opaque_ptr->GetAddressRef(); ModuleSP module_sp = symbol_addr.GetModule(); if (module_sp) { AddressRange symbol_range(symbol_addr, m_opaque_ptr->GetByteSize()); const bool prefer_file_cache = false; sb_instructions.SetDisassembler(Disassembler::DisassembleRange( - module_sp->GetArchitecture(), nullptr, flavor_string, exe_ctx, + module_sp->GetArchitecture(), nullptr, flavor_string, *target_sp, symbol_range, prefer_file_cache)); } } diff --git a/lldb/source/API/SBSymbolContext.cpp b/lldb/source/API/SBSymbolContext.cpp index 6e01e5535c322..488d498849038 100644 --- a/lldb/source/API/SBSymbolContext.cpp +++ b/lldb/source/API/SBSymbolContext.cpp @@ -1,4 +1,4 @@ -//===-- SBSymbolContext.cpp -------------------------------------*- C++ -*-===// +//===-- SBSymbolContext.cpp -----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -37,7 +37,7 @@ SBSymbolContext::SBSymbolContext(const SBSymbolContext &rhs) : m_opaque_up() { m_opaque_up = clone(rhs.m_opaque_up); } -SBSymbolContext::~SBSymbolContext() {} +SBSymbolContext::~SBSymbolContext() = default; const SBSymbolContext &SBSymbolContext::operator=(const SBSymbolContext &rhs) { LLDB_RECORD_METHOD(const lldb::SBSymbolContext &, @@ -185,13 +185,13 @@ const lldb_private::SymbolContext &SBSymbolContext::operator*() const { lldb_private::SymbolContext &SBSymbolContext::operator*() { if (m_opaque_up == nullptr) - m_opaque_up.reset(new SymbolContext); + m_opaque_up = std::make_unique<SymbolContext>(); return *m_opaque_up; } lldb_private::SymbolContext &SBSymbolContext::ref() { if (m_opaque_up == nullptr) - m_opaque_up.reset(new SymbolContext); + m_opaque_up = std::make_unique<SymbolContext>(); return *m_opaque_up; } diff --git a/lldb/source/API/SBSymbolContextList.cpp b/lldb/source/API/SBSymbolContextList.cpp index 915d04a0282a2..9db84dc1bf4b8 100644 --- a/lldb/source/API/SBSymbolContextList.cpp +++ b/lldb/source/API/SBSymbolContextList.cpp @@ -1,4 +1,4 @@ -//===-- SBSymbolContextList.cpp ---------------------------------*- C++ -*-===// +//===-- SBSymbolContextList.cpp -------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -28,7 +28,7 @@ SBSymbolContextList::SBSymbolContextList(const SBSymbolContextList &rhs) m_opaque_up = clone(rhs.m_opaque_up); } -SBSymbolContextList::~SBSymbolContextList() {} +SBSymbolContextList::~SBSymbolContextList() = default; const SBSymbolContextList &SBSymbolContextList:: operator=(const SBSymbolContextList &rhs) { diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 312e4df758631..b84e9f10fafe9 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -1,4 +1,4 @@ -//===-- SBTarget.cpp --------------------------------------------*- C++ -*-===// +//===-- SBTarget.cpp ------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -13,6 +13,7 @@ #include "lldb/API/SBBreakpoint.h" #include "lldb/API/SBDebugger.h" +#include "lldb/API/SBEnvironment.h" #include "lldb/API/SBEvent.h" #include "lldb/API/SBExpressionOptions.h" #include "lldb/API/SBFileSpec.h" @@ -118,7 +119,7 @@ const SBTarget &SBTarget::operator=(const SBTarget &rhs) { } // Destructor -SBTarget::~SBTarget() {} +SBTarget::~SBTarget() = default; bool SBTarget::EventIsTargetEvent(const SBEvent &event) { LLDB_RECORD_STATIC_METHOD(bool, SBTarget, EventIsTargetEvent, @@ -371,10 +372,19 @@ SBProcess SBTarget::Launch(SBListener &listener, char const **argv, Module *exe_module = target_sp->GetExecutableModulePointer(); if (exe_module) launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true); - if (argv) + if (argv) { launch_info.GetArguments().AppendArguments(argv); - if (envp) + } else { + auto default_launch_info = target_sp->GetProcessLaunchInfo(); + launch_info.GetArguments().AppendArguments( + default_launch_info.GetArguments()); + } + if (envp) { launch_info.GetEnvironment() = Environment(envp); + } else { + auto default_launch_info = target_sp->GetProcessLaunchInfo(); + launch_info.GetEnvironment() = default_launch_info.GetEnvironment(); + } if (listener.IsValid()) launch_info.SetListener(listener.GetSP()); @@ -556,7 +566,7 @@ lldb::SBProcess SBTarget::ConnectRemote(SBListener &listener, const char *url, if (process_sp) { sb_process.SetSP(process_sp); - error.SetError(process_sp->ConnectRemote(nullptr, url)); + error.SetError(process_sp->ConnectRemote(url)); } else { error.SetErrorString("unable to create lldb_private::Process"); } @@ -677,9 +687,9 @@ SBTarget::ResolveSymbolContextForAddress(const SBAddress &addr, size_t SBTarget::ReadMemory(const SBAddress addr, void *buf, size_t size, lldb::SBError &error) { - LLDB_RECORD_DUMMY(size_t, SBTarget, ReadMemory, - (const lldb::SBAddress, void *, size_t, lldb::SBError &), - addr, buf, size, error); + LLDB_RECORD_METHOD(size_t, SBTarget, ReadMemory, + (const lldb::SBAddress, void *, size_t, lldb::SBError &), + addr, buf, size, error); SBError sb_error; size_t bytes_read = 0; @@ -2054,21 +2064,22 @@ lldb::SBInstructionList SBTarget::ReadInstructions(lldb::SBAddress base_addr, lldb::SBInstructionList SBTarget::GetInstructions(lldb::SBAddress base_addr, const void *buf, size_t size) { - LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, GetInstructions, - (lldb::SBAddress, const void *, size_t), base_addr, buf, - size); + LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, GetInstructions, + (lldb::SBAddress, const void *, size_t), base_addr, buf, + size); - return GetInstructionsWithFlavor(base_addr, nullptr, buf, size); + return LLDB_RECORD_RESULT( + GetInstructionsWithFlavor(base_addr, nullptr, buf, size)); } lldb::SBInstructionList SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr, const char *flavor_string, const void *buf, size_t size) { - LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, - GetInstructionsWithFlavor, - (lldb::SBAddress, const char *, const void *, size_t), - base_addr, flavor_string, buf, size); + LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, + GetInstructionsWithFlavor, + (lldb::SBAddress, const char *, const void *, size_t), + base_addr, flavor_string, buf, size); SBInstructionList sb_instructions; @@ -2086,30 +2097,31 @@ SBTarget::GetInstructionsWithFlavor(lldb::SBAddress base_addr, UINT32_MAX, data_from_file)); } - return sb_instructions; + return LLDB_RECORD_RESULT(sb_instructions); } lldb::SBInstructionList SBTarget::GetInstructions(lldb::addr_t base_addr, const void *buf, size_t size) { - LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, GetInstructions, - (lldb::addr_t, const void *, size_t), base_addr, buf, size); + LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, GetInstructions, + (lldb::addr_t, const void *, size_t), base_addr, buf, + size); - return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), nullptr, buf, - size); + return LLDB_RECORD_RESULT(GetInstructionsWithFlavor( + ResolveLoadAddress(base_addr), nullptr, buf, size)); } lldb::SBInstructionList SBTarget::GetInstructionsWithFlavor(lldb::addr_t base_addr, const char *flavor_string, const void *buf, size_t size) { - LLDB_RECORD_DUMMY(lldb::SBInstructionList, SBTarget, - GetInstructionsWithFlavor, - (lldb::addr_t, const char *, const void *, size_t), - base_addr, flavor_string, buf, size); + LLDB_RECORD_METHOD(lldb::SBInstructionList, SBTarget, + GetInstructionsWithFlavor, + (lldb::addr_t, const char *, const void *, size_t), + base_addr, flavor_string, buf, size); - return GetInstructionsWithFlavor(ResolveLoadAddress(base_addr), flavor_string, - buf, size); + return LLDB_RECORD_RESULT(GetInstructionsWithFlavor( + ResolveLoadAddress(base_addr), flavor_string, buf, size)); } SBError SBTarget::SetSectionLoadAddress(lldb::SBSection section, @@ -2328,16 +2340,6 @@ lldb::SBValue SBTarget::EvaluateExpression(const char *expr, Target *target = exe_ctx.GetTargetPtr(); if (target) { -#ifdef LLDB_CONFIGURATION_DEBUG - StreamString frame_description; - if (frame) - frame->DumpUsingSettingsFormat(&frame_description); - llvm::PrettyStackTraceFormat stack_trace( - "SBTarget::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = " - "%u) %s", - expr, options.GetFetchDynamicValue(), - frame_description.GetString().str().c_str()); -#endif target->EvaluateExpression(expr, frame, expr_value_sp, options.ref()); expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue()); @@ -2386,6 +2388,17 @@ void SBTarget::SetLaunchInfo(const lldb::SBLaunchInfo &launch_info) { m_opaque_sp->SetProcessLaunchInfo(launch_info.ref()); } +SBEnvironment SBTarget::GetEnvironment() { + LLDB_RECORD_METHOD_NO_ARGS(lldb::SBEnvironment, SBTarget, GetEnvironment); + TargetSP target_sp(GetSP()); + + if (target_sp) { + return LLDB_RECORD_RESULT(SBEnvironment(target_sp->GetEnvironment())); + } + + return LLDB_RECORD_RESULT(SBEnvironment()); +} + namespace lldb_private { namespace repro { @@ -2628,6 +2641,20 @@ void RegisterMethods<SBTarget>(Registry &R) { LLDB_REGISTER_METHOD_CONST(lldb::SBLaunchInfo, SBTarget, GetLaunchInfo, ()); LLDB_REGISTER_METHOD(void, SBTarget, SetLaunchInfo, (const lldb::SBLaunchInfo &)); + LLDB_REGISTER_METHOD( + size_t, SBTarget, ReadMemory, + (const lldb::SBAddress, void *, size_t, lldb::SBError &)); + LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, GetInstructions, + (lldb::SBAddress, const void *, size_t)); + LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, + GetInstructionsWithFlavor, + (lldb::SBAddress, const char *, const void *, size_t)); + LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, GetInstructions, + (lldb::addr_t, const void *, size_t)); + LLDB_REGISTER_METHOD(lldb::SBInstructionList, SBTarget, + GetInstructionsWithFlavor, + (lldb::addr_t, const char *, const void *, size_t)); + LLDB_REGISTER_METHOD(lldb::SBEnvironment, SBTarget, GetEnvironment, ()); } } diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index f7f748f568321..0d50aceee5e41 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -1,4 +1,4 @@ -//===-- SBThread.cpp --------------------------------------------*- C++ -*-===// +//===-- SBThread.cpp ------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -40,7 +40,6 @@ #include "lldb/Target/ThreadPlanStepInstruction.h" #include "lldb/Target/ThreadPlanStepOut.h" #include "lldb/Target/ThreadPlanStepRange.h" -#include "lldb/Target/UnixSignals.h" #include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StructuredData.h" @@ -86,7 +85,7 @@ const lldb::SBThread &SBThread::operator=(const SBThread &rhs) { } // Destructor -SBThread::~SBThread() {} +SBThread::~SBThread() = default; lldb::SBQueue SBThread::GetQueue() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::SBQueue, SBThread, GetQueue); @@ -292,14 +291,13 @@ SBThread::GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type) { GetStopReasonExtendedBacktraces, (lldb::InstrumentationRuntimeType), type); - ThreadCollectionSP threads; - threads = std::make_shared<ThreadCollection>(); + SBThreadCollection threads; std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); if (!exe_ctx.HasThreadScope()) - return LLDB_RECORD_RESULT(threads); + return LLDB_RECORD_RESULT(SBThreadCollection()); ProcessSP process_sp = exe_ctx.GetProcessSP(); @@ -308,105 +306,38 @@ SBThread::GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type) { if (!info) return LLDB_RECORD_RESULT(threads); - return LLDB_RECORD_RESULT(process_sp->GetInstrumentationRuntime(type) - ->GetBacktracesFromExtendedStopInfo(info)); + threads = process_sp->GetInstrumentationRuntime(type) + ->GetBacktracesFromExtendedStopInfo(info); + return LLDB_RECORD_RESULT(threads); } size_t SBThread::GetStopDescription(char *dst, size_t dst_len) { - LLDB_RECORD_METHOD(size_t, SBThread, GetStopDescription, (char *, size_t), - dst, dst_len); + LLDB_RECORD_CHAR_PTR_METHOD(size_t, SBThread, GetStopDescription, + (char *, size_t), dst, "", dst_len); std::unique_lock<std::recursive_mutex> lock; ExecutionContext exe_ctx(m_opaque_sp.get(), lock); - if (exe_ctx.HasThreadScope()) { - Process::StopLocker stop_locker; - if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) { + if (dst) + *dst = 0; - StopInfoSP stop_info_sp = exe_ctx.GetThreadPtr()->GetStopInfo(); - if (stop_info_sp) { - const char *stop_desc = stop_info_sp->GetDescription(); - if (stop_desc) { - if (dst) - return ::snprintf(dst, dst_len, "%s", stop_desc); - else { - // NULL dst passed in, return the length needed to contain the - // description - return ::strlen(stop_desc) + 1; // Include the NULL byte for size - } - } else { - size_t stop_desc_len = 0; - switch (stop_info_sp->GetStopReason()) { - case eStopReasonTrace: - case eStopReasonPlanComplete: { - static char trace_desc[] = "step"; - stop_desc = trace_desc; - stop_desc_len = - sizeof(trace_desc); // Include the NULL byte for size - } break; - - case eStopReasonBreakpoint: { - static char bp_desc[] = "breakpoint hit"; - stop_desc = bp_desc; - stop_desc_len = sizeof(bp_desc); // Include the NULL byte for size - } break; - - case eStopReasonWatchpoint: { - static char wp_desc[] = "watchpoint hit"; - stop_desc = wp_desc; - stop_desc_len = sizeof(wp_desc); // Include the NULL byte for size - } break; - - case eStopReasonSignal: { - stop_desc = - exe_ctx.GetProcessPtr()->GetUnixSignals()->GetSignalAsCString( - stop_info_sp->GetValue()); - if (stop_desc == nullptr || stop_desc[0] == '\0') { - static char signal_desc[] = "signal"; - stop_desc = signal_desc; - stop_desc_len = - sizeof(signal_desc); // Include the NULL byte for size - } - } break; - - case eStopReasonException: { - char exc_desc[] = "exception"; - stop_desc = exc_desc; - stop_desc_len = sizeof(exc_desc); // Include the NULL byte for size - } break; - - case eStopReasonExec: { - char exc_desc[] = "exec"; - stop_desc = exc_desc; - stop_desc_len = sizeof(exc_desc); // Include the NULL byte for size - } break; - - case eStopReasonThreadExiting: { - char limbo_desc[] = "thread exiting"; - stop_desc = limbo_desc; - stop_desc_len = sizeof(limbo_desc); - } break; - default: - break; - } + if (!exe_ctx.HasThreadScope()) + return 0; - if (stop_desc && stop_desc[0]) { - if (dst) - return ::snprintf(dst, dst_len, "%s", stop_desc) + - 1; // Include the NULL byte + Process::StopLocker stop_locker; + if (!stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock())) + return 0; - if (stop_desc_len == 0) - stop_desc_len = ::strlen(stop_desc) + 1; // Include the NULL byte + std::string thread_stop_desc = exe_ctx.GetThreadPtr()->GetStopDescription(); + if (thread_stop_desc.empty()) + return 0; - return stop_desc_len; - } - } - } - } - } if (dst) - *dst = 0; - return 0; + return ::snprintf(dst, dst_len, "%s", thread_stop_desc.c_str()) + 1; + + // NULL dst passed in, return the length needed to contain the + // description. + return thread_stop_desc.size() + 1; // Include the NULL byte for size } SBValue SBThread::GetStopReturnValue() { @@ -970,23 +901,20 @@ SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name) { SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name, bool resume_immediately) { LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan, - (const char *, bool), script_class_name, + (const char *, bool), script_class_name, resume_immediately); lldb::SBStructuredData no_data; - return LLDB_RECORD_RESULT( - StepUsingScriptedThreadPlan(script_class_name, - no_data, - resume_immediately)); + return LLDB_RECORD_RESULT(StepUsingScriptedThreadPlan( + script_class_name, no_data, resume_immediately)); } SBError SBThread::StepUsingScriptedThreadPlan(const char *script_class_name, SBStructuredData &args_data, bool resume_immediately) { LLDB_RECORD_METHOD(lldb::SBError, SBThread, StepUsingScriptedThreadPlan, - (const char *, lldb::SBStructuredData &, bool), - script_class_name, args_data, - resume_immediately); + (const char *, lldb::SBStructuredData &, bool), + script_class_name, args_data, resume_immediately); SBError error; @@ -1444,8 +1372,6 @@ void RegisterMethods<SBThread>(Registry &R) { LLDB_REGISTER_METHOD(lldb::SBThreadCollection, SBThread, GetStopReasonExtendedBacktraces, (lldb::InstrumentationRuntimeType)); - LLDB_REGISTER_METHOD(size_t, SBThread, GetStopDescription, - (char *, size_t)); LLDB_REGISTER_METHOD(lldb::SBValue, SBThread, GetStopReturnValue, ()); LLDB_REGISTER_METHOD_CONST(lldb::tid_t, SBThread, GetThreadID, ()); LLDB_REGISTER_METHOD_CONST(uint32_t, SBThread, GetIndexID, ()); @@ -1522,6 +1448,7 @@ void RegisterMethods<SBThread>(Registry &R) { LLDB_REGISTER_METHOD(lldb::SBThread, SBThread, GetCurrentExceptionBacktrace, ()); LLDB_REGISTER_METHOD(bool, SBThread, SafeToCallFunctions, ()); + LLDB_REGISTER_CHAR_PTR_METHOD(size_t, SBThread, GetStopDescription); } } diff --git a/lldb/source/API/SBThreadCollection.cpp b/lldb/source/API/SBThreadCollection.cpp index 3c1cf98650620..bfca864d6bcdb 100644 --- a/lldb/source/API/SBThreadCollection.cpp +++ b/lldb/source/API/SBThreadCollection.cpp @@ -1,4 +1,4 @@ -//===-- SBThreadCollection.cpp ----------------------------------*- C++ -*-===// +//===-- SBThreadCollection.cpp --------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -38,7 +38,7 @@ operator=(const SBThreadCollection &rhs) { SBThreadCollection::SBThreadCollection(const ThreadCollectionSP &threads) : m_opaque_sp(threads) {} -SBThreadCollection::~SBThreadCollection() {} +SBThreadCollection::~SBThreadCollection() = default; void SBThreadCollection::SetOpaque(const lldb::ThreadCollectionSP &threads) { m_opaque_sp = threads; diff --git a/lldb/source/API/SBThreadPlan.cpp b/lldb/source/API/SBThreadPlan.cpp index eed4d1bfb9c49..1a947bbc26081 100644 --- a/lldb/source/API/SBThreadPlan.cpp +++ b/lldb/source/API/SBThreadPlan.cpp @@ -1,4 +1,4 @@ -//===-- SBThreadPlan.cpp ----------------------------------------*- C++ -*-===// +//===-- SBThreadPlan.cpp --------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -96,7 +96,7 @@ const lldb::SBThreadPlan &SBThreadPlan::operator=(const SBThreadPlan &rhs) { return LLDB_RECORD_RESULT(*this); } // Destructor -SBThreadPlan::~SBThreadPlan() {} +SBThreadPlan::~SBThreadPlan() = default; lldb_private::ThreadPlan *SBThreadPlan::get() { return m_opaque_sp.get(); } @@ -237,7 +237,9 @@ SBThreadPlan SBThreadPlan::QueueThreadPlanForStepOverRange( if (plan_status.Fail()) error.SetErrorString(plan_status.AsCString()); - + else + plan.m_opaque_sp->SetPrivate(true); + return LLDB_RECORD_RESULT(plan); } else { return LLDB_RECORD_RESULT(SBThreadPlan()); @@ -281,6 +283,8 @@ SBThreadPlan::QueueThreadPlanForStepInRange(SBAddress &sb_start_address, if (plan_status.Fail()) error.SetErrorString(plan_status.AsCString()); + else + plan.m_opaque_sp->SetPrivate(true); return LLDB_RECORD_RESULT(plan); } else { @@ -321,6 +325,8 @@ SBThreadPlan::QueueThreadPlanForStepOut(uint32_t frame_idx_to_step_to, if (plan_status.Fail()) error.SetErrorString(plan_status.AsCString()); + else + plan.m_opaque_sp->SetPrivate(true); return LLDB_RECORD_RESULT(plan); } else { @@ -356,6 +362,8 @@ SBThreadPlan SBThreadPlan::QueueThreadPlanForRunToAddress(SBAddress sb_address, if (plan_status.Fail()) error.SetErrorString(plan_status.AsCString()); + else + plan.m_opaque_sp->SetPrivate(true); return LLDB_RECORD_RESULT(plan); } else { @@ -390,6 +398,8 @@ SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name, if (plan_status.Fail()) error.SetErrorString(plan_status.AsCString()); + else + plan.m_opaque_sp->SetPrivate(true); return LLDB_RECORD_RESULT(plan); } else { @@ -415,6 +425,8 @@ SBThreadPlan::QueueThreadPlanForStepScripted(const char *script_class_name, if (plan_status.Fail()) error.SetErrorString(plan_status.AsCString()); + else + plan.m_opaque_sp->SetPrivate(true); return LLDB_RECORD_RESULT(plan); } else { diff --git a/lldb/source/API/SBTrace.cpp b/lldb/source/API/SBTrace.cpp index 9b871e6781d9b..3fdabaa29ac21 100644 --- a/lldb/source/API/SBTrace.cpp +++ b/lldb/source/API/SBTrace.cpp @@ -1,4 +1,4 @@ -//===-- SBTrace.cpp ---------------------------------------------*- C++ -*-===// +//===-- SBTrace.cpp -------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/lldb/source/API/SBTraceOptions.cpp b/lldb/source/API/SBTraceOptions.cpp index a24cdd59af0bf..f1f5a63edf069 100644 --- a/lldb/source/API/SBTraceOptions.cpp +++ b/lldb/source/API/SBTraceOptions.cpp @@ -1,4 +1,4 @@ -//===-- SBTraceOptions.cpp --------------------------------------*- C++ -*-===// +//===-- 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. diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp index 33b67ad4c0043..852630f2d01a6 100644 --- a/lldb/source/API/SBType.cpp +++ b/lldb/source/API/SBType.cpp @@ -1,4 +1,4 @@ -//===-- SBType.cpp ----------------------------------------------*- C++ -*-===// +//===-- SBType.cpp --------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -89,7 +89,7 @@ SBType &SBType::operator=(const SBType &rhs) { return LLDB_RECORD_RESULT(*this); } -SBType::~SBType() {} +SBType::~SBType() = default; TypeImpl &SBType::ref() { if (m_opaque_sp.get() == nullptr) @@ -589,7 +589,7 @@ SBTypeList &SBTypeList::operator=(const SBTypeList &rhs) { SBTypeList, operator=,(const lldb::SBTypeList &), rhs); if (this != &rhs) { - m_opaque_up.reset(new TypeListImpl()); + m_opaque_up = std::make_unique<TypeListImpl>(); for (uint32_t i = 0, rhs_size = const_cast<SBTypeList &>(rhs).GetSize(); i < rhs_size; i++) Append(const_cast<SBTypeList &>(rhs).GetTypeAtIndex(i)); @@ -619,20 +619,20 @@ uint32_t SBTypeList::GetSize() { return m_opaque_up->GetSize(); } -SBTypeList::~SBTypeList() {} +SBTypeList::~SBTypeList() = default; SBTypeMember::SBTypeMember() : m_opaque_up() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeMember); } -SBTypeMember::~SBTypeMember() {} +SBTypeMember::~SBTypeMember() = default; SBTypeMember::SBTypeMember(const SBTypeMember &rhs) : m_opaque_up() { LLDB_RECORD_CONSTRUCTOR(SBTypeMember, (const lldb::SBTypeMember &), rhs); if (this != &rhs) { if (rhs.IsValid()) - m_opaque_up.reset(new TypeMemberImpl(rhs.ref())); + m_opaque_up = std::make_unique<TypeMemberImpl>(rhs.ref()); } } @@ -642,7 +642,7 @@ lldb::SBTypeMember &SBTypeMember::operator=(const lldb::SBTypeMember &rhs) { if (this != &rhs) { if (rhs.IsValid()) - m_opaque_up.reset(new TypeMemberImpl(rhs.ref())); + m_opaque_up = std::make_unique<TypeMemberImpl>(rhs.ref()); } return LLDB_RECORD_RESULT(*this); } @@ -746,7 +746,7 @@ void SBTypeMember::reset(TypeMemberImpl *type_member_impl) { TypeMemberImpl &SBTypeMember::ref() { if (m_opaque_up == nullptr) - m_opaque_up.reset(new TypeMemberImpl()); + m_opaque_up = std::make_unique<TypeMemberImpl>(); return *m_opaque_up; } @@ -756,7 +756,7 @@ SBTypeMemberFunction::SBTypeMemberFunction() : m_opaque_sp() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeMemberFunction); } -SBTypeMemberFunction::~SBTypeMemberFunction() {} +SBTypeMemberFunction::~SBTypeMemberFunction() = default; SBTypeMemberFunction::SBTypeMemberFunction(const SBTypeMemberFunction &rhs) : m_opaque_sp(rhs.m_opaque_sp) { @@ -802,7 +802,7 @@ const char *SBTypeMemberFunction::GetDemangledName() { ConstString mangled_str = m_opaque_sp->GetMangledName(); if (mangled_str) { Mangled mangled(mangled_str); - return mangled.GetDemangledName(mangled.GuessLanguage()).GetCString(); + return mangled.GetDemangledName().GetCString(); } } return nullptr; diff --git a/lldb/source/API/SBTypeCategory.cpp b/lldb/source/API/SBTypeCategory.cpp index 1e4496575098b..9ce1a57ec4f72 100644 --- a/lldb/source/API/SBTypeCategory.cpp +++ b/lldb/source/API/SBTypeCategory.cpp @@ -1,5 +1,4 @@ -//===-- SBTypeCategory.cpp ----------------------------------------*- C++ -//-*-===// +//===-- SBTypeCategory.cpp ------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -40,7 +39,7 @@ SBTypeCategory::SBTypeCategory(const lldb::SBTypeCategory &rhs) LLDB_RECORD_CONSTRUCTOR(SBTypeCategory, (const lldb::SBTypeCategory &), rhs); } -SBTypeCategory::~SBTypeCategory() {} +SBTypeCategory::~SBTypeCategory() = default; bool SBTypeCategory::IsValid() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeCategory, IsValid); diff --git a/lldb/source/API/SBTypeEnumMember.cpp b/lldb/source/API/SBTypeEnumMember.cpp index bd0755a140c33..43a4891b54b10 100644 --- a/lldb/source/API/SBTypeEnumMember.cpp +++ b/lldb/source/API/SBTypeEnumMember.cpp @@ -1,4 +1,4 @@ -//===-- SBTypeEnumMember.cpp ---------------------------------- -*- C++ -*-===// +//===-- SBTypeEnumMember.cpp ----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -25,7 +25,7 @@ SBTypeEnumMember::SBTypeEnumMember() : m_opaque_sp() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeEnumMember); } -SBTypeEnumMember::~SBTypeEnumMember() {} +SBTypeEnumMember::~SBTypeEnumMember() = default; SBTypeEnumMember::SBTypeEnumMember( const lldb::TypeEnumMemberImplSP &enum_member_sp) @@ -141,7 +141,7 @@ operator=(const SBTypeEnumMemberList &rhs) { rhs); if (this != &rhs) { - m_opaque_up.reset(new TypeEnumMemberListImpl()); + m_opaque_up = std::make_unique<TypeEnumMemberListImpl>(); for (uint32_t i = 0, rhs_size = const_cast<SBTypeEnumMemberList &>(rhs).GetSize(); i < rhs_size; i++) @@ -176,7 +176,7 @@ uint32_t SBTypeEnumMemberList::GetSize() { return m_opaque_up->GetSize(); } -SBTypeEnumMemberList::~SBTypeEnumMemberList() {} +SBTypeEnumMemberList::~SBTypeEnumMemberList() = default; bool SBTypeEnumMember::GetDescription( lldb::SBStream &description, lldb::DescriptionLevel description_level) { diff --git a/lldb/source/API/SBTypeFilter.cpp b/lldb/source/API/SBTypeFilter.cpp index d40301b4c1538..5f91a194f16bf 100644 --- a/lldb/source/API/SBTypeFilter.cpp +++ b/lldb/source/API/SBTypeFilter.cpp @@ -1,5 +1,4 @@ -//===-- SBTypeFilter.cpp ------------------------------------------*- C++ -//-*-===// +//===-- SBTypeFilter.cpp --------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -31,7 +30,7 @@ SBTypeFilter::SBTypeFilter(const lldb::SBTypeFilter &rhs) LLDB_RECORD_CONSTRUCTOR(SBTypeFilter, (const lldb::SBTypeFilter &), rhs); } -SBTypeFilter::~SBTypeFilter() {} +SBTypeFilter::~SBTypeFilter() = default; bool SBTypeFilter::IsValid() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeFilter, IsValid); diff --git a/lldb/source/API/SBTypeFormat.cpp b/lldb/source/API/SBTypeFormat.cpp index 6024631e7054f..70289bef8db5d 100644 --- a/lldb/source/API/SBTypeFormat.cpp +++ b/lldb/source/API/SBTypeFormat.cpp @@ -1,5 +1,4 @@ -//===-- SBTypeFormat.cpp ------------------------------------------*- C++ -//-*-===// +//===-- SBTypeFormat.cpp --------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -40,7 +39,7 @@ SBTypeFormat::SBTypeFormat(const lldb::SBTypeFormat &rhs) LLDB_RECORD_CONSTRUCTOR(SBTypeFormat, (const lldb::SBTypeFormat &), rhs); } -SBTypeFormat::~SBTypeFormat() {} +SBTypeFormat::~SBTypeFormat() = default; bool SBTypeFormat::IsValid() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeFormat, IsValid); diff --git a/lldb/source/API/SBTypeNameSpecifier.cpp b/lldb/source/API/SBTypeNameSpecifier.cpp index 895f697756598..3673a50245304 100644 --- a/lldb/source/API/SBTypeNameSpecifier.cpp +++ b/lldb/source/API/SBTypeNameSpecifier.cpp @@ -1,5 +1,4 @@ -//===-- SBTypeNameSpecifier.cpp ------------------------------------*- C++ -//-*-===// +//===-- SBTypeNameSpecifier.cpp -------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -45,7 +44,7 @@ SBTypeNameSpecifier::SBTypeNameSpecifier(const lldb::SBTypeNameSpecifier &rhs) (const lldb::SBTypeNameSpecifier &), rhs); } -SBTypeNameSpecifier::~SBTypeNameSpecifier() {} +SBTypeNameSpecifier::~SBTypeNameSpecifier() = default; bool SBTypeNameSpecifier::IsValid() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeNameSpecifier, IsValid); diff --git a/lldb/source/API/SBTypeSummary.cpp b/lldb/source/API/SBTypeSummary.cpp index 8ffb234357572..3800ae940c703 100644 --- a/lldb/source/API/SBTypeSummary.cpp +++ b/lldb/source/API/SBTypeSummary.cpp @@ -1,5 +1,4 @@ -//===-- SBTypeSummary.cpp -----------------------------------------*- C++ -//-*-===// +//===-- SBTypeSummary.cpp -------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -22,7 +21,7 @@ using namespace lldb_private; SBTypeSummaryOptions::SBTypeSummaryOptions() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeSummaryOptions); - m_opaque_up.reset(new TypeSummaryOptions()); + m_opaque_up = std::make_unique<TypeSummaryOptions>(); } SBTypeSummaryOptions::SBTypeSummaryOptions( @@ -33,7 +32,7 @@ SBTypeSummaryOptions::SBTypeSummaryOptions( m_opaque_up = clone(rhs.m_opaque_up); } -SBTypeSummaryOptions::~SBTypeSummaryOptions() {} +SBTypeSummaryOptions::~SBTypeSummaryOptions() = default; bool SBTypeSummaryOptions::IsValid() { LLDB_RECORD_METHOD_NO_ARGS(bool, SBTypeSummaryOptions, IsValid); @@ -112,9 +111,9 @@ SBTypeSummaryOptions::SBTypeSummaryOptions( void SBTypeSummaryOptions::SetOptions( const lldb_private::TypeSummaryOptions *lldb_object_ptr) { if (lldb_object_ptr) - m_opaque_up.reset(new TypeSummaryOptions(*lldb_object_ptr)); + m_opaque_up = std::make_unique<TypeSummaryOptions>(*lldb_object_ptr); else - m_opaque_up.reset(new TypeSummaryOptions()); + m_opaque_up = std::make_unique<TypeSummaryOptions>(); } SBTypeSummary::SBTypeSummary() : m_opaque_sp() { @@ -193,7 +192,7 @@ SBTypeSummary::SBTypeSummary(const lldb::SBTypeSummary &rhs) LLDB_RECORD_CONSTRUCTOR(SBTypeSummary, (const lldb::SBTypeSummary &), rhs); } -SBTypeSummary::~SBTypeSummary() {} +SBTypeSummary::~SBTypeSummary() = default; bool SBTypeSummary::IsValid() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSummary, IsValid); diff --git a/lldb/source/API/SBTypeSynthetic.cpp b/lldb/source/API/SBTypeSynthetic.cpp index df6fce1269f09..af5e167b9c247 100644 --- a/lldb/source/API/SBTypeSynthetic.cpp +++ b/lldb/source/API/SBTypeSynthetic.cpp @@ -1,5 +1,4 @@ -//===-- SBTypeSynthetic.cpp -----------------------------------------*- C++ -//-*-===// +//===-- SBTypeSynthetic.cpp -----------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -51,7 +50,7 @@ SBTypeSynthetic::SBTypeSynthetic(const lldb::SBTypeSynthetic &rhs) rhs); } -SBTypeSynthetic::~SBTypeSynthetic() {} +SBTypeSynthetic::~SBTypeSynthetic() = default; bool SBTypeSynthetic::IsValid() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBTypeSynthetic, IsValid); diff --git a/lldb/source/API/SBUnixSignals.cpp b/lldb/source/API/SBUnixSignals.cpp index 277a92d21ae98..a933f6d223336 100644 --- a/lldb/source/API/SBUnixSignals.cpp +++ b/lldb/source/API/SBUnixSignals.cpp @@ -1,5 +1,4 @@ -//===-- SBUnixSignals.cpp -------------------------------------------*- C++ -//-*-===// +//===-- SBUnixSignals.cpp -------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -43,7 +42,7 @@ const SBUnixSignals &SBUnixSignals::operator=(const SBUnixSignals &rhs) { return LLDB_RECORD_RESULT(*this); } -SBUnixSignals::~SBUnixSignals() {} +SBUnixSignals::~SBUnixSignals() = default; UnixSignalsSP SBUnixSignals::GetSP() const { return m_opaque_wp.lock(); } diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 396a9d3ea10c4..7485b0ee1838e 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -1,4 +1,4 @@ -//===-- SBValue.cpp ---------------------------------------------*- C++ -*-===// +//===-- SBValue.cpp -------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -53,7 +53,7 @@ using namespace lldb_private; class ValueImpl { public: - ValueImpl() {} + ValueImpl() = default; ValueImpl(lldb::ValueObjectSP in_valobj_sp, lldb::DynamicValueType use_dynamic, bool use_synthetic, @@ -137,7 +137,7 @@ public: } if (m_use_synthetic) { - ValueObjectSP synthetic_sp = value_sp->GetSyntheticValue(m_use_synthetic); + ValueObjectSP synthetic_sp = value_sp->GetSyntheticValue(); if (synthetic_sp) value_sp = synthetic_sp; } @@ -201,7 +201,7 @@ private: class ValueLocker { public: - ValueLocker() {} + ValueLocker() = default; ValueObjectSP GetLockedSP(ValueImpl &in_value) { return in_value.GetSP(m_stop_locker, m_lock, m_lock_error); @@ -239,7 +239,7 @@ SBValue &SBValue::operator=(const SBValue &rhs) { return LLDB_RECORD_RESULT(*this); } -SBValue::~SBValue() {} +SBValue::~SBValue() = default; bool SBValue::IsValid() { LLDB_RECORD_METHOD_NO_ARGS(bool, SBValue, IsValid); @@ -1154,7 +1154,7 @@ bool SBValue::GetExpressionPath(SBStream &description) { ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { - value_sp->GetExpressionPath(description.ref(), false); + value_sp->GetExpressionPath(description.ref()); return true; } return false; @@ -1168,7 +1168,7 @@ bool SBValue::GetExpressionPath(SBStream &description, ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) { - value_sp->GetExpressionPath(description.ref(), qualify_cxx_base_classes); + value_sp->GetExpressionPath(description.ref()); return true; } return false; @@ -1493,7 +1493,7 @@ lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write, StreamString ss; // True to show fullpath for declaration file. decl.DumpStopContext(&ss, true); - watchpoint_sp->SetDeclInfo(ss.GetString()); + watchpoint_sp->SetDeclInfo(std::string(ss.GetString())); } } } diff --git a/lldb/source/API/SBValueList.cpp b/lldb/source/API/SBValueList.cpp index 7e909df260d7d..0fd2a591c321c 100644 --- a/lldb/source/API/SBValueList.cpp +++ b/lldb/source/API/SBValueList.cpp @@ -1,4 +1,4 @@ -//===-- SBValueList.cpp -----------------------------------------*- C++ -*-===// +//===-- SBValueList.cpp ---------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -75,15 +75,15 @@ SBValueList::SBValueList(const SBValueList &rhs) : m_opaque_up() { LLDB_RECORD_CONSTRUCTOR(SBValueList, (const lldb::SBValueList &), rhs); if (rhs.IsValid()) - m_opaque_up.reset(new ValueListImpl(*rhs)); + m_opaque_up = std::make_unique<ValueListImpl>(*rhs); } SBValueList::SBValueList(const ValueListImpl *lldb_object_ptr) : m_opaque_up() { if (lldb_object_ptr) - m_opaque_up.reset(new ValueListImpl(*lldb_object_ptr)); + m_opaque_up = std::make_unique<ValueListImpl>(*lldb_object_ptr); } -SBValueList::~SBValueList() {} +SBValueList::~SBValueList() = default; bool SBValueList::IsValid() const { LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBValueList, IsValid); @@ -107,7 +107,7 @@ const SBValueList &SBValueList::operator=(const SBValueList &rhs) { if (this != &rhs) { if (rhs.IsValid()) - m_opaque_up.reset(new ValueListImpl(*rhs)); + m_opaque_up = std::make_unique<ValueListImpl>(*rhs); else m_opaque_up.reset(); } @@ -173,7 +173,7 @@ uint32_t SBValueList::GetSize() const { void SBValueList::CreateIfNeeded() { if (m_opaque_up == nullptr) - m_opaque_up.reset(new ValueListImpl()); + m_opaque_up = std::make_unique<ValueListImpl>(); } SBValue SBValueList::FindValueObjectByUID(lldb::user_id_t uid) { diff --git a/lldb/source/API/SBVariablesOptions.cpp b/lldb/source/API/SBVariablesOptions.cpp index bf0197cd960bd..4ef16364e6280 100644 --- a/lldb/source/API/SBVariablesOptions.cpp +++ b/lldb/source/API/SBVariablesOptions.cpp @@ -1,5 +1,4 @@ -//===-- SBVariablesOptions.cpp --------------------------------------*- C++ -//-*-===// +//===-- SBVariablesOptions.cpp --------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -98,7 +97,7 @@ operator=(const SBVariablesOptions &options) { SBVariablesOptions, operator=,(const lldb::SBVariablesOptions &), options); - m_opaque_up.reset(new VariablesOptionsImpl(options.ref())); + m_opaque_up = std::make_unique<VariablesOptionsImpl>(options.ref()); return LLDB_RECORD_RESULT(*this); } diff --git a/lldb/source/API/SBWatchpoint.cpp b/lldb/source/API/SBWatchpoint.cpp index d0a36b71e5c18..eba75dea8f8dd 100644 --- a/lldb/source/API/SBWatchpoint.cpp +++ b/lldb/source/API/SBWatchpoint.cpp @@ -1,4 +1,4 @@ -//===-- SBWatchpoint.cpp --------------------------------*- C++ -*-===// +//===-- SBWatchpoint.cpp --------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -46,7 +46,7 @@ const SBWatchpoint &SBWatchpoint::operator=(const SBWatchpoint &rhs) { return LLDB_RECORD_RESULT(*this); } -SBWatchpoint::~SBWatchpoint() {} +SBWatchpoint::~SBWatchpoint() = default; watch_id_t SBWatchpoint::GetID() { LLDB_RECORD_METHOD_NO_ARGS(lldb::watch_id_t, SBWatchpoint, GetID); diff --git a/lldb/source/API/SystemInitializerFull.cpp b/lldb/source/API/SystemInitializerFull.cpp index 06f1a6cd3b750..7f95e7acf62ab 100644 --- a/lldb/source/API/SystemInitializerFull.cpp +++ b/lldb/source/API/SystemInitializerFull.cpp @@ -1,4 +1,4 @@ -//===-- SystemInitializerFull.cpp -------------------------------*- C++ -*-===// +//===-- SystemInitializerFull.cpp -----------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -8,119 +8,13 @@ #include "SystemInitializerFull.h" #include "lldb/API/SBCommandInterpreter.h" -#include "lldb/Host/Config.h" - -#if LLDB_ENABLE_PYTHON -#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h" -#endif - -#if LLDB_ENABLE_LUA -#include "Plugins/ScriptInterpreter/Lua/ScriptInterpreterLua.h" -#endif - #include "lldb/Core/Debugger.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Host/Config.h" #include "lldb/Host/Host.h" #include "lldb/Initialization/SystemInitializerCommon.h" #include "lldb/Interpreter/CommandInterpreter.h" -#include "lldb/Symbol/ClangASTContext.h" #include "lldb/Utility/Timer.h" - -#include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h" -#include "Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.h" -#include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h" -#include "Plugins/ABI/SysV-arc/ABISysV_arc.h" -#include "Plugins/ABI/SysV-arm/ABISysV_arm.h" -#include "Plugins/ABI/SysV-arm64/ABISysV_arm64.h" -#include "Plugins/ABI/SysV-hexagon/ABISysV_hexagon.h" -#include "Plugins/ABI/SysV-i386/ABISysV_i386.h" -#include "Plugins/ABI/SysV-mips/ABISysV_mips.h" -#include "Plugins/ABI/SysV-mips64/ABISysV_mips64.h" -#include "Plugins/ABI/SysV-ppc/ABISysV_ppc.h" -#include "Plugins/ABI/SysV-ppc64/ABISysV_ppc64.h" -#include "Plugins/ABI/SysV-s390x/ABISysV_s390x.h" -#include "Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h" -#include "Plugins/ABI/Windows-x86_64/ABIWindows_x86_64.h" -#include "Plugins/Architecture/Arm/ArchitectureArm.h" -#include "Plugins/Architecture/Mips/ArchitectureMips.h" -#include "Plugins/Architecture/PPC64/ArchitecturePPC64.h" -#include "Plugins/Disassembler/llvm/DisassemblerLLVMC.h" -#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h" -#include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h" -#include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h" -#include "Plugins/DynamicLoader/Static/DynamicLoaderStatic.h" -#include "Plugins/DynamicLoader/Windows-DYLD/DynamicLoaderWindowsDYLD.h" -#include "Plugins/Instruction/ARM/EmulateInstructionARM.h" -#include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h" -#include "Plugins/Instruction/MIPS/EmulateInstructionMIPS.h" -#include "Plugins/Instruction/MIPS64/EmulateInstructionMIPS64.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" -#include "Plugins/InstrumentationRuntime/UBSan/UBSanRuntime.h" -#include "Plugins/JITLoader/GDB/JITLoaderGDB.h" -#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h" -#include "Plugins/Language/ObjC/ObjCLanguage.h" -#include "Plugins/Language/ObjCPlusPlus/ObjCPlusPlusLanguage.h" -#include "Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.h" -#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV1.h" -#include "Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.h" -#include "Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h" -#include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h" -#include "Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h" -#include "Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h" -#include "Plugins/ObjectFile/Breakpad/ObjectFileBreakpad.h" -#include "Plugins/ObjectFile/ELF/ObjectFileELF.h" -#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h" -#include "Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h" -#include "Plugins/OperatingSystem/Python/OperatingSystemPython.h" -#include "Plugins/Platform/Android/PlatformAndroid.h" -#include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h" -#include "Plugins/Platform/Linux/PlatformLinux.h" -#include "Plugins/Platform/MacOSX/PlatformMacOSX.h" -#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h" -#include "Plugins/Platform/NetBSD/PlatformNetBSD.h" -#include "Plugins/Platform/OpenBSD/PlatformOpenBSD.h" -#include "Plugins/Platform/Windows/PlatformWindows.h" -#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/Breakpad/SymbolFileBreakpad.h" -#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" -#include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h" -#include "Plugins/SymbolFile/PDB/SymbolFilePDB.h" -#include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h" -#include "Plugins/SymbolVendor/ELF/SymbolVendorELF.h" -#include "Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h" -#include "Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h" -#include "Plugins/UnwindAssembly/x86/UnwindAssembly-x86.h" - -#if defined(__APPLE__) -#include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h" -#include "Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h" -#include "Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h" -#include "Plugins/Platform/MacOSX/PlatformDarwinKernel.h" -#include "Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h" -#include "Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h" -#include "Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h" -#include "Plugins/Platform/MacOSX/PlatformiOSSimulator.h" -#include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h" -#include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h" -#endif -#include "Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.h" - -#if defined(__FreeBSD__) -#include "Plugins/Process/FreeBSD/ProcessFreeBSD.h" -#endif - -#if defined(_WIN32) -#include "Plugins/Process/Windows/Common/ProcessWindows.h" -#include "lldb/Host/windows/windows.h" -#endif - #include "llvm/Support/TargetSelect.h" #pragma clang diagnostic push @@ -130,174 +24,32 @@ #include <string> -using namespace lldb_private; - -SystemInitializerFull::SystemInitializerFull() {} - -SystemInitializerFull::~SystemInitializerFull() {} +#define LLDB_PLUGIN(p) LLDB_PLUGIN_DECLARE(p) +#include "Plugins/Plugins.def" -#define LLDB_PROCESS_AArch64(op) \ - ABIMacOSX_arm64::op(); \ - ABISysV_arm64::op(); -#define LLDB_PROCESS_ARM(op) \ - ABIMacOSX_arm::op(); \ - ABISysV_arm::op(); -#define LLDB_PROCESS_ARC(op) \ - ABISysV_arc::op(); -#define LLDB_PROCESS_Hexagon(op) ABISysV_hexagon::op(); -#define LLDB_PROCESS_Mips(op) \ - ABISysV_mips::op(); \ - ABISysV_mips64::op(); -#define LLDB_PROCESS_PowerPC(op) \ - ABISysV_ppc::op(); \ - ABISysV_ppc64::op(); -#define LLDB_PROCESS_SystemZ(op) ABISysV_s390x::op(); -#define LLDB_PROCESS_X86(op) \ - ABIMacOSX_i386::op(); \ - ABISysV_i386::op(); \ - ABISysV_x86_64::op(); \ - ABIWindows_x86_64::op(); +using namespace lldb_private; -#define LLDB_PROCESS_AMDGPU(op) -#define LLDB_PROCESS_AVR(op) -#define LLDB_PROCESS_BPF(op) -#define LLDB_PROCESS_Lanai(op) -#define LLDB_PROCESS_MSP430(op) -#define LLDB_PROCESS_NVPTX(op) -#define LLDB_PROCESS_RISCV(op) -#define LLDB_PROCESS_Sparc(op) -#define LLDB_PROCESS_WebAssembly(op) -#define LLDB_PROCESS_XCore(op) +SystemInitializerFull::SystemInitializerFull() = default; +SystemInitializerFull::~SystemInitializerFull() = default; llvm::Error SystemInitializerFull::Initialize() { if (auto e = SystemInitializerCommon::Initialize()) return e; - breakpad::ObjectFileBreakpad::Initialize(); - ObjectFileELF::Initialize(); - ObjectFileMachO::Initialize(); - ObjectFilePECOFF::Initialize(); - - ObjectContainerBSDArchive::Initialize(); - ObjectContainerUniversalMachO::Initialize(); - - ScriptInterpreterNone::Initialize(); - -#if LLDB_ENABLE_PYTHON - OperatingSystemPython::Initialize(); -#endif - -#if LLDB_ENABLE_PYTHON - ScriptInterpreterPython::Initialize(); -#endif - -#if LLDB_ENABLE_LUA - ScriptInterpreterLua::Initialize(); -#endif - - platform_freebsd::PlatformFreeBSD::Initialize(); - platform_linux::PlatformLinux::Initialize(); - platform_netbsd::PlatformNetBSD::Initialize(); - platform_openbsd::PlatformOpenBSD::Initialize(); - PlatformWindows::Initialize(); - platform_android::PlatformAndroid::Initialize(); - PlatformRemoteiOS::Initialize(); - PlatformMacOSX::Initialize(); -#if defined(__APPLE__) - PlatformiOSSimulator::Initialize(); - PlatformDarwinKernel::Initialize(); -#endif - // Initialize LLVM and Clang llvm::InitializeAllTargets(); llvm::InitializeAllAsmPrinters(); llvm::InitializeAllTargetMCs(); llvm::InitializeAllDisassemblers(); - ClangASTContext::Initialize(); - -#define LLVM_TARGET(t) LLDB_PROCESS_ ## t(Initialize) -#include "llvm/Config/Targets.def" - - ArchitectureArm::Initialize(); - ArchitectureMips::Initialize(); - ArchitecturePPC64::Initialize(); - - DisassemblerLLVMC::Initialize(); - - JITLoaderGDB::Initialize(); - ProcessElfCore::Initialize(); - ProcessMachCore::Initialize(); - minidump::ProcessMinidump::Initialize(); - MemoryHistoryASan::Initialize(); - AddressSanitizerRuntime::Initialize(); - ThreadSanitizerRuntime::Initialize(); - UndefinedBehaviorSanitizerRuntime::Initialize(); - MainThreadCheckerRuntime::Initialize(); - - SymbolVendorELF::Initialize(); - breakpad::SymbolFileBreakpad::Initialize(); - SymbolFileDWARF::Initialize(); - SymbolFilePDB::Initialize(); - SymbolFileSymtab::Initialize(); - UnwindAssemblyInstEmulation::Initialize(); - UnwindAssembly_x86::Initialize(); - - EmulateInstructionARM::Initialize(); - EmulateInstructionARM64::Initialize(); - EmulateInstructionMIPS::Initialize(); - EmulateInstructionMIPS64::Initialize(); - EmulateInstructionPPC64::Initialize(); - - SymbolFileDWARFDebugMap::Initialize(); - ItaniumABILanguageRuntime::Initialize(); - AppleObjCRuntimeV2::Initialize(); - AppleObjCRuntimeV1::Initialize(); - SystemRuntimeMacOSX::Initialize(); - RenderScriptRuntime::Initialize(); - - CPlusPlusLanguage::Initialize(); - ObjCLanguage::Initialize(); - ObjCPlusPlusLanguage::Initialize(); - -#if defined(_WIN32) - ProcessWindows::Initialize(); -#endif -#if defined(__FreeBSD__) - ProcessFreeBSD::Initialize(); -#endif -#if defined(__APPLE__) - SymbolVendorMacOSX::Initialize(); - ProcessKDP::Initialize(); - PlatformAppleTVSimulator::Initialize(); - PlatformAppleWatchSimulator::Initialize(); - PlatformRemoteAppleTV::Initialize(); - PlatformRemoteAppleWatch::Initialize(); - PlatformRemoteAppleBridge::Initialize(); - DynamicLoaderDarwinKernel::Initialize(); -#endif - - // This plugin is valid on any host that talks to a Darwin remote. It - // shouldn't be limited to __APPLE__. - StructuredDataDarwinLog::Initialize(); - - // Platform agnostic plugins - platform_gdb_server::PlatformRemoteGDBServer::Initialize(); - - process_gdb_remote::ProcessGDBRemote::Initialize(); - DynamicLoaderMacOSXDYLD::Initialize(); - DynamicLoaderMacOS::Initialize(); - DynamicLoaderPOSIXDYLD::Initialize(); - DynamicLoaderStatic::Initialize(); - DynamicLoaderWindowsDYLD::Initialize(); +#define LLDB_PLUGIN(p) LLDB_PLUGIN_INITIALIZE(p); +#include "Plugins/Plugins.def" // 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 - // AFTER PluginManager::Initialize is called. - + // Settings must be initialized AFTER PluginManager::Initialize is called. Debugger::SettingsInitialize(); return llvm::Error::success(); @@ -312,101 +64,8 @@ void SystemInitializerFull::Terminate() { // Terminate and unload and loaded system or user LLDB plug-ins PluginManager::Terminate(); - ClangASTContext::Terminate(); - - ArchitectureArm::Terminate(); - ArchitectureMips::Terminate(); - ArchitecturePPC64::Terminate(); - -#define LLVM_TARGET(t) LLDB_PROCESS_ ## t(Terminate) -#include "llvm/Config/Targets.def" - - DisassemblerLLVMC::Terminate(); - - JITLoaderGDB::Terminate(); - ProcessElfCore::Terminate(); - ProcessMachCore::Terminate(); - minidump::ProcessMinidump::Terminate(); - MemoryHistoryASan::Terminate(); - AddressSanitizerRuntime::Terminate(); - ThreadSanitizerRuntime::Terminate(); - UndefinedBehaviorSanitizerRuntime::Terminate(); - MainThreadCheckerRuntime::Terminate(); - SymbolVendorELF::Terminate(); - breakpad::SymbolFileBreakpad::Terminate(); - SymbolFileDWARF::Terminate(); - SymbolFilePDB::Terminate(); - SymbolFileSymtab::Terminate(); - UnwindAssembly_x86::Terminate(); - UnwindAssemblyInstEmulation::Terminate(); - - EmulateInstructionARM::Terminate(); - EmulateInstructionARM64::Terminate(); - EmulateInstructionMIPS::Terminate(); - EmulateInstructionMIPS64::Terminate(); - EmulateInstructionPPC64::Terminate(); - - SymbolFileDWARFDebugMap::Terminate(); - ItaniumABILanguageRuntime::Terminate(); - AppleObjCRuntimeV2::Terminate(); - AppleObjCRuntimeV1::Terminate(); - SystemRuntimeMacOSX::Terminate(); - RenderScriptRuntime::Terminate(); - - CPlusPlusLanguage::Terminate(); - ObjCLanguage::Terminate(); - ObjCPlusPlusLanguage::Terminate(); - -#if defined(__APPLE__) - DynamicLoaderDarwinKernel::Terminate(); - ProcessKDP::Terminate(); - SymbolVendorMacOSX::Terminate(); - PlatformAppleTVSimulator::Terminate(); - PlatformAppleWatchSimulator::Terminate(); - PlatformRemoteAppleTV::Terminate(); - PlatformRemoteAppleWatch::Terminate(); - PlatformRemoteAppleBridge::Terminate(); -#endif - -#if defined(__FreeBSD__) - ProcessFreeBSD::Terminate(); -#endif - Debugger::SettingsTerminate(); - - platform_gdb_server::PlatformRemoteGDBServer::Terminate(); - process_gdb_remote::ProcessGDBRemote::Terminate(); - StructuredDataDarwinLog::Terminate(); - - DynamicLoaderMacOSXDYLD::Terminate(); - DynamicLoaderMacOS::Terminate(); - DynamicLoaderPOSIXDYLD::Terminate(); - DynamicLoaderStatic::Terminate(); - DynamicLoaderWindowsDYLD::Terminate(); - -#if LLDB_ENABLE_PYTHON - OperatingSystemPython::Terminate(); -#endif - - platform_freebsd::PlatformFreeBSD::Terminate(); - platform_linux::PlatformLinux::Terminate(); - platform_netbsd::PlatformNetBSD::Terminate(); - platform_openbsd::PlatformOpenBSD::Terminate(); - PlatformWindows::Terminate(); - platform_android::PlatformAndroid::Terminate(); - PlatformMacOSX::Terminate(); - PlatformRemoteiOS::Terminate(); -#if defined(__APPLE__) - PlatformiOSSimulator::Terminate(); - PlatformDarwinKernel::Terminate(); -#endif - - breakpad::ObjectFileBreakpad::Terminate(); - ObjectFileELF::Terminate(); - ObjectFileMachO::Terminate(); - ObjectFilePECOFF::Terminate(); - - ObjectContainerBSDArchive::Terminate(); - ObjectContainerUniversalMachO::Terminate(); +#define LLDB_PLUGIN(p) LLDB_PLUGIN_TERMINATE(p); +#include "Plugins/Plugins.def" // Now shutdown the common parts, in reverse order. SystemInitializerCommon::Terminate(); diff --git a/lldb/source/API/SystemInitializerFull.h b/lldb/source/API/SystemInitializerFull.h index cd88bae978585..7cab6cb97533d 100644 --- a/lldb/source/API/SystemInitializerFull.h +++ b/lldb/source/API/SystemInitializerFull.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_API_SYSTEM_INITIALIZER_FULL_H -#define LLDB_API_SYSTEM_INITIALIZER_FULL_H +#ifndef LLDB_SOURCE_API_SYSTEMINITIALIZERFULL_H +#define LLDB_SOURCE_API_SYSTEMINITIALIZERFULL_H #include "lldb/Initialization/SystemInitializerCommon.h" @@ -29,4 +29,4 @@ public: } // namespace lldb_private -#endif // LLDB_API_SYSTEM_INITIALIZER_FULL_H +#endif // LLDB_SOURCE_API_SYSTEMINITIALIZERFULL_H diff --git a/lldb/source/API/Utils.h b/lldb/source/API/Utils.h index ed81534d2d12c..4201e825c4469 100644 --- a/lldb/source/API/Utils.h +++ b/lldb/source/API/Utils.h @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLDB_API_UTILS_H -#define LLDB_API_UTILS_H +#ifndef LLDB_SOURCE_API_UTILS_H +#define LLDB_SOURCE_API_UTILS_H #include "llvm/ADT/STLExtras.h" #include <memory> |