diff options
Diffstat (limited to 'source')
615 files changed, 80806 insertions, 43799 deletions
diff --git a/source/API/SBAttachInfo.cpp b/source/API/SBAttachInfo.cpp index 07446df27dff..0f2ab7afc9c2 100644 --- a/source/API/SBAttachInfo.cpp +++ b/source/API/SBAttachInfo.cpp @@ -36,6 +36,15 @@ SBAttachInfo::SBAttachInfo (const char *path, bool wait_for) : m_opaque_sp->SetWaitForLaunch (wait_for); } +SBAttachInfo::SBAttachInfo (const char *path, bool wait_for, bool async) : + m_opaque_sp (new ProcessAttachInfo()) +{ + if (path && path[0]) + m_opaque_sp->GetExecutableFile().SetFile(path, false); + m_opaque_sp->SetWaitForLaunch (wait_for); + m_opaque_sp->SetAsync(async); +} + SBAttachInfo::SBAttachInfo (const SBAttachInfo &rhs) : m_opaque_sp (new ProcessAttachInfo()) { @@ -127,6 +136,13 @@ SBAttachInfo::SetWaitForLaunch (bool b) m_opaque_sp->SetWaitForLaunch (b); } +void +SBAttachInfo::SetWaitForLaunch (bool b, bool async) +{ + m_opaque_sp->SetWaitForLaunch (b); + m_opaque_sp->SetAsync(async); +} + bool SBAttachInfo::GetIgnoreExisting () { diff --git a/source/API/SBBreakpoint.cpp b/source/API/SBBreakpoint.cpp index dd4c80caf45d..1f58ddb7152a 100644 --- a/source/API/SBBreakpoint.cpp +++ b/source/API/SBBreakpoint.cpp @@ -7,6 +7,10 @@ // //===----------------------------------------------------------------------===// +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/API/SBBreakpoint.h" #include "lldb/API/SBBreakpointLocation.h" #include "lldb/API/SBDebugger.h" @@ -32,7 +36,6 @@ #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadSpec.h" - #include "lldb/lldb-enumerations.h" using namespace lldb; @@ -47,7 +50,6 @@ struct CallbackData class SBBreakpointCallbackBaton : public Baton { public: - SBBreakpointCallbackBaton (SBBreakpoint::BreakpointHitCallback callback, void *baton) : Baton (new CallbackData) { @@ -56,19 +58,18 @@ public: data->callback_baton = baton; } - virtual ~SBBreakpointCallbackBaton() + ~SBBreakpointCallbackBaton() override { CallbackData *data = (CallbackData *)m_data; if (data) { delete data; - m_data = NULL; + m_data = nullptr; } } }; - SBBreakpoint::SBBreakpoint () : m_opaque_sp () { @@ -79,15 +80,12 @@ SBBreakpoint::SBBreakpoint (const SBBreakpoint& rhs) : { } - SBBreakpoint::SBBreakpoint (const lldb::BreakpointSP &bp_sp) : m_opaque_sp (bp_sp) { } -SBBreakpoint::~SBBreakpoint() -{ -} +SBBreakpoint::~SBBreakpoint() = default; const SBBreakpoint & SBBreakpoint::operator = (const SBBreakpoint& rhs) @@ -135,7 +133,6 @@ SBBreakpoint::GetID () const return break_id; } - bool SBBreakpoint::IsValid() const { @@ -169,7 +166,7 @@ SBBreakpoint::FindLocationByAddress (addr_t vm_addr) Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); Address address; Target &target = m_opaque_sp->GetTarget(); - if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false) + if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) { address.SetRawAddress (vm_addr); } @@ -189,7 +186,7 @@ SBBreakpoint::FindLocationIDByAddress (addr_t vm_addr) Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); Address address; Target &target = m_opaque_sp->GetTarget(); - if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false) + if (!target.GetSectionLoadList().ResolveLoadAddress(vm_addr, address)) { address.SetRawAddress (vm_addr); } @@ -329,7 +326,7 @@ SBBreakpoint::GetCondition () Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); return m_opaque_sp->GetConditionText (); } - return NULL; + return nullptr; } uint32_t @@ -380,7 +377,6 @@ SBBreakpoint::SetThreadID (tid_t tid) if (log) log->Printf ("SBBreakpoint(%p)::SetThreadID (tid=0x%4.4" PRIx64 ")", static_cast<void*>(m_opaque_sp.get()), tid); - } tid_t @@ -422,7 +418,7 @@ SBBreakpoint::GetThreadIndex() const { Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); - if (thread_spec != NULL) + if (thread_spec != nullptr) thread_idx = thread_spec->GetIndex(); } Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -451,12 +447,12 @@ SBBreakpoint::SetThreadName (const char *thread_name) const char * SBBreakpoint::GetThreadName () const { - const char *name = NULL; + const char *name = nullptr; if (m_opaque_sp) { Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); const ThreadSpec *thread_spec = m_opaque_sp->GetOptions()->GetThreadSpecNoCreate(); - if (thread_spec != NULL) + if (thread_spec != nullptr) name = thread_spec->GetName(); } Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -484,7 +480,7 @@ SBBreakpoint::SetQueueName (const char *queue_name) const char * SBBreakpoint::GetQueueName () const { - const char *name = NULL; + const char *name = nullptr; if (m_opaque_sp) { Mutex::Locker api_locker (m_opaque_sp->GetTarget().GetAPIMutex()); @@ -552,13 +548,10 @@ SBBreakpoint::GetDescription (SBStream &s) } bool -SBBreakpoint::PrivateBreakpointHitCallback -( - void *baton, - StoppointCallbackContext *ctx, - lldb::user_id_t break_id, - lldb::user_id_t break_loc_id -) +SBBreakpoint::PrivateBreakpointHitCallback(void *baton, + StoppointCallbackContext *ctx, + lldb::user_id_t break_id, + lldb::user_id_t break_loc_id) { ExecutionContext exe_ctx (ctx->exe_ctx_ref); BreakpointSP bp_sp(exe_ctx.GetTargetRef().GetBreakpointList().FindBreakpointByID(break_id)); @@ -758,8 +751,7 @@ SBBreakpoint::operator *() const bool SBBreakpoint::EventIsBreakpointEvent (const lldb::SBEvent &event) { - return Breakpoint::BreakpointEventData::GetEventDataFromEvent(event.get()) != NULL; - + return Breakpoint::BreakpointEventData::GetEventDataFromEvent(event.get()) != nullptr; } BreakpointEventType @@ -796,5 +788,3 @@ SBBreakpoint::GetNumBreakpointLocationsFromEvent (const lldb::SBEvent &event) num_locations = (Breakpoint::BreakpointEventData::GetNumBreakpointLocationsFromEvent (event.GetSP())); return num_locations; } - - diff --git a/source/API/SBCommandInterpreter.cpp b/source/API/SBCommandInterpreter.cpp index d901e728105b..21f431dac6a3 100644 --- a/source/API/SBCommandInterpreter.cpp +++ b/source/API/SBCommandInterpreter.cpp @@ -7,8 +7,12 @@ // //===----------------------------------------------------------------------===// +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/lldb-types.h" -#include "lldb/Core/SourceManager.h" + #include "lldb/Core/Listener.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandObjectMultiword.h" @@ -34,10 +38,7 @@ SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions() m_opaque_up.reset(new CommandInterpreterRunOptions()); } -SBCommandInterpreterRunOptions::~SBCommandInterpreterRunOptions() -{ - -} +SBCommandInterpreterRunOptions::~SBCommandInterpreterRunOptions() = default; bool SBCommandInterpreterRunOptions::GetStopOnContinue () const @@ -126,21 +127,24 @@ SBCommandInterpreterRunOptions::ref () const class CommandPluginInterfaceImplementation : public CommandObjectParsed { public: - CommandPluginInterfaceImplementation (CommandInterpreter &interpreter, - const char *name, - lldb::SBCommandPluginInterface* backend, - const char *help = NULL, - const char *syntax = NULL, - uint32_t flags = 0) : + CommandPluginInterfaceImplementation(CommandInterpreter &interpreter, + const char *name, + lldb::SBCommandPluginInterface* backend, + const char *help = nullptr, + const char *syntax = nullptr, + uint32_t flags = 0) : CommandObjectParsed (interpreter, name, help, syntax, flags), m_backend(backend) {} - virtual bool - IsRemovable() const { return true; } + bool + IsRemovable() const override + { + return true; + } protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute(Args& command, CommandReturnObject &result) override { SBCommandReturnObject sb_return(&result); SBCommandInterpreter sb_interpreter(&m_interpreter); @@ -169,6 +173,8 @@ SBCommandInterpreter::SBCommandInterpreter(const SBCommandInterpreter &rhs) : { } +SBCommandInterpreter::~SBCommandInterpreter() = default; + const SBCommandInterpreter & SBCommandInterpreter::operator = (const SBCommandInterpreter &rhs) { @@ -176,47 +182,34 @@ SBCommandInterpreter::operator = (const SBCommandInterpreter &rhs) return *this; } -SBCommandInterpreter::~SBCommandInterpreter () -{ -} - bool SBCommandInterpreter::IsValid() const { - return m_opaque_ptr != NULL; + return m_opaque_ptr != nullptr; } - bool -SBCommandInterpreter::CommandExists (const char *cmd) +SBCommandInterpreter::CommandExists(const char *cmd) { - if (cmd && m_opaque_ptr) - return m_opaque_ptr->CommandExists (cmd); - return false; + return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->CommandExists(cmd) : false); } bool SBCommandInterpreter::AliasExists (const char *cmd) { - if (cmd && m_opaque_ptr) - return m_opaque_ptr->AliasExists (cmd); - return false; + return (((cmd != nullptr) && IsValid()) ? m_opaque_ptr->AliasExists(cmd) : false); } bool -SBCommandInterpreter::IsActive () +SBCommandInterpreter::IsActive() { - if (m_opaque_ptr) - return m_opaque_ptr->IsActive (); - return false; + return (IsValid() ? m_opaque_ptr->IsActive() : false); } const char * SBCommandInterpreter::GetIOHandlerControlSequence(char ch) { - if (m_opaque_ptr) - return m_opaque_ptr->GetDebugger().GetTopIOHandlerControlSequence (ch).GetCString(); - return NULL; + return (IsValid() ? m_opaque_ptr->GetDebugger().GetTopIOHandlerControlSequence(ch).GetCString() : nullptr); } lldb::ReturnStatus @@ -247,7 +240,7 @@ SBCommandInterpreter::HandleCommand (const char *command_line, SBExecutionContex result.Clear(); - if (command_line && m_opaque_ptr) + if (command_line && IsValid()) { result.ref().SetInteractive(false); m_opaque_ptr->HandleCommand (command_line, add_to_history ? eLazyBoolYes : eLazyBoolNo, result.ref(), ctx_ptr); @@ -290,7 +283,7 @@ SBCommandInterpreter::HandleCommandsFromFile (lldb::SBFileSpec &file, static_cast<void*>(result.get())); } - if (!m_opaque_ptr) + if (!IsValid()) { result->AppendError ("SBCommandInterpreter is not valid."); result->SetStatus (eReturnStatusFailed); @@ -315,12 +308,9 @@ SBCommandInterpreter::HandleCommandsFromFile (lldb::SBFileSpec &file, else ctx_ptr = nullptr; - m_opaque_ptr->HandleCommandsFromFile (tmp_spec, ctx_ptr, options.ref(), result.ref()); - } - int SBCommandInterpreter::HandleCompletion (const char *current_line, const char *cursor, @@ -334,7 +324,7 @@ SBCommandInterpreter::HandleCompletion (const char *current_line, // Sanity check the arguments that are passed in: // cursor & last_char have to be within the current_line. - if (current_line == NULL || cursor == NULL || last_char == NULL) + if (current_line == nullptr || cursor == nullptr || last_char == nullptr) return 0; if (cursor < current_line || last_char < current_line) @@ -352,11 +342,11 @@ SBCommandInterpreter::HandleCompletion (const char *current_line, static_cast<uint64_t>(last_char - current_line), match_start_point, max_return_elements); - if (m_opaque_ptr) + if (IsValid()) { lldb_private::StringList lldb_matches; - num_completions = m_opaque_ptr->HandleCompletion (current_line, cursor, last_char, match_start_point, - max_return_elements, lldb_matches); + num_completions = m_opaque_ptr->HandleCompletion(current_line, cursor, last_char, match_start_point, + max_return_elements, lldb_matches); SBStringList temp_list (&lldb_matches); matches.AppendList (temp_list); @@ -381,27 +371,21 @@ SBCommandInterpreter::HandleCompletion (const char *current_line, } bool -SBCommandInterpreter::HasCommands () +SBCommandInterpreter::HasCommands() { - if (m_opaque_ptr) - return m_opaque_ptr->HasCommands(); - return false; + return (IsValid() ? m_opaque_ptr->HasCommands() : false); } bool -SBCommandInterpreter::HasAliases () +SBCommandInterpreter::HasAliases() { - if (m_opaque_ptr) - return m_opaque_ptr->HasAliases(); - return false; + return (IsValid() ? m_opaque_ptr->HasAliases() : false); } bool -SBCommandInterpreter::HasAliasOptions () +SBCommandInterpreter::HasAliasOptions() { - if (m_opaque_ptr) - return m_opaque_ptr->HasAliasOptions (); - return false; + return (IsValid() ? m_opaque_ptr->HasAliasOptions() : false); } SBProcess @@ -409,7 +393,7 @@ SBCommandInterpreter::GetProcess () { SBProcess sb_process; ProcessSP process_sp; - if (m_opaque_ptr) + if (IsValid()) { TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); if (target_sp) @@ -433,7 +417,7 @@ SBDebugger SBCommandInterpreter::GetDebugger () { SBDebugger sb_debugger; - if (m_opaque_ptr) + if (IsValid()) sb_debugger.reset(m_opaque_ptr->GetDebugger().shared_from_this()); Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -448,15 +432,13 @@ SBCommandInterpreter::GetDebugger () bool SBCommandInterpreter::GetPromptOnQuit() { - if (m_opaque_ptr) - return m_opaque_ptr->GetPromptOnQuit(); - return false; + return (IsValid() ? m_opaque_ptr->GetPromptOnQuit() : false); } void SBCommandInterpreter::SetPromptOnQuit (bool b) { - if (m_opaque_ptr) + if (IsValid()) m_opaque_ptr->SetPromptOnQuit(b); } @@ -464,7 +446,7 @@ void SBCommandInterpreter::ResolveCommand(const char *command_line, SBCommandReturnObject &result) { result.Clear(); - if (command_line && m_opaque_ptr) + if (command_line && IsValid()) { m_opaque_ptr->ResolveCommand(command_line, result.ref()); } @@ -475,7 +457,6 @@ SBCommandInterpreter::ResolveCommand(const char *command_line, SBCommandReturnOb } } - CommandInterpreter * SBCommandInterpreter::get () { @@ -499,7 +480,7 @@ void SBCommandInterpreter::SourceInitFileInHomeDirectory (SBCommandReturnObject &result) { result.Clear(); - if (m_opaque_ptr) + if (IsValid()) { TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); Mutex::Locker api_locker; @@ -524,7 +505,7 @@ void SBCommandInterpreter::SourceInitFileInCurrentWorkingDirectory (SBCommandReturnObject &result) { result.Clear(); - if (m_opaque_ptr) + if (IsValid()) { TargetSP target_sp(m_opaque_ptr->GetDebugger().GetSelectedTarget()); Mutex::Locker api_locker; @@ -588,7 +569,7 @@ SBCommandInterpreter::SetCommandOverrideCallback (const char *command_name, lldb::CommandOverrideCallback callback, void *baton) { - if (command_name && command_name[0] && m_opaque_ptr) + if (command_name && command_name[0] && IsValid()) { std::string command_name_str (command_name); CommandObject *cmd_obj = m_opaque_ptr->GetCommandObjectForCommand(command_name_str); @@ -605,7 +586,7 @@ SBCommandInterpreter::SetCommandOverrideCallback (const char *command_name, lldb::SBCommand SBCommandInterpreter::AddMultiwordCommand (const char* name, const char* help) { - CommandObjectMultiword *new_command = new CommandObjectMultiword(*m_opaque_ptr,name,help); + CommandObjectMultiword *new_command = new CommandObjectMultiword(*m_opaque_ptr, name, help); new_command->SetRemovable (true); lldb::CommandObjectSP new_command_sp(new_command); if (new_command_sp && m_opaque_ptr->AddUserCommand(name, new_command_sp, true)) @@ -617,47 +598,40 @@ lldb::SBCommand SBCommandInterpreter::AddCommand (const char* name, lldb::SBCommandPluginInterface* impl, const char* help) { lldb::CommandObjectSP new_command_sp; - new_command_sp.reset(new CommandPluginInterfaceImplementation(*m_opaque_ptr,name,impl,help)); + new_command_sp.reset(new CommandPluginInterfaceImplementation(*m_opaque_ptr,name, impl, help)); if (new_command_sp && m_opaque_ptr->AddUserCommand(name, new_command_sp, true)) return lldb::SBCommand(new_command_sp); return lldb::SBCommand(); } -SBCommand::SBCommand () -{} +SBCommand::SBCommand() = default; SBCommand::SBCommand (lldb::CommandObjectSP cmd_sp) : m_opaque_sp (cmd_sp) {} bool -SBCommand::IsValid () +SBCommand::IsValid() { - return (bool)m_opaque_sp; + return m_opaque_sp.get() != nullptr; } const char* -SBCommand::GetName () +SBCommand::GetName() { - if (IsValid ()) - return m_opaque_sp->GetCommandName (); - return NULL; + return (IsValid() ? m_opaque_sp->GetCommandName() : nullptr); } const char* -SBCommand::GetHelp () +SBCommand::GetHelp() { - if (IsValid ()) - return m_opaque_sp->GetHelp (); - return NULL; + return (IsValid() ? m_opaque_sp->GetHelp() : nullptr); } const char* -SBCommand::GetHelpLong () +SBCommand::GetHelpLong() { - if (IsValid ()) - return m_opaque_sp->GetHelpLong (); - return NULL; + return (IsValid() ? m_opaque_sp->GetHelpLong() : nullptr); } void @@ -679,7 +653,7 @@ SBCommand::AddMultiwordCommand (const char* name, const char* help) { if (!IsValid ()) return lldb::SBCommand(); - if (m_opaque_sp->IsMultiwordObject() == false) + if (!m_opaque_sp->IsMultiwordObject()) return lldb::SBCommand(); CommandObjectMultiword *new_command = new CommandObjectMultiword(m_opaque_sp->GetCommandInterpreter(),name,help); new_command->SetRemovable (true); @@ -694,7 +668,7 @@ SBCommand::AddCommand (const char* name, lldb::SBCommandPluginInterface *impl, c { if (!IsValid ()) return lldb::SBCommand(); - if (m_opaque_sp->IsMultiwordObject() == false) + if (!m_opaque_sp->IsMultiwordObject()) return lldb::SBCommand(); lldb::CommandObjectSP new_command_sp; new_command_sp.reset(new CommandPluginInterfaceImplementation(m_opaque_sp->GetCommandInterpreter(),name,impl,help)); @@ -706,9 +680,7 @@ SBCommand::AddCommand (const char* name, lldb::SBCommandPluginInterface *impl, c uint32_t SBCommand::GetFlags () { - if (!IsValid()) - return 0; - return m_opaque_sp->GetFlags().Get(); + return (IsValid() ? m_opaque_sp->GetFlags().Get() : 0); } void diff --git a/source/API/SBCommandReturnObject.cpp b/source/API/SBCommandReturnObject.cpp index 1ae2df76c979..a2ed4d6e8c26 100644 --- a/source/API/SBCommandReturnObject.cpp +++ b/source/API/SBCommandReturnObject.cpp @@ -7,6 +7,10 @@ // //===----------------------------------------------------------------------===// +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/API/SBCommandReturnObject.h" #include "lldb/API/SBError.h" #include "lldb/API/SBStream.h" @@ -26,7 +30,7 @@ SBCommandReturnObject::SBCommandReturnObject () : SBCommandReturnObject::SBCommandReturnObject (const SBCommandReturnObject &rhs): m_opaque_ap () { - if (rhs.m_opaque_ap.get()) + if (rhs.m_opaque_ap) m_opaque_ap.reset (new CommandReturnObject (*rhs.m_opaque_ap)); } @@ -35,6 +39,8 @@ SBCommandReturnObject::SBCommandReturnObject (CommandReturnObject *ptr) : { } +SBCommandReturnObject::~SBCommandReturnObject() = default; + CommandReturnObject * SBCommandReturnObject::Release () { @@ -46,7 +52,7 @@ SBCommandReturnObject::operator = (const SBCommandReturnObject &rhs) { if (this != &rhs) { - if (rhs.m_opaque_ap.get()) + if (rhs.m_opaque_ap) m_opaque_ap.reset (new CommandReturnObject (*rhs.m_opaque_ap)); else m_opaque_ap.reset(); @@ -54,25 +60,18 @@ SBCommandReturnObject::operator = (const SBCommandReturnObject &rhs) return *this; } - -SBCommandReturnObject::~SBCommandReturnObject () -{ - // m_opaque_ap will automatically delete any pointer it owns -} - bool SBCommandReturnObject::IsValid() const { - return m_opaque_ap.get() != NULL; + return m_opaque_ap.get() != nullptr; } - const char * SBCommandReturnObject::GetOutput () { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - if (m_opaque_ap.get()) + if (m_opaque_ap) { if (log) log->Printf ("SBCommandReturnObject(%p)::GetOutput () => \"%s\"", @@ -83,10 +82,10 @@ SBCommandReturnObject::GetOutput () } if (log) - log->Printf ("SBCommandReturnObject(%p)::GetOutput () => NULL", + log->Printf ("SBCommandReturnObject(%p)::GetOutput () => nullptr", static_cast<void*>(m_opaque_ap.get())); - return NULL; + return nullptr; } const char * @@ -94,7 +93,7 @@ SBCommandReturnObject::GetError () { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - if (m_opaque_ap.get()) + if (m_opaque_ap) { if (log) log->Printf ("SBCommandReturnObject(%p)::GetError () => \"%s\"", @@ -105,26 +104,22 @@ SBCommandReturnObject::GetError () } if (log) - log->Printf ("SBCommandReturnObject(%p)::GetError () => NULL", + log->Printf ("SBCommandReturnObject(%p)::GetError () => nullptr", static_cast<void*>(m_opaque_ap.get())); - return NULL; + return nullptr; } size_t -SBCommandReturnObject::GetOutputSize () +SBCommandReturnObject::GetOutputSize() { - if (m_opaque_ap.get()) - return strlen (m_opaque_ap->GetOutputData()); - return 0; + return (m_opaque_ap ? strlen(m_opaque_ap->GetOutputData()) : 0); } size_t -SBCommandReturnObject::GetErrorSize () +SBCommandReturnObject::GetErrorSize() { - if (m_opaque_ap.get()) - return strlen(m_opaque_ap->GetErrorData()); - return 0; + return (m_opaque_ap ? strlen(m_opaque_ap->GetErrorData()) : 0); } size_t @@ -154,52 +149,46 @@ SBCommandReturnObject::PutError (FILE *fh) void SBCommandReturnObject::Clear() { - if (m_opaque_ap.get()) + if (m_opaque_ap) m_opaque_ap->Clear(); } lldb::ReturnStatus SBCommandReturnObject::GetStatus() { - if (m_opaque_ap.get()) - return m_opaque_ap->GetStatus(); - return lldb::eReturnStatusInvalid; + return (m_opaque_ap ? m_opaque_ap->GetStatus() : lldb::eReturnStatusInvalid); } void SBCommandReturnObject::SetStatus(lldb::ReturnStatus status) { - if (m_opaque_ap.get()) + if (m_opaque_ap) m_opaque_ap->SetStatus(status); } bool -SBCommandReturnObject::Succeeded () +SBCommandReturnObject::Succeeded() { - if (m_opaque_ap.get()) - return m_opaque_ap->Succeeded(); - return false; + return (m_opaque_ap ? m_opaque_ap->Succeeded() : false); } bool -SBCommandReturnObject::HasResult () +SBCommandReturnObject::HasResult() { - if (m_opaque_ap.get()) - return m_opaque_ap->HasResult(); - return false; + return (m_opaque_ap ? m_opaque_ap->HasResult() : false); } void SBCommandReturnObject::AppendMessage (const char *message) { - if (m_opaque_ap.get()) + if (m_opaque_ap) m_opaque_ap->AppendMessage (message); } void SBCommandReturnObject::AppendWarning (const char *message) { - if (m_opaque_ap.get()) + if (m_opaque_ap) m_opaque_ap->AppendWarning (message); } @@ -222,7 +211,6 @@ SBCommandReturnObject::operator *() const return *(m_opaque_ap.get()); } - CommandReturnObject & SBCommandReturnObject::ref() const { @@ -230,11 +218,10 @@ SBCommandReturnObject::ref() const return *(m_opaque_ap.get()); } - void SBCommandReturnObject::SetLLDBObjectPtr (CommandReturnObject *ptr) { - if (m_opaque_ap.get()) + if (m_opaque_ap) m_opaque_ap.reset (ptr); } @@ -243,7 +230,7 @@ SBCommandReturnObject::GetDescription (SBStream &description) { Stream &strm = description.ref(); - if (m_opaque_ap.get()) + if (m_opaque_ap) { description.Printf ("Status: "); lldb::ReturnStatus status = m_opaque_ap->GetStatus(); @@ -269,25 +256,25 @@ SBCommandReturnObject::GetDescription (SBStream &description) } void -SBCommandReturnObject::SetImmediateOutputFile (FILE *fh) +SBCommandReturnObject::SetImmediateOutputFile(FILE *fh) { - if (m_opaque_ap.get()) - m_opaque_ap->SetImmediateOutputFile (fh); + if (m_opaque_ap) + m_opaque_ap->SetImmediateOutputFile(fh); } void -SBCommandReturnObject::SetImmediateErrorFile (FILE *fh) +SBCommandReturnObject::SetImmediateErrorFile(FILE *fh) { - if (m_opaque_ap.get()) - m_opaque_ap->SetImmediateErrorFile (fh); + if (m_opaque_ap) + m_opaque_ap->SetImmediateErrorFile(fh); } void SBCommandReturnObject::PutCString(const char* string, int len) { - if (m_opaque_ap.get()) + if (m_opaque_ap) { - if (len == 0 || string == NULL || *string == 0) + if (len == 0 || string == nullptr || *string == 0) { return; } @@ -304,27 +291,27 @@ SBCommandReturnObject::PutCString(const char* string, int len) const char * SBCommandReturnObject::GetOutput (bool only_if_no_immediate) { - if (!m_opaque_ap.get()) - return NULL; - if (only_if_no_immediate == false || m_opaque_ap->GetImmediateOutputStream().get() == NULL) + if (!m_opaque_ap) + return nullptr; + if (!only_if_no_immediate || m_opaque_ap->GetImmediateOutputStream().get() == nullptr) return GetOutput(); - return NULL; + return nullptr; } const char * SBCommandReturnObject::GetError (bool only_if_no_immediate) { - if (!m_opaque_ap.get()) - return NULL; - if (only_if_no_immediate == false || m_opaque_ap->GetImmediateErrorStream().get() == NULL) + if (!m_opaque_ap) + return nullptr; + if (!only_if_no_immediate || m_opaque_ap->GetImmediateErrorStream().get() == nullptr) return GetError(); - return NULL; + return nullptr; } size_t SBCommandReturnObject::Printf(const char* format, ...) { - if (m_opaque_ap.get()) + if (m_opaque_ap) { va_list args; va_start (args, format); @@ -338,7 +325,7 @@ SBCommandReturnObject::Printf(const char* format, ...) void SBCommandReturnObject::SetError (lldb::SBError &error, const char *fallback_error_cstr) { - if (m_opaque_ap.get()) + if (m_opaque_ap) { if (error.IsValid()) m_opaque_ap->SetError(error.ref(), fallback_error_cstr); @@ -350,7 +337,6 @@ SBCommandReturnObject::SetError (lldb::SBError &error, const char *fallback_erro void SBCommandReturnObject::SetError (const char *error_cstr) { - if (m_opaque_ap.get() && error_cstr) + if (m_opaque_ap && error_cstr) m_opaque_ap->SetError(error_cstr); } - diff --git a/source/API/SBDebugger.cpp b/source/API/SBDebugger.cpp index df2019f5a46b..1645294b5a3f 100644 --- a/source/API/SBDebugger.cpp +++ b/source/API/SBDebugger.cpp @@ -7,6 +7,10 @@ // //===----------------------------------------------------------------------===// +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/API/SBDebugger.h" #include "lldb/lldb-private.h" @@ -43,13 +47,13 @@ #include "lldb/Target/Process.h" #include "lldb/Target/TargetList.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/DynamicLibrary.h" using namespace lldb; using namespace lldb_private; - static llvm::sys::DynamicLibrary LoadPlugin (const lldb::DebuggerSP &debugger_sp, const FileSpec& spec, Error& error) { @@ -86,13 +90,6 @@ LoadPlugin (const lldb::DebuggerSP &debugger_sp, const FileSpec& spec, Error& er static llvm::ManagedStatic<SystemLifetimeManager> g_debugger_lifetime; -SBInputReader::SBInputReader() -{ -} -SBInputReader::~SBInputReader() -{ -} - SBError SBInputReader::Initialize(lldb::SBDebugger &sb_debugger, unsigned long (*)(void *, lldb::SBInputReader *, lldb::InputReaderAction, char const *, @@ -106,12 +103,37 @@ void SBInputReader::SetIsDone(bool) { } + bool SBInputReader::IsActive() const { return false; } +SBDebugger::SBDebugger() = default; + +SBDebugger::SBDebugger(const lldb::DebuggerSP &debugger_sp) : + m_opaque_sp(debugger_sp) +{ +} + +SBDebugger::SBDebugger(const SBDebugger &rhs) : + m_opaque_sp (rhs.m_opaque_sp) +{ +} + +SBDebugger::~SBDebugger() = default; + +SBDebugger & +SBDebugger::operator = (const SBDebugger &rhs) +{ + if (this != &rhs) + { + m_opaque_sp = rhs.m_opaque_sp; + } + return *this; +} + void SBDebugger::Initialize () { @@ -147,13 +169,13 @@ SBDebugger::Clear () SBDebugger SBDebugger::Create() { - return SBDebugger::Create(false, NULL, NULL); + return SBDebugger::Create(false, nullptr, nullptr); } SBDebugger SBDebugger::Create(bool source_init_files) { - return SBDebugger::Create (source_init_files, NULL, NULL); + return SBDebugger::Create (source_init_files, nullptr, nullptr); } SBDebugger @@ -215,7 +237,7 @@ SBDebugger::Destroy (SBDebugger &debugger) Debugger::Destroy (debugger.m_opaque_sp); - if (debugger.m_opaque_sp.get() != NULL) + if (debugger.m_opaque_sp.get() != nullptr) debugger.m_opaque_sp.reset(); } @@ -237,42 +259,12 @@ SBDebugger::MemoryPressureDetected () ModuleList::RemoveOrphanSharedModules(mandatory); } -SBDebugger::SBDebugger () : - m_opaque_sp () -{ -} - -SBDebugger::SBDebugger(const lldb::DebuggerSP &debugger_sp) : - m_opaque_sp(debugger_sp) -{ -} - -SBDebugger::SBDebugger(const SBDebugger &rhs) : - m_opaque_sp (rhs.m_opaque_sp) -{ -} - -SBDebugger & -SBDebugger::operator = (const SBDebugger &rhs) -{ - if (this != &rhs) - { - m_opaque_sp = rhs.m_opaque_sp; - } - return *this; -} - -SBDebugger::~SBDebugger () -{ -} - bool SBDebugger::IsValid() const { - return m_opaque_sp.get() != NULL; + return m_opaque_sp.get() != nullptr; } - void SBDebugger::SetAsync (bool b) { @@ -281,12 +273,9 @@ SBDebugger::SetAsync (bool b) } bool -SBDebugger::GetAsync () +SBDebugger::GetAsync() { - if (m_opaque_sp) - return m_opaque_sp->GetAsyncExecution(); - else - return false; + return (m_opaque_sp ? m_opaque_sp->GetAsyncExecution() : false); } void @@ -358,7 +347,7 @@ SBDebugger::GetInputFileHandle () if (stream_file_sp) return stream_file_sp->GetFile().GetStream(); } - return NULL; + return nullptr; } FILE * @@ -370,20 +359,19 @@ SBDebugger::GetOutputFileHandle () if (stream_file_sp) return stream_file_sp->GetFile().GetStream(); } - return NULL; + return nullptr; } FILE * SBDebugger::GetErrorFileHandle () { if (m_opaque_sp) - if (m_opaque_sp) - { - StreamFileSP stream_file_sp (m_opaque_sp->GetErrorFile()); - if (stream_file_sp) - return stream_file_sp->GetFile().GetStream(); - } - return NULL; + { + StreamFileSP stream_file_sp(m_opaque_sp->GetErrorFile()); + if (stream_file_sp) + return stream_file_sp->GetFile().GetStream(); + } + return nullptr; } void @@ -432,12 +420,12 @@ SBDebugger::HandleCommand (const char *command) sb_interpreter.HandleCommand (command, result, false); - if (GetErrorFileHandle() != NULL) + if (GetErrorFileHandle() != nullptr) result.PutError (GetErrorFileHandle()); - if (GetOutputFileHandle() != NULL) + if (GetOutputFileHandle() != nullptr) result.PutOutput (GetOutputFileHandle()); - if (m_opaque_sp->GetAsyncExecution() == false) + if (!m_opaque_sp->GetAsyncExecution()) { SBProcess process(GetCommandInterpreter().GetProcess ()); ProcessSP process_sp (process.GetSP()); @@ -492,7 +480,7 @@ SBDebugger::HandleProcessEvent (const SBProcess &process, const SBEvent &event, { // Drain stdout when we stop just in case we have any bytes while ((len = process.GetSTDOUT (stdio_buffer, sizeof (stdio_buffer))) > 0) - if (out != NULL) + if (out != nullptr) ::fwrite (stdio_buffer, 1, len, out); } @@ -500,7 +488,7 @@ SBDebugger::HandleProcessEvent (const SBProcess &process, const SBEvent &event, { // Drain stderr when we stop just in case we have any bytes while ((len = process.GetSTDERR (stdio_buffer, sizeof (stdio_buffer))) > 0) - if (err != NULL) + if (err != nullptr) ::fwrite (stdio_buffer, 1, len, err); } @@ -524,7 +512,6 @@ SBDebugger::GetSourceManager () return sb_source_manager; } - bool SBDebugger::GetDefaultArchitecture (char *arch_name, size_t arch_name_len) { @@ -547,7 +534,6 @@ SBDebugger::GetDefaultArchitecture (char *arch_name, size_t arch_name_len) return false; } - bool SBDebugger::SetDefaultArchitecture (const char *arch_name) { @@ -564,12 +550,11 @@ SBDebugger::SetDefaultArchitecture (const char *arch_name) } ScriptLanguage -SBDebugger::GetScriptingLanguage (const char *script_language_name) +SBDebugger::GetScriptingLanguage(const char *script_language_name) { - - return Args::StringToScriptLanguage (script_language_name, - eScriptLanguageDefault, - NULL); + return Args::StringToScriptLanguage(script_language_name, + eScriptLanguageDefault, + nullptr); } const char * @@ -637,7 +622,7 @@ SBDebugger::CreateTarget (const char *filename, } else { - sb_error.SetErrorString("invalid target"); + sb_error.SetErrorString("invalid debugger"); } Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -659,12 +644,12 @@ SBDebugger::CreateTargetWithFileAndTargetTriple (const char *filename, if (m_opaque_sp) { const bool add_dependent_modules = true; - Error error (m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, - filename, - target_triple, - add_dependent_modules, - NULL, - target_sp)); + Error error (m_opaque_sp->GetTargetList().CreateTarget(*m_opaque_sp, + filename, + target_triple, + add_dependent_modules, + nullptr, + target_sp)); sb_target.SetSP (target_sp); } @@ -689,12 +674,12 @@ SBDebugger::CreateTargetWithFileAndArch (const char *filename, const char *arch_ Error error; const bool add_dependent_modules = true; - error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, - filename, - arch_cstr, - add_dependent_modules, - NULL, - target_sp); + error = m_opaque_sp->GetTargetList().CreateTarget(*m_opaque_sp, + filename, + arch_cstr, + add_dependent_modules, + nullptr, + target_sp); if (error.Success()) { @@ -720,12 +705,12 @@ SBDebugger::CreateTarget (const char *filename) { Error error; const bool add_dependent_modules = true; - error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp, - filename, - NULL, - add_dependent_modules, - NULL, - target_sp); + error = m_opaque_sp->GetTargetList().CreateTarget(*m_opaque_sp, + filename, + nullptr, + add_dependent_modules, + nullptr, + target_sp); if (error.Success()) { @@ -767,6 +752,7 @@ SBDebugger::DeleteTarget (lldb::SBTarget &target) return result; } + SBTarget SBDebugger::GetTargetAtIndex (uint32_t idx) { @@ -813,7 +799,7 @@ SBDebugger::FindTargetWithFileAndArch (const char *filename, const char *arch_na { // No need to lock, the target list is thread safe ArchSpec arch (arch_name, m_opaque_sp->GetPlatformList().GetSelectedPlatform().get()); - TargetSP target_sp (m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture (FileSpec(filename, false), arch_name ? &arch : NULL)); + TargetSP target_sp (m_opaque_sp->GetTargetList().FindTargetWithExecutableAndArchitecture(FileSpec(filename, false), arch_name ? &arch : nullptr)); sb_target.SetSP (target_sp); } return sb_target; @@ -831,7 +817,6 @@ SBDebugger::FindTargetWithLLDBProcess (const ProcessSP &process_sp) return sb_target; } - uint32_t SBDebugger::GetNumTargets () { @@ -1000,6 +985,17 @@ SBDebugger::RunCommandInterpreter (bool auto_handle_events, } } +SBError +SBDebugger::RunREPL (lldb::LanguageType language, const char *repl_options) +{ + SBError error; + if (m_opaque_sp) + error.ref() = m_opaque_sp->RunREPL(language, repl_options); + else + error.SetErrorString ("invalid debugger"); + return error; +} + void SBDebugger::reset (const DebuggerSP &debugger_sp) { @@ -1039,10 +1035,7 @@ SBDebugger::FindDebuggerWithID (int id) const char * SBDebugger::GetInstanceName() { - if (m_opaque_sp) - return m_opaque_sp->GetInstanceName().AsCString(); - else - return NULL; + return (m_opaque_sp ? m_opaque_sp->GetInstanceName().AsCString() : nullptr); } SBError @@ -1098,11 +1091,9 @@ SBDebugger::GetInternalVariableValue (const char *var_name, const char *debugger } uint32_t -SBDebugger::GetTerminalWidth () const +SBDebugger::GetTerminalWidth() const { - if (m_opaque_sp) - return m_opaque_sp->GetTerminalWidth (); - return 0; + return (m_opaque_sp ? m_opaque_sp->GetTerminalWidth() : 0); } void @@ -1122,9 +1113,7 @@ SBDebugger::GetPrompt() const static_cast<void*>(m_opaque_sp.get()), (m_opaque_sp ? m_opaque_sp->GetPrompt() : "")); - if (m_opaque_sp) - return m_opaque_sp->GetPrompt (); - return 0; + return (m_opaque_sp ? m_opaque_sp->GetPrompt() : nullptr); } void @@ -1133,14 +1122,11 @@ SBDebugger::SetPrompt (const char *prompt) if (m_opaque_sp) m_opaque_sp->SetPrompt (prompt); } - ScriptLanguage SBDebugger::GetScriptLanguage() const { - if (m_opaque_sp) - return m_opaque_sp->GetScriptLanguage (); - return eScriptLanguageNone; + return (m_opaque_sp ? m_opaque_sp->GetScriptLanguage() : eScriptLanguageNone); } void @@ -1153,35 +1139,27 @@ SBDebugger::SetScriptLanguage (ScriptLanguage script_lang) } bool -SBDebugger::SetUseExternalEditor (bool value) +SBDebugger::SetUseExternalEditor(bool value) { - if (m_opaque_sp) - return m_opaque_sp->SetUseExternalEditor (value); - return false; + return (m_opaque_sp ? m_opaque_sp->SetUseExternalEditor(value) : false); } bool -SBDebugger::GetUseExternalEditor () +SBDebugger::GetUseExternalEditor() { - if (m_opaque_sp) - return m_opaque_sp->GetUseExternalEditor (); - return false; + return (m_opaque_sp ? m_opaque_sp->GetUseExternalEditor() : false); } bool -SBDebugger::SetUseColor (bool value) +SBDebugger::SetUseColor(bool value) { - if (m_opaque_sp) - return m_opaque_sp->SetUseColor (value); - return false; + return (m_opaque_sp ? m_opaque_sp->SetUseColor(value) : false); } bool -SBDebugger::GetUseColor () const +SBDebugger::GetUseColor() const { - if (m_opaque_sp) - return m_opaque_sp->GetUseColor (); - return false; + return (m_opaque_sp ? m_opaque_sp->GetUseColor() : false); } bool @@ -1204,12 +1182,9 @@ SBDebugger::GetDescription (SBStream &description) user_id_t SBDebugger::GetID() { - if (m_opaque_sp) - return m_opaque_sp->GetID(); - return LLDB_INVALID_UID; + return (m_opaque_sp ? m_opaque_sp->GetID() : LLDB_INVALID_UID); } - SBError SBDebugger::SetCurrentPlatform (const char *platform_name_cstr) { @@ -1267,11 +1242,9 @@ SBDebugger::SetCurrentPlatformSDKRoot (const char *sysroot) } bool -SBDebugger::GetCloseInputOnEOF () const +SBDebugger::GetCloseInputOnEOF() const { - if (m_opaque_sp) - return m_opaque_sp->GetCloseInputOnEOF (); - return false; + return (m_opaque_sp ? m_opaque_sp->GetCloseInputOnEOF() : false); } void @@ -1296,6 +1269,16 @@ SBDebugger::GetCategory (const char* category_name) } SBTypeCategory +SBDebugger::GetCategory (lldb::LanguageType lang_type) +{ + TypeCategoryImplSP category_sp; + if (DataVisualization::Categories::GetCategory(lang_type, category_sp)) + return SBTypeCategory(category_sp); + else + return SBTypeCategory(); +} + +SBTypeCategory SBDebugger::CreateCategory (const char* category_name) { if (!category_name || *category_name == 0) @@ -1349,7 +1332,7 @@ SBDebugger::GetFormatForType (SBTypeNameSpecifier type_name) SBTypeSummary SBDebugger::GetSummaryForType (SBTypeNameSpecifier type_name) { - if (type_name.IsValid() == false) + if (!type_name.IsValid()) return SBTypeSummary(); return SBTypeSummary(DataVisualization::GetSummaryForType(type_name.GetSP())); } @@ -1358,7 +1341,7 @@ SBDebugger::GetSummaryForType (SBTypeNameSpecifier type_name) SBTypeFilter SBDebugger::GetFilterForType (SBTypeNameSpecifier type_name) { - if (type_name.IsValid() == false) + if (!type_name.IsValid()) return SBTypeFilter(); return SBTypeFilter(DataVisualization::GetFilterForType(type_name.GetSP())); } @@ -1367,7 +1350,7 @@ SBDebugger::GetFilterForType (SBTypeNameSpecifier type_name) SBTypeSynthetic SBDebugger::GetSyntheticForType (SBTypeNameSpecifier type_name) { - if (type_name.IsValid() == false) + if (!type_name.IsValid()) return SBTypeSynthetic(); return SBTypeSynthetic(DataVisualization::GetSyntheticForType(type_name.GetSP())); } @@ -1380,8 +1363,7 @@ SBDebugger::EnableLog (const char *channel, const char **categories) { uint32_t log_options = LLDB_LOG_OPTION_PREPEND_TIMESTAMP | LLDB_LOG_OPTION_PREPEND_THREAD_NAME; StreamString errors; - return m_opaque_sp->EnableLog (channel, categories, NULL, log_options, errors); - + return m_opaque_sp->EnableLog(channel, categories, nullptr, log_options, errors); } else return false; @@ -1395,5 +1377,3 @@ SBDebugger::SetLoggingCallback (lldb::LogOutputCallback log_callback, void *bato return m_opaque_sp->SetLoggingCallback (log_callback, baton); } } - - diff --git a/source/API/SBFrame.cpp b/source/API/SBFrame.cpp index 08a5822cb781..02a215beb07d 100644 --- a/source/API/SBFrame.cpp +++ b/source/API/SBFrame.cpp @@ -7,10 +7,14 @@ // //===----------------------------------------------------------------------===// -#include "lldb/API/SBFrame.h" - -#include <string> +// C Includes +// C++ Includes #include <algorithm> +#include <string> + +// Other libraries and framework includes +// Project includes +#include "lldb/API/SBFrame.h" #include "lldb/lldb-types.h" @@ -21,8 +25,8 @@ #include "lldb/Core/StreamFile.h" #include "lldb/Core/ValueObjectRegister.h" #include "lldb/Core/ValueObjectVariable.h" -#include "lldb/Expression/ClangPersistentVariables.h" -#include "lldb/Expression/ClangUserExpression.h" +#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h" +#include "lldb/Expression/UserExpression.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/Function.h" @@ -50,7 +54,6 @@ using namespace lldb; using namespace lldb_private; - SBFrame::SBFrame () : m_opaque_sp (new ExecutionContextRef()) { @@ -76,6 +79,8 @@ SBFrame::SBFrame(const SBFrame &rhs) : { } +SBFrame::~SBFrame() = default; + const SBFrame & SBFrame::operator = (const SBFrame &rhs) { @@ -84,16 +89,10 @@ SBFrame::operator = (const SBFrame &rhs) return *this; } -SBFrame::~SBFrame() -{ -} - StackFrameSP SBFrame::GetFrameSP() const { - if (m_opaque_sp) - return m_opaque_sp->GetFrameSP(); - return StackFrameSP(); + return (m_opaque_sp ? m_opaque_sp->GetFrameSP() : StackFrameSP()); } void @@ -105,7 +104,7 @@ SBFrame::SetFrameSP (const StackFrameSP &lldb_object_sp) bool SBFrame::IsValid() const { - return GetFrameSP().get() != NULL; + return GetFrameSP().get() != nullptr; } SBSymbolContext @@ -116,7 +115,7 @@ SBFrame::GetSymbolContext (uint32_t resolve_scope) const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -159,7 +158,7 @@ SBFrame::GetModule () const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -202,7 +201,7 @@ SBFrame::GetCompileUnit () const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -243,7 +242,7 @@ SBFrame::GetFunction () const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -284,7 +283,7 @@ SBFrame::GetSymbol () const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -324,7 +323,7 @@ SBFrame::GetBlock () const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -364,7 +363,7 @@ SBFrame::GetFrameBlock () const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); Process *process = exe_ctx.GetProcessPtr(); @@ -405,7 +404,7 @@ SBFrame::GetLineEntry () const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -464,7 +463,6 @@ SBFrame::GetCFA () const return LLDB_INVALID_ADDRESS; } - addr_t SBFrame::GetPC () const { @@ -473,7 +471,7 @@ SBFrame::GetPC () const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -484,7 +482,7 @@ SBFrame::GetPC () const frame = exe_ctx.GetFramePtr(); if (frame) { - addr = frame->GetFrameCodeAddress().GetOpcodeLoadAddress (target); + addr = frame->GetFrameCodeAddress().GetOpcodeLoadAddress (target, eAddressClassCode); } else { @@ -514,7 +512,7 @@ SBFrame::SetPC (addr_t new_pc) Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -555,7 +553,7 @@ SBFrame::GetSP () const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -587,7 +585,6 @@ SBFrame::GetSP () const return addr; } - addr_t SBFrame::GetFP () const { @@ -596,7 +593,7 @@ SBFrame::GetFP () const Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -628,7 +625,6 @@ SBFrame::GetFP () const return addr; } - SBAddress SBFrame::GetPCAddress () const { @@ -696,7 +692,7 @@ SBFrame::GetValueForVariablePath (const char *var_path, DynamicValueType use_dyn SBValue sb_value; Mutex::Locker api_locker; Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - if (var_path == NULL || var_path[0] == '\0') + if (var_path == nullptr || var_path[0] == '\0') { if (log) log->Printf ("SBFrame::GetValueForVariablePath called with empty variable path."); @@ -705,7 +701,7 @@ SBFrame::GetValueForVariablePath (const char *var_path, DynamicValueType use_dyn ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -762,7 +758,7 @@ SBFrame::FindVariable (const char *name, lldb::DynamicValueType use_dynamic) VariableSP var_sp; SBValue sb_value; - if (name == NULL || name[0] == '\0') + if (name == nullptr || name[0] == '\0') { if (log) log->Printf ("SBFrame::FindVariable called with empty name"); @@ -773,7 +769,7 @@ SBFrame::FindVariable (const char *name, lldb::DynamicValueType use_dynamic) Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -850,7 +846,7 @@ SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueTy Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBValue sb_value; - if (name == NULL || name[0] == '\0') + if (name == nullptr || name[0] == '\0') { if (log) log->Printf ("SBFrame::FindValue called with empty name."); @@ -861,7 +857,7 @@ SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueTy Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -956,7 +952,7 @@ SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueTy case eValueTypeConstResult: // constant result variables { ConstString const_name(name); - ClangExpressionVariableSP expr_var_sp (target->GetPersistentVariables().GetVariable (const_name)); + ExpressionVariableSP expr_var_sp (target->GetPersistentVariable (const_name)); if (expr_var_sp) { value_sp = expr_var_sp->GetValueObject(); @@ -1035,11 +1031,11 @@ const char * SBFrame::Disassemble () const { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - const char *disassembly = NULL; + const char *disassembly = nullptr; Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -1072,7 +1068,6 @@ SBFrame::Disassemble () const return disassembly; } - SBValueList SBFrame::GetVariables (bool arguments, bool locals, @@ -1130,7 +1125,7 @@ SBFrame::GetVariables (const lldb::SBVariablesOptions& options) Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); const bool statics = options.GetIncludeStatics(); @@ -1156,7 +1151,7 @@ SBFrame::GetVariables (const lldb::SBVariablesOptions& options) if (frame) { size_t i; - VariableList *variable_list = NULL; + VariableList *variable_list = nullptr; variable_list = frame->GetVariableList(true); if (variable_list) { @@ -1194,9 +1189,9 @@ SBFrame::GetVariables (const lldb::SBVariablesOptions& options) ValueObjectSP valobj_sp(frame->GetValueObjectForFrameVariable (variable_sp, eNoDynamicValues)); - if (false == include_runtime_support_values && - valobj_sp && - true == valobj_sp->IsRuntimeSupportValue()) + if (!include_runtime_support_values && + valobj_sp != nullptr && + valobj_sp->IsRuntimeSupportValue()) continue; SBValue value_sb; @@ -1238,7 +1233,7 @@ SBFrame::GetRegisters () Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -1290,7 +1285,7 @@ SBFrame::FindRegister (const char *name) Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -1394,6 +1389,10 @@ SBFrame::EvaluateExpression (const char *expr) lldb::DynamicValueType fetch_dynamic_value = frame->CalculateTarget()->GetPreferDynamicValue(); options.SetFetchDynamicValue (fetch_dynamic_value); options.SetUnwindOnError (true); + if (target->GetLanguage() != eLanguageTypeUnknown) + options.SetLanguage(target->GetLanguage()); + else + options.SetLanguage(frame->GetLanguage()); return EvaluateExpression (expr, options); } return result; @@ -1405,6 +1404,13 @@ SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dyna SBExpressionOptions options; options.SetFetchDynamicValue (fetch_dynamic_value); options.SetUnwindOnError (true); + ExecutionContext exe_ctx(m_opaque_sp.get()); + StackFrame *frame = exe_ctx.GetFramePtr(); + Target *target = exe_ctx.GetTargetPtr(); + if (target && target->GetLanguage() != eLanguageTypeUnknown) + options.SetLanguage(target->GetLanguage()); + else if (frame) + options.SetLanguage(frame->GetLanguage()); return EvaluateExpression (expr, options); } @@ -1412,8 +1418,15 @@ SBValue SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value, bool unwind_on_error) { SBExpressionOptions options; + ExecutionContext exe_ctx(m_opaque_sp.get()); options.SetFetchDynamicValue (fetch_dynamic_value); options.SetUnwindOnError (unwind_on_error); + StackFrame *frame = exe_ctx.GetFramePtr(); + Target *target = exe_ctx.GetTargetPtr(); + if (target && target->GetLanguage() != eLanguageTypeUnknown) + options.SetLanguage(target->GetLanguage()); + else if (frame) + options.SetLanguage(frame->GetLanguage()); return EvaluateExpression (expr, options); } @@ -1427,7 +1440,7 @@ SBFrame::EvaluateExpression (const char *expr, const SBExpressionOptions &option ExpressionResults exe_results = eExpressionSetupError; SBValue expr_result; - if (expr == NULL || expr[0] == '\0') + if (expr == nullptr || expr[0] == '\0') { if (log) log->Printf ("SBFrame::EvaluateExpression called with an empty expression"); @@ -1442,7 +1455,7 @@ SBFrame::EvaluateExpression (const char *expr, const SBExpressionOptions &option if (log) log->Printf ("SBFrame()::EvaluateExpression (expr=\"%s\")...", expr); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); @@ -1469,7 +1482,7 @@ SBFrame::EvaluateExpression (const char *expr, const SBExpressionOptions &option expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue()); if (target->GetDisplayExpressionsInCrashlogs()) - Host::SetCrashDescription (NULL); + Host::SetCrashDescription(nullptr); } else { @@ -1509,7 +1522,7 @@ SBFrame::IsInlined() const { Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); ExecutionContext exe_ctx(m_opaque_sp.get()); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -1523,7 +1536,7 @@ SBFrame::IsInlined() const Block *block = frame->GetSymbolContext(eSymbolContextBlock).block; if (block) - return block->GetContainingInlinedBlock () != NULL; + return block->GetContainingInlinedBlock() != nullptr; } else { @@ -1551,9 +1564,9 @@ const char * SBFrame::GetFunctionName() const { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - const char *name = NULL; + const char *name = nullptr; ExecutionContext exe_ctx(m_opaque_sp.get()); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -1575,13 +1588,13 @@ SBFrame::GetFunctionName() const } } - if (name == NULL) + if (name == nullptr) { if (sc.function) name = sc.function->GetName().GetCString(); } - if (name == NULL) + if (name == nullptr) { if (sc.symbol) name = sc.symbol->GetName().GetCString(); @@ -1607,9 +1620,9 @@ const char * SBFrame::GetDisplayFunctionName() { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - const char *name = NULL; + const char *name = nullptr; ExecutionContext exe_ctx(m_opaque_sp.get()); - StackFrame *frame = NULL; + StackFrame *frame = nullptr; Target *target = exe_ctx.GetTargetPtr(); Process *process = exe_ctx.GetProcessPtr(); if (target && process) @@ -1631,13 +1644,13 @@ SBFrame::GetDisplayFunctionName() } } - if (name == NULL) + if (name == nullptr) { if (sc.function) name = sc.function->GetDisplayName().GetCString(); } - if (name == NULL) + if (name == nullptr) { if (sc.symbol) name = sc.symbol->GetDisplayName().GetCString(); diff --git a/source/API/SBFunction.cpp b/source/API/SBFunction.cpp index 2ec6072b51eb..2d03d53fd9f7 100644 --- a/source/API/SBFunction.cpp +++ b/source/API/SBFunction.cpp @@ -16,6 +16,7 @@ #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/Type.h" +#include "lldb/Symbol/VariableList.h" #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Target.h" @@ -216,6 +217,24 @@ SBFunction::GetEndAddress () return addr; } +const char * +SBFunction::GetArgumentName (uint32_t arg_idx) +{ + if (m_opaque_ptr) + { + Block &block = m_opaque_ptr->GetBlock(true); + VariableListSP variable_list_sp = block.GetBlockVariableList(true); + if (variable_list_sp) + { + VariableList arguments; + variable_list_sp->AppendVariablesWithScope (eValueTypeVariableArgument, arguments, true); + lldb::VariableSP variable_sp = arguments.GetVariableAtIndex(arg_idx); + if (variable_sp) + return variable_sp->GetName().GetCString(); + } + } + return nullptr; +} uint32_t SBFunction::GetPrologueByteSize () @@ -258,4 +277,13 @@ SBFunction::GetLanguage () return lldb::eLanguageTypeUnknown; } - +bool +SBFunction::GetIsOptimized () +{ + if (m_opaque_ptr) + { + if (m_opaque_ptr->GetCompileUnit()) + return m_opaque_ptr->GetCompileUnit()->GetIsOptimized(); + } + return false; +} diff --git a/source/API/SBLanguageRuntime.cpp b/source/API/SBLanguageRuntime.cpp index 93a54cd76dff..743343e48589 100644 --- a/source/API/SBLanguageRuntime.cpp +++ b/source/API/SBLanguageRuntime.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBLanguageRuntime.h" -#include "lldb/Target/LanguageRuntime.h" +#include "lldb/Target/Language.h" using namespace lldb; using namespace lldb_private; @@ -16,11 +16,11 @@ using namespace lldb_private; lldb::LanguageType SBLanguageRuntime::GetLanguageTypeFromString (const char *string) { - return LanguageRuntime::GetLanguageTypeFromString(string); + return Language::GetLanguageTypeFromString(string); } const char * SBLanguageRuntime::GetNameForLanguageType (lldb::LanguageType language) { - return LanguageRuntime::GetNameForLanguageType(language); + return Language::GetNameForLanguageType(language); } diff --git a/source/API/SBModule.cpp b/source/API/SBModule.cpp index 0249a7edcd2b..a810940f301f 100644 --- a/source/API/SBModule.cpp +++ b/source/API/SBModule.cpp @@ -20,10 +20,10 @@ #include "lldb/Core/StreamString.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Core/ValueObjectVariable.h" -#include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolVendor.h" #include "lldb/Symbol/Symtab.h" +#include "lldb/Symbol/TypeSystem.h" #include "lldb/Symbol/VariableList.h" #include "lldb/Target/Target.h" @@ -521,7 +521,11 @@ SBModule::FindFirstType (const char *name_cstr) sb_type = SBType (module_sp->FindFirstType(sc, name, exact_match)); if (!sb_type.IsValid()) - sb_type = SBType (ClangASTContext::GetBasicType (module_sp->GetClangASTContext().getASTContext(), name)); + { + TypeSystem *type_system = module_sp->GetTypeSystemForLanguage(eLanguageTypeC); + if (type_system) + sb_type = SBType (type_system->GetBuiltinTypeByName(name)); + } } return sb_type; } @@ -531,7 +535,11 @@ SBModule::GetBasicType(lldb::BasicType type) { ModuleSP module_sp (GetSP ()); if (module_sp) - return SBType (ClangASTContext::GetBasicType (module_sp->GetClangASTContext().getASTContext(), type)); + { + TypeSystem *type_system = module_sp->GetTypeSystemForLanguage(eLanguageTypeC); + if (type_system) + return SBType (type_system->GetBasicTypeFromAST(type)); + } return SBType(); } @@ -564,9 +572,13 @@ SBModule::FindTypes (const char *type) } else { - SBType sb_type(ClangASTContext::GetBasicType (module_sp->GetClangASTContext().getASTContext(), name)); - if (sb_type.IsValid()) - retval.Append(sb_type); + TypeSystem *type_system = module_sp->GetTypeSystemForLanguage(eLanguageTypeC); + if (type_system) + { + CompilerType compiler_type = type_system->GetBuiltinTypeByName(name); + if (compiler_type) + retval.Append(SBType(compiler_type)); + } } } diff --git a/source/API/SBPlatform.cpp b/source/API/SBPlatform.cpp index 97ffcf149750..b8dc01ba7811 100644 --- a/source/API/SBPlatform.cpp +++ b/source/API/SBPlatform.cpp @@ -189,7 +189,7 @@ SBPlatformShellCommand::~SBPlatformShellCommand() void SBPlatformShellCommand::Clear() { - m_opaque_ptr->m_output = std::move(std::string()); + m_opaque_ptr->m_output = std::string(); m_opaque_ptr->m_status = 0; m_opaque_ptr->m_signo = 0; } diff --git a/source/API/SBProcess.cpp b/source/API/SBProcess.cpp index 01bfaf9aff01..dceadeca69e5 100644 --- a/source/API/SBProcess.cpp +++ b/source/API/SBProcess.cpp @@ -19,6 +19,7 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" +#include "lldb/Core/PluginManager.h" #include "lldb/Core/State.h" #include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" @@ -409,7 +410,7 @@ SBProcess::GetAsyncProfileData(char *dst, size_t dst_len) const Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (log) - log->Printf ("SBProcess(%p)::GetProfileData (dst=\"%.*s\", dst_len=%" PRIu64 ") => %" PRIu64, + log->Printf ("SBProcess(%p)::GetAsyncProfileData (dst=\"%.*s\", dst_len=%" PRIu64 ") => %" PRIu64, static_cast<void*>(process_sp.get()), static_cast<int>(bytes_read), dst, static_cast<uint64_t>(dst_len), @@ -1287,7 +1288,15 @@ SBProcess::GetNumSupportedHardwareWatchpoints (lldb::SBError &sb_error) const } uint32_t -SBProcess::LoadImage (lldb::SBFileSpec &sb_image_spec, lldb::SBError &sb_error) +SBProcess::LoadImage (lldb::SBFileSpec &sb_remote_image_spec, lldb::SBError &sb_error) +{ + return LoadImage(SBFileSpec(), sb_remote_image_spec, sb_error); +} + +uint32_t +SBProcess::LoadImage (const lldb::SBFileSpec &sb_local_image_spec, + const lldb::SBFileSpec &sb_remote_image_spec, + lldb::SBError &sb_error) { ProcessSP process_sp(GetSP()); if (process_sp) @@ -1296,7 +1305,11 @@ SBProcess::LoadImage (lldb::SBFileSpec &sb_image_spec, lldb::SBError &sb_error) if (stop_locker.TryLock(&process_sp->GetRunLock())) { Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); - return process_sp->LoadImage (*sb_image_spec, sb_error.ref()); + PlatformSP platform_sp = process_sp->GetTarget().GetPlatform(); + return platform_sp->LoadImage (process_sp.get(), + *sb_local_image_spec, + *sb_remote_image_spec, + sb_error.ref()); } else { @@ -1321,7 +1334,8 @@ SBProcess::UnloadImage (uint32_t image_token) if (stop_locker.TryLock(&process_sp->GetRunLock())) { Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); - sb_error.SetError (process_sp->UnloadImage (image_token)); + PlatformSP platform_sp = process_sp->GetTarget().GetPlatform(); + sb_error.SetError (platform_sp->UnloadImage (process_sp.get(), image_token)); } else { @@ -1425,3 +1439,27 @@ SBProcess::IsInstrumentationRuntimePresent(InstrumentationRuntimeType type) return runtime_sp->IsActive(); } + +lldb::SBError +SBProcess::SaveCore(const char *file_name) +{ + lldb::SBError error; + ProcessSP process_sp(GetSP()); + if (!process_sp) + { + error.SetErrorString("SBProcess is invalid"); + return error; + } + + Mutex::Locker api_locker(process_sp->GetTarget().GetAPIMutex()); + + if (process_sp->GetState() != eStateStopped) + { + error.SetErrorString("the process is not stopped"); + return error; + } + + FileSpec core_file(file_name, false); + error.ref() = PluginManager::SaveCore(process_sp, core_file); + return error; +} diff --git a/source/API/SBStream.cpp b/source/API/SBStream.cpp index f50334f74189..f3be3be6a10d 100644 --- a/source/API/SBStream.cpp +++ b/source/API/SBStream.cpp @@ -23,6 +23,13 @@ SBStream::SBStream () : { } +SBStream::SBStream (SBStream &&rhs) : + m_opaque_ap (std::move(rhs.m_opaque_ap)), + m_is_file (rhs.m_is_file) +{ +} + + SBStream::~SBStream () { } diff --git a/source/API/SBTarget.cpp b/source/API/SBTarget.cpp index 6597d4e77c73..c7595c3c39fb 100644 --- a/source/API/SBTarget.cpp +++ b/source/API/SBTarget.cpp @@ -52,6 +52,7 @@ #include "lldb/Symbol/SymbolVendor.h" #include "lldb/Symbol/VariableList.h" #include "lldb/Target/ABI.h" +#include "lldb/Target/Language.h" #include "lldb/Target/LanguageRuntime.h" #include "lldb/Target/ObjCLanguageRuntime.h" #include "lldb/Target/Process.h" @@ -847,11 +848,11 @@ SBTarget::BreakpointCreateByName (const char *symbol_name, { FileSpecList module_spec_list; module_spec_list.Append (FileSpec (module_name, false)); - *sb_bp = target_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, skip_prologue, internal, hardware); + *sb_bp = target_sp->CreateBreakpoint (&module_spec_list, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, skip_prologue, internal, hardware); } else { - *sb_bp = target_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, skip_prologue, internal, hardware); + *sb_bp = target_sp->CreateBreakpoint (NULL, NULL, symbol_name, eFunctionNameTypeAuto, eLanguageTypeUnknown, skip_prologue, internal, hardware); } } @@ -869,7 +870,7 @@ SBTarget::BreakpointCreateByName (const char *symbol_name, const SBFileSpecList &comp_unit_list) { uint32_t name_type_mask = eFunctionNameTypeAuto; - return BreakpointCreateByName (symbol_name, name_type_mask, module_list, comp_unit_list); + return BreakpointCreateByName (symbol_name, name_type_mask, eLanguageTypeUnknown, module_list, comp_unit_list); } lldb::SBBreakpoint @@ -878,6 +879,16 @@ SBTarget::BreakpointCreateByName (const char *symbol_name, const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { + return BreakpointCreateByName (symbol_name, name_type_mask, eLanguageTypeUnknown, module_list, comp_unit_list); +} + +lldb::SBBreakpoint +SBTarget::BreakpointCreateByName (const char *symbol_name, + uint32_t name_type_mask, + LanguageType symbol_language, + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list) +{ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBBreakpoint sb_bp; @@ -892,6 +903,7 @@ SBTarget::BreakpointCreateByName (const char *symbol_name, comp_unit_list.get(), symbol_name, name_type_mask, + symbol_language, skip_prologue, internal, hardware); @@ -912,6 +924,17 @@ SBTarget::BreakpointCreateByNames (const char *symbol_names[], const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list) { + return BreakpointCreateByNames(symbol_names, num_names, name_type_mask, eLanguageTypeUnknown, module_list, comp_unit_list); +} + +lldb::SBBreakpoint +SBTarget::BreakpointCreateByNames (const char *symbol_names[], + uint32_t num_names, + uint32_t name_type_mask, + LanguageType symbol_language, + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list) +{ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBBreakpoint sb_bp; @@ -923,13 +946,14 @@ SBTarget::BreakpointCreateByNames (const char *symbol_names[], const bool hardware = false; const LazyBool skip_prologue = eLazyBoolCalculate; *sb_bp = target_sp->CreateBreakpoint (module_list.get(), - comp_unit_list.get(), - symbol_names, - num_names, - name_type_mask, - skip_prologue, - internal, - hardware); + comp_unit_list.get(), + symbol_names, + num_names, + name_type_mask, + symbol_language, + skip_prologue, + internal, + hardware); } if (log) @@ -959,6 +983,30 @@ SBBreakpoint SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, const char *module_name) { + SBFileSpecList module_spec_list; + SBFileSpecList comp_unit_list; + if (module_name && module_name[0]) + { + module_spec_list.Append (FileSpec (module_name, false)); + + } + return BreakpointCreateByRegex (symbol_name_regex, eLanguageTypeUnknown, module_spec_list, comp_unit_list); +} + +lldb::SBBreakpoint +SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list) +{ + return BreakpointCreateByRegex (symbol_name_regex, eLanguageTypeUnknown, module_list, comp_unit_list); +} + +lldb::SBBreakpoint +SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, + LanguageType symbol_language, + const SBFileSpecList &module_list, + const SBFileSpecList &comp_unit_list) +{ Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBBreakpoint sb_bp; @@ -970,75 +1018,72 @@ SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, const bool internal = false; const bool hardware = false; const LazyBool skip_prologue = eLazyBoolCalculate; - - if (module_name && module_name[0]) - { - FileSpecList module_spec_list; - module_spec_list.Append (FileSpec (module_name, false)); - - *sb_bp = target_sp->CreateFuncRegexBreakpoint (&module_spec_list, NULL, regexp, skip_prologue, internal, hardware); - } - else - { - *sb_bp = target_sp->CreateFuncRegexBreakpoint (NULL, NULL, regexp, skip_prologue, internal, hardware); - } + + *sb_bp = target_sp->CreateFuncRegexBreakpoint (module_list.get(), comp_unit_list.get(), regexp, symbol_language, skip_prologue, internal, hardware); } if (log) - log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\", module_name=\"%s\") => SBBreakpoint(%p)", + log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") => SBBreakpoint(%p)", static_cast<void*>(target_sp.get()), symbol_name_regex, - module_name, static_cast<void*>(sb_bp.get())); + static_cast<void*>(sb_bp.get())); return sb_bp; } -lldb::SBBreakpoint -SBTarget::BreakpointCreateByRegex (const char *symbol_name_regex, - const SBFileSpecList &module_list, - const SBFileSpecList &comp_unit_list) +SBBreakpoint +SBTarget::BreakpointCreateByAddress (addr_t address) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); - if (target_sp && symbol_name_regex && symbol_name_regex[0]) + if (target_sp) { Mutex::Locker api_locker (target_sp->GetAPIMutex()); - RegularExpression regexp(symbol_name_regex); - const bool internal = false; const bool hardware = false; - const LazyBool skip_prologue = eLazyBoolCalculate; - - *sb_bp = target_sp->CreateFuncRegexBreakpoint (module_list.get(), comp_unit_list.get(), regexp, skip_prologue, internal, hardware); + *sb_bp = target_sp->CreateBreakpoint (address, false, hardware); } if (log) - log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (symbol_regex=\"%s\") => SBBreakpoint(%p)", - static_cast<void*>(target_sp.get()), symbol_name_regex, + log->Printf ("SBTarget(%p)::BreakpointCreateByAddress (address=%" PRIu64 ") => SBBreakpoint(%p)", + static_cast<void*>(target_sp.get()), + static_cast<uint64_t>(address), static_cast<void*>(sb_bp.get())); return sb_bp; } SBBreakpoint -SBTarget::BreakpointCreateByAddress (addr_t address) +SBTarget::BreakpointCreateBySBAddress (SBAddress &sb_address) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBBreakpoint sb_bp; TargetSP target_sp(GetSP()); + if (!sb_address.IsValid()) + { + if (log) + log->Printf ("SBTarget(%p)::BreakpointCreateBySBAddress called with invalid address", + static_cast<void*>(target_sp.get())); + return sb_bp; + } + if (target_sp) { Mutex::Locker api_locker (target_sp->GetAPIMutex()); const bool hardware = false; - *sb_bp = target_sp->CreateBreakpoint (address, false, hardware); + *sb_bp = target_sp->CreateBreakpoint (sb_address.ref(), false, hardware); } if (log) - log->Printf ("SBTarget(%p)::BreakpointCreateByAddress (address=%" PRIu64 ") => SBBreakpoint(%p)", + { + SBStream s; + sb_address.GetDescription(s); + log->Printf ("SBTarget(%p)::BreakpointCreateBySBAddress (address=%s) => SBBreakpoint(%p)", static_cast<void*>(target_sp.get()), - static_cast<uint64_t>(address), + s.GetData(), static_cast<void*>(sb_bp.get())); + } return sb_bp; } @@ -1131,7 +1176,7 @@ SBTarget::BreakpointCreateForException (lldb::LanguageType language, if (log) log->Printf ("SBTarget(%p)::BreakpointCreateByRegex (Language: %s, catch: %s throw: %s) => SBBreakpoint(%p)", static_cast<void*>(target_sp.get()), - LanguageRuntime::GetNameForLanguageType(language), + Language::GetNameForLanguageType(language), catch_bp ? "on" : "off", throw_bp ? "on" : "off", static_cast<void*>(sb_bp.get())); @@ -1344,7 +1389,7 @@ SBTarget::WatchAddress (lldb::addr_t addr, size_t size, bool read, bool write, S // Target::CreateWatchpoint() is thread safe. Error cw_error; // This API doesn't take in a type, so we can't figure out what it is. - ClangASTType *type = NULL; + CompilerType *type = NULL; watchpoint_sp = target_sp->CreateWatchpoint(addr, size, type, watch_type, cw_error); error.SetError(cw_error); sb_watchpoint.SetSP (watchpoint_sp); @@ -1398,7 +1443,7 @@ SBTarget::CreateValueFromAddress (const char *name, SBAddress addr, SBType type) { lldb::addr_t load_addr(addr.GetLoadAddress(*this)); ExecutionContext exe_ctx (ExecutionContextRef(ExecutionContext(m_opaque_sp.get(),false))); - ClangASTType ast_type(type.GetSP()->GetClangASTType(true)); + CompilerType ast_type(type.GetSP()->GetCompilerType(true)); new_value_sp = ValueObject::CreateValueObjectFromAddress(name, load_addr, exe_ctx, ast_type); } sb_value.SetSP(new_value_sp); @@ -1425,7 +1470,7 @@ SBTarget::CreateValueFromData (const char *name, lldb::SBData data, lldb::SBType { DataExtractorSP extractor(*data); ExecutionContext exe_ctx (ExecutionContextRef(ExecutionContext(m_opaque_sp.get(),false))); - ClangASTType ast_type(type.GetSP()->GetClangASTType(true)); + CompilerType ast_type(type.GetSP()->GetCompilerType(true)); new_value_sp = ValueObject::CreateValueObjectFromData(name, *extractor, exe_ctx, ast_type); } sb_value.SetSP(new_value_sp); @@ -1806,7 +1851,7 @@ SBTarget::FindFirstType (const char* typename_cstr) if (objc_decl_vendor->FindDecls(const_typename, true, 1, decls) > 0) { - if (ClangASTType type = ClangASTContext::GetTypeForDecl(decls[0])) + if (CompilerType type = ClangASTContext::GetTypeForDecl(decls[0])) { return SBType(type); } @@ -1886,7 +1931,7 @@ SBTarget::FindTypes (const char* typename_cstr) { for (clang::NamedDecl *decl : decls) { - if (ClangASTType type = ClangASTContext::GetTypeForDecl(decl)) + if (CompilerType type = ClangASTContext::GetTypeForDecl(decl)) { sb_type_list.Append(SBType(type)); } diff --git a/source/API/SBThread.cpp b/source/API/SBThread.cpp index 42b5c9affe50..2f3887ebce3a 100644 --- a/source/API/SBThread.cpp +++ b/source/API/SBThread.cpp @@ -747,7 +747,7 @@ SBThread::StepOver (lldb::RunMode stop_other_threads) const LazyBool avoid_no_debug = eLazyBoolCalculate; SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); new_plan_sp = thread->QueueThreadPlanForStepOverRange (abort_other_plans, - sc.line_entry.range, + sc.line_entry, sc, stop_other_threads, avoid_no_debug); @@ -799,7 +799,7 @@ SBThread::StepInto (const char *target_name, lldb::RunMode stop_other_threads) const LazyBool step_in_avoids_code_without_debug_info = eLazyBoolCalculate; SymbolContext sc(frame_sp->GetSymbolContext(eSymbolContextEverything)); new_plan_sp = thread->QueueThreadPlanForStepInRange (abort_other_plans, - sc.line_entry.range, + sc.line_entry, sc, target_name, stop_other_threads, @@ -826,7 +826,6 @@ SBThread::StepOut () Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); - if (log) log->Printf ("SBThread(%p)::StepOut ()", static_cast<void*>(exe_ctx.GetThreadPtr())); @@ -861,6 +860,14 @@ SBThread::StepOutOfFrame (lldb::SBFrame &sb_frame) Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); + if (!sb_frame.IsValid()) + { + if (log) + log->Printf("SBThread(%p)::StepOutOfFrame passed an invalid frame, returning.", + static_cast<void*>(exe_ctx.GetThreadPtr())); + return; + } + StackFrameSP frame_sp (sb_frame.GetFrameSP()); if (log) { @@ -877,6 +884,13 @@ SBThread::StepOutOfFrame (lldb::SBFrame &sb_frame) bool abort_other_plans = false; bool stop_other_threads = false; Thread *thread = exe_ctx.GetThreadPtr(); + if (sb_frame.GetThread().GetThreadID() != thread->GetID()) + { + log->Printf("SBThread(%p)::StepOutOfFrame passed a frame from another thread (0x%" PRIx64 " vrs. 0x%" PRIx64 ", returning.", + static_cast<void*>(exe_ctx.GetThreadPtr()), + sb_frame.GetThread().GetThreadID(), + thread->GetID()); + } ThreadPlanSP new_plan_sp(thread->QueueThreadPlanForStepOut (abort_other_plans, NULL, diff --git a/source/API/SBType.cpp b/source/API/SBType.cpp index 31a4eba8bf33..4922b491a227 100644 --- a/source/API/SBType.cpp +++ b/source/API/SBType.cpp @@ -13,24 +13,24 @@ #include "lldb/API/SBStream.h" #include "lldb/Core/ConstString.h" #include "lldb/Core/Log.h" +#include "lldb/Core/Mangled.h" #include "lldb/Core/Stream.h" -#include "lldb/Symbol/ClangASTContext.h" -#include "lldb/Symbol/ClangASTType.h" +#include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Type.h" +#include "lldb/Symbol/TypeSystem.h" -#include "clang/AST/Decl.h" +#include "llvm/ADT/APSInt.h" using namespace lldb; using namespace lldb_private; -using namespace clang; SBType::SBType() : m_opaque_sp() { } -SBType::SBType (const ClangASTType &type) : - m_opaque_sp(new TypeImpl(ClangASTType(type.GetASTContext(), +SBType::SBType (const CompilerType &type) : + m_opaque_sp(new TypeImpl(CompilerType(type.GetTypeSystem(), type.GetOpaqueQualType()))) { } @@ -143,7 +143,7 @@ SBType::GetByteSize() if (!IsValid()) return 0; - return m_opaque_sp->GetClangASTType(false).GetByteSize(nullptr); + return m_opaque_sp->GetCompilerType(false).GetByteSize(nullptr); } @@ -152,7 +152,7 @@ SBType::IsPointerType() { if (!IsValid()) return false; - return m_opaque_sp->GetClangASTType(true).IsPointerType(); + return m_opaque_sp->GetCompilerType(true).IsPointerType(); } bool @@ -160,7 +160,7 @@ SBType::IsArrayType() { if (!IsValid()) return false; - return m_opaque_sp->GetClangASTType(true).IsArrayType(nullptr, nullptr, nullptr); + return m_opaque_sp->GetCompilerType(true).IsArrayType(nullptr, nullptr, nullptr); } bool @@ -168,7 +168,7 @@ SBType::IsVectorType() { if (!IsValid()) return false; - return m_opaque_sp->GetClangASTType(true).IsVectorType(nullptr, nullptr); + return m_opaque_sp->GetCompilerType(true).IsVectorType(nullptr, nullptr); } bool @@ -176,7 +176,7 @@ SBType::IsReferenceType() { if (!IsValid()) return false; - return m_opaque_sp->GetClangASTType(true).IsReferenceType(); + return m_opaque_sp->GetCompilerType(true).IsReferenceType(); } SBType @@ -225,7 +225,7 @@ SBType::GetArrayElementType() { if (!IsValid()) return SBType(); - return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetClangASTType(true).GetArrayElementType()))); + return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetCompilerType(true).GetArrayElementType()))); } SBType @@ -234,8 +234,8 @@ SBType::GetVectorElementType () SBType type_sb; if (IsValid()) { - ClangASTType vector_element_type; - if (m_opaque_sp->GetClangASTType(true).IsVectorType(&vector_element_type, nullptr)) + CompilerType vector_element_type; + if (m_opaque_sp->GetCompilerType(true).IsVectorType(&vector_element_type, nullptr)) type_sb.SetSP(TypeImplSP(new TypeImpl(vector_element_type))); } return type_sb; @@ -246,7 +246,7 @@ SBType::IsFunctionType () { if (!IsValid()) return false; - return m_opaque_sp->GetClangASTType(true).IsFunctionType(); + return m_opaque_sp->GetCompilerType(true).IsFunctionType(); } bool @@ -254,7 +254,7 @@ SBType::IsPolymorphicClass () { if (!IsValid()) return false; - return m_opaque_sp->GetClangASTType(true).IsPolymorphicClass(); + return m_opaque_sp->GetCompilerType(true).IsPolymorphicClass(); } bool @@ -262,7 +262,15 @@ SBType::IsTypedefType () { if (!IsValid()) return false; - return m_opaque_sp->GetClangASTType(true).IsTypedefType(); + return m_opaque_sp->GetCompilerType(true).IsTypedefType(); +} + +bool +SBType::IsAnonymousType () +{ + if (!IsValid()) + return false; + return m_opaque_sp->GetCompilerType(true).IsAnonymousType(); } lldb::SBType @@ -270,9 +278,9 @@ SBType::GetFunctionReturnType () { if (IsValid()) { - ClangASTType return_clang_type (m_opaque_sp->GetClangASTType(true).GetFunctionReturnType()); - if (return_clang_type.IsValid()) - return SBType(return_clang_type); + CompilerType return_type (m_opaque_sp->GetCompilerType(true).GetFunctionReturnType()); + if (return_type.IsValid()) + return SBType(return_type); } return lldb::SBType(); } @@ -283,7 +291,7 @@ SBType::GetFunctionArgumentTypes () SBTypeList sb_type_list; if (IsValid()) { - ClangASTType func_type(m_opaque_sp->GetClangASTType(true)); + CompilerType func_type(m_opaque_sp->GetCompilerType(true)); size_t count = func_type.GetNumberOfFunctionArguments(); for (size_t i = 0; i < count; @@ -300,7 +308,7 @@ SBType::GetNumberOfMemberFunctions () { if (IsValid()) { - return m_opaque_sp->GetClangASTType(true).GetNumMemberFunctions(); + return m_opaque_sp->GetCompilerType(true).GetNumMemberFunctions(); } return 0; } @@ -310,7 +318,7 @@ SBType::GetMemberFunctionAtIndex (uint32_t idx) { SBTypeMemberFunction sb_func_type; if (IsValid()) - sb_func_type.reset(new TypeMemberFunctionImpl(m_opaque_sp->GetClangASTType(true).GetMemberFunctionAtIndex(idx))); + sb_func_type.reset(new TypeMemberFunctionImpl(m_opaque_sp->GetCompilerType(true).GetMemberFunctionAtIndex(idx))); return sb_func_type; } @@ -335,15 +343,15 @@ lldb::BasicType SBType::GetBasicType() { if (IsValid()) - return m_opaque_sp->GetClangASTType(false).GetBasicTypeEnumeration (); + return m_opaque_sp->GetCompilerType(false).GetBasicTypeEnumeration (); return eBasicTypeInvalid; } SBType SBType::GetBasicType(lldb::BasicType basic_type) { - if (IsValid()) - return SBType (ClangASTContext::GetBasicType (m_opaque_sp->GetClangASTContext(false), basic_type)); + if (IsValid() && m_opaque_sp->IsValid()) + return SBType(m_opaque_sp->GetTypeSystem(false)->GetBasicTypeFromAST(basic_type)); return SBType(); } @@ -351,7 +359,7 @@ uint32_t SBType::GetNumberOfDirectBaseClasses () { if (IsValid()) - return m_opaque_sp->GetClangASTType(true).GetNumDirectBaseClasses(); + return m_opaque_sp->GetCompilerType(true).GetNumDirectBaseClasses(); return 0; } @@ -359,7 +367,7 @@ uint32_t SBType::GetNumberOfVirtualBaseClasses () { if (IsValid()) - return m_opaque_sp->GetClangASTType(true).GetNumVirtualBaseClasses(); + return m_opaque_sp->GetCompilerType(true).GetNumVirtualBaseClasses(); return 0; } @@ -367,7 +375,7 @@ uint32_t SBType::GetNumberOfFields () { if (IsValid()) - return m_opaque_sp->GetClangASTType(true).GetNumFields(); + return m_opaque_sp->GetCompilerType(true).GetNumFields(); return 0; } @@ -394,16 +402,10 @@ SBType::GetDirectBaseClassAtIndex (uint32_t idx) SBTypeMember sb_type_member; if (IsValid()) { - ClangASTType this_type (m_opaque_sp->GetClangASTType (true)); - if (this_type.IsValid()) - { - uint32_t bit_offset = 0; - ClangASTType base_class_type (this_type.GetDirectBaseClassAtIndex(idx, &bit_offset)); - if (base_class_type.IsValid()) - { - sb_type_member.reset (new TypeMemberImpl (TypeImplSP(new TypeImpl(base_class_type)), bit_offset)); - } - } + uint32_t bit_offset = 0; + CompilerType base_class_type = m_opaque_sp->GetCompilerType (true).GetDirectBaseClassAtIndex(idx, &bit_offset); + if (base_class_type.IsValid()) + sb_type_member.reset (new TypeMemberImpl (TypeImplSP(new TypeImpl(base_class_type)), bit_offset)); } return sb_type_member; @@ -415,16 +417,10 @@ SBType::GetVirtualBaseClassAtIndex (uint32_t idx) SBTypeMember sb_type_member; if (IsValid()) { - ClangASTType this_type (m_opaque_sp->GetClangASTType (true)); - if (this_type.IsValid()) - { - uint32_t bit_offset = 0; - ClangASTType base_class_type (this_type.GetVirtualBaseClassAtIndex(idx, &bit_offset)); - if (base_class_type.IsValid()) - { - sb_type_member.reset (new TypeMemberImpl (TypeImplSP(new TypeImpl(base_class_type)), bit_offset)); - } - } + uint32_t bit_offset = 0; + CompilerType base_class_type = m_opaque_sp->GetCompilerType (true).GetVirtualBaseClassAtIndex(idx, &bit_offset); + if (base_class_type.IsValid()) + sb_type_member.reset (new TypeMemberImpl (TypeImplSP(new TypeImpl(base_class_type)), bit_offset)); } return sb_type_member; } @@ -435,16 +431,14 @@ SBType::GetEnumMembers () SBTypeEnumMemberList sb_enum_member_list; if (IsValid()) { - const clang::EnumDecl *enum_decl = m_opaque_sp->GetClangASTType(true).GetFullyUnqualifiedType().GetAsEnumDecl(); - if (enum_decl) + CompilerType this_type (m_opaque_sp->GetCompilerType (true)); + if (this_type.IsValid()) { - clang::EnumDecl::enumerator_iterator enum_pos, enum_end_pos; - for (enum_pos = enum_decl->enumerator_begin(), enum_end_pos = enum_decl->enumerator_end(); enum_pos != enum_end_pos; ++enum_pos) - { - SBTypeEnumMember enum_member; - enum_member.reset(new TypeEnumMemberImpl(*enum_pos, ClangASTType(m_opaque_sp->GetClangASTContext(true), enum_decl->getIntegerType()))); + this_type.ForEachEnumerator([&sb_enum_member_list] (const CompilerType &integer_type, const ConstString &name, const llvm::APSInt &value) -> bool { + SBTypeEnumMember enum_member (lldb::TypeEnumMemberImplSP (new TypeEnumMemberImpl(lldb::TypeImplSP(new TypeImpl(integer_type)), name, value))); sb_enum_member_list.Append(enum_member); - } + return true; // Keep iterating + }); } } return sb_enum_member_list; @@ -456,14 +450,14 @@ SBType::GetFieldAtIndex (uint32_t idx) SBTypeMember sb_type_member; if (IsValid()) { - ClangASTType this_type (m_opaque_sp->GetClangASTType (false)); + CompilerType this_type (m_opaque_sp->GetCompilerType (false)); if (this_type.IsValid()) { uint64_t bit_offset = 0; uint32_t bitfield_bit_size = 0; bool is_bitfield = false; std::string name_sstr; - ClangASTType field_type (this_type.GetFieldAtIndex (idx, + CompilerType field_type (this_type.GetFieldAtIndex (idx, name_sstr, &bit_offset, &bitfield_bit_size, @@ -489,7 +483,7 @@ SBType::IsTypeComplete() { if (!IsValid()) return false; - return m_opaque_sp->GetClangASTType(false).IsCompleteType(); + return m_opaque_sp->GetCompilerType(false).IsCompleteType(); } uint32_t @@ -497,7 +491,7 @@ SBType::GetTypeFlags () { if (!IsValid()) return 0; - return m_opaque_sp->GetClangASTType(true).GetTypeInfo(); + return m_opaque_sp->GetCompilerType(true).GetTypeInfo(); } const char* @@ -520,7 +514,7 @@ lldb::TypeClass SBType::GetTypeClass () { if (IsValid()) - return m_opaque_sp->GetClangASTType(true).GetTypeClass(); + return m_opaque_sp->GetCompilerType(true).GetTypeClass(); return lldb::eTypeClassInvalid; } @@ -528,7 +522,7 @@ uint32_t SBType::GetNumberOfTemplateArguments () { if (IsValid()) - return m_opaque_sp->GetClangASTType(false).GetNumTemplateArguments(); + return m_opaque_sp->GetCompilerType(false).GetNumTemplateArguments(); return 0; } @@ -538,7 +532,7 @@ SBType::GetTemplateArgumentType (uint32_t idx) if (IsValid()) { TemplateArgumentKind kind = eTemplateArgumentKindNull; - ClangASTType template_arg_type = m_opaque_sp->GetClangASTType(false).GetTemplateArgument (idx, kind); + CompilerType template_arg_type = m_opaque_sp->GetCompilerType(false).GetTemplateArgument(idx, kind); if (template_arg_type.IsValid()) return SBType(template_arg_type); } @@ -551,7 +545,7 @@ SBType::GetTemplateArgumentKind (uint32_t idx) { TemplateArgumentKind kind = eTemplateArgumentKindNull; if (IsValid()) - m_opaque_sp->GetClangASTType(false).GetTemplateArgument (idx, kind); + m_opaque_sp->GetCompilerType(false).GetTemplateArgument(idx, kind); return kind; } @@ -791,6 +785,30 @@ SBTypeMemberFunction::GetName () return NULL; } +const char * +SBTypeMemberFunction::GetDemangledName () +{ + if (m_opaque_sp) + { + ConstString mangled_str = m_opaque_sp->GetMangledName(); + if (mangled_str) + { + Mangled mangled(mangled_str, true); + return mangled.GetDemangledName(mangled.GuessLanguage()).GetCString(); + } + } + return NULL; +} + +const char * +SBTypeMemberFunction::GetMangledName() +{ + if (m_opaque_sp) + return m_opaque_sp->GetMangledName().GetCString(); + return NULL; +} + + SBType SBTypeMemberFunction::GetType () { diff --git a/source/API/SBTypeCategory.cpp b/source/API/SBTypeCategory.cpp index ee9553ca6abd..33dada8da39d 100644 --- a/source/API/SBTypeCategory.cpp +++ b/source/API/SBTypeCategory.cpp @@ -79,6 +79,29 @@ SBTypeCategory::GetName() return m_opaque_sp->GetName(); } +lldb::LanguageType +SBTypeCategory::GetLanguageAtIndex (uint32_t idx) +{ + if (IsValid()) + return m_opaque_sp->GetLanguageAtIndex(idx); + return lldb::eLanguageTypeUnknown; +} + +uint32_t +SBTypeCategory::GetNumLanguages () +{ + if (IsValid()) + return m_opaque_sp->GetNumLanguages(); + return 0; +} + +void +SBTypeCategory::AddLanguage (lldb::LanguageType language) +{ + if (IsValid()) + m_opaque_sp->AddLanguage(language); +} + uint32_t SBTypeCategory::GetNumFormats () { @@ -157,7 +180,7 @@ SBTypeCategory::GetFilterForType (SBTypeNameSpecifier spec) if (!spec.IsValid()) return SBTypeFilter(); - lldb::SyntheticChildrenSP children_sp; + lldb::TypeFilterImplSP children_sp; if (spec.IsRegex()) m_opaque_sp->GetRegexTypeFiltersContainer()->GetExact(ConstString(spec.GetName()), children_sp); diff --git a/source/API/SBTypeEnumMember.cpp b/source/API/SBTypeEnumMember.cpp index 47c57dd213fb..c23f7ea8c6ce 100644 --- a/source/API/SBTypeEnumMember.cpp +++ b/source/API/SBTypeEnumMember.cpp @@ -12,12 +12,11 @@ #include "lldb/API/SBTypeEnumMember.h" #include "lldb/API/SBStream.h" #include "lldb/Core/Stream.h" -#include "lldb/Symbol/ClangASTType.h" +#include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/Type.h" using namespace lldb; using namespace lldb_private; -using namespace clang; SBTypeEnumMember::SBTypeEnumMember() : m_opaque_sp() diff --git a/source/API/SBTypeNameSpecifier.cpp b/source/API/SBTypeNameSpecifier.cpp index c58747170b5a..6f6801099b7c 100644 --- a/source/API/SBTypeNameSpecifier.cpp +++ b/source/API/SBTypeNameSpecifier.cpp @@ -34,7 +34,7 @@ SBTypeNameSpecifier::SBTypeNameSpecifier (SBType type) : m_opaque_sp() { if (type.IsValid()) - m_opaque_sp = TypeNameSpecifierImplSP(new TypeNameSpecifierImpl(type.m_opaque_sp->GetClangASTType(true))); + m_opaque_sp = TypeNameSpecifierImplSP(new TypeNameSpecifierImpl(type.m_opaque_sp->GetCompilerType(true))); } SBTypeNameSpecifier::SBTypeNameSpecifier (const lldb::SBTypeNameSpecifier &rhs) : @@ -65,7 +65,7 @@ SBTypeNameSpecifier::GetType () { if (!IsValid()) return SBType(); - lldb_private::ClangASTType c_type = m_opaque_sp->GetClangASTType(); + lldb_private::CompilerType c_type = m_opaque_sp->GetCompilerType(); if (c_type.IsValid()) return SBType(c_type); return SBType(); diff --git a/source/API/SBTypeSummary.cpp b/source/API/SBTypeSummary.cpp index 2c114545419c..2985b7659547 100644 --- a/source/API/SBTypeSummary.cpp +++ b/source/API/SBTypeSummary.cpp @@ -8,16 +8,15 @@ //===----------------------------------------------------------------------===// #include "lldb/API/SBTypeSummary.h" - #include "lldb/API/SBStream.h" - +#include "lldb/API/SBValue.h" #include "lldb/DataFormatters/DataVisualization.h" +#include "llvm/Support/Casting.h" + using namespace lldb; using namespace lldb_private; -#ifndef LLDB_DISABLE_PYTHON - SBTypeSummaryOptions::SBTypeSummaryOptions() { m_opaque_ap.reset(new TypeSummaryOptions()); @@ -147,6 +146,28 @@ SBTypeSummary::CreateWithScriptCode (const char* data, uint32_t options) return SBTypeSummary(TypeSummaryImplSP(new ScriptSummaryFormat(options, "", data))); } +SBTypeSummary +SBTypeSummary::CreateWithCallback (FormatCallback cb, uint32_t options, const char* description) +{ + SBTypeSummary retval; + if (cb) + { + retval.SetSP(TypeSummaryImplSP(new CXXFunctionSummaryFormat(options, + [cb] (ValueObject& valobj, Stream& stm, const TypeSummaryOptions& opt) -> bool { + SBStream stream; + SBValue sb_value(valobj.GetSP()); + SBTypeSummaryOptions options(&opt); + if (!cb(sb_value, options, stream)) + return false; + stm.Write(stream.GetData(), stream.GetSize()); + return true; + }, + description ? description : "callback summary formatter"))); + } + + return retval; +} + SBTypeSummary::SBTypeSummary (const lldb::SBTypeSummary &rhs) : m_opaque_sp(rhs.m_opaque_sp) { @@ -167,9 +188,8 @@ SBTypeSummary::IsFunctionCode() { if (!IsValid()) return false; - if (m_opaque_sp->IsScripted()) + if (ScriptSummaryFormat* script_summary_ptr = llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get())) { - ScriptSummaryFormat* script_summary_ptr = (ScriptSummaryFormat*)m_opaque_sp.get(); const char* ftext = script_summary_ptr->GetPythonScript(); return (ftext && *ftext != 0); } @@ -181,9 +201,8 @@ SBTypeSummary::IsFunctionName() { if (!IsValid()) return false; - if (m_opaque_sp->IsScripted()) + if (ScriptSummaryFormat* script_summary_ptr = llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get())) { - ScriptSummaryFormat* script_summary_ptr = (ScriptSummaryFormat*)m_opaque_sp.get(); const char* ftext = script_summary_ptr->GetPythonScript(); return (!ftext || *ftext == 0); } @@ -196,10 +215,7 @@ SBTypeSummary::IsSummaryString() if (!IsValid()) return false; - if (m_opaque_sp->GetType() == lldb_private::TypeSummaryImpl::eTypeCallback) - return false; - - return !m_opaque_sp->IsScripted(); + return m_opaque_sp->GetKind() == TypeSummaryImpl::Kind::eSummaryString; } const char* @@ -207,22 +223,17 @@ SBTypeSummary::GetData () { if (!IsValid()) return NULL; - if (m_opaque_sp->GetType() == lldb_private::TypeSummaryImpl::eTypeCallback) - return NULL; - if (m_opaque_sp->IsScripted()) + if (ScriptSummaryFormat* script_summary_ptr = llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get())) { - ScriptSummaryFormat* script_summary_ptr = (ScriptSummaryFormat*)m_opaque_sp.get(); const char* fname = script_summary_ptr->GetFunctionName(); const char* ftext = script_summary_ptr->GetPythonScript(); if (ftext && *ftext) return ftext; return fname; } - else - { - StringSummaryFormat* string_summary_ptr = (StringSummaryFormat*)m_opaque_sp.get(); + else if (StringSummaryFormat* string_summary_ptr = llvm::dyn_cast<StringSummaryFormat>(m_opaque_sp.get())) return string_summary_ptr->GetSummaryString(); - } + return nullptr; } uint32_t @@ -246,9 +257,10 @@ SBTypeSummary::SetSummaryString (const char* data) { if (!IsValid()) return; - if (m_opaque_sp->IsScripted() || (m_opaque_sp->GetType() == lldb_private::TypeSummaryImpl::eTypeCallback)) + if (!llvm::isa<StringSummaryFormat>(m_opaque_sp.get())) ChangeSummaryType(false); - ((StringSummaryFormat*)m_opaque_sp.get())->SetSummaryString(data); + if (StringSummaryFormat* string_summary_ptr = llvm::dyn_cast<StringSummaryFormat>(m_opaque_sp.get())) + string_summary_ptr->SetSummaryString(data); } void @@ -256,9 +268,10 @@ SBTypeSummary::SetFunctionName (const char* data) { if (!IsValid()) return; - if (!m_opaque_sp->IsScripted()) + if (!llvm::isa<ScriptSummaryFormat>(m_opaque_sp.get())) ChangeSummaryType(true); - ((ScriptSummaryFormat*)m_opaque_sp.get())->SetFunctionName(data); + if (ScriptSummaryFormat* script_summary_ptr = llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get())) + script_summary_ptr->SetFunctionName(data); } void @@ -266,9 +279,10 @@ SBTypeSummary::SetFunctionCode (const char* data) { if (!IsValid()) return; - if (!m_opaque_sp->IsScripted()) + if (!llvm::isa<ScriptSummaryFormat>(m_opaque_sp.get())) ChangeSummaryType(true); - ((ScriptSummaryFormat*)m_opaque_sp.get())->SetPythonScript(data); + if (ScriptSummaryFormat* script_summary_ptr = llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get())) + script_summary_ptr->SetPythonScript(data); } bool @@ -284,6 +298,15 @@ SBTypeSummary::GetDescription (lldb::SBStream &description, } } +bool +SBTypeSummary::DoesPrintValue (lldb::SBValue value) +{ + if (!IsValid()) + return false; + lldb::ValueObjectSP value_sp = value.GetSP(); + return m_opaque_sp->DoesPrintValue(value_sp.get()); +} + lldb::SBTypeSummary & SBTypeSummary::operator = (const lldb::SBTypeSummary &rhs) { @@ -305,36 +328,44 @@ SBTypeSummary::operator == (lldb::SBTypeSummary &rhs) bool SBTypeSummary::IsEqualTo (lldb::SBTypeSummary &rhs) { - if (IsValid() == false) - return !rhs.IsValid(); - - if (m_opaque_sp->GetType() != rhs.m_opaque_sp->GetType()) - return false; - - if (m_opaque_sp->GetType() == lldb_private::TypeSummaryImpl::eTypeCallback) + if (IsValid()) { - lldb_private::CXXFunctionSummaryFormat *self_cxx = (lldb_private::CXXFunctionSummaryFormat*)m_opaque_sp.get(); - lldb_private::CXXFunctionSummaryFormat *other_cxx = (lldb_private::CXXFunctionSummaryFormat*)rhs.m_opaque_sp.get(); - return (self_cxx->m_impl == other_cxx->m_impl); + // valid and invalid are different + if (!rhs.IsValid()) + return false; + } + else + { + // invalid and valid are different + if (rhs.IsValid()) + return false; + else + // both invalid are the same + return true; } - - if (m_opaque_sp->IsScripted() != rhs.m_opaque_sp->IsScripted()) - return false; - - if (IsFunctionCode() != rhs.IsFunctionCode()) - return false; - - if (IsSummaryString() != rhs.IsSummaryString()) - return false; - if (IsFunctionName() != rhs.IsFunctionName()) - return false; - - if ( GetData() == NULL || rhs.GetData() == NULL || strcmp(GetData(), rhs.GetData()) ) + if (m_opaque_sp->GetKind() != rhs.m_opaque_sp->GetKind()) return false; - return GetOptions() == rhs.GetOptions(); + switch (m_opaque_sp->GetKind()) + { + case TypeSummaryImpl::Kind::eCallback: + return llvm::dyn_cast<CXXFunctionSummaryFormat>(m_opaque_sp.get()) == llvm::dyn_cast<CXXFunctionSummaryFormat>(rhs.m_opaque_sp.get()); + case TypeSummaryImpl::Kind::eScript: + if (IsFunctionCode() != rhs.IsFunctionCode()) + return false; + if (IsFunctionName() != rhs.IsFunctionName()) + return false; + return GetOptions() == rhs.GetOptions(); + case TypeSummaryImpl::Kind::eSummaryString: + if (IsSummaryString() != rhs.IsSummaryString()) + return false; + return GetOptions() == rhs.GetOptions(); + case TypeSummaryImpl::Kind::eInternal: + return (m_opaque_sp.get() == rhs.m_opaque_sp.get()); + } + return false; } bool @@ -373,29 +404,27 @@ SBTypeSummary::CopyOnWrite_Impl() TypeSummaryImplSP new_sp; - if (m_opaque_sp->GetType() == lldb_private::TypeSummaryImpl::eTypeCallback) + if (CXXFunctionSummaryFormat* current_summary_ptr = llvm::dyn_cast<CXXFunctionSummaryFormat>(m_opaque_sp.get())) { - CXXFunctionSummaryFormat* current_summary_ptr = (CXXFunctionSummaryFormat*)m_opaque_sp.get(); new_sp = TypeSummaryImplSP(new CXXFunctionSummaryFormat(GetOptions(), current_summary_ptr->m_impl, current_summary_ptr->m_description.c_str())); } - else if (m_opaque_sp->IsScripted()) + else if (ScriptSummaryFormat* current_summary_ptr = llvm::dyn_cast<ScriptSummaryFormat>(m_opaque_sp.get())) { - ScriptSummaryFormat* current_summary_ptr = (ScriptSummaryFormat*)m_opaque_sp.get(); new_sp = TypeSummaryImplSP(new ScriptSummaryFormat(GetOptions(), current_summary_ptr->GetFunctionName(), current_summary_ptr->GetPythonScript())); } - else { - StringSummaryFormat* current_summary_ptr = (StringSummaryFormat*)m_opaque_sp.get(); + else if (StringSummaryFormat* current_summary_ptr = llvm::dyn_cast<StringSummaryFormat>(m_opaque_sp.get())) + { new_sp = TypeSummaryImplSP(new StringSummaryFormat(GetOptions(), current_summary_ptr->GetSummaryString())); } - + SetSP(new_sp); - return true; + return nullptr != new_sp.get(); } bool @@ -406,9 +435,9 @@ SBTypeSummary::ChangeSummaryType (bool want_script) TypeSummaryImplSP new_sp; - if (want_script == m_opaque_sp->IsScripted()) + if (want_script == (m_opaque_sp->GetKind() == TypeSummaryImpl::Kind::eScript)) { - if (m_opaque_sp->GetType() == lldb_private::TypeSummaryImpl::eTypeCallback && !want_script) + if (m_opaque_sp->GetKind() == lldb_private::TypeSummaryImpl::Kind::eCallback && !want_script) new_sp = TypeSummaryImplSP(new StringSummaryFormat(GetOptions(), "")); else return CopyOnWrite_Impl(); @@ -426,5 +455,3 @@ SBTypeSummary::ChangeSummaryType (bool want_script) return true; } - -#endif // LLDB_DISABLE_PYTHON diff --git a/source/API/SBValue.cpp b/source/API/SBValue.cpp index ef62c30e42cf..a8584c5d38c9 100644 --- a/source/API/SBValue.cpp +++ b/source/API/SBValue.cpp @@ -632,7 +632,6 @@ SBValue::GetValueDidChange () return result; } -#ifndef LLDB_DISABLE_PYTHON const char * SBValue::GetSummary () { @@ -681,7 +680,6 @@ SBValue::GetSummary (lldb::SBStream& stream, } return cstr; } -#endif // LLDB_DISABLE_PYTHON const char * SBValue::GetLocation () @@ -753,7 +751,6 @@ SBValue::GetTypeFormat () return format; } -#ifndef LLDB_DISABLE_PYTHON lldb::SBTypeSummary SBValue::GetTypeSummary () { @@ -771,7 +768,6 @@ SBValue::GetTypeSummary () } return summary; } -#endif // LLDB_DISABLE_PYTHON lldb::SBTypeFilter SBValue::GetTypeFilter () @@ -831,7 +827,7 @@ SBValue::CreateChildAtOffset (const char *name, uint32_t offset, SBType type) TypeImplSP type_sp (type.GetSP()); if (type.IsValid()) { - sb_value.SetSP(value_sp->GetSyntheticChildAtOffset(offset, type_sp->GetClangASTType(false), true),GetPreferDynamicValue(),GetPreferSyntheticValue(), name); + sb_value.SetSP(value_sp->GetSyntheticChildAtOffset(offset, type_sp->GetCompilerType(false), true),GetPreferDynamicValue(),GetPreferSyntheticValue(), name); } } Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); @@ -856,7 +852,7 @@ SBValue::Cast (SBType type) lldb::ValueObjectSP value_sp(GetSP(locker)); TypeImplSP type_sp (type.GetSP()); if (value_sp && type_sp) - sb_value.SetSP(value_sp->Cast(type_sp->GetClangASTType(false)),GetPreferDynamicValue(),GetPreferSyntheticValue()); + sb_value.SetSP(value_sp->Cast(type_sp->GetCompilerType(false)),GetPreferDynamicValue(),GetPreferSyntheticValue()); return sb_value; } @@ -907,7 +903,7 @@ SBValue::CreateValueFromAddress(const char* name, lldb::addr_t address, SBType s lldb::TypeImplSP type_impl_sp (sb_type.GetSP()); if (value_sp && type_impl_sp) { - ClangASTType ast_type(type_impl_sp->GetClangASTType(true)); + CompilerType ast_type(type_impl_sp->GetCompilerType(true)); ExecutionContext exe_ctx (value_sp->GetExecutionContextRef()); new_value_sp = ValueObject::CreateValueObjectFromAddress(name, address, exe_ctx, ast_type); } @@ -936,7 +932,7 @@ SBValue::CreateValueFromData (const char* name, SBData data, SBType type) if (value_sp) { ExecutionContext exe_ctx (value_sp->GetExecutionContextRef()); - new_value_sp = ValueObject::CreateValueObjectFromData(name, **data, exe_ctx, type.GetSP()->GetClangASTType(true)); + new_value_sp = ValueObject::CreateValueObjectFromData(name, **data, exe_ctx, type.GetSP()->GetCompilerType(true)); new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad); } sb_value.SetSP(new_value_sp); @@ -1270,22 +1266,27 @@ SBValue::IsRuntimeSupportValue () uint32_t SBValue::GetNumChildren () { + return GetNumChildren (UINT32_MAX); +} + +uint32_t +SBValue::GetNumChildren (uint32_t max) +{ uint32_t num_children = 0; Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) - num_children = value_sp->GetNumChildren(); + num_children = value_sp->GetNumChildren(max); if (log) - log->Printf ("SBValue(%p)::GetNumChildren () => %u", - static_cast<void*>(value_sp.get()), num_children); + log->Printf ("SBValue(%p)::GetNumChildren (%u) => %u", + static_cast<void*>(value_sp.get()), max, num_children); return num_children; } - SBValue SBValue::Dereference () { @@ -1306,22 +1307,11 @@ SBValue::Dereference () return sb_value; } +// Deprecated - please use GetType().IsPointerType() instead. bool SBValue::TypeIsPointerType () { - bool is_ptr_type = false; - - ValueLocker locker; - lldb::ValueObjectSP value_sp(GetSP(locker)); - if (value_sp) - is_ptr_type = value_sp->IsPointerType(); - - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - if (log) - log->Printf ("SBValue(%p)::TypeIsPointerType () => %i", - static_cast<void*>(value_sp.get()), is_ptr_type); - - return is_ptr_type; + return GetType().IsPointerType(); } void * @@ -1330,7 +1320,7 @@ SBValue::GetOpaqueType() ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); if (value_sp) - return value_sp->GetClangType().GetOpaqueQualType(); + return value_sp->GetCompilerType().GetOpaqueQualType(); return NULL; } @@ -1435,7 +1425,10 @@ lldb::ValueObjectSP SBValue::GetSP (ValueLocker &locker) const { if (!m_opaque_sp || !m_opaque_sp->IsValid()) + { + locker.GetError().SetErrorString("No value"); return ValueObjectSP(); + } return locker.GetLockedSP(*m_opaque_sp.get()); } @@ -1823,7 +1816,7 @@ SBValue::Watch (bool resolve_location, bool read, bool write, SBError &error) watch_type |= LLDB_WATCH_TYPE_WRITE; Error rc; - ClangASTType type (value_sp->GetClangType()); + CompilerType type (value_sp->GetCompilerType()); WatchpointSP watchpoint_sp = target_sp->CreateWatchpoint(addr, byte_size, &type, watch_type, rc); error.SetError(rc); diff --git a/source/API/SBValueList.cpp b/source/API/SBValueList.cpp index 71fabe0dfc0a..5461b05fb196 100644 --- a/source/API/SBValueList.cpp +++ b/source/API/SBValueList.cpp @@ -39,7 +39,7 @@ public: return *this; m_values = rhs.m_values; return *this; - }; + } uint32_t GetSize () @@ -297,5 +297,3 @@ SBValueList::ref () CreateIfNeeded(); return *m_opaque_ap.get(); } - - diff --git a/source/API/SystemInitializerFull.cpp b/source/API/SystemInitializerFull.cpp index 01ad8157646e..f223357824e8 100644 --- a/source/API/SystemInitializerFull.cpp +++ b/source/API/SystemInitializerFull.cpp @@ -7,18 +7,32 @@ // //===----------------------------------------------------------------------===// +#if !defined(LLDB_DISABLE_PYTHON) +#include "Plugins/ScriptInterpreter/Python/lldb-python.h" +#endif + #include "lldb/API/SystemInitializerFull.h" +#include "lldb/API/SBCommandInterpreter.h" + +#if !defined(LLDB_DISABLE_PYTHON) +#include "Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h" +#endif + #include "lldb/Core/Debugger.h" #include "lldb/Core/Timer.h" #include "lldb/Host/Host.h" #include "lldb/Initialization/SystemInitializerCommon.h" +#include "lldb/Interpreter/CommandInterpreter.h" +#include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/GoASTContext.h" #include "Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h" #include "Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.h" #include "Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.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-x86_64/ABISysV_x86_64.h" #include "Plugins/ABI/SysV-ppc/ABISysV_ppc.h" @@ -30,14 +44,20 @@ #include "Plugins/Instruction/ARM64/EmulateInstructionARM64.h" #include "Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.h" #include "Plugins/JITLoader/GDB/JITLoaderGDB.h" +#include "Plugins/Language/CPlusPlus/CPlusPlusLanguage.h" +#include "Plugins/Language/Go/GoLanguage.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/Go/GoLanguageRuntime.h" #include "Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h" #include "Plugins/MemoryHistory/asan/MemoryHistoryASan.h" #include "Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h" #include "Plugins/Process/elf-core/ProcessElfCore.h" #include "Plugins/Process/gdb-remote/ProcessGDBRemote.h" +#include "Plugins/ScriptInterpreter/None/ScriptInterpreterNone.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" #include "Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h" #include "Plugins/SymbolFile/Symtab/SymbolFileSymtab.h" @@ -50,6 +70,10 @@ #include "Plugins/Process/mach-core/ProcessMachCore.h" #include "Plugins/Process/MacOSX-Kernel/ProcessKDP.h" #include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h" +#include "Plugins/Platform/MacOSX/PlatformAppleTVSimulator.h" +#include "Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.h" +#include "Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h" +#include "Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h" #endif #if defined(__FreeBSD__) @@ -58,11 +82,8 @@ #if defined(_MSC_VER) #include "lldb/Host/windows/windows.h" -#include "Plugins/Process/Windows/ProcessWindows.h" -#endif - -#if !defined(LLDB_DISABLE_PYTHON) -#include "lldb/Interpreter/ScriptInterpreterPython.h" +#include "Plugins/Process/Windows/Live/ProcessWindowsLive.h" +#include "Plugins/Process/Windows/MiniDump/ProcessWinMiniDump.h" #endif #include "llvm/Support/TargetSelect.h" @@ -74,9 +95,19 @@ using namespace lldb_private; #ifndef LLDB_DISABLE_PYTHON // Defined in the SWIG source file +#if PY_MAJOR_VERSION >= 3 +extern "C" PyObject* +PyInit__lldb(void); + +#define LLDBSwigPyInit PyInit__lldb + +#else extern "C" void init_lldb(void); +#define LLDBSwigPyInit init_lldb +#endif + // these are the Pythonic implementations of the required callbacks // these are scripting-language specific, which is why they belong here // we still need to use function pointers to them instead of relying @@ -124,7 +155,7 @@ LLDBSWIGPythonCallThreadPlan (void *implementor, bool &got_error); extern "C" size_t -LLDBSwigPython_CalculateNumChildren (void *implementor); +LLDBSwigPython_CalculateNumChildren (void *implementor, uint32_t max); extern "C" void * LLDBSwigPython_GetChildAtIndex (void *implementor, uint32_t idx); @@ -221,9 +252,17 @@ SystemInitializerFull::~SystemInitializerFull() void SystemInitializerFull::Initialize() { + SystemInitializerCommon::Initialize(); + ScriptInterpreterNone::Initialize(); + +#if !defined(LLDB_DISABLE_PYTHON) InitializeSWIG(); - SystemInitializerCommon::Initialize(); + // ScriptInterpreterPython::Initialize() depends on things like HostInfo being initialized + // so it can compute the python directory etc, so we need to do this after + // SystemInitializerCommon::Initialize(). + ScriptInterpreterPython::Initialize(); +#endif // Initialize LLVM and Clang llvm::InitializeAllTargets(); @@ -231,11 +270,15 @@ SystemInitializerFull::Initialize() llvm::InitializeAllTargetMCs(); llvm::InitializeAllDisassemblers(); + ClangASTContext::Initialize(); + GoASTContext::Initialize(); + ABIMacOSX_i386::Initialize(); ABIMacOSX_arm::Initialize(); ABIMacOSX_arm64::Initialize(); ABISysV_arm::Initialize(); ABISysV_arm64::Initialize(); + ABISysV_hexagon::Initialize(); ABISysV_i386::Initialize(); ABISysV_x86_64::Initialize(); ABISysV_ppc::Initialize(); @@ -246,6 +289,9 @@ SystemInitializerFull::Initialize() JITLoaderGDB::Initialize(); ProcessElfCore::Initialize(); +#if defined(_MSC_VER) + ProcessWinMiniDump::Initialize(); +#endif MemoryHistoryASan::Initialize(); AddressSanitizerRuntime::Initialize(); @@ -261,9 +307,15 @@ SystemInitializerFull::Initialize() AppleObjCRuntimeV1::Initialize(); SystemRuntimeMacOSX::Initialize(); RenderScriptRuntime::Initialize(); + GoLanguageRuntime::Initialize(); + + CPlusPlusLanguage::Initialize(); + GoLanguage::Initialize(); + ObjCLanguage::Initialize(); + ObjCPlusPlusLanguage::Initialize(); #if defined(_MSC_VER) - ProcessWindows::Initialize(); + ProcessWindowsLive::Initialize(); #endif #if defined(__FreeBSD__) ProcessFreeBSD::Initialize(); @@ -272,6 +324,10 @@ SystemInitializerFull::Initialize() SymbolVendorMacOSX::Initialize(); ProcessKDP::Initialize(); ProcessMachCore::Initialize(); + PlatformAppleTVSimulator::Initialize(); + PlatformAppleWatchSimulator::Initialize(); + PlatformRemoteAppleTV::Initialize(); + PlatformRemoteAppleWatch::Initialize(); #endif //---------------------------------------------------------------------- // Platform agnostic plugins @@ -294,7 +350,7 @@ void SystemInitializerFull::InitializeSWIG() { #if !defined(LLDB_DISABLE_PYTHON) ScriptInterpreterPython::InitializeInterpreter( - init_lldb, + LLDBSwigPyInit, LLDBSwigPythonBreakpointCallbackFunction, LLDBSwigPythonWatchpointCallbackFunction, LLDBSwigPythonCallTypeScript, @@ -332,11 +388,16 @@ SystemInitializerFull::Terminate() // Terminate and unload and loaded system or user LLDB plug-ins PluginManager::Terminate(); + + ClangASTContext::Terminate(); + GoASTContext::Terminate(); + ABIMacOSX_i386::Terminate(); ABIMacOSX_arm::Terminate(); ABIMacOSX_arm64::Terminate(); ABISysV_arm::Terminate(); ABISysV_arm64::Terminate(); + ABISysV_hexagon::Terminate(); ABISysV_i386::Terminate(); ABISysV_x86_64::Terminate(); ABISysV_ppc::Terminate(); @@ -347,6 +408,9 @@ SystemInitializerFull::Terminate() JITLoaderGDB::Terminate(); ProcessElfCore::Terminate(); +#if defined(_MSC_VER) + ProcessWinMiniDump::Terminate(); +#endif MemoryHistoryASan::Terminate(); AddressSanitizerRuntime::Terminate(); SymbolVendorELF::Terminate(); @@ -362,10 +426,19 @@ SystemInitializerFull::Terminate() SystemRuntimeMacOSX::Terminate(); RenderScriptRuntime::Terminate(); + CPlusPlusLanguage::Terminate(); + GoLanguage::Terminate(); + ObjCLanguage::Terminate(); + ObjCPlusPlusLanguage::Terminate(); + #if defined(__APPLE__) ProcessMachCore::Terminate(); ProcessKDP::Terminate(); SymbolVendorMacOSX::Terminate(); + PlatformAppleTVSimulator::Terminate(); + PlatformAppleWatchSimulator::Terminate(); + PlatformRemoteAppleTV::Terminate(); + PlatformRemoteAppleWatch::Terminate(); #endif #if defined(__FreeBSD__) @@ -380,8 +453,3 @@ SystemInitializerFull::Terminate() // Now shutdown the common parts, in reverse order. SystemInitializerCommon::Terminate(); } - -void SystemInitializerFull::TerminateSWIG() -{ - -} diff --git a/source/API/liblldb.exports b/source/API/liblldb.exports new file mode 100644 index 000000000000..fd234d11c40c --- /dev/null +++ b/source/API/liblldb.exports @@ -0,0 +1,3 @@ +_ZN4lldb* +_ZNK4lldb* +init_lld* diff --git a/source/API/liblldb.xcode.exports b/source/API/liblldb.xcode.exports new file mode 100644 index 000000000000..9c194fa6ff67 --- /dev/null +++ b/source/API/liblldb.xcode.exports @@ -0,0 +1,3 @@ +__ZN4lldb* +__ZNK4lldb* +_init_lld* diff --git a/source/Breakpoint/Breakpoint.cpp b/source/Breakpoint/Breakpoint.cpp index 23d484f0f68a..54f67b90220a 100644 --- a/source/Breakpoint/Breakpoint.cpp +++ b/source/Breakpoint/Breakpoint.cpp @@ -7,12 +7,12 @@ // //===----------------------------------------------------------------------===// - // C Includes // C++ Includes // Other libraries and framework includes -// Project includes +#include "llvm/Support/Casting.h" +// Project includes #include "lldb/Core/Address.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" @@ -31,7 +31,6 @@ #include "lldb/Symbol/SymbolContext.h" #include "lldb/Target/Target.h" #include "lldb/Target/ThreadSpec.h" -#include "llvm/Support/Casting.h" using namespace lldb; using namespace lldb_private; @@ -83,9 +82,7 @@ Breakpoint::Breakpoint (Target &new_target, Breakpoint &source_bp) : //---------------------------------------------------------------------- // Destructor //---------------------------------------------------------------------- -Breakpoint::~Breakpoint() -{ -} +Breakpoint::~Breakpoint() = default; const lldb::TargetSP Breakpoint::GetTargetSP () @@ -236,7 +233,7 @@ Breakpoint::SetThreadID (lldb::tid_t thread_id) lldb::tid_t Breakpoint::GetThreadID () const { - if (m_options.GetThreadSpecNoCreate() == NULL) + if (m_options.GetThreadSpecNoCreate() == nullptr) return LLDB_INVALID_THREAD_ID; else return m_options.GetThreadSpecNoCreate()->GetTID(); @@ -255,7 +252,7 @@ Breakpoint::SetThreadIndex (uint32_t index) uint32_t Breakpoint::GetThreadIndex() const { - if (m_options.GetThreadSpecNoCreate() == NULL) + if (m_options.GetThreadSpecNoCreate() == nullptr) return 0; else return m_options.GetThreadSpecNoCreate()->GetIndex(); @@ -264,7 +261,7 @@ Breakpoint::GetThreadIndex() const void Breakpoint::SetThreadName (const char *thread_name) { - if (m_options.GetThreadSpec()->GetName() != NULL + if (m_options.GetThreadSpec()->GetName() != nullptr && ::strcmp (m_options.GetThreadSpec()->GetName(), thread_name) == 0) return; @@ -275,8 +272,8 @@ Breakpoint::SetThreadName (const char *thread_name) const char * Breakpoint::GetThreadName () const { - if (m_options.GetThreadSpecNoCreate() == NULL) - return NULL; + if (m_options.GetThreadSpecNoCreate() == nullptr) + return nullptr; else return m_options.GetThreadSpecNoCreate()->GetName(); } @@ -284,7 +281,7 @@ Breakpoint::GetThreadName () const void Breakpoint::SetQueueName (const char *queue_name) { - if (m_options.GetThreadSpec()->GetQueueName() != NULL + if (m_options.GetThreadSpec()->GetQueueName() != nullptr && ::strcmp (m_options.GetThreadSpec()->GetQueueName(), queue_name) == 0) return; @@ -295,8 +292,8 @@ Breakpoint::SetQueueName (const char *queue_name) const char * Breakpoint::GetQueueName () const { - if (m_options.GetThreadSpecNoCreate() == NULL) - return NULL; + if (m_options.GetThreadSpecNoCreate() == nullptr) + return nullptr; else return m_options.GetThreadSpecNoCreate()->GetQueueName(); } @@ -456,7 +453,6 @@ Breakpoint::ModulesChanged (ModuleList &module_list, bool load, bool delete_loca if (!seen) new_modules.AppendIfNeeded (module_sp); - } if (new_modules.GetSize() > 0) @@ -474,7 +470,7 @@ Breakpoint::ModulesChanged (ModuleList &module_list, bool load, bool delete_loca removed_locations_event = new BreakpointEventData (eBreakpointEventTypeLocationsRemoved, shared_from_this()); else - removed_locations_event = NULL; + removed_locations_event = nullptr; size_t num_modules = module_list.GetSize(); for (size_t i = 0; i < num_modules; i++) @@ -502,7 +498,6 @@ Breakpoint::ModulesChanged (ModuleList &module_list, bool load, bool delete_loca } if (delete_locations) locations_to_remove.Add (break_loc_sp); - } } @@ -568,7 +563,7 @@ SymbolContextsMightBeEquivalent(SymbolContext &old_sc, SymbolContext &new_sc) } return equivalent_scs; } -} +} // anonymous namespace void Breakpoint::ModuleReplaced (ModuleSP old_module_sp, ModuleSP new_module_sp) @@ -740,7 +735,7 @@ Breakpoint::ModuleReplaced (ModuleSP old_module_sp, ModuleSP new_module_sp) locations_event = new BreakpointEventData (eBreakpointEventTypeLocationsRemoved, shared_from_this()); else - locations_event = NULL; + locations_event = nullptr; for (BreakpointLocationSP loc_sp : locations_to_remove.BreakpointLocations()) { @@ -804,7 +799,7 @@ Breakpoint::AddName (const char *new_name, Error &error) void Breakpoint::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_locations) { - assert (s != NULL); + assert (s != nullptr); if (!m_kind_description.empty()) { @@ -849,6 +844,9 @@ Breakpoint::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_l GetOptions()->GetDescription(s, level); + if (m_precondition_sp) + m_precondition_sp->GetDescription(*s, level); + if (level == lldb::eDescriptionLevelFull) { if (!m_name_list.empty()) @@ -876,7 +874,7 @@ Breakpoint::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_l { s->Printf ("no locations (pending)."); } - else if (num_locations == 1 && show_locations == false) + else if (num_locations == 1 && !show_locations) { // There is only one location, so we'll just print that location information. GetLocationAtIndex(0)->GetDescription(s, level); @@ -922,7 +920,6 @@ Breakpoint::GetResolverDescription (Stream *s) m_resolver_sp->GetDescription (s); } - bool Breakpoint::GetMatchingFileLine (const ConstString &filename, uint32_t line_number, BreakpointLocationCollection &loc_coll) { @@ -965,7 +962,7 @@ Breakpoint::BreakpointPrecondition::EvaluatePrecondition(StoppointCallbackContex } void -Breakpoint::BreakpointPrecondition::DescribePrecondition(Stream &stream, lldb::DescriptionLevel level) +Breakpoint::BreakpointPrecondition::GetDescription(Stream &stream, lldb::DescriptionLevel level) { } @@ -993,8 +990,7 @@ Breakpoint::SendBreakpointChangedEvent (lldb::BreakpointEventType eventKind) void Breakpoint::SendBreakpointChangedEvent (BreakpointEventData *data) { - - if (data == NULL) + if (data == nullptr) return; if (!m_being_created @@ -1013,9 +1009,7 @@ Breakpoint::BreakpointEventData::BreakpointEventData (BreakpointEventType sub_ty { } -Breakpoint::BreakpointEventData::~BreakpointEventData () -{ -} +Breakpoint::BreakpointEventData::~BreakpointEventData() = default; const ConstString & Breakpoint::BreakpointEventData::GetFlavorString () @@ -1030,7 +1024,6 @@ Breakpoint::BreakpointEventData::GetFlavor () const return BreakpointEventData::GetFlavorString (); } - BreakpointSP & Breakpoint::BreakpointEventData::GetBreakpoint () { @@ -1057,7 +1050,7 @@ Breakpoint::BreakpointEventData::GetEventDataFromEvent (const Event *event) if (event_data && event_data->GetFlavor() == BreakpointEventData::GetFlavorString()) return static_cast <const BreakpointEventData *> (event->GetData()); } - return NULL; + return nullptr; } BreakpointEventType @@ -1065,7 +1058,7 @@ Breakpoint::BreakpointEventData::GetBreakpointEventTypeFromEvent (const EventSP { const BreakpointEventData *data = GetEventDataFromEvent (event_sp.get()); - if (data == NULL) + if (data == nullptr) return eBreakpointEventTypeInvalidType; else return data->GetBreakpointEventType(); diff --git a/source/Breakpoint/BreakpointID.cpp b/source/Breakpoint/BreakpointID.cpp index 31823886dd9f..81a3dfe50d9b 100644 --- a/source/Breakpoint/BreakpointID.cpp +++ b/source/Breakpoint/BreakpointID.cpp @@ -7,14 +7,12 @@ // //===----------------------------------------------------------------------===// - // C Includes #include <stdio.h> // C++ Includes // Other libraries and framework includes // Project includes - #include "lldb/Breakpoint/BreakpointID.h" #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Core/Stream.h" @@ -29,11 +27,9 @@ BreakpointID::BreakpointID (break_id_t bp_id, break_id_t loc_id) : { } -BreakpointID::~BreakpointID () -{ -} +BreakpointID::~BreakpointID() = default; -const char *BreakpointID::g_range_specifiers[] = { "-", "to", "To", "TO", NULL }; +const char *BreakpointID::g_range_specifiers[] = { "-", "to", "To", "TO", nullptr }; // Tells whether or not STR is valid to use between two strings representing breakpoint IDs, to // indicate a range of breakpoint IDs. This is broken out into a separate function so that we can @@ -43,7 +39,7 @@ bool BreakpointID::IsRangeIdentifier (const char *str) { int specifier_count = 0; - for (int i = 0; g_range_specifiers[i] != NULL; ++i) + for (int i = 0; g_range_specifiers[i] != nullptr; ++i) ++specifier_count; for (int i = 0; i < specifier_count; ++i) @@ -62,10 +58,7 @@ BreakpointID::IsValidIDExpression (const char *str) break_id_t loc_id; BreakpointID::ParseCanonicalReference (str, &bp_id, &loc_id); - if (bp_id == LLDB_INVALID_BREAK_ID) - return false; - else - return true; + return (bp_id != LLDB_INVALID_BREAK_ID); } void @@ -99,7 +92,7 @@ BreakpointID::ParseCanonicalReference (const char *input, break_id_t *break_id_p *break_id_ptr = LLDB_INVALID_BREAK_ID; *break_loc_id_ptr = LLDB_INVALID_BREAK_ID; - if (input == NULL || *input == '\0') + if (input == nullptr || *input == '\0') return false; const char *format = "%i%n.%i%n"; diff --git a/source/Breakpoint/BreakpointIDList.cpp b/source/Breakpoint/BreakpointIDList.cpp index b8b506750b34..ebf0697c271b 100644 --- a/source/Breakpoint/BreakpointIDList.cpp +++ b/source/Breakpoint/BreakpointIDList.cpp @@ -7,6 +7,10 @@ // //===----------------------------------------------------------------------===// +// C Includes +// C++ Includes +// Other libraries and framework includes +// Project includes #include "lldb/Breakpoint/BreakpointIDList.h" #include "lldb/Breakpoint/Breakpoint.h" @@ -27,9 +31,7 @@ m_invalid_id (LLDB_INVALID_BREAK_ID, LLDB_INVALID_BREAK_ID) { } -BreakpointIDList::~BreakpointIDList () -{ -} +BreakpointIDList::~BreakpointIDList() = default; size_t BreakpointIDList::GetSize() @@ -38,12 +40,9 @@ BreakpointIDList::GetSize() } BreakpointID & -BreakpointIDList::GetBreakpointIDAtIndex (size_t index) +BreakpointIDList::GetBreakpointIDAtIndex(size_t index) { - if (index < m_breakpoint_ids.size()) - return m_breakpoint_ids[index]; - else - return m_invalid_id; + return ((index < m_breakpoint_ids.size()) ? m_breakpoint_ids[index] : m_invalid_id); } bool @@ -124,7 +123,7 @@ BreakpointIDList::FindBreakpointID (const char *bp_id_str, size_t *position) void BreakpointIDList::InsertStringArray (const char **string_array, size_t array_size, CommandReturnObject &result) { - if (string_array == NULL) + if (string_array == nullptr) return; for (uint32_t i = 0; i < array_size; ++i) @@ -385,7 +384,6 @@ BreakpointIDList::FindAndReplaceIDRanges (Args &old_args, } result.SetStatus (eReturnStatusSuccessFinishNoResult); - return; } bool @@ -402,7 +400,7 @@ BreakpointIDList::StringContainsIDRangeExpression (const char *in_string, *range_end_pos = 0; int specifiers_size = 0; - for (int i = 0; BreakpointID::g_range_specifiers[i] != NULL; ++i) + for (int i = 0; BreakpointID::g_range_specifiers[i] != nullptr; ++i) ++specifiers_size; for (int i = 0; i < specifiers_size && !is_range_expression; ++i) diff --git a/source/Breakpoint/BreakpointLocation.cpp b/source/Breakpoint/BreakpointLocation.cpp index a199d390803b..5ff91102aadd 100644 --- a/source/Breakpoint/BreakpointLocation.cpp +++ b/source/Breakpoint/BreakpointLocation.cpp @@ -9,8 +9,6 @@ // C Includes // C++ Includes -#include <string> - // Other libraries and framework includes // Project includes #include "lldb/Breakpoint/BreakpointLocation.h" @@ -21,9 +19,11 @@ #include "lldb/Core/Module.h" #include "lldb/Core/StreamString.h" #include "lldb/Core/ValueObject.h" -#include "lldb/Expression/ClangUserExpression.h" +#include "lldb/Expression/ExpressionVariable.h" +#include "lldb/Expression/UserExpression.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/Symbol.h" +#include "lldb/Symbol/TypeSystem.h" #include "lldb/Target/Target.h" #include "lldb/Target/Process.h" #include "lldb/Target/Thread.h" @@ -88,12 +88,18 @@ BreakpointLocation::GetBreakpoint () return m_owner; } +Target & +BreakpointLocation::GetTarget() +{ + return m_owner.GetTarget(); +} + bool BreakpointLocation::IsEnabled () const { if (!m_owner.IsEnabled()) return false; - else if (m_options_ap.get() != NULL) + else if (m_options_ap.get() != nullptr) return m_options_ap->IsEnabled(); else return true; @@ -123,7 +129,7 @@ BreakpointLocation::SetThreadID (lldb::tid_t thread_id) { // If we're resetting this to an invalid thread id, then // don't make an options pointer just to do that. - if (m_options_ap.get() != NULL) + if (m_options_ap.get() != nullptr) m_options_ap->SetThreadID (thread_id); } SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged); @@ -147,11 +153,10 @@ BreakpointLocation::SetThreadIndex (uint32_t index) { // If we're resetting this to an invalid thread id, then // don't make an options pointer just to do that. - if (m_options_ap.get() != NULL) + if (m_options_ap.get() != nullptr) m_options_ap->GetThreadSpec()->SetIndex(index); } SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged); - } uint32_t @@ -166,13 +171,13 @@ BreakpointLocation::GetThreadIndex() const void BreakpointLocation::SetThreadName (const char *thread_name) { - if (thread_name != NULL) + if (thread_name != nullptr) GetLocationOptions()->GetThreadSpec()->SetName(thread_name); else { // If we're resetting this to an invalid thread id, then // don't make an options pointer just to do that. - if (m_options_ap.get() != NULL) + if (m_options_ap.get() != nullptr) m_options_ap->GetThreadSpec()->SetName(thread_name); } SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged); @@ -184,19 +189,19 @@ BreakpointLocation::GetThreadName () const if (GetOptionsNoCreate()->GetThreadSpecNoCreate()) return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetName(); else - return NULL; + return nullptr; } void BreakpointLocation::SetQueueName (const char *queue_name) { - if (queue_name != NULL) + if (queue_name != nullptr) GetLocationOptions()->GetThreadSpec()->SetQueueName(queue_name); else { // If we're resetting this to an invalid thread id, then // don't make an options pointer just to do that. - if (m_options_ap.get() != NULL) + if (m_options_ap.get() != nullptr) m_options_ap->GetThreadSpec()->SetQueueName(queue_name); } SendBreakpointLocationChangedEvent (eBreakpointEventTypeThreadChanged); @@ -208,13 +213,13 @@ BreakpointLocation::GetQueueName () const if (GetOptionsNoCreate()->GetThreadSpecNoCreate()) return GetOptionsNoCreate()->GetThreadSpecNoCreate()->GetQueueName(); else - return NULL; + return nullptr; } bool BreakpointLocation::InvokeCallback (StoppointCallbackContext *context) { - if (m_options_ap.get() != NULL && m_options_ap->HasCallback()) + if (m_options_ap.get() != nullptr && m_options_ap->HasCallback()) return m_options_ap->InvokeCallback (context, m_owner.GetID(), GetID()); else return m_owner.InvokeCallback (context, GetID()); @@ -238,7 +243,6 @@ BreakpointLocation::SetCallback (BreakpointHitCallback callback, const BatonSP & SendBreakpointLocationChangedEvent (eBreakpointEventTypeCommandChanged); } - void BreakpointLocation::ClearCallback () { @@ -278,11 +282,27 @@ BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error) !m_user_expression_sp || !m_user_expression_sp->MatchesContext(exe_ctx)) { - m_user_expression_sp.reset(new ClangUserExpression(condition_text, - NULL, - lldb::eLanguageTypeUnknown, - ClangUserExpression::eResultTypeAny)); + LanguageType language = eLanguageTypeUnknown; + // See if we can figure out the language from the frame, otherwise use the default language: + CompileUnit *comp_unit = m_address.CalculateSymbolContextCompileUnit(); + if (comp_unit) + language = comp_unit->GetLanguage(); + Error error; + m_user_expression_sp.reset(GetTarget().GetUserExpressionForLanguage(condition_text, + nullptr, + language, + Expression::eResultTypeAny, + EvaluateExpressionOptions(), + error)); + if (error.Fail()) + { + if (log) + log->Printf("Error getting condition expression: %s.", error.AsCString()); + m_user_expression_sp.reset(); + return true; + } + StreamString errors; if (!m_user_expression_sp->Parse(errors, @@ -314,7 +334,7 @@ BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error) StreamString execution_errors; - ClangExpressionVariableSP result_variable_sp; + ExpressionVariableSP result_variable_sp; ExpressionResults result_code = m_user_expression_sp->Execute(execution_errors, @@ -337,21 +357,20 @@ BreakpointLocation::ConditionSaysStop (ExecutionContext &exe_ctx, Error &error) if (result_value_sp) { - Scalar scalar_value; - if (result_value_sp->ResolveValue (scalar_value)) + ret = result_value_sp->IsLogicalTrue(error); + if (log) { - if (scalar_value.ULongLong(1) == 0) - ret = false; - else - ret = true; - if (log) + if (error.Success()) + { log->Printf("Condition successfully evaluated, result is %s.\n", ret ? "true" : "false"); - } - else - { - ret = false; - error.SetErrorString("Failed to get an integer result from the expression"); + } + else + { + error.SetErrorString("Failed to get an integer result from the expression"); + ret = false; + } + } } else @@ -385,7 +404,7 @@ BreakpointLocation::SetIgnoreCount (uint32_t n) void BreakpointLocation::DecrementIgnoreCount() { - if (m_options_ap.get() != NULL) + if (m_options_ap.get() != nullptr) { uint32_t loc_ignore = m_options_ap->GetIgnoreCount(); if (loc_ignore != 0) @@ -396,7 +415,7 @@ BreakpointLocation::DecrementIgnoreCount() bool BreakpointLocation::IgnoreCountShouldStop() { - if (m_options_ap.get() != NULL) + if (m_options_ap.get() != nullptr) { uint32_t loc_ignore = m_options_ap->GetIgnoreCount(); if (loc_ignore != 0) @@ -413,7 +432,7 @@ BreakpointLocation::IgnoreCountShouldStop() const BreakpointOptions * BreakpointLocation::GetOptionsNoCreate () const { - if (m_options_ap.get() != NULL) + if (m_options_ap.get() != nullptr) return m_options_ap.get(); else return m_owner.GetOptions (); @@ -425,7 +444,7 @@ BreakpointLocation::GetLocationOptions () // If we make the copy we don't copy the callbacks because that is potentially // expensive and we don't want to do that for the simple case where someone is // just disabling the location. - if (m_options_ap.get() == NULL) + if (m_options_ap.get() == nullptr) m_options_ap.reset(BreakpointOptions::CopyOptionsNoCallback(*m_owner.GetOptions ())); return m_options_ap.get(); @@ -497,7 +516,7 @@ BreakpointLocation::UndoBumpHitCount() bool BreakpointLocation::IsResolved () const { - return m_bp_site_sp.get() != NULL; + return m_bp_site_sp.get() != nullptr; } lldb::BreakpointSiteSP @@ -513,7 +532,7 @@ BreakpointLocation::ResolveBreakpointSite () return true; Process *process = m_owner.GetTarget().GetProcessSP().get(); - if (process == NULL) + if (process == nullptr) return false; lldb::break_id_t new_id = process->CreateBreakpointSite (shared_from_this(), m_owner.IsHardware()); @@ -601,13 +620,13 @@ BreakpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level) sc.module_sp->GetFileSpec().Dump (s); } - if (sc.comp_unit != NULL) + if (sc.comp_unit != nullptr) { s->EOL(); s->Indent("compile unit = "); static_cast<FileSpec*>(sc.comp_unit)->GetFilename().Dump (s); - if (sc.function != NULL) + if (sc.function != nullptr) { s->EOL(); s->Indent("function = "); @@ -648,11 +667,11 @@ BreakpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level) s->Printf (", "); s->Printf ("address = "); - ExecutionContextScope *exe_scope = NULL; + ExecutionContextScope *exe_scope = nullptr; Target *target = &m_owner.GetTarget(); if (target) exe_scope = target->GetProcessSP().get(); - if (exe_scope == NULL) + if (exe_scope == nullptr) exe_scope = target; if (level == eDescriptionLevelInitial) @@ -710,7 +729,7 @@ BreakpointLocation::GetDescription (Stream *s, lldb::DescriptionLevel level) void BreakpointLocation::Dump(Stream *s) const { - if (s == NULL) + if (s == nullptr) return; s->Printf("BreakpointLocation %u: tid = %4.4" PRIx64 " load addr = 0x%8.8" PRIx64 " state = %s type = %s breakpoint " diff --git a/source/Breakpoint/BreakpointLocationList.cpp b/source/Breakpoint/BreakpointLocationList.cpp index 06b270a08ce9..d57cfa68fb80 100644 --- a/source/Breakpoint/BreakpointLocationList.cpp +++ b/source/Breakpoint/BreakpointLocationList.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// - // C Includes // C++ Includes // Other libraries and framework includes @@ -22,7 +21,6 @@ #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/Target.h" - using namespace lldb; using namespace lldb_private; @@ -32,13 +30,11 @@ BreakpointLocationList::BreakpointLocationList(Breakpoint &owner) : m_address_to_location (), m_mutex (Mutex::eMutexTypeRecursive), m_next_id (0), - m_new_location_recorder (NULL) + m_new_location_recorder (nullptr) { } -BreakpointLocationList::~BreakpointLocationList() -{ -} +BreakpointLocationList::~BreakpointLocationList() = default; BreakpointLocationSP BreakpointLocationList::Create (const Address &addr, bool resolve_indirect_symbols) @@ -163,7 +159,6 @@ BreakpointLocationList::Dump (Stream *s) const s->IndentLess(); } - BreakpointLocationSP BreakpointLocationList::GetByIndex (size_t i) { @@ -285,7 +280,6 @@ BreakpointLocationList::SwapLocation (BreakpointLocationSP to_location_sp, Break to_location_sp->ResolveBreakpointSite(); } - bool BreakpointLocationList::RemoveLocation (const lldb::BreakpointLocationSP &bp_loc_sp) { @@ -304,7 +298,7 @@ BreakpointLocationList::RemoveLocation (const lldb::BreakpointLocationSP &bp_loc return true; } } - } + } return false; } @@ -348,7 +342,7 @@ void BreakpointLocationList::StartRecordingNewLocations (BreakpointLocationCollection &new_locations) { Mutex::Locker locker (m_mutex); - assert (m_new_location_recorder == NULL); + assert(m_new_location_recorder == nullptr); m_new_location_recorder = &new_locations; } @@ -356,7 +350,7 @@ void BreakpointLocationList::StopRecordingNewLocations () { Mutex::Locker locker (m_mutex); - m_new_location_recorder = NULL; + m_new_location_recorder = nullptr; } void diff --git a/source/Breakpoint/BreakpointOptions.cpp b/source/Breakpoint/BreakpointOptions.cpp index db76ffb8685c..d2a919756857 100644 --- a/source/Breakpoint/BreakpointOptions.cpp +++ b/source/Breakpoint/BreakpointOptions.cpp @@ -7,12 +7,12 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Breakpoint/BreakpointOptions.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Breakpoint/BreakpointOptions.h" + #include "lldb/Core/Stream.h" #include "lldb/Core/StringList.h" #include "lldb/Core/Value.h" @@ -20,7 +20,6 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/ThreadSpec.h" -#include "lldb/Expression/ClangUserExpression.h" using namespace lldb; using namespace lldb_private; @@ -59,7 +58,7 @@ BreakpointOptions::BreakpointOptions(const BreakpointOptions& rhs) : m_ignore_count (rhs.m_ignore_count), m_thread_spec_ap () { - if (rhs.m_thread_spec_ap.get() != NULL) + if (rhs.m_thread_spec_ap.get() != nullptr) m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get())); m_condition_text = rhs.m_condition_text; m_condition_text_hash = rhs.m_condition_text_hash; @@ -77,7 +76,7 @@ BreakpointOptions::operator=(const BreakpointOptions& rhs) m_enabled = rhs.m_enabled; m_one_shot = rhs.m_one_shot; m_ignore_count = rhs.m_ignore_count; - if (rhs.m_thread_spec_ap.get() != NULL) + if (rhs.m_thread_spec_ap.get() != nullptr) m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get())); m_condition_text = rhs.m_condition_text; m_condition_text_hash = rhs.m_condition_text_hash; @@ -102,9 +101,7 @@ BreakpointOptions::CopyOptionsNoCallback (BreakpointOptions &orig) //---------------------------------------------------------------------- // Destructor //---------------------------------------------------------------------- -BreakpointOptions::~BreakpointOptions() -{ -} +BreakpointOptions::~BreakpointOptions() = default; //------------------------------------------------------------------ // Callbacks @@ -144,10 +141,10 @@ BreakpointOptions::InvokeCallback (StoppointCallbackContext *context, { if (m_callback && context->is_synchronous == IsCallbackSynchronous()) { - return m_callback (m_callback_baton_sp ? m_callback_baton_sp->m_data : NULL, - context, - break_id, - break_loc_id); + return m_callback(m_callback_baton_sp ? m_callback_baton_sp->m_data : nullptr, + context, + break_id, + break_loc_id); } else return true; @@ -182,7 +179,7 @@ BreakpointOptions::GetConditionText (size_t *hash) const } else { - return NULL; + return nullptr; } } @@ -195,7 +192,7 @@ BreakpointOptions::GetThreadSpecNoCreate () const ThreadSpec * BreakpointOptions::GetThreadSpec () { - if (m_thread_spec_ap.get() == NULL) + if (m_thread_spec_ap.get() == nullptr) m_thread_spec_ap.reset (new ThreadSpec()); return m_thread_spec_ap.get(); @@ -210,11 +207,10 @@ BreakpointOptions::SetThreadID (lldb::tid_t thread_id) void BreakpointOptions::GetDescription (Stream *s, lldb::DescriptionLevel level) const { - // Figure out if there are any options not at their default value, and only print // anything if there are: - if (m_ignore_count != 0 || !m_enabled || m_one_shot || (GetThreadSpecNoCreate() != NULL && GetThreadSpecNoCreate()->HasSpecification ())) + if (m_ignore_count != 0 || !m_enabled || m_one_shot || (GetThreadSpecNoCreate() != nullptr && GetThreadSpecNoCreate()->HasSpecification ())) { if (level == lldb::eDescriptionLevelVerbose) { @@ -294,4 +290,3 @@ BreakpointOptions::CommandBaton::GetDescription (Stream *s, lldb::DescriptionLev s->IndentLess (); s->IndentLess (); } - diff --git a/source/Breakpoint/BreakpointResolverAddress.cpp b/source/Breakpoint/BreakpointResolverAddress.cpp index 193bc413af05..8a0469a07e46 100644 --- a/source/Breakpoint/BreakpointResolverAddress.cpp +++ b/source/Breakpoint/BreakpointResolverAddress.cpp @@ -16,6 +16,7 @@ #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Log.h" +#include "lldb/Core/Module.h" #include "lldb/Core/StreamString.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" @@ -29,10 +30,25 @@ using namespace lldb_private; BreakpointResolverAddress::BreakpointResolverAddress ( Breakpoint *bkpt, + const Address &addr, + const FileSpec &module_spec +) : + BreakpointResolver (bkpt, BreakpointResolver::AddressResolver), + m_addr (addr), + m_resolved_addr(LLDB_INVALID_ADDRESS), + m_module_filespec(module_spec) +{ +} + +BreakpointResolverAddress::BreakpointResolverAddress +( + Breakpoint *bkpt, const Address &addr ) : BreakpointResolver (bkpt, BreakpointResolver::AddressResolver), - m_addr (addr) + m_addr (addr), + m_resolved_addr(LLDB_INVALID_ADDRESS), + m_module_filespec() { } @@ -44,10 +60,16 @@ BreakpointResolverAddress::~BreakpointResolverAddress () void BreakpointResolverAddress::ResolveBreakpoint (SearchFilter &filter) { - // The address breakpoint only takes once, so if we've already set it we're done. - if (m_breakpoint->GetNumLocations() > 0) - return; - else + // If the address is not section relative, then we should not try to re-resolve it, it is just some + // random address and we wouldn't know what to do on reload. But if it is section relative, we need to + // re-resolve it since the section it's in may have shifted on re-run. + bool re_resolve = false; + if (m_addr.GetSection() || m_module_filespec) + re_resolve = true; + else if (m_breakpoint->GetNumLocations() == 0) + re_resolve = true; + + if (re_resolve) BreakpointResolver::ResolveBreakpoint(filter); } @@ -58,10 +80,14 @@ BreakpointResolverAddress::ResolveBreakpointInModules ModuleList &modules ) { - // The address breakpoint only takes once, so if we've already set it we're done. - if (m_breakpoint->GetNumLocations() > 0) - return; - else + // See comment in ResolveBreakpoint. + bool re_resolve = false; + if (m_addr.GetSection()) + re_resolve = true; + else if (m_breakpoint->GetNumLocations() == 0) + re_resolve = true; + + if (re_resolve) BreakpointResolver::ResolveBreakpointInModules (filter, modules); } @@ -78,14 +104,44 @@ BreakpointResolverAddress::SearchCallback if (filter.AddressPasses (m_addr)) { - BreakpointLocationSP bp_loc_sp(m_breakpoint->AddLocation(m_addr)); - if (bp_loc_sp && !m_breakpoint->IsInternal()) + if (m_breakpoint->GetNumLocations() == 0) + { + // If the address is just an offset, and we're given a module, see if we can find the appropriate module + // loaded in the binary, and fix up m_addr to use that. + if (!m_addr.IsSectionOffset() && m_module_filespec) + { + Target &target = m_breakpoint->GetTarget(); + ModuleSpec module_spec(m_module_filespec); + ModuleSP module_sp = target.GetImages().FindFirstModule(module_spec); + if (module_sp) + { + Address tmp_address; + if (module_sp->ResolveFileAddress(m_addr.GetOffset(), tmp_address)) + m_addr = tmp_address; + } + } + + BreakpointLocationSP bp_loc_sp(m_breakpoint->AddLocation(m_addr)); + m_resolved_addr = m_addr.GetLoadAddress(&m_breakpoint->GetTarget()); + if (bp_loc_sp && !m_breakpoint->IsInternal()) + { + StreamString s; + bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose); + Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); + if (log) + log->Printf ("Added location: %s\n", s.GetData()); + } + } + else { - StreamString s; - bp_loc_sp->GetDescription(&s, lldb::eDescriptionLevelVerbose); - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); - if (log) - log->Printf ("Added location: %s\n", s.GetData()); + BreakpointLocationSP loc_sp = m_breakpoint->GetLocationAtIndex(0); + lldb::addr_t cur_load_location = m_addr.GetLoadAddress(&m_breakpoint->GetTarget()); + if (cur_load_location != m_resolved_addr) + { + m_resolved_addr = cur_load_location; + loc_sp->ClearBreakpointSite(); + loc_sp->ResolveBreakpointSite(); + } } } return Searcher::eCallbackReturnStop; @@ -101,7 +157,7 @@ void BreakpointResolverAddress::GetDescription (Stream *s) { s->PutCString ("address = "); - m_addr.Dump(s, m_breakpoint->GetTarget().GetProcessSP().get(), Address::DumpStyleLoadAddress, Address::DumpStyleModuleWithFileAddress); + m_addr.Dump(s, m_breakpoint->GetTarget().GetProcessSP().get(), Address::DumpStyleModuleWithFileAddress, Address::DumpStyleLoadAddress); } void diff --git a/source/Breakpoint/BreakpointResolverName.cpp b/source/Breakpoint/BreakpointResolverName.cpp index 581f7b016173..9ae3fe5256d4 100644 --- a/source/Breakpoint/BreakpointResolverName.cpp +++ b/source/Breakpoint/BreakpointResolverName.cpp @@ -7,22 +7,21 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Breakpoint/BreakpointResolverName.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Breakpoint/BreakpointResolverName.h" + #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/StreamString.h" -#include "lldb/Symbol/ClangNamespaceDecl.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/Function.h" #include "lldb/Symbol/Symbol.h" #include "lldb/Symbol/SymbolContext.h" -#include "lldb/Target/ObjCLanguageRuntime.h" +#include "Plugins/Language/ObjC/ObjCLanguage.h" using namespace lldb; using namespace lldb_private; @@ -30,15 +29,16 @@ using namespace lldb_private; BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt, const char *name_cstr, uint32_t name_type_mask, + LanguageType language, Breakpoint::MatchType type, bool skip_prologue) : BreakpointResolver (bkpt, BreakpointResolver::NameResolver), m_class_name (), m_regex (), m_match_type (type), + m_language (language), m_skip_prologue (skip_prologue) { - if (m_match_type == Breakpoint::Regexp) { if (!m_regex.Compile (name_cstr)) @@ -59,9 +59,11 @@ BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt, const char *names[], size_t num_names, uint32_t name_type_mask, + LanguageType language, bool skip_prologue) : BreakpointResolver (bkpt, BreakpointResolver::NameResolver), m_match_type (Breakpoint::Exact), + m_language (language), m_skip_prologue (skip_prologue) { for (size_t i = 0; i < num_names; i++) @@ -73,9 +75,11 @@ BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt, BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt, std::vector<std::string> names, uint32_t name_type_mask, + LanguageType language, bool skip_prologue) : BreakpointResolver (bkpt, BreakpointResolver::NameResolver), m_match_type (Breakpoint::Exact), + m_language (language), m_skip_prologue (skip_prologue) { for (const std::string& name : names) @@ -86,27 +90,27 @@ BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt, BreakpointResolverName::BreakpointResolverName (Breakpoint *bkpt, RegularExpression &func_regex, + lldb::LanguageType language, bool skip_prologue) : BreakpointResolver (bkpt, BreakpointResolver::NameResolver), - m_class_name (NULL), + m_class_name (nullptr), m_regex (func_regex), m_match_type (Breakpoint::Regexp), + m_language (language), m_skip_prologue (skip_prologue) { } -BreakpointResolverName::BreakpointResolverName -( - Breakpoint *bkpt, - const char *class_name, - const char *method, - Breakpoint::MatchType type, - bool skip_prologue -) : +BreakpointResolverName::BreakpointResolverName(Breakpoint *bkpt, + const char *class_name, + const char *method, + Breakpoint::MatchType type, + bool skip_prologue ) : BreakpointResolver (bkpt, BreakpointResolver::NameResolver), m_class_name (class_name), m_regex (), m_match_type (type), + m_language (eLanguageTypeUnknown), m_skip_prologue (skip_prologue) { LookupInfo lookup; @@ -117,9 +121,7 @@ BreakpointResolverName::BreakpointResolverName m_lookups.push_back (lookup); } -BreakpointResolverName::~BreakpointResolverName () -{ -} +BreakpointResolverName::~BreakpointResolverName() = default; BreakpointResolverName::BreakpointResolverName(const BreakpointResolverName &rhs) : BreakpointResolver(rhs.m_breakpoint, BreakpointResolver::NameResolver), @@ -127,15 +129,15 @@ BreakpointResolverName::BreakpointResolverName(const BreakpointResolverName &rhs m_class_name(rhs.m_class_name), m_regex(rhs.m_regex), m_match_type (rhs.m_match_type), + m_language (rhs.m_language), m_skip_prologue (rhs.m_skip_prologue) { - } void BreakpointResolverName::AddNameLookup (const ConstString &name, uint32_t name_type_mask) { - ObjCLanguageRuntime::MethodName objc_method(name.GetCString(), false); + ObjCLanguage::MethodName objc_method(name.GetCString(), false); if (objc_method.IsValid(false)) { std::vector<ConstString> objc_names; @@ -154,12 +156,11 @@ BreakpointResolverName::AddNameLookup (const ConstString &name, uint32_t name_ty { LookupInfo lookup; lookup.name = name; - Module::PrepareForFunctionNameLookup(lookup.name, name_type_mask, lookup.lookup_name, lookup.name_type_mask, lookup.match_name_after_lookup); + Module::PrepareForFunctionNameLookup(lookup.name, name_type_mask, m_language, lookup.lookup_name, lookup.name_type_mask, lookup.match_name_after_lookup); m_lookups.push_back (lookup); } } - void BreakpointResolverName::LookupInfo::Prune (SymbolContextList &sc_list, size_t start_idx) const { @@ -172,7 +173,7 @@ BreakpointResolverName::LookupInfo::Prune (SymbolContextList &sc_list, size_t st if (!sc_list.GetContextAtIndex(i, sc)) break; ConstString full_name (sc.GetFunctionName()); - if (full_name && ::strstr(full_name.GetCString(), name.GetCString()) == NULL) + if (full_name && ::strstr(full_name.GetCString(), name.GetCString()) == nullptr) { sc_list.RemoveContextAtIndex(i); } @@ -184,19 +185,15 @@ BreakpointResolverName::LookupInfo::Prune (SymbolContextList &sc_list, size_t st } } - // FIXME: Right now we look at the module level, and call the module's "FindFunctions". // Greg says he will add function tables, maybe at the CompileUnit level to accelerate function // lookup. At that point, we should switch the depth to CompileUnit, and look in these tables. Searcher::CallbackReturn -BreakpointResolverName::SearchCallback -( - SearchFilter &filter, - SymbolContext &context, - Address *addr, - bool containing -) +BreakpointResolverName::SearchCallback(SearchFilter &filter, + SymbolContext &context, + Address *addr, + bool containing) { SymbolContextList func_list; //SymbolContextList sym_list; @@ -204,7 +201,7 @@ BreakpointResolverName::SearchCallback uint32_t i; bool new_location; Address break_addr; - assert (m_breakpoint != NULL); + assert (m_breakpoint != nullptr); Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_BREAKPOINTS)); @@ -215,7 +212,8 @@ BreakpointResolverName::SearchCallback return Searcher::eCallbackReturnStop; } bool filter_by_cu = (filter.GetFilterRequiredItems() & eSymbolContextCompUnit) != 0; - const bool include_symbols = filter_by_cu == false; + bool filter_by_language = (m_language != eLanguageTypeUnknown); + const bool include_symbols = !filter_by_cu; const bool include_inlines = true; const bool append = true; @@ -227,13 +225,13 @@ BreakpointResolverName::SearchCallback for (const LookupInfo &lookup : m_lookups) { const size_t start_func_idx = func_list.GetSize(); - context.module_sp->FindFunctions (lookup.lookup_name, - NULL, - lookup.name_type_mask, - include_symbols, - include_inlines, - append, - func_list); + context.module_sp->FindFunctions(lookup.lookup_name, + nullptr, + lookup.name_type_mask, + include_symbols, + include_inlines, + append, + func_list); const size_t end_func_idx = func_list.GetSize(); if (start_func_idx < end_func_idx) @@ -258,15 +256,33 @@ BreakpointResolverName::SearchCallback } // If the filter specifies a Compilation Unit, remove the ones that don't pass at this point. - if (filter_by_cu) + if (filter_by_cu || filter_by_language) { uint32_t num_functions = func_list.GetSize(); for (size_t idx = 0; idx < num_functions; idx++) { + bool remove_it = false; SymbolContext sc; func_list.GetContextAtIndex(idx, sc); - if (!sc.comp_unit || !filter.CompUnitPasses(*sc.comp_unit)) + if (filter_by_cu) + { + if (!sc.comp_unit || !filter.CompUnitPasses(*sc.comp_unit)) + remove_it = true; + } + + if (filter_by_language) + { + LanguageType sym_language = sc.GetLanguage(); + if ((Language::GetPrimaryLanguage(sym_language) != + Language::GetPrimaryLanguage(m_language)) && + (sym_language != eLanguageTypeUnknown)) + { + remove_it = true; + } + } + + if (remove_it) { func_list.RemoveContextAtIndex(idx); num_functions--; @@ -374,12 +390,15 @@ BreakpointResolverName::GetDescription (Stream *s) s->Printf ("'%s'}", m_lookups[num_names - 1].name.GetCString()); } } + if (m_language != eLanguageTypeUnknown) + { + s->Printf (", language = %s", Language::GetNameForLanguageType(m_language)); + } } void BreakpointResolverName::Dump (Stream *s) const { - } lldb::BreakpointResolverSP diff --git a/source/Breakpoint/BreakpointSite.cpp b/source/Breakpoint/BreakpointSite.cpp index e9ce812e7732..d2aaea098cdb 100644 --- a/source/Breakpoint/BreakpointSite.cpp +++ b/source/Breakpoint/BreakpointSite.cpp @@ -7,14 +7,14 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Breakpoint/BreakpointSite.h" - // C Includes // C++ Includes #include <inttypes.h> // Other libraries and framework includes // Project includes +#include "lldb/Breakpoint/BreakpointSite.h" + #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Breakpoint/BreakpointLocation.h" #include "lldb/Breakpoint/BreakpointSiteList.h" @@ -23,13 +23,10 @@ using namespace lldb; using namespace lldb_private; -BreakpointSite::BreakpointSite -( - BreakpointSiteList *list, - const BreakpointLocationSP& owner, - lldb::addr_t addr, - bool use_hardware -) : +BreakpointSite::BreakpointSite(BreakpointSiteList *list, + const BreakpointLocationSP& owner, + lldb::addr_t addr, + bool use_hardware) : StoppointLocation(GetNextID(), addr, 0, use_hardware), m_type (eSoftware), // Process subclasses need to set this correctly using SetType() m_saved_opcode(), @@ -85,7 +82,7 @@ BreakpointSite::IsBreakpointAtThisSite (lldb::break_id_t bp_id) void BreakpointSite::Dump(Stream *s) const { - if (s == NULL) + if (s == nullptr) return; s->Printf("BreakpointSite %u: addr = 0x%8.8" PRIx64 " type = %s breakpoint hw_index = %i hit_count = %-4u", @@ -205,6 +202,7 @@ BreakpointSite::ValidForThisThread (Thread *thread) void BreakpointSite::BumpHitCounts() { + Mutex::Locker locker(m_owners_mutex); for (BreakpointLocationSP loc_sp : m_owners.BreakpointLocations()) { loc_sp->BumpHitCount(); @@ -253,3 +251,14 @@ BreakpointSite::IntersectsRange(lldb::addr_t addr, size_t size, lldb::addr_t *in } return false; } + +size_t +BreakpointSite::CopyOwnersList (BreakpointLocationCollection &out_collection) +{ + Mutex::Locker locker(m_owners_mutex); + for (BreakpointLocationSP loc_sp : m_owners.BreakpointLocations()) + { + out_collection.Add(loc_sp); + } + return out_collection.GetSize(); +} diff --git a/source/Breakpoint/StoppointCallbackContext.cpp b/source/Breakpoint/StoppointCallbackContext.cpp index 2266c3e429c6..9932843714f8 100644 --- a/source/Breakpoint/StoppointCallbackContext.cpp +++ b/source/Breakpoint/StoppointCallbackContext.cpp @@ -7,17 +7,16 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Breakpoint/StoppointCallbackContext.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Breakpoint/StoppointCallbackContext.h" using namespace lldb_private; StoppointCallbackContext::StoppointCallbackContext() : - event (NULL), + event (nullptr), exe_ctx_ref (), is_synchronous (false) { @@ -33,7 +32,7 @@ StoppointCallbackContext::StoppointCallbackContext(Event *e, const ExecutionCont void StoppointCallbackContext::Clear() { - event = NULL; + event = nullptr; exe_ctx_ref.Clear(); is_synchronous = false; } diff --git a/source/Breakpoint/Watchpoint.cpp b/source/Breakpoint/Watchpoint.cpp index 45559b1901ad..00a328e3039f 100644 --- a/source/Breakpoint/Watchpoint.cpp +++ b/source/Breakpoint/Watchpoint.cpp @@ -7,12 +7,12 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Breakpoint/Watchpoint.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Breakpoint/Watchpoint.h" + #include "lldb/Breakpoint/StoppointCallbackContext.h" #include "lldb/Core/Stream.h" #include "lldb/Core/Value.h" @@ -22,12 +22,12 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/ThreadSpec.h" -#include "lldb/Expression/ClangUserExpression.h" +#include "lldb/Expression/UserExpression.h" using namespace lldb; using namespace lldb_private; -Watchpoint::Watchpoint (Target& target, lldb::addr_t addr, uint32_t size, const ClangASTType *type, bool hardware) : +Watchpoint::Watchpoint (Target& target, lldb::addr_t addr, uint32_t size, const CompilerType *type, bool hardware) : StoppointLocation (0, addr, size, hardware), m_target(target), m_enabled(false), @@ -67,9 +67,7 @@ Watchpoint::Watchpoint (Target& target, lldb::addr_t addr, uint32_t size, const m_being_created = false; } -Watchpoint::~Watchpoint() -{ -} +Watchpoint::~Watchpoint() = default; // This function is used when "baton" doesn't need to be freed void @@ -102,7 +100,6 @@ void Watchpoint::SetDeclInfo (const std::string &str) { m_decl_str = str; - return; } std::string @@ -115,7 +112,6 @@ void Watchpoint::SetWatchSpec (const std::string &str) { m_watch_spec_str = str; - return; } // Override default impl of StoppointLocation::IsHardware() since m_is_hardware @@ -154,10 +150,7 @@ Watchpoint::CaptureWatchedValue (const ExecutionContext &exe_ctx) } m_new_value_sp = ValueObjectMemory::Create (exe_ctx.GetBestExecutionContextScope(), watch_name.AsCString(), watch_address, m_type); m_new_value_sp = m_new_value_sp->CreateConstantValue(watch_name); - if (m_new_value_sp && m_new_value_sp->GetError().Success()) - return true; - else - return false; + return (m_new_value_sp && m_new_value_sp->GetError().Success()); } void @@ -190,9 +183,6 @@ Watchpoint::ShouldStop (StoppointCallbackContext *context) if (!IsEnabled()) return false; - if (GetHitCount() <= GetIgnoreCount()) - return false; - return true; } @@ -200,7 +190,6 @@ void Watchpoint::GetDescription (Stream *s, lldb::DescriptionLevel level) { DumpWithLevel(s, level); - return; } void @@ -209,7 +198,7 @@ Watchpoint::Dump(Stream *s) const DumpWithLevel(s, lldb::eDescriptionLevelBrief); } -// If prefix is NULL, we display the watch id and ignore the prefix altogether. +// If prefix is nullptr, we display the watch id and ignore the prefix altogether. void Watchpoint::DumpSnapshots(Stream *s, const char *prefix) const { @@ -218,21 +207,38 @@ Watchpoint::DumpSnapshots(Stream *s, const char *prefix) const s->Printf("\nWatchpoint %u hit:", GetID()); prefix = ""; } - + if (m_old_value_sp) { - s->Printf("\n%sold value: %s", prefix, m_old_value_sp->GetValueAsCString()); + const char *old_value_cstr = m_old_value_sp->GetValueAsCString(); + if (old_value_cstr && old_value_cstr[0]) + s->Printf("\n%sold value: %s", prefix, old_value_cstr); + else + { + const char *old_summary_cstr = m_old_value_sp-> GetSummaryAsCString(); + if (old_summary_cstr && old_summary_cstr[0]) + s->Printf("\n%sold value: %s", prefix, old_summary_cstr); + } } + if (m_new_value_sp) { - s->Printf("\n%snew value: %s", prefix, m_new_value_sp->GetValueAsCString()); + const char *new_value_cstr = m_new_value_sp->GetValueAsCString(); + if (new_value_cstr && new_value_cstr[0]) + s->Printf("\n%snew value: %s", prefix, new_value_cstr); + else + { + const char *new_summary_cstr = m_new_value_sp-> GetSummaryAsCString(); + if (new_summary_cstr && new_summary_cstr[0]) + s->Printf("\n%snew value: %s", prefix, new_summary_cstr); + } } } void Watchpoint::DumpWithLevel(Stream *s, lldb::DescriptionLevel description_level) const { - if (s == NULL) + if (s == nullptr) return; assert(description_level >= lldb::eDescriptionLevelBrief && @@ -334,11 +340,13 @@ Watchpoint::WatchpointRead () const { return m_watch_read != 0; } + bool Watchpoint::WatchpointWrite () const { return m_watch_write != 0; } + uint32_t Watchpoint::GetIgnoreCount () const { @@ -363,15 +371,26 @@ Watchpoint::InvokeCallback (StoppointCallbackContext *context) void Watchpoint::SetCondition (const char *condition) { - if (condition == NULL || condition[0] == '\0') + if (condition == nullptr || condition[0] == '\0') { if (m_condition_ap.get()) m_condition_ap.reset(); } else { - // Pass NULL for expr_prefix (no translation-unit level definitions). - m_condition_ap.reset(new ClangUserExpression (condition, NULL, lldb::eLanguageTypeUnknown, ClangUserExpression::eResultTypeAny)); + // Pass nullptr for expr_prefix (no translation-unit level definitions). + Error error; + m_condition_ap.reset(m_target.GetUserExpressionForLanguage(condition, + nullptr, + lldb::eLanguageTypeUnknown, + UserExpression::eResultTypeAny, + EvaluateExpressionOptions(), + error)); + if (error.Fail()) + { + // FIXME: Log something... + m_condition_ap.reset(); + } } SendWatchpointChangedEvent (eWatchpointEventTypeConditionChanged); } @@ -382,7 +401,7 @@ Watchpoint::GetConditionText () const if (m_condition_ap.get()) return m_condition_ap->GetUserText(); else - return NULL; + return nullptr; } void @@ -399,8 +418,7 @@ Watchpoint::SendWatchpointChangedEvent (lldb::WatchpointEventType eventKind) void Watchpoint::SendWatchpointChangedEvent (WatchpointEventData *data) { - - if (data == NULL) + if (data == nullptr) return; if (!m_being_created @@ -418,9 +436,7 @@ Watchpoint::WatchpointEventData::WatchpointEventData (WatchpointEventType sub_ty { } -Watchpoint::WatchpointEventData::~WatchpointEventData () -{ -} +Watchpoint::WatchpointEventData::~WatchpointEventData() = default; const ConstString & Watchpoint::WatchpointEventData::GetFlavorString () @@ -435,7 +451,6 @@ Watchpoint::WatchpointEventData::GetFlavor () const return WatchpointEventData::GetFlavorString (); } - WatchpointSP & Watchpoint::WatchpointEventData::GetWatchpoint () { @@ -462,7 +477,7 @@ Watchpoint::WatchpointEventData::GetEventDataFromEvent (const Event *event) if (event_data && event_data->GetFlavor() == WatchpointEventData::GetFlavorString()) return static_cast <const WatchpointEventData *> (event->GetData()); } - return NULL; + return nullptr; } WatchpointEventType @@ -470,7 +485,7 @@ Watchpoint::WatchpointEventData::GetWatchpointEventTypeFromEvent (const EventSP { const WatchpointEventData *data = GetEventDataFromEvent (event_sp.get()); - if (data == NULL) + if (data == nullptr) return eWatchpointEventTypeInvalidType; else return data->GetWatchpointEventType(); diff --git a/source/Breakpoint/WatchpointList.cpp b/source/Breakpoint/WatchpointList.cpp index 472bae06b441..64bf5cd63ed0 100644 --- a/source/Breakpoint/WatchpointList.cpp +++ b/source/Breakpoint/WatchpointList.cpp @@ -75,10 +75,15 @@ WatchpointList::FindByAddress (lldb::addr_t addr) const { wp_collection::const_iterator pos, end = m_watchpoints.end(); for (pos = m_watchpoints.begin(); pos != end; ++pos) - if ((*pos)->GetLoadAddress() == addr) { + { + lldb::addr_t wp_addr = (*pos)->GetLoadAddress(); + uint32_t wp_bytesize = (*pos)->GetByteSize(); + if ((wp_addr <= addr) && ((wp_addr + wp_bytesize) > addr)) + { wp_sp = *pos; break; } + } } return wp_sp; diff --git a/source/Breakpoint/WatchpointOptions.cpp b/source/Breakpoint/WatchpointOptions.cpp index c2c9696c4ce7..365d884691ef 100644 --- a/source/Breakpoint/WatchpointOptions.cpp +++ b/source/Breakpoint/WatchpointOptions.cpp @@ -7,12 +7,12 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Breakpoint/WatchpointOptions.h" - // C Includes // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Breakpoint/WatchpointOptions.h" + #include "lldb/Core/Stream.h" #include "lldb/Core/StringList.h" #include "lldb/Core/Value.h" @@ -20,7 +20,6 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/ThreadSpec.h" -#include "lldb/Expression/ClangUserExpression.h" using namespace lldb; using namespace lldb_private; @@ -51,7 +50,7 @@ WatchpointOptions::WatchpointOptions(const WatchpointOptions& rhs) : m_callback_is_synchronous (rhs.m_callback_is_synchronous), m_thread_spec_ap () { - if (rhs.m_thread_spec_ap.get() != NULL) + if (rhs.m_thread_spec_ap.get() != nullptr) m_thread_spec_ap.reset (new ThreadSpec(*rhs.m_thread_spec_ap.get())); } @@ -64,7 +63,7 @@ WatchpointOptions::operator=(const WatchpointOptions& rhs) m_callback = rhs.m_callback; m_callback_baton_sp = rhs.m_callback_baton_sp; m_callback_is_synchronous = rhs.m_callback_is_synchronous; - if (rhs.m_thread_spec_ap.get() != NULL) + if (rhs.m_thread_spec_ap.get() != nullptr) m_thread_spec_ap.reset(new ThreadSpec(*rhs.m_thread_spec_ap.get())); return *this; } @@ -87,9 +86,7 @@ WatchpointOptions::CopyOptionsNoCallback (WatchpointOptions &orig) //---------------------------------------------------------------------- // Destructor //---------------------------------------------------------------------- -WatchpointOptions::~WatchpointOptions() -{ -} +WatchpointOptions::~WatchpointOptions() = default; //------------------------------------------------------------------ // Callbacks @@ -128,9 +125,9 @@ WatchpointOptions::InvokeCallback (StoppointCallbackContext *context, { if (m_callback && context->is_synchronous == IsCallbackSynchronous()) { - return m_callback (m_callback_baton_sp ? m_callback_baton_sp->m_data : NULL, - context, - watch_id); + return m_callback(m_callback_baton_sp ? m_callback_baton_sp->m_data : nullptr, + context, + watch_id); } else return true; @@ -151,7 +148,7 @@ WatchpointOptions::GetThreadSpecNoCreate () const ThreadSpec * WatchpointOptions::GetThreadSpec () { - if (m_thread_spec_ap.get() == NULL) + if (m_thread_spec_ap.get() == nullptr) m_thread_spec_ap.reset (new ThreadSpec()); return m_thread_spec_ap.get(); @@ -172,14 +169,14 @@ WatchpointOptions::GetCallbackDescription (Stream *s, lldb::DescriptionLevel lev m_callback_baton_sp->GetDescription (s, level); } } + void WatchpointOptions::GetDescription (Stream *s, lldb::DescriptionLevel level) const { - // Figure out if there are any options not at their default value, and only print // anything if there are: - if ((GetThreadSpecNoCreate() != NULL && GetThreadSpecNoCreate()->HasSpecification ())) + if ((GetThreadSpecNoCreate() != nullptr && GetThreadSpecNoCreate()->HasSpecification ())) { if (level == lldb::eDescriptionLevelVerbose) { @@ -238,4 +235,3 @@ WatchpointOptions::CommandBaton::GetDescription (Stream *s, lldb::DescriptionLev s->IndentLess (); s->IndentLess (); } - diff --git a/source/Commands/CommandObjectApropos.h b/source/Commands/CommandObjectApropos.h index f5154177bb29..d04620bc5f2d 100644 --- a/source/Commands/CommandObjectApropos.h +++ b/source/Commands/CommandObjectApropos.h @@ -28,17 +28,14 @@ public: CommandObjectApropos (CommandInterpreter &interpreter); - virtual - ~CommandObjectApropos (); + ~CommandObjectApropos() override; protected: - virtual bool - DoExecute (Args& command, - CommandReturnObject &result); - - + bool + DoExecute(Args& command, + CommandReturnObject &result) override; }; } // namespace lldb_private -#endif // liblldb_CommandObjectApropos_h_ +#endif // liblldb_CommandObjectApropos_h_ diff --git a/source/Commands/CommandObjectArgs.cpp b/source/Commands/CommandObjectArgs.cpp index cf32d104911c..9f22bba78c55 100644 --- a/source/Commands/CommandObjectArgs.cpp +++ b/source/Commands/CommandObjectArgs.cpp @@ -17,9 +17,7 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/Value.h" -#include "lldb/Expression/ClangExpression.h" -#include "lldb/Expression/ClangExpressionVariable.h" -#include "lldb/Expression/ClangFunction.h" +#include "Plugins/ExpressionParser/Clang/ClangExpressionVariable.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -148,8 +146,14 @@ CommandObjectArgs::DoExecute (Args& args, CommandReturnObject &result) result.SetStatus (eReturnStatusFailed); return false; } - - ClangASTContext &ast_context = thread_module_sp->GetClangASTContext(); + + TypeSystem *type_system = thread_module_sp->GetTypeSystemForLanguage(eLanguageTypeC); + if (type_system == nullptr) + { + result.AppendError ("Unable to create C type system."); + result.SetStatus (eReturnStatusFailed); + return false; + } ValueList value_list; @@ -158,7 +162,7 @@ CommandObjectArgs::DoExecute (Args& args, CommandReturnObject &result) const char *arg_type_cstr = args.GetArgumentAtIndex(arg_index); Value value; value.SetValueType(Value::eValueTypeScalar); - ClangASTType clang_type; + CompilerType compiler_type; char *int_pos; if ((int_pos = strstr (const_cast<char*>(arg_type_cstr), "int"))) @@ -200,10 +204,9 @@ CommandObjectArgs::DoExecute (Args& args, CommandReturnObject &result) result.SetStatus (eReturnStatusFailed); return false; } + compiler_type = type_system->GetBuiltinTypeForEncodingAndBitSize(encoding, width); - clang_type = ast_context.GetBuiltinTypeForEncodingAndBitSize(encoding, width); - - if (!clang_type.IsValid()) + if (!compiler_type.IsValid()) { result.AppendErrorWithFormat ("Couldn't get Clang type for format %s (%s integer, width %d).\n", arg_type_cstr, @@ -217,9 +220,9 @@ CommandObjectArgs::DoExecute (Args& args, CommandReturnObject &result) else if (strchr (arg_type_cstr, '*')) { if (!strcmp (arg_type_cstr, "void*")) - clang_type = ast_context.GetBasicType(eBasicTypeVoid).GetPointerType(); + compiler_type = type_system->GetBasicTypeFromAST(eBasicTypeVoid).GetPointerType(); else if (!strcmp (arg_type_cstr, "char*")) - clang_type = ast_context.GetCStringType (false); + compiler_type = type_system->GetBasicTypeFromAST(eBasicTypeChar).GetPointerType(); else { result.AppendErrorWithFormat ("Invalid format: %s.\n", arg_type_cstr); @@ -234,7 +237,7 @@ CommandObjectArgs::DoExecute (Args& args, CommandReturnObject &result) return false; } - value.SetClangType (clang_type); + value.SetCompilerType (compiler_type); value_list.PushValue(value); } diff --git a/source/Commands/CommandObjectArgs.h b/source/Commands/CommandObjectArgs.h index 6691283ce099..4a4e1c35cf31 100644 --- a/source/Commands/CommandObjectArgs.h +++ b/source/Commands/CommandObjectArgs.h @@ -16,7 +16,6 @@ // Project includes #include "lldb/Interpreter/CommandObject.h" #include "lldb/Interpreter/Options.h" -#include "lldb/Core/Language.h" namespace lldb_private { @@ -30,17 +29,16 @@ namespace lldb_private { CommandOptions (CommandInterpreter &interpreter); - virtual - ~CommandOptions (); + ~CommandOptions() override; - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg); + Error + SetOptionValue(uint32_t option_idx, const char *option_arg) override; void - OptionParsingStarting (); + OptionParsingStarting() override; const OptionDefinition* - GetDefinitions (); + GetDefinitions() override; // Options table: Required for subclasses of Options. @@ -49,24 +47,20 @@ namespace lldb_private { CommandObjectArgs (CommandInterpreter &interpreter); - virtual - ~CommandObjectArgs (); + ~CommandObjectArgs() override; - virtual Options * - GetOptions (); - + GetOptions() override; protected: CommandOptions m_options; - virtual bool - DoExecute ( Args& command, - CommandReturnObject &result); - + bool + DoExecute(Args& command, + CommandReturnObject &result) override; }; } // namespace lldb_private -#endif // liblldb_CommandObjectArgs_h_ +#endif // liblldb_CommandObjectArgs_h_ diff --git a/source/Commands/CommandObjectBreakpoint.cpp b/source/Commands/CommandObjectBreakpoint.cpp index 162bfb4b5a76..bb59e1f82e8d 100644 --- a/source/Commands/CommandObjectBreakpoint.cpp +++ b/source/Commands/CommandObjectBreakpoint.cpp @@ -26,7 +26,7 @@ #include "lldb/Core/StreamString.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Target/LanguageRuntime.h" +#include "lldb/Target/Language.h" #include "lldb/Target/Target.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Target/StackFrame.h" @@ -77,11 +77,10 @@ public: } - virtual - ~CommandObjectBreakpointSet () {} + ~CommandObjectBreakpointSet () override {} - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_options; } @@ -111,6 +110,7 @@ public: m_throw_bp (true), m_hardware (false), m_exception_language (eLanguageTypeUnknown), + m_language (lldb::eLanguageTypeUnknown), m_skip_prologue (eLazyBoolCalculate), m_one_shot (false), m_all_files (false), @@ -119,11 +119,10 @@ public: } - virtual - ~CommandOptions () {} + ~CommandOptions () override {} - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -164,7 +163,7 @@ public: case 'E': { - LanguageType language = LanguageRuntime::GetLanguageTypeFromString (option_arg); + LanguageType language = Language::GetLanguageTypeFromString (option_arg); switch (language) { @@ -249,6 +248,12 @@ public: break; } + case 'L': + m_language = Language::GetLanguageTypeFromString (option_arg); + if (m_language == eLanguageTypeUnknown) + error.SetErrorStringWithFormat ("Unknown language type: '%s' for breakpoint", option_arg); + break; + case 'm': { bool success; @@ -349,7 +354,7 @@ public: return error; } void - OptionParsingStarting () + OptionParsingStarting () override { m_condition.clear(); m_filenames.Clear(); @@ -370,6 +375,7 @@ public: m_throw_bp = true; m_hardware = false; m_exception_language = eLanguageTypeUnknown; + m_language = lldb::eLanguageTypeUnknown; m_skip_prologue = eLazyBoolCalculate; m_one_shot = false; m_use_dummy = false; @@ -380,7 +386,7 @@ public: } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -411,6 +417,7 @@ public: bool m_throw_bp; bool m_hardware; // Request to use hardware breakpoints lldb::LanguageType m_exception_language; + lldb::LanguageType m_language; LazyBool m_skip_prologue; bool m_one_shot; bool m_use_dummy; @@ -421,9 +428,9 @@ public: }; protected: - virtual bool + bool DoExecute (Args& command, - CommandReturnObject &result) + CommandReturnObject &result) override { Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy); @@ -500,11 +507,32 @@ protected: break; case eSetTypeAddress: // Breakpoint by address - bp = target->CreateBreakpoint (m_options.m_load_addr, - internal, - m_options.m_hardware).get(); + { + // If a shared library has been specified, make an lldb_private::Address with the library, and + // use that. That way the address breakpoint will track the load location of the library. + size_t num_modules_specified = m_options.m_modules.GetSize(); + if (num_modules_specified == 1) + { + const FileSpec *file_spec = m_options.m_modules.GetFileSpecPointerAtIndex(0); + bp = target->CreateAddressInModuleBreakpoint (m_options.m_load_addr, + internal, + file_spec, + m_options.m_hardware).get(); + } + else if (num_modules_specified == 0) + { + bp = target->CreateBreakpoint (m_options.m_load_addr, + internal, + m_options.m_hardware).get(); + } + else + { + result.AppendError("Only one shared library can be specified for address breakpoints."); + result.SetStatus(eReturnStatusFailed); + return false; + } break; - + } case eSetTypeFunctionName: // Breakpoint by function name { uint32_t name_type_mask = m_options.m_func_name_type_mask; @@ -516,6 +544,7 @@ protected: &(m_options.m_filenames), m_options.m_func_names, name_type_mask, + m_options.m_language, m_options.m_skip_prologue, internal, m_options.m_hardware).get(); @@ -538,6 +567,7 @@ protected: bp = target->CreateFuncRegexBreakpoint (&(m_options.m_modules), &(m_options.m_filenames), regexp, + m_options.m_language, m_options.m_skip_prologue, internal, m_options.m_hardware).get(); @@ -709,6 +739,7 @@ private: #define LLDB_OPT_NOT_10 ( LLDB_OPT_SET_FROM_TO(1, 10) & ~LLDB_OPT_SET_10 ) #define LLDB_OPT_SKIP_PROLOGUE ( LLDB_OPT_SET_1 | LLDB_OPT_SET_FROM_TO(3,8) ) #define LLDB_OPT_MOVE_TO_NEAREST_CODE ( LLDB_OPT_SET_1 | LLDB_OPT_SET_9 ) +#define LLDB_OPT_EXPR_LANGUAGE ( LLDB_OPT_SET_FROM_TO(3, 8) ) OptionDefinition CommandObjectBreakpointSet::CommandOptions::g_option_table[] = @@ -756,14 +787,21 @@ CommandObjectBreakpointSet::CommandOptions::g_option_table[] = // "Set the breakpoint by source location at this particular column."}, { LLDB_OPT_SET_2, true, "address", 'a', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeAddressOrExpression, - "Set the breakpoint by address, at the specified address."}, + "Set the breakpoint at the specified address. " + "If the address maps uniquely to a particular " + "binary, then the address will be converted to a \"file\" address, so that the breakpoint will track that binary+offset no matter where " + "the binary eventually loads. " + "Alternately, if you also specify the module - with the -s option - then the address will be treated as " + "a file address in that module, and resolved accordingly. Again, this will allow lldb to track that offset on " + "subsequent reloads. The module need not have been loaded at the time you specify this breakpoint, and will " + "get resolved when the module is loaded."}, { LLDB_OPT_SET_3, true, "name", 'n', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFunctionName, "Set the breakpoint by function name. Can be repeated multiple times to make one breakpoint for multiple names" }, { LLDB_OPT_SET_4, true, "fullname", 'F', OptionParser::eRequiredArgument, NULL, NULL, CommandCompletions::eSymbolCompletion, eArgTypeFullName, "Set the breakpoint by fully qualified function names. For C++ this means namespaces and all arguments, and " - "for Objective C this means a full function prototype with class and selector. " + "for Objective C this means a full function prototype with class and selector. " "Can be repeated multiple times to make one breakpoint for multiple names." }, { LLDB_OPT_SET_5, true, "selector", 'S', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeSelector, @@ -800,6 +838,9 @@ CommandObjectBreakpointSet::CommandOptions::g_option_table[] = // { LLDB_OPT_SET_10, false, "exception-typename", 'O', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeTypeName, // "The breakpoint will only stop if an exception Object of this type is thrown. Can be repeated multiple times to stop for multiple object types" }, + { LLDB_OPT_EXPR_LANGUAGE, false, "language", 'L', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage, + "Specifies the Language to use when interpreting the breakpoint's expression (note: currently only implemented for setting breakpoints on identifiers). If not set the target.language setting is used." }, + { LLDB_OPT_SKIP_PROLOGUE, false, "skip-prologue", 'K', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "sKip the prologue if the breakpoint is at the beginning of a function. If not set the target.skip-prologue setting is used." }, @@ -840,11 +881,10 @@ public: } - virtual - ~CommandObjectBreakpointModify () {} + ~CommandObjectBreakpointModify () override {} - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_options; } @@ -874,11 +914,10 @@ public: { } - virtual - ~CommandOptions () {} + ~CommandOptions () override {} - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -979,7 +1018,7 @@ public: return error; } void - OptionParsingStarting () + OptionParsingStarting () override { m_ignore_count = 0; m_thread_id = LLDB_INVALID_THREAD_ID; @@ -999,7 +1038,7 @@ public: } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -1031,8 +1070,8 @@ public: }; protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy); if (target == NULL) @@ -1159,12 +1198,11 @@ public: } - virtual - ~CommandObjectBreakpointEnable () {} + ~CommandObjectBreakpointEnable () override {} protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = GetSelectedOrDummyTarget(); if (target == NULL) @@ -1279,12 +1317,11 @@ the second re-enables the first location." } - virtual - ~CommandObjectBreakpointDisable () {} + ~CommandObjectBreakpointDisable () override {} protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = GetSelectedOrDummyTarget(); if (target == NULL) @@ -1389,11 +1426,10 @@ public: } - virtual - ~CommandObjectBreakpointList () {} + ~CommandObjectBreakpointList () override {} - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_options; } @@ -1409,11 +1445,10 @@ public: { } - virtual - ~CommandOptions () {} + ~CommandOptions () override {} - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -1444,7 +1479,7 @@ public: } void - OptionParsingStarting () + OptionParsingStarting () override { m_level = lldb::eDescriptionLevelFull; m_internal = false; @@ -1452,7 +1487,7 @@ public: } const OptionDefinition * - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -1470,8 +1505,8 @@ public: }; protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy); @@ -1586,11 +1621,10 @@ public: { } - virtual - ~CommandObjectBreakpointClear () {} + ~CommandObjectBreakpointClear () override {} - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_options; } @@ -1606,11 +1640,10 @@ public: { } - virtual - ~CommandOptions () {} + ~CommandOptions () override {} - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -1634,14 +1667,14 @@ public: } void - OptionParsingStarting () + OptionParsingStarting () override { m_filename.clear(); m_line_num = 0; } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -1658,8 +1691,8 @@ public: }; protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = GetSelectedOrDummyTarget(); if (target == NULL) @@ -1786,11 +1819,10 @@ public: m_arguments.push_back (arg); } - virtual - ~CommandObjectBreakpointDelete () {} + ~CommandObjectBreakpointDelete () override {} - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_options; } @@ -1806,11 +1838,10 @@ public: { } - virtual - ~CommandOptions () {} + ~CommandOptions () override {} - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -1834,14 +1865,14 @@ public: } void - OptionParsingStarting () + OptionParsingStarting () override { m_use_dummy = false; m_force = false; } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -1856,8 +1887,8 @@ public: }; protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy); @@ -1976,27 +2007,26 @@ public: } - virtual - ~BreakpointNameOptionGroup () + ~BreakpointNameOptionGroup () override { } - virtual uint32_t - GetNumDefinitions () + uint32_t + GetNumDefinitions () override { return sizeof (g_breakpoint_name_options) / sizeof (OptionDefinition); } - virtual const OptionDefinition* - GetDefinitions () + const OptionDefinition* + GetDefinitions () override { return g_breakpoint_name_options; } - virtual Error + Error SetOptionValue (CommandInterpreter &interpreter, uint32_t option_idx, - const char *option_value) + const char *option_value) override { Error error; const int short_option = g_breakpoint_name_options[option_idx].short_option; @@ -2024,8 +2054,8 @@ public: return error; } - virtual void - OptionParsingStarting (CommandInterpreter &interpreter) + void + OptionParsingStarting (CommandInterpreter &interpreter) override { m_name.Clear(); m_breakpoint.Clear(); @@ -2062,18 +2092,17 @@ public: m_option_group.Finalize(); } - virtual - ~CommandObjectBreakpointNameAdd () {} + ~CommandObjectBreakpointNameAdd () override {} Options * - GetOptions () + GetOptions () override { return &m_option_group; } protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { if (!m_name_options.m_name.OptionWasSet()) { @@ -2158,18 +2187,17 @@ public: m_option_group.Finalize(); } - virtual - ~CommandObjectBreakpointNameDelete () {} + ~CommandObjectBreakpointNameDelete () override {} Options * - GetOptions () + GetOptions () override { return &m_option_group; } protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { if (!m_name_options.m_name.OptionWasSet()) { @@ -2243,18 +2271,17 @@ public: m_option_group.Finalize(); } - virtual - ~CommandObjectBreakpointNameList () {} + ~CommandObjectBreakpointNameList () override {} Options * - GetOptions () + GetOptions () override { return &m_option_group; } protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = GetSelectedOrDummyTarget(m_name_options.m_use_dummy.GetCurrentValue()); @@ -2339,8 +2366,7 @@ public: } - virtual - ~CommandObjectBreakpointName () + ~CommandObjectBreakpointName () override { } diff --git a/source/Commands/CommandObjectBreakpoint.h b/source/Commands/CommandObjectBreakpoint.h index 3fdd2a5f56be..123e8232c987 100644 --- a/source/Commands/CommandObjectBreakpoint.h +++ b/source/Commands/CommandObjectBreakpoint.h @@ -34,8 +34,7 @@ class CommandObjectMultiwordBreakpoint : public CommandObjectMultiword public: CommandObjectMultiwordBreakpoint (CommandInterpreter &interpreter); - virtual - ~CommandObjectMultiwordBreakpoint (); + ~CommandObjectMultiwordBreakpoint() override; static void VerifyBreakpointOrLocationIDs (Args &args, Target *target, CommandReturnObject &result, BreakpointIDList *valid_ids) @@ -56,4 +55,4 @@ private: } // namespace lldb_private -#endif // liblldb_CommandObjectBreakpoint_h_ +#endif // liblldb_CommandObjectBreakpoint_h_ diff --git a/source/Commands/CommandObjectBreakpointCommand.cpp b/source/Commands/CommandObjectBreakpointCommand.cpp index ac9c9a64188c..7b58bf9185bc 100644 --- a/source/Commands/CommandObjectBreakpointCommand.cpp +++ b/source/Commands/CommandObjectBreakpointCommand.cpp @@ -178,17 +178,16 @@ are no syntax errors may indicate that a function was declared but never called. m_arguments.push_back (arg); } - virtual - ~CommandObjectBreakpointCommandAdd () {} + ~CommandObjectBreakpointCommandAdd () override {} - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_options; } - virtual void - IOHandlerActivated (IOHandler &io_handler) + void + IOHandlerActivated (IOHandler &io_handler) override { StreamFileSP output_sp(io_handler.GetOutputStreamFile()); if (output_sp) @@ -199,8 +198,8 @@ are no syntax errors may indicate that a function was declared but never called. } - virtual void - IOHandlerInputComplete (IOHandler &io_handler, std::string &line) + void + IOHandlerInputComplete (IOHandler &io_handler, std::string &line) override { io_handler.SetIsDone(true); @@ -315,11 +314,10 @@ are no syntax errors may indicate that a function was declared but never called. { } - virtual - ~CommandOptions () {} + ~CommandOptions () override {} - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -374,7 +372,7 @@ are no syntax errors may indicate that a function was declared but never called. return error; } void - OptionParsingStarting () + OptionParsingStarting () override { m_use_commands = true; m_use_script_language = false; @@ -388,7 +386,7 @@ are no syntax errors may indicate that a function was declared but never called. } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -412,8 +410,8 @@ are no syntax errors may indicate that a function was declared but never called. }; protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy); @@ -596,11 +594,10 @@ public: } - virtual - ~CommandObjectBreakpointCommandDelete () {} + ~CommandObjectBreakpointCommandDelete () override {} - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_options; } @@ -615,11 +612,10 @@ public: { } - virtual - ~CommandOptions () {} + ~CommandOptions () override {} - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -639,13 +635,13 @@ public: } void - OptionParsingStarting () + OptionParsingStarting () override { m_use_dummy = false; } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -659,8 +655,8 @@ public: }; protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = GetSelectedOrDummyTarget(m_options.m_use_dummy); @@ -764,13 +760,12 @@ public: m_arguments.push_back (arg); } - virtual - ~CommandObjectBreakpointCommandList () {} + ~CommandObjectBreakpointCommandList () override {} protected: - virtual bool + bool DoExecute (Args& command, - CommandReturnObject &result) + CommandReturnObject &result) override { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); diff --git a/source/Commands/CommandObjectBreakpointCommand.h b/source/Commands/CommandObjectBreakpointCommand.h index e91790779510..94afc785c575 100644 --- a/source/Commands/CommandObjectBreakpointCommand.h +++ b/source/Commands/CommandObjectBreakpointCommand.h @@ -13,7 +13,6 @@ // C Includes // C++ Includes - // Other libraries and framework includes // Project includes @@ -23,7 +22,6 @@ #include "lldb/Interpreter/CommandReturnObject.h" #include "lldb/Interpreter/CommandObjectMultiword.h" - namespace lldb_private { //------------------------------------------------------------------------- @@ -35,11 +33,9 @@ class CommandObjectBreakpointCommand : public CommandObjectMultiword public: CommandObjectBreakpointCommand (CommandInterpreter &interpreter); - virtual - ~CommandObjectBreakpointCommand (); - + ~CommandObjectBreakpointCommand() override; }; } // namespace lldb_private -#endif // liblldb_CommandObjectBreakpointCommand_h_ +#endif // liblldb_CommandObjectBreakpointCommand_h_ diff --git a/source/Commands/CommandObjectBugreport.cpp b/source/Commands/CommandObjectBugreport.cpp index f171d2f6267f..3d00cb817e3d 100644 --- a/source/Commands/CommandObjectBugreport.cpp +++ b/source/Commands/CommandObjectBugreport.cpp @@ -43,7 +43,7 @@ public: m_option_group.Finalize(); } - ~CommandObjectBugreportUnwind() + ~CommandObjectBugreportUnwind() override { } diff --git a/source/Commands/CommandObjectBugreport.h b/source/Commands/CommandObjectBugreport.h index d062e0d79373..3adde51e0274 100644 --- a/source/Commands/CommandObjectBugreport.h +++ b/source/Commands/CommandObjectBugreport.h @@ -27,10 +27,9 @@ class CommandObjectMultiwordBugreport : public CommandObjectMultiword public: CommandObjectMultiwordBugreport(CommandInterpreter &interpreter); - virtual - ~CommandObjectMultiwordBugreport(); + ~CommandObjectMultiwordBugreport() override; }; } // namespace lldb_private -#endif // liblldb_CommandObjectBugreport_h_ +#endif // liblldb_CommandObjectBugreport_h_ diff --git a/source/Commands/CommandObjectCommands.cpp b/source/Commands/CommandObjectCommands.cpp index f56d089877de..e859b5d64b11 100644 --- a/source/Commands/CommandObjectCommands.cpp +++ b/source/Commands/CommandObjectCommands.cpp @@ -47,10 +47,10 @@ public: { } - ~CommandObjectCommandsHistory () {} + ~CommandObjectCommandsHistory () override {} - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_options; } @@ -70,11 +70,10 @@ protected: { } - virtual - ~CommandOptions (){} + ~CommandOptions () override {} - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -109,7 +108,7 @@ protected: } void - OptionParsingStarting () + OptionParsingStarting () override { m_start_idx.Clear(); m_stop_idx.Clear(); @@ -118,7 +117,7 @@ protected: } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -136,7 +135,7 @@ protected: }; bool - DoExecute (Args& command, CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { if (m_options.m_clear.GetCurrentValue() && m_options.m_clear.OptionWasSet()) { @@ -259,15 +258,15 @@ public: m_arguments.push_back (arg); } - ~CommandObjectCommandsSource () {} + ~CommandObjectCommandsSource () override {} - virtual const char* - GetRepeatCommand (Args ¤t_command_args, uint32_t index) + const char* + GetRepeatCommand (Args ¤t_command_args, uint32_t index) override { return ""; } - virtual int + int HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, @@ -275,7 +274,7 @@ public: int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); @@ -291,8 +290,8 @@ public: return matches.GetSize(); } - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_options; } @@ -311,11 +310,10 @@ protected: { } - virtual - ~CommandOptions (){} + ~CommandOptions () override {} - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -343,7 +341,7 @@ protected: } void - OptionParsingStarting () + OptionParsingStarting () override { m_stop_on_error.Clear(); m_silent_run.Clear(); @@ -351,7 +349,7 @@ protected: } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -368,7 +366,7 @@ protected: }; bool - DoExecute(Args& command, CommandReturnObject &result) + DoExecute(Args& command, CommandReturnObject &result) override { const size_t argc = command.GetArgumentCount(); if (argc == 1) @@ -553,13 +551,13 @@ rather than using a positional placeholder:" R"( m_arguments.push_back (arg3); } - ~CommandObjectCommandsAlias () + ~CommandObjectCommandsAlias () override { } protected: - virtual bool - DoExecute (const char *raw_command_line, CommandReturnObject &result) + bool + DoExecute (const char *raw_command_line, CommandReturnObject &result) override { Args args (raw_command_line); std::string raw_command_string (raw_command_line); @@ -820,13 +818,13 @@ public: m_arguments.push_back (arg); } - ~CommandObjectCommandsUnalias() + ~CommandObjectCommandsUnalias() override { } protected: bool - DoExecute (Args& args, CommandReturnObject &result) + DoExecute (Args& args, CommandReturnObject &result) override { CommandObject::CommandMap::iterator pos; CommandObject *cmd_obj; @@ -913,13 +911,13 @@ public: m_arguments.push_back (arg); } - ~CommandObjectCommandsDelete() + ~CommandObjectCommandsDelete() override { } protected: bool - DoExecute (Args& args, CommandReturnObject &result) + DoExecute (Args& args, CommandReturnObject &result) override { CommandObject::CommandMap::iterator pos; @@ -1000,7 +998,7 @@ a number follows 'f':" R"( ); } - ~CommandObjectCommandsAddRegex() + ~CommandObjectCommandsAddRegex() override { } @@ -1250,11 +1248,10 @@ private: { } - virtual - ~CommandOptions (){} + ~CommandOptions () override {} - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -1277,14 +1274,14 @@ private: } void - OptionParsingStarting () + OptionParsingStarting () override { m_help.clear(); m_syntax.clear(); } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -1363,13 +1360,12 @@ public: } } - virtual - ~CommandObjectPythonFunction () + ~CommandObjectPythonFunction () override { } - virtual bool - IsRemovable () const + bool + IsRemovable () const override { return true; } @@ -1386,8 +1382,8 @@ public: return m_synchro; } - virtual const char * - GetHelpLong () + const char * + GetHelpLong () override { if (!m_fetched_help_long) { @@ -1404,8 +1400,8 @@ public: } protected: - virtual bool - DoExecute (const char *raw_command_line, CommandReturnObject &result) + bool + DoExecute (const char *raw_command_line, CommandReturnObject &result) override { ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter(); @@ -1470,13 +1466,12 @@ public: GetFlags().Set(scripter->GetFlagsForCommandObject(cmd_obj_sp)); } - virtual - ~CommandObjectScriptingObject () + ~CommandObjectScriptingObject () override { } - virtual bool - IsRemovable () const + bool + IsRemovable () const override { return true; } @@ -1493,8 +1488,8 @@ public: return m_synchro; } - virtual const char * - GetHelp () + const char * + GetHelp () override { if (!m_fetched_help_short) { @@ -1510,8 +1505,8 @@ public: return CommandObjectRaw::GetHelp(); } - virtual const char * - GetHelpLong () + const char * + GetHelpLong () override { if (!m_fetched_help_long) { @@ -1528,8 +1523,8 @@ public: } protected: - virtual bool - DoExecute (const char *raw_command_line, CommandReturnObject &result) + bool + DoExecute (const char *raw_command_line, CommandReturnObject &result) override { ScriptInterpreter* scripter = m_interpreter.GetScriptInterpreter(); @@ -1592,11 +1587,11 @@ public: m_arguments.push_back (arg1); } - ~CommandObjectCommandsScriptImport () + ~CommandObjectCommandsScriptImport () override { } - virtual int + int HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, @@ -1604,7 +1599,7 @@ public: int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); @@ -1620,8 +1615,8 @@ public: return matches.GetSize(); } - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_options; } @@ -1637,11 +1632,10 @@ protected: { } - virtual - ~CommandOptions (){} + ~CommandOptions () override {} - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -1660,13 +1654,13 @@ protected: } void - OptionParsingStarting () + OptionParsingStarting () override { m_allow_reload = true; } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -1681,7 +1675,7 @@ protected: }; bool - DoExecute (Args& command, CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { if (m_interpreter.GetDebugger().GetScriptLanguage() != lldb::eScriptLanguagePython) { @@ -1772,12 +1766,12 @@ public: m_arguments.push_back (arg1); } - ~CommandObjectCommandsScriptAdd () + ~CommandObjectCommandsScriptAdd () override { } - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_options; } @@ -1797,11 +1791,10 @@ protected: { } - virtual - ~CommandOptions (){} + ~CommandOptions () override {} - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -1834,7 +1827,7 @@ protected: } void - OptionParsingStarting () + OptionParsingStarting () override { m_class_name.clear(); m_funct_name.clear(); @@ -1843,7 +1836,7 @@ protected: } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -1860,8 +1853,8 @@ protected: ScriptedCommandSynchronicity m_synchronicity; }; - virtual void - IOHandlerActivated (IOHandler &io_handler) + void + IOHandlerActivated (IOHandler &io_handler) override { StreamFileSP output_sp(io_handler.GetOutputStreamFile()); if (output_sp) @@ -1872,8 +1865,8 @@ protected: } - virtual void - IOHandlerInputComplete (IOHandler &io_handler, std::string &data) + void + IOHandlerInputComplete (IOHandler &io_handler, std::string &data) override { StreamFileSP error_sp = io_handler.GetErrorStreamFile(); @@ -1935,7 +1928,7 @@ protected: protected: bool - DoExecute (Args& command, CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { if (m_interpreter.GetDebugger().GetScriptLanguage() != lldb::eScriptLanguagePython) @@ -2064,12 +2057,12 @@ public: { } - ~CommandObjectCommandsScriptList () + ~CommandObjectCommandsScriptList () override { } bool - DoExecute (Args& command, CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { m_interpreter.GetHelp(result, @@ -2100,13 +2093,13 @@ public: { } - ~CommandObjectCommandsScriptClear () + ~CommandObjectCommandsScriptClear () override { } protected: bool - DoExecute (Args& command, CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { m_interpreter.RemoveAllUser(); @@ -2144,13 +2137,13 @@ public: m_arguments.push_back (arg1); } - ~CommandObjectCommandsScriptDelete () + ~CommandObjectCommandsScriptDelete () override { } protected: bool - DoExecute (Args& command, CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { size_t argc = command.GetArgumentCount(); @@ -2202,7 +2195,7 @@ public: LoadSubCommand ("import", CommandObjectSP (new CommandObjectCommandsScriptImport (interpreter))); } - ~CommandObjectMultiwordCommandsScript () + ~CommandObjectMultiwordCommandsScript () override { } diff --git a/source/Commands/CommandObjectCommands.h b/source/Commands/CommandObjectCommands.h index 8a56e8dae6ff..c12c71051ffe 100644 --- a/source/Commands/CommandObjectCommands.h +++ b/source/Commands/CommandObjectCommands.h @@ -30,11 +30,9 @@ public: CommandObjectMultiwordCommands (CommandInterpreter &interpreter); - virtual - ~CommandObjectMultiwordCommands (); - + ~CommandObjectMultiwordCommands() override; }; } // namespace lldb_private -#endif // liblldb_CommandObjectCommands_h_ +#endif // liblldb_CommandObjectCommands_h_ diff --git a/source/Commands/CommandObjectDisassemble.cpp b/source/Commands/CommandObjectDisassemble.cpp index 1e575fe963f3..100d8692039f 100644 --- a/source/Commands/CommandObjectDisassemble.cpp +++ b/source/Commands/CommandObjectDisassemble.cpp @@ -289,7 +289,7 @@ CommandObjectDisassemble::DoExecute (Args& command, CommandReturnObject &result) if (!m_options.arch.IsValid()) { - result.AppendError ("use the --arch option or set the target architecure to disassemble"); + result.AppendError ("use the --arch option or set the target architecture to disassemble"); result.SetStatus (eReturnStatusFailed); return false; } diff --git a/source/Commands/CommandObjectDisassemble.h b/source/Commands/CommandObjectDisassemble.h index 7a7509858b98..d892824d017d 100644 --- a/source/Commands/CommandObjectDisassemble.h +++ b/source/Commands/CommandObjectDisassemble.h @@ -33,17 +33,16 @@ public: CommandOptions (CommandInterpreter &interpreter); - virtual - ~CommandOptions (); + ~CommandOptions() override; - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg); + Error + SetOptionValue(uint32_t option_idx, const char *option_arg) override; void - OptionParsingStarting (); + OptionParsingStarting() override; const OptionDefinition* - GetDefinitions (); + GetDefinitions() override; const char * GetPluginName () @@ -61,8 +60,8 @@ public: return flavor_string.c_str(); } - virtual Error - OptionParsingFinished (); + Error + OptionParsingFinished() override; bool show_mixed; // Show mixed source/assembly bool show_bytes; @@ -86,25 +85,22 @@ public: CommandObjectDisassemble (CommandInterpreter &interpreter); - virtual - ~CommandObjectDisassemble (); + ~CommandObjectDisassemble() override; - virtual Options * - GetOptions () + GetOptions() override { return &m_options; } protected: - virtual bool - DoExecute (Args& command, - CommandReturnObject &result); + bool + DoExecute(Args& command, + CommandReturnObject &result) override; CommandOptions m_options; - }; } // namespace lldb_private -#endif // liblldb_CommandObjectDisassemble_h_ +#endif // liblldb_CommandObjectDisassemble_h_ diff --git a/source/Commands/CommandObjectExpression.cpp b/source/Commands/CommandObjectExpression.cpp index 1be17a0cfddc..7f0b03b37c20 100644 --- a/source/Commands/CommandObjectExpression.cpp +++ b/source/Commands/CommandObjectExpression.cpp @@ -16,16 +16,16 @@ #include "lldb/Core/Value.h" #include "lldb/Core/ValueObjectVariable.h" #include "lldb/DataFormatters/ValueObjectPrinter.h" -#include "lldb/Expression/ClangExpressionVariable.h" -#include "lldb/Expression/ClangUserExpression.h" -#include "lldb/Expression/ClangFunction.h" +#include "Plugins/ExpressionParser/Clang/ClangExpressionVariable.h" +#include "lldb/Expression/UserExpression.h" #include "lldb/Expression/DWARFExpression.h" +#include "lldb/Expression/REPL.h" #include "lldb/Host/Host.h" #include "lldb/Host/StringConvert.h" #include "lldb/Core/Debugger.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" -#include "lldb/Target/ObjCLanguageRuntime.h" +#include "lldb/Target/Language.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/Variable.h" #include "lldb/Target/Process.h" @@ -63,6 +63,7 @@ CommandObjectExpression::CommandOptions::g_option_table[] = { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "timeout", 't', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeUnsignedInteger, "Timeout value (in microseconds) for running the expression."}, { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "unwind-on-error", 'u', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeBoolean, "Clean up program state if the expression causes a crash, or raises a signal. Note, unlike gdb hitting a breakpoint is controlled by another option (-i)."}, { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "debug", 'g', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone, "When specified, debug the JIT code by setting a breakpoint on the first instruction and forcing breakpoints to not be ignored (-i0) and no unwinding to happen on error (-u0)."}, + { LLDB_OPT_SET_1 | LLDB_OPT_SET_2, false, "language", 'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeLanguage, "Specifies the Language to use when parsing the expression. If not set the target.language setting is used." }, { LLDB_OPT_SET_1, false, "description-verbosity", 'v', OptionParser::eOptionalArgument, NULL, g_description_verbosity_type, 0, eArgTypeDescriptionVerbosity, "How verbose should the output of this expression be, if the object description is asked for."}, }; @@ -84,12 +85,11 @@ CommandObjectExpression::CommandOptions::SetOptionValue (CommandInterpreter &int switch (short_option) { - //case 'l': - //if (language.SetLanguageFromCString (option_arg) == false) - //{ - // error.SetErrorStringWithFormat("invalid language option argument '%s'", option_arg); - //} - //break; + case 'l': + language = Language::GetLanguageTypeFromString (option_arg); + if (language == eLanguageTypeUnknown) + error.SetErrorStringWithFormat ("unknown language type: '%s' for expression", option_arg); + break; case 'a': { @@ -180,6 +180,7 @@ CommandObjectExpression::CommandOptions::OptionParsingStarting (CommandInterpret try_all_threads = true; timeout = 0; debug = false; + language = eLanguageTypeUnknown; m_verbosity = eLanguageRuntimeDescriptionDisplayVerbosityCompact; } @@ -192,12 +193,13 @@ CommandObjectExpression::CommandOptions::GetDefinitions () CommandObjectExpression::CommandObjectExpression (CommandInterpreter &interpreter) : CommandObjectRaw (interpreter, "expression", - "Evaluate a C/ObjC/C++ expression in the current program context, using user defined variables and variables currently in scope.", + "Evaluate an expression in the current program context, using user defined variables and variables currently in scope.", NULL, eCommandProcessMustBePaused | eCommandTryTargetAPILock), IOHandlerDelegate (IOHandlerDelegate::Completion::Expression), m_option_group (interpreter), m_format_options (eFormatDefault), + m_repl_option (LLDB_OPT_SET_1, false, "repl", 'r', "Drop into REPL", false, true), m_command_options (), m_expr_line_count (0), m_expr_lines () @@ -253,6 +255,7 @@ Examples: m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_FORMAT | OptionGroupFormat::OPTION_GROUP_GDB_FMT, LLDB_OPT_SET_1); m_option_group.Append (&m_command_options); m_option_group.Append (&m_varobj_options, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1 | LLDB_OPT_SET_2); + m_option_group.Append (&m_repl_option, LLDB_OPT_SET_ALL, LLDB_OPT_SET_3); m_option_group.Finalize(); } @@ -288,8 +291,8 @@ CommandObjectExpression::EvaluateExpression if (target) { lldb::ValueObjectSP result_valobj_sp; - bool keep_in_memory = true; + StackFrame *frame = exe_ctx.GetFramePtr(); EvaluateExpressionOptions options; options.SetCoerceToId(m_varobj_options.use_objc); @@ -299,7 +302,8 @@ CommandObjectExpression::EvaluateExpression options.SetUseDynamic(m_varobj_options.use_dynamic); options.SetTryAllThreads(m_command_options.try_all_threads); options.SetDebug(m_command_options.debug); - + options.SetLanguage(m_command_options.language); + // If there is any chance we are going to stop and want to see // what went wrong with our expression, we should generate debug info if (!m_command_options.ignore_breakpoints || @@ -311,8 +315,7 @@ CommandObjectExpression::EvaluateExpression else options.SetTimeoutUsec(0); - target->EvaluateExpression(expr, exe_ctx.GetFramePtr(), - result_valobj_sp, options); + target->EvaluateExpression(expr, frame, result_valobj_sp, options); if (result_valobj_sp) { @@ -326,6 +329,7 @@ CommandObjectExpression::EvaluateExpression result_valobj_sp->SetFormat (format); DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(m_command_options.m_verbosity,format)); + options.SetVariableFormatDisplayLanguage(result_valobj_sp->GetPreferredDisplayLanguage()); result_valobj_sp->Dump(*output_stream,options); @@ -335,7 +339,7 @@ CommandObjectExpression::EvaluateExpression } else { - if (result_valobj_sp->GetError().GetError() == ClangUserExpression::kNoResult) + if (result_valobj_sp->GetError().GetError() == UserExpression::kNoResult) { if (format != eFormatVoid && m_interpreter.GetDebugger().GetNotifyVoid()) { @@ -501,8 +505,70 @@ CommandObjectExpression::DoExecute return false; } + if (m_repl_option.GetOptionValue().GetCurrentValue()) + { + Target *target = m_interpreter.GetExecutionContext().GetTargetPtr(); + if (target) + { + // Drop into REPL + m_expr_lines.clear(); + m_expr_line_count = 0; + + Debugger &debugger = target->GetDebugger(); + + // Check if the LLDB command interpreter is sitting on top of a REPL that + // launched it... + if (debugger.CheckTopIOHandlerTypes(IOHandler::Type::CommandInterpreter, IOHandler::Type::REPL)) + { + // the LLDB command interpreter is sitting on top of a REPL that launched it, + // so just say the command interpreter is done and fall back to the existing REPL + m_interpreter.GetIOHandler(false)->SetIsDone(true); + } + else + { + // We are launching the REPL on top of the current LLDB command interpreter, + // so just push one + bool initialize = false; + Error repl_error; + REPLSP repl_sp (target->GetREPL(repl_error, m_command_options.language, nullptr, false)); + + if (!repl_sp) + { + initialize = true; + repl_sp = target->GetREPL(repl_error, m_command_options.language, nullptr, true); + if (!repl_error.Success()) + { + result.SetError(repl_error); + return result.Succeeded(); + } + } + + if (repl_sp) + { + if (initialize) + { + repl_sp->SetCommandOptions(m_command_options); + repl_sp->SetFormatOptions(m_format_options); + repl_sp->SetValueObjectDisplayOptions(m_varobj_options); + } + + IOHandlerSP io_handler_sp (repl_sp->GetIOHandler()); + + io_handler_sp->SetIsDone(false); + + debugger.PushIOHandler(io_handler_sp); + } + else + { + repl_error.SetErrorStringWithFormat("Couldn't create a REPL for %s", Language::GetNameForLanguageType(m_command_options.language)); + result.SetError(repl_error); + return result.Succeeded(); + } + } + } + } // No expression following options - if (expr == NULL || expr[0] == '\0') + else if (expr == NULL || expr[0] == '\0') { GetMultilineExpression (); return result.Succeeded(); diff --git a/source/Commands/CommandObjectExpression.h b/source/Commands/CommandObjectExpression.h index 168140d7fe56..7103675f3992 100644 --- a/source/Commands/CommandObjectExpression.h +++ b/source/Commands/CommandObjectExpression.h @@ -16,6 +16,7 @@ // Project includes #include "lldb/Core/IOHandler.h" #include "lldb/Interpreter/CommandObject.h" +#include "lldb/Interpreter/OptionGroupBoolean.h" #include "lldb/Interpreter/OptionGroupFormat.h" #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" #include "lldb/Target/ExecutionContext.h" @@ -34,22 +35,21 @@ public: CommandOptions (); - virtual - ~CommandOptions (); + ~CommandOptions() override; - virtual uint32_t - GetNumDefinitions (); + uint32_t + GetNumDefinitions() override; - virtual const OptionDefinition* - GetDefinitions (); + const OptionDefinition* + GetDefinitions() override; - virtual Error - SetOptionValue (CommandInterpreter &interpreter, - uint32_t option_idx, - const char *option_value); + Error + SetOptionValue(CommandInterpreter &interpreter, + uint32_t option_idx, + const char *option_value) override; - virtual void - OptionParsingStarting (CommandInterpreter &interpreter); + void + OptionParsingStarting(CommandInterpreter &interpreter) override; // Options table: Required for subclasses of Options. @@ -61,35 +61,34 @@ public: bool debug; uint32_t timeout; bool try_all_threads; + lldb::LanguageType language; LanguageRuntimeDescriptionDisplayVerbosity m_verbosity; }; CommandObjectExpression (CommandInterpreter &interpreter); - virtual - ~CommandObjectExpression (); + ~CommandObjectExpression() override; - virtual Options * - GetOptions (); + GetOptions() override; protected: //------------------------------------------------------------------ // IOHandler::Delegate functions //------------------------------------------------------------------ - virtual void - IOHandlerInputComplete (IOHandler &io_handler, - std::string &line); + void + IOHandlerInputComplete(IOHandler &io_handler, + std::string &line) override; virtual LineStatus IOHandlerLinesUpdated (IOHandler &io_handler, StringList &lines, uint32_t line_idx, Error &error); - virtual bool - DoExecute (const char *command, - CommandReturnObject &result); + bool + DoExecute(const char *command, + CommandReturnObject &result) override; bool EvaluateExpression (const char *expr, @@ -103,6 +102,7 @@ protected: OptionGroupOptions m_option_group; OptionGroupFormat m_format_options; OptionGroupValueObjectDisplay m_varobj_options; + OptionGroupBoolean m_repl_option; CommandOptions m_command_options; uint32_t m_expr_line_count; std::string m_expr_lines; // Multi-line expression support @@ -110,4 +110,4 @@ protected: } // namespace lldb_private -#endif // liblldb_CommandObjectExpression_h_ +#endif // liblldb_CommandObjectExpression_h_ diff --git a/source/Commands/CommandObjectFrame.cpp b/source/Commands/CommandObjectFrame.cpp index d8b65e3b551a..9477b50a58df 100644 --- a/source/Commands/CommandObjectFrame.cpp +++ b/source/Commands/CommandObjectFrame.cpp @@ -33,8 +33,9 @@ #include "lldb/Interpreter/OptionGroupFormat.h" #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" #include "lldb/Interpreter/OptionGroupVariable.h" -#include "lldb/Symbol/ClangASTType.h" +#include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/ClangASTContext.h" +#include "lldb/Symbol/Function.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContext.h" #include "lldb/Symbol/Type.h" @@ -70,13 +71,13 @@ public: { } - ~CommandObjectFrameInfo () + ~CommandObjectFrameInfo () override { } protected: bool - DoExecute (Args& command, CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { m_exe_ctx.GetFrameRef().DumpUsingSettingsFormat (&result.GetOutputStream()); result.SetStatus (eReturnStatusSuccessFinishResult); @@ -104,13 +105,12 @@ public: OptionParsingStarting (); } - virtual - ~CommandOptions () + ~CommandOptions () override { } - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; bool success = false; @@ -132,13 +132,13 @@ public: } void - OptionParsingStarting () + OptionParsingStarting () override { relative_frame_offset = INT32_MIN; } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -174,13 +174,12 @@ public: m_arguments.push_back (arg); } - ~CommandObjectFrameSelect () + ~CommandObjectFrameSelect () override { } - virtual Options * - GetOptions () + GetOptions () override { return &m_options; } @@ -188,7 +187,7 @@ public: protected: bool - DoExecute (Args& command, CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { // No need to check "thread" for validity as eCommandRequiresThread ensures it is valid Thread *thread = m_exe_ctx.GetThreadPtr(); @@ -263,8 +262,10 @@ protected: } else { - result.AppendError ("invalid arguments.\n"); + result.AppendErrorWithFormat ("too many arguments; expected frame-index, saw '%s'.\n", + command.GetArgumentAtIndex(0)); m_options.GenerateOptionUsage (result.GetErrorStream(), this); + return false; } } @@ -341,20 +342,18 @@ public: m_option_group.Finalize(); } - virtual - ~CommandObjectFrameVariable () + ~CommandObjectFrameVariable () override { } - virtual Options * - GetOptions () + GetOptions () override { return &m_option_group; } - virtual int + int HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, @@ -362,7 +361,7 @@ public: int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { // Arguments are the standard source file completer. std::string completion_str (input.GetArgumentAtIndex(cursor_index)); @@ -380,8 +379,8 @@ public: } protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { // No need to check "frame" for validity as eCommandRequiresFrame ensures it is valid StackFrame *frame = m_exe_ctx.GetFramePtr(); @@ -409,6 +408,10 @@ protected: DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(eLanguageRuntimeDescriptionDisplayVerbosityFull,eFormatDefault,summary_format_sp)); + const SymbolContext& sym_ctx = frame->GetSymbolContext(eSymbolContextFunction); + if (sym_ctx.function && sym_ctx.function->IsTopLevelFunction()) + m_option_variable.show_globals = true; + if (variable_list) { const Format format = m_option_format.GetFormat(); @@ -477,7 +480,8 @@ protected: { Error error; uint32_t expr_path_options = StackFrame::eExpressionPathOptionCheckPtrVsMember | - StackFrame::eExpressionPathOptionsAllowDirectIVarAccess; + StackFrame::eExpressionPathOptionsAllowDirectIVarAccess | + StackFrame::eExpressionPathOptionsInspectAnonymousUnions; lldb::VariableSP var_sp; valobj_sp = frame->GetValueForVariableExpressionPath (name_cstr, m_varobj_options.use_dynamic, @@ -495,6 +499,7 @@ protected: } options.SetFormat(format); + options.SetVariableFormatDisplayLanguage(valobj_sp->GetPreferredDisplayLanguage()); Stream &output_stream = result.GetOutputStream(); options.SetRootValueObjectName(valobj_sp->GetParent() ? name_cstr : NULL); @@ -581,6 +586,7 @@ protected: } options.SetFormat(format); + options.SetVariableFormatDisplayLanguage(valobj_sp->GetPreferredDisplayLanguage()); options.SetRootValueObjectName(name_cstr); valobj_sp->Dump(result.GetOutputStream(),options); } diff --git a/source/Commands/CommandObjectFrame.h b/source/Commands/CommandObjectFrame.h index ea7c808e84b1..a72988078f6d 100644 --- a/source/Commands/CommandObjectFrame.h +++ b/source/Commands/CommandObjectFrame.h @@ -30,11 +30,9 @@ public: CommandObjectMultiwordFrame (CommandInterpreter &interpreter); - virtual - ~CommandObjectMultiwordFrame (); - + ~CommandObjectMultiwordFrame() override; }; } // namespace lldb_private -#endif // liblldb_CommandObjectFrame_h_ +#endif // liblldb_CommandObjectFrame_h_ diff --git a/source/Commands/CommandObjectGUI.h b/source/Commands/CommandObjectGUI.h index 72ddb961c266..494bcc48e20e 100644 --- a/source/Commands/CommandObjectGUI.h +++ b/source/Commands/CommandObjectGUI.h @@ -28,16 +28,14 @@ public: CommandObjectGUI (CommandInterpreter &interpreter); - virtual - ~CommandObjectGUI (); + ~CommandObjectGUI() override; protected: - virtual bool - DoExecute (Args& args, - CommandReturnObject &result); - + bool + DoExecute(Args& args, + CommandReturnObject &result) override; }; } // namespace lldb_private -#endif // liblldb_CommandObjectGUI_h_ +#endif // liblldb_CommandObjectGUI_h_ diff --git a/source/Commands/CommandObjectHelp.h b/source/Commands/CommandObjectHelp.h index 7db659c472c9..1dd7b9b8d6a8 100644 --- a/source/Commands/CommandObjectHelp.h +++ b/source/Commands/CommandObjectHelp.h @@ -29,17 +29,16 @@ public: CommandObjectHelp (CommandInterpreter &interpreter); - virtual - ~CommandObjectHelp (); + ~CommandObjectHelp() override; - virtual int - HandleCompletion (Args &input, - int &cursor_index, - int &cursor_char_position, - int match_start_point, - int max_return_elements, - bool &word_complete, - StringList &matches); + int + HandleCompletion(Args &input, + int &cursor_index, + int &cursor_char_position, + int match_start_point, + int max_return_elements, + bool &word_complete, + StringList &matches) override; class CommandOptions : public Options { @@ -50,11 +49,10 @@ public: { } - virtual - ~CommandOptions (){} + ~CommandOptions() override {} - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue(uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -79,7 +77,7 @@ public: } void - OptionParsingStarting () + OptionParsingStarting() override { m_show_aliases = true; m_show_user_defined = true; @@ -87,7 +85,7 @@ public: } const OptionDefinition* - GetDefinitions () + GetDefinitions() override { return g_option_table; } @@ -103,22 +101,21 @@ public: bool m_show_hidden; }; - virtual Options * - GetOptions () + Options * + GetOptions() override { return &m_options; } protected: - virtual bool - DoExecute (Args& command, - CommandReturnObject &result); + bool + DoExecute(Args& command, + CommandReturnObject &result) override; private: CommandOptions m_options; - }; } // namespace lldb_private -#endif // liblldb_CommandObjectHelp_h_ +#endif // liblldb_CommandObjectHelp_h_ diff --git a/source/Commands/CommandObjectLanguage.cpp b/source/Commands/CommandObjectLanguage.cpp index 9d4b85630a1f..5a8f166cb3a6 100644 --- a/source/Commands/CommandObjectLanguage.cpp +++ b/source/Commands/CommandObjectLanguage.cpp @@ -14,6 +14,7 @@ #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" +#include "lldb/Target/Language.h" #include "lldb/Target/LanguageRuntime.h" using namespace lldb; @@ -33,10 +34,6 @@ CommandObjectMultiword (interpreter, void CommandObjectLanguage::GenerateHelpText (Stream &output_stream) { CommandObjectMultiword::GenerateHelpText(output_stream); - - output_stream << "\nlanguage name can be one of the following:\n"; - - LanguageRuntime::PrintAllLanguages(output_stream, " ", "\n"); } CommandObjectLanguage::~CommandObjectLanguage () diff --git a/source/Commands/CommandObjectLanguage.h b/source/Commands/CommandObjectLanguage.h index 751fe1440a8b..15902bb8ad4b 100644 --- a/source/Commands/CommandObjectLanguage.h +++ b/source/Commands/CommandObjectLanguage.h @@ -13,7 +13,6 @@ // C Includes // C++ Includes - // Other libraries and framework includes // Project includes @@ -26,11 +25,10 @@ namespace lldb_private { public: CommandObjectLanguage (CommandInterpreter &interpreter); - virtual - ~CommandObjectLanguage (); + ~CommandObjectLanguage() override; - virtual void - GenerateHelpText (Stream &output_stream); + void + GenerateHelpText(Stream &output_stream) override; protected: bool @@ -38,4 +36,4 @@ namespace lldb_private { }; } // namespace lldb_private -#endif // liblldb_CommandObjectLanguage_h_ +#endif // liblldb_CommandObjectLanguage_h_ diff --git a/source/Commands/CommandObjectLog.cpp b/source/Commands/CommandObjectLog.cpp index e68eaf17bb9f..8e29cd5223b0 100644 --- a/source/Commands/CommandObjectLog.cpp +++ b/source/Commands/CommandObjectLog.cpp @@ -77,13 +77,12 @@ public: m_arguments.push_back (arg2); } - virtual - ~CommandObjectLogEnable() + ~CommandObjectLogEnable() override { } Options * - GetOptions () + GetOptions () override { return &m_options; } @@ -122,13 +121,12 @@ public: } - virtual - ~CommandOptions () + ~CommandOptions () override { } - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -154,14 +152,14 @@ public: } void - OptionParsingStarting () + OptionParsingStarting () override { log_file.Clear(); log_options = 0; } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -177,9 +175,9 @@ public: }; protected: - virtual bool + bool DoExecute (Args& args, - CommandReturnObject &result) + CommandReturnObject &result) override { if (args.GetArgumentCount() < 2) { @@ -260,15 +258,14 @@ public: m_arguments.push_back (arg2); } - virtual - ~CommandObjectLogDisable() + ~CommandObjectLogDisable() override { } protected: - virtual bool + bool DoExecute (Args& args, - CommandReturnObject &result) + CommandReturnObject &result) override { const size_t argc = args.GetArgumentCount(); if (argc == 0) @@ -332,15 +329,14 @@ public: m_arguments.push_back (arg); } - virtual - ~CommandObjectLogList() + ~CommandObjectLogList() override { } protected: - virtual bool + bool DoExecute (Args& args, - CommandReturnObject &result) + CommandReturnObject &result) override { const size_t argc = args.GetArgumentCount(); if (argc == 0) @@ -396,15 +392,14 @@ public: { } - virtual - ~CommandObjectLogTimer() + ~CommandObjectLogTimer() override { } protected: - virtual bool + bool DoExecute (Args& args, - CommandReturnObject &result) + CommandReturnObject &result) override { const size_t argc = args.GetArgumentCount(); result.SetStatus(eReturnStatusFailed); diff --git a/source/Commands/CommandObjectLog.h b/source/Commands/CommandObjectLog.h index 3e731fa1d186..be5215f2bdc3 100644 --- a/source/Commands/CommandObjectLog.h +++ b/source/Commands/CommandObjectLog.h @@ -33,8 +33,7 @@ public: //------------------------------------------------------------------ CommandObjectLog(CommandInterpreter &interpreter); - virtual - ~CommandObjectLog(); + ~CommandObjectLog() override; private: //------------------------------------------------------------------ @@ -45,4 +44,4 @@ private: } // namespace lldb_private -#endif // liblldb_CommandObjectLog_h_ +#endif // liblldb_CommandObjectLog_h_ diff --git a/source/Commands/CommandObjectMemory.cpp b/source/Commands/CommandObjectMemory.cpp index d589800299a3..f8fe456d4d46 100644 --- a/source/Commands/CommandObjectMemory.cpp +++ b/source/Commands/CommandObjectMemory.cpp @@ -23,7 +23,7 @@ #include "lldb/Core/StreamString.h" #include "lldb/Core/ValueObjectMemory.h" #include "lldb/DataFormatters/ValueObjectPrinter.h" -#include "lldb/Expression/ClangPersistentVariables.h" +#include "Plugins/ExpressionParser/Clang/ClangPersistentVariables.h" #include "lldb/Host/StringConvert.h" #include "lldb/Interpreter/Args.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -33,6 +33,7 @@ #include "lldb/Interpreter/OptionGroupOutputFile.h" #include "lldb/Interpreter/OptionGroupValueObjectDisplay.h" #include "lldb/Interpreter/OptionValueString.h" +#include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/TypeList.h" #include "lldb/Target/MemoryHistory.h" #include "lldb/Target/Process.h" @@ -48,6 +49,7 @@ g_option_table[] = { LLDB_OPT_SET_1, false, "num-per-line" ,'l', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeNumberPerLine ,"The number of items per line to display."}, { LLDB_OPT_SET_2, false, "binary" ,'b', OptionParser::eNoArgument , NULL, NULL, 0, eArgTypeNone ,"If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that uses the format, size, count and number per line settings."}, { LLDB_OPT_SET_3, true , "type" ,'t', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeNone ,"The name of a type to view memory as."}, + { LLDB_OPT_SET_3, false , "offset" ,'E', OptionParser::eRequiredArgument, NULL, NULL, 0, eArgTypeCount ,"How many elements of the specified type to skip before starting to display data."}, { LLDB_OPT_SET_1| LLDB_OPT_SET_2| LLDB_OPT_SET_3, false, "force" ,'r', OptionParser::eNoArgument, NULL, NULL, 0, eArgTypeNone ,"Necessary if reading over target.max-memory-read-size bytes."}, @@ -62,32 +64,32 @@ public: OptionGroupReadMemory () : m_num_per_line (1,1), m_output_as_binary (false), - m_view_as_type() + m_view_as_type(), + m_offset(0,0) { } - virtual - ~OptionGroupReadMemory () + ~OptionGroupReadMemory () override { } - virtual uint32_t - GetNumDefinitions () + uint32_t + GetNumDefinitions () override { return sizeof (g_option_table) / sizeof (OptionDefinition); } - virtual const OptionDefinition* - GetDefinitions () + const OptionDefinition* + GetDefinitions () override { return g_option_table; } - virtual Error + Error SetOptionValue (CommandInterpreter &interpreter, uint32_t option_idx, - const char *option_arg) + const char *option_arg) override { Error error; const int short_option = g_option_table[option_idx].short_option; @@ -112,6 +114,10 @@ public: m_force = true; break; + case 'E': + error = m_offset.SetValueFromString(option_arg); + break; + default: error.SetErrorStringWithFormat("unrecognized short option '%c'", short_option); break; @@ -119,13 +125,14 @@ public: return error; } - virtual void - OptionParsingStarting (CommandInterpreter &interpreter) + void + OptionParsingStarting (CommandInterpreter &interpreter) override { m_num_per_line.Clear(); m_output_as_binary = false; m_view_as_type.Clear(); m_force = false; + m_offset.Clear(); } Error @@ -271,6 +278,7 @@ public: case eFormatVectorOfUInt32: case eFormatVectorOfSInt64: case eFormatVectorOfUInt64: + case eFormatVectorOfFloat16: case eFormatVectorOfFloat32: case eFormatVectorOfFloat64: case eFormatVectorOfUInt128: @@ -290,13 +298,15 @@ public: { return m_num_per_line.OptionWasSet() || m_output_as_binary || - m_view_as_type.OptionWasSet(); + m_view_as_type.OptionWasSet() || + m_offset.OptionWasSet(); } OptionValueUInt64 m_num_per_line; bool m_output_as_binary; OptionValueString m_view_as_type; bool m_force; + OptionValueUInt64 m_offset; }; @@ -366,25 +376,25 @@ public: m_option_group.Finalize(); } - virtual - ~CommandObjectMemoryRead () + ~CommandObjectMemoryRead () override { } Options * - GetOptions () + GetOptions () override { return &m_option_group; } - virtual const char *GetRepeatCommand (Args ¤t_command_args, uint32_t index) + const char * + GetRepeatCommand (Args ¤t_command_args, uint32_t index) override { return m_cmd_name.c_str(); } protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { // No need to check "target" for validity as eCommandRequiresTarget ensures it is valid Target *target = m_exe_ctx.GetTargetPtr(); @@ -399,7 +409,7 @@ protected: return false; } - ClangASTType clang_ast_type; + CompilerType clang_ast_type; Error error; const char *view_as_type_cstr = m_memory_options.m_view_as_type.GetCurrentValue(); @@ -526,16 +536,21 @@ protected: 1, type_list); } - + if (type_list.GetSize() == 0 && lookup_type_name.GetCString() && *lookup_type_name.GetCString() == '$') { - clang::TypeDecl *tdecl = target->GetPersistentVariables().GetPersistentType(ConstString(lookup_type_name)); - if (tdecl) + if (ClangPersistentVariables *persistent_vars = llvm::dyn_cast_or_null<ClangPersistentVariables>(target->GetPersistentExpressionStateForLanguage(lldb::eLanguageTypeC))) { - clang_ast_type.SetClangType(&tdecl->getASTContext(),(const lldb::clang_type_t)tdecl->getTypeForDecl()); + clang::TypeDecl *tdecl = persistent_vars->GetPersistentType(ConstString(lookup_type_name)); + + if (tdecl) + { + clang_ast_type.SetCompilerType(ClangASTContext::GetASTContext(&tdecl->getASTContext()), + reinterpret_cast<lldb::opaque_compiler_type_t>(const_cast<clang::Type*>(tdecl->getTypeForDecl()))); + } } } - + if (clang_ast_type.IsValid() == false) { if (type_list.GetSize() == 0) @@ -549,13 +564,13 @@ protected: else { TypeSP type_sp (type_list.GetTypeAtIndex(0)); - clang_ast_type = type_sp->GetClangFullType(); + clang_ast_type = type_sp->GetFullCompilerType (); } } while (pointer_count > 0) { - ClangASTType pointer_type = clang_ast_type.GetPointerType(); + CompilerType pointer_type = clang_ast_type.GetPointerType(); if (pointer_type.IsValid()) clang_ast_type = pointer_type; else @@ -691,6 +706,9 @@ protected: m_format_options.GetFormatValue().SetCurrentValue(eFormatDefault); bytes_read = clang_ast_type.GetByteSize(nullptr) * m_format_options.GetCountValue().GetCurrentValue(); + + if (argc > 0) + addr = addr + (clang_ast_type.GetByteSize(nullptr) * m_memory_options.m_offset.GetCurrentValue()); } else if (m_format_options.GetFormatValue().GetCurrentValue() != eFormatCString) { @@ -932,7 +950,7 @@ protected: OptionGroupReadMemory m_prev_memory_options; OptionGroupOutputFile m_prev_outfile_options; OptionGroupValueObjectDisplay m_prev_varobj_options; - ClangASTType m_prev_clang_ast_type; + CompilerType m_prev_clang_ast_type; }; OptionDefinition @@ -961,27 +979,26 @@ public: { } - virtual - ~OptionGroupFindMemory () + ~OptionGroupFindMemory () override { } - virtual uint32_t - GetNumDefinitions () + uint32_t + GetNumDefinitions () override { return sizeof (g_memory_find_option_table) / sizeof (OptionDefinition); } - virtual const OptionDefinition* - GetDefinitions () + const OptionDefinition* + GetDefinitions () override { return g_memory_find_option_table; } - virtual Error + Error SetOptionValue (CommandInterpreter &interpreter, uint32_t option_idx, - const char *option_arg) + const char *option_arg) override { Error error; const int short_option = g_memory_find_option_table[option_idx].short_option; @@ -1013,8 +1030,8 @@ public: return error; } - virtual void - OptionParsingStarting (CommandInterpreter &interpreter) + void + OptionParsingStarting (CommandInterpreter &interpreter) override { m_expr.Clear(); m_string.Clear(); @@ -1042,15 +1059,15 @@ public: CommandArgumentData value_arg; // Define the first (and only) variant of this arg. - addr_arg.arg_type = eArgTypeAddress; + addr_arg.arg_type = eArgTypeAddressOrExpression; addr_arg.arg_repetition = eArgRepeatPlain; // There is only one variant this argument could be; put it into the argument entry. arg1.push_back (addr_arg); // Define the first (and only) variant of this arg. - value_arg.arg_type = eArgTypeValue; - value_arg.arg_repetition = eArgRepeatPlus; + value_arg.arg_type = eArgTypeAddressOrExpression; + value_arg.arg_repetition = eArgRepeatPlain; // There is only one variant this argument could be; put it into the argument entry. arg2.push_back (value_arg); @@ -1063,20 +1080,19 @@ public: m_option_group.Finalize(); } - virtual - ~CommandObjectMemoryFind () + ~CommandObjectMemoryFind () override { } Options * - GetOptions () + GetOptions () override { return &m_option_group; } protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { // No need to check "process" for validity as eCommandRequiresProcess ensures it is valid Process *process = m_exe_ctx.GetProcessPtr(); @@ -1119,10 +1135,11 @@ protected: { StackFrame* frame = m_exe_ctx.GetFramePtr(); ValueObjectSP result_sp; - if (process->GetTarget().EvaluateExpression(m_memory_options.m_expr.GetStringValue(), frame, result_sp) && result_sp.get()) + if ((eExpressionCompleted == process->GetTarget().EvaluateExpression(m_memory_options.m_expr.GetStringValue(), frame, result_sp)) && + result_sp.get()) { uint64_t value = result_sp->GetValueAsUnsigned(0); - switch (result_sp->GetClangType().GetByteSize(nullptr)) + switch (result_sp->GetCompilerType().GetByteSize(nullptr)) { case 1: { uint8_t byte = (uint8_t)value; @@ -1150,13 +1167,13 @@ protected: result.AppendError("unknown type. pass a string instead"); return false; default: - result.AppendError("do not know how to deal with larger than 8 byte result types. pass a string instead"); + result.AppendError("result size larger than 8 bytes. pass a string instead"); return false; } } else { - result.AppendError("expression evaluation failed. pass a string instead?"); + result.AppendError("expression evaluation failed. pass a string instead"); return false; } } @@ -1176,14 +1193,14 @@ protected: { if (!ever_found) { - result.AppendMessage("Your data was not found within the range.\n"); + result.AppendMessage("data not found within the range.\n"); result.SetStatus(lldb::eReturnStatusSuccessFinishNoResult); } else - result.AppendMessage("No more matches found within the range.\n"); + result.AppendMessage("no more matches within the range.\n"); break; } - result.AppendMessageWithFormat("Your data was found at location: 0x%" PRIx64 "\n", found_location); + result.AppendMessageWithFormat("data found at location: 0x%" PRIx64 "\n", found_location); DataBufferHeap dumpbuffer(32,0); process->ReadMemory(found_location+m_memory_options.m_offset.GetCurrentValue(), dumpbuffer.GetBytes(), dumpbuffer.GetByteSize(), error); @@ -1211,27 +1228,16 @@ protected: { Process *process = m_exe_ctx.GetProcessPtr(); DataBufferHeap heap(buffer_size, 0); - lldb::addr_t fictional_ptr = low; for (auto ptr = low; - low < high; - fictional_ptr++) + ptr < high; + ptr++) { Error error; - if (ptr == low || buffer_size == 1) - process->ReadMemory(ptr, heap.GetBytes(), buffer_size, error); - else - { - memmove(heap.GetBytes(), heap.GetBytes()+1, buffer_size-1); - process->ReadMemory(ptr, heap.GetBytes()+buffer_size-1, 1, error); - } + process->ReadMemory(ptr, heap.GetBytes(), buffer_size, error); if (error.Fail()) return LLDB_INVALID_ADDRESS; if (memcmp(heap.GetBytes(), buffer, buffer_size) == 0) - return fictional_ptr; - if (ptr == low) - ptr += buffer_size; - else - ptr += 1; + return ptr; } return LLDB_INVALID_ADDRESS; } @@ -1263,27 +1269,26 @@ public: { } - virtual - ~OptionGroupWriteMemory () + ~OptionGroupWriteMemory () override { } - virtual uint32_t - GetNumDefinitions () + uint32_t + GetNumDefinitions () override { return sizeof (g_memory_write_option_table) / sizeof (OptionDefinition); } - virtual const OptionDefinition* - GetDefinitions () + const OptionDefinition* + GetDefinitions () override { return g_memory_write_option_table; } - virtual Error + Error SetOptionValue (CommandInterpreter &interpreter, uint32_t option_idx, - const char *option_arg) + const char *option_arg) override { Error error; const int short_option = g_memory_write_option_table[option_idx].short_option; @@ -1317,8 +1322,8 @@ public: return error; } - virtual void - OptionParsingStarting (CommandInterpreter &interpreter) + void + OptionParsingStarting (CommandInterpreter &interpreter) override { m_infile.Clear(); m_infile_offset = 0; @@ -1368,13 +1373,12 @@ public: } - virtual - ~CommandObjectMemoryWrite () + ~CommandObjectMemoryWrite () override { } Options * - GetOptions () + GetOptions () override { return &m_option_group; } @@ -1407,8 +1411,8 @@ public: } protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { // No need to check "process" for validity as eCommandRequiresProcess ensures it is valid Process *process = m_exe_ctx.GetProcessPtr(); @@ -1528,6 +1532,7 @@ protected: case eFormatVectorOfUInt32: case eFormatVectorOfSInt64: case eFormatVectorOfUInt64: + case eFormatVectorOfFloat16: case eFormatVectorOfFloat32: case eFormatVectorOfFloat64: case eFormatVectorOfUInt128: @@ -1716,19 +1721,19 @@ public: m_arguments.push_back (arg1); } - virtual - ~CommandObjectMemoryHistory () + ~CommandObjectMemoryHistory () override { } - virtual const char *GetRepeatCommand (Args ¤t_command_args, uint32_t index) + const char * + GetRepeatCommand (Args ¤t_command_args, uint32_t index) override { return m_cmd_name.c_str(); } protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { const size_t argc = command.GetArgumentCount(); diff --git a/source/Commands/CommandObjectMemory.h b/source/Commands/CommandObjectMemory.h index b044921ae077..cf5b4419746c 100644 --- a/source/Commands/CommandObjectMemory.h +++ b/source/Commands/CommandObjectMemory.h @@ -23,11 +23,9 @@ class CommandObjectMemory : public CommandObjectMultiword public: CommandObjectMemory (CommandInterpreter &interpreter); - virtual - ~CommandObjectMemory (); + ~CommandObjectMemory() override; }; - } // namespace lldb_private -#endif // liblldb_CommandObjectMemory_h_ +#endif // liblldb_CommandObjectMemory_h_ diff --git a/source/Commands/CommandObjectMultiword.cpp b/source/Commands/CommandObjectMultiword.cpp index 2f0e2a78a0cc..206f3b6fb7df 100644 --- a/source/Commands/CommandObjectMultiword.cpp +++ b/source/Commands/CommandObjectMultiword.cpp @@ -382,6 +382,14 @@ CommandObjectProxy::IsMultiwordObject () return false; } +void +CommandObjectProxy::GenerateHelpText (Stream &result) +{ + CommandObject *proxy_command = GetProxyCommandObject(); + if (proxy_command) + return proxy_command->GenerateHelpText(result); +} + lldb::CommandObjectSP CommandObjectProxy::GetSubcommandSP (const char *sub_cmd, StringList *matches) { diff --git a/source/Commands/CommandObjectPlatform.cpp b/source/Commands/CommandObjectPlatform.cpp index a0979d059edb..aad8bea692e7 100644 --- a/source/Commands/CommandObjectPlatform.cpp +++ b/source/Commands/CommandObjectPlatform.cpp @@ -86,15 +86,14 @@ public: { } - virtual - ~OptionPermissions () + ~OptionPermissions () override { } - virtual lldb_private::Error + lldb_private::Error SetOptionValue (CommandInterpreter &interpreter, uint32_t option_idx, - const char *option_arg) + const char *option_arg) override { Error error; char short_option = (char) GetDefinitions()[option_idx].short_option; @@ -155,19 +154,19 @@ public: } void - OptionParsingStarting (CommandInterpreter &interpreter) + OptionParsingStarting (CommandInterpreter &interpreter) override { m_permissions = 0; } - virtual uint32_t - GetNumDefinitions () + uint32_t + GetNumDefinitions () override { return llvm::array_lengthof(g_permissions_options); } const lldb_private::OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_permissions_options; } @@ -198,19 +197,18 @@ public: m_option_group.Finalize(); } - virtual - ~CommandObjectPlatformSelect () + ~CommandObjectPlatformSelect () override { } - virtual int + int HandleCompletion (Args &input, int &cursor_index, int &cursor_char_position, int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); @@ -225,15 +223,15 @@ public: return matches.GetSize(); } - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_option_group; } protected: - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { if (args.GetArgumentCount() == 1) { @@ -291,14 +289,13 @@ public: { } - virtual - ~CommandObjectPlatformList () + ~CommandObjectPlatformList () override { } protected: - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { Stream &ostrm = result.GetOutputStream(); ostrm.Printf("Available platforms:\n"); @@ -346,14 +343,13 @@ public: { } - virtual - ~CommandObjectPlatformStatus () + ~CommandObjectPlatformStatus () override { } protected: - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { Stream &ostrm = result.GetOutputStream(); @@ -396,14 +392,13 @@ public: { } - virtual - ~CommandObjectPlatformConnect () + ~CommandObjectPlatformConnect () override { } protected: - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { Stream &ostrm = result.GetOutputStream(); @@ -414,12 +409,19 @@ protected: if (error.Success()) { platform_sp->GetStatus (ostrm); - result.SetStatus (eReturnStatusSuccessFinishResult); + result.SetStatus (eReturnStatusSuccessFinishResult); + + platform_sp->ConnectToWaitingProcesses(m_interpreter.GetDebugger(), error); + if (error.Fail()) + { + result.AppendError (error.AsCString()); + result.SetStatus (eReturnStatusFailed); + } } else { result.AppendErrorWithFormat ("%s\n", error.AsCString()); - result.SetStatus (eReturnStatusFailed); + result.SetStatus (eReturnStatusFailed); } } else @@ -430,8 +432,8 @@ protected: return result.Succeeded(); } - virtual Options * - GetOptions () + Options * + GetOptions () override { PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); OptionGroupOptions* m_platform_options = NULL; @@ -461,14 +463,13 @@ public: { } - virtual - ~CommandObjectPlatformDisconnect () + ~CommandObjectPlatformDisconnect () override { } protected: - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) @@ -543,14 +544,13 @@ public: m_options.Append (&m_option_working_dir, LLDB_OPT_SET_ALL, LLDB_OPT_SET_1); } - virtual - ~CommandObjectPlatformSettings () + ~CommandObjectPlatformSettings () override { } protected: - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) @@ -566,8 +566,8 @@ protected: return result.Succeeded(); } - virtual Options * - GetOptions () + Options * + GetOptions () override { if (m_options.DidFinalize() == false) m_options.Finalize(); @@ -597,13 +597,12 @@ public: { } - virtual - ~CommandObjectPlatformMkDir () + ~CommandObjectPlatformMkDir () override { } - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) @@ -635,8 +634,8 @@ public: return result.Succeeded(); } - virtual Options * - GetOptions () + Options * + GetOptions () override { if (m_options.DidFinalize() == false) { @@ -665,13 +664,12 @@ public: { } - virtual - ~CommandObjectPlatformFOpen () + ~CommandObjectPlatformFOpen () override { } - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) @@ -708,8 +706,8 @@ public: } return result.Succeeded(); } - virtual Options * - GetOptions () + Options * + GetOptions () override { if (m_options.DidFinalize() == false) { @@ -736,13 +734,12 @@ public: { } - virtual - ~CommandObjectPlatformFClose () + ~CommandObjectPlatformFClose () override { } - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) @@ -788,13 +785,12 @@ public: { } - virtual - ~CommandObjectPlatformFRead () + ~CommandObjectPlatformFRead () override { } - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) @@ -816,8 +812,8 @@ public: } return result.Succeeded(); } - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_options; } @@ -832,13 +828,12 @@ protected: { } - virtual - ~CommandOptions () + ~CommandOptions () override { } - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -866,14 +861,14 @@ protected: } void - OptionParsingStarting () + OptionParsingStarting () override { m_offset = 0; m_count = 1; } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -914,13 +909,12 @@ public: { } - virtual - ~CommandObjectPlatformFWrite () + ~CommandObjectPlatformFWrite () override { } - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) @@ -944,8 +938,8 @@ public: } return result.Succeeded(); } - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_options; } @@ -960,13 +954,12 @@ protected: { } - virtual - ~CommandOptions () + ~CommandOptions () override { } - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -992,14 +985,14 @@ protected: } void - OptionParsingStarting () + OptionParsingStarting () override { m_offset = 0; m_data.clear(); } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -1041,8 +1034,7 @@ public: LoadSubCommand ("write", CommandObjectSP (new CommandObjectPlatformFWrite (interpreter))); } - virtual - ~CommandObjectPlatformFile () + ~CommandObjectPlatformFile () override { } @@ -1094,13 +1086,12 @@ R"(Examples: m_arguments.push_back (arg2); } - virtual - ~CommandObjectPlatformGetFile () + ~CommandObjectPlatformGetFile () override { } - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { // If the number of arguments is incorrect, issue an error message. if (args.GetArgumentCount() != 2) @@ -1172,13 +1163,12 @@ R"(Examples: m_arguments.push_back (arg1); } - virtual - ~CommandObjectPlatformGetSize () + ~CommandObjectPlatformGetSize () override { } - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { // If the number of arguments is incorrect, issue an error message. if (args.GetArgumentCount() != 1) @@ -1228,13 +1218,12 @@ public: { } - virtual - ~CommandObjectPlatformPutFile () + ~CommandObjectPlatformPutFile () override { } - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { const char* src = args.GetArgumentAtIndex(0); const char* dst = args.GetArgumentAtIndex(1); @@ -1281,20 +1270,19 @@ public: { } - virtual - ~CommandObjectPlatformProcessLaunch () + ~CommandObjectPlatformProcessLaunch () override { } - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_options; } protected: - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); PlatformSP platform_sp; @@ -1398,20 +1386,19 @@ public: { } - virtual - ~CommandObjectPlatformProcessList () + ~CommandObjectPlatformProcessList () override { } - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_options; } protected: - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); PlatformSP platform_sp; @@ -1524,13 +1511,12 @@ protected: { } - virtual - ~CommandOptions () + ~CommandOptions () override { } - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -1620,7 +1606,7 @@ protected: } void - OptionParsingStarting () + OptionParsingStarting () override { match_info.Clear(); show_args = false; @@ -1628,7 +1614,7 @@ protected: } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -1698,14 +1684,13 @@ public: m_arguments.push_back (arg); } - virtual - ~CommandObjectPlatformProcessInfo () + ~CommandObjectPlatformProcessInfo () override { } protected: - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); PlatformSP platform_sp; @@ -1793,12 +1778,12 @@ public: OptionParsingStarting (); } - ~CommandOptions () + ~CommandOptions () override { } Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; char short_option = (char) m_getopt_table[option_idx].val; @@ -1839,18 +1824,18 @@ public: } void - OptionParsingStarting () + OptionParsingStarting () override { attach_info.Clear(); } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } - virtual bool + bool HandleOptionArgumentCompletion (Args &input, int cursor_index, int char_pos, @@ -1859,7 +1844,7 @@ public: int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos; int opt_defs_index = opt_element_vector[opt_element_index].opt_defs_index; @@ -1921,13 +1906,13 @@ public: { } - ~CommandObjectPlatformProcessAttach () + ~CommandObjectPlatformProcessAttach () override { } bool DoExecute (Args& command, - CommandReturnObject &result) + CommandReturnObject &result) override { PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); if (platform_sp) @@ -1957,7 +1942,7 @@ public: } Options * - GetOptions () + GetOptions () override { return &m_options; } @@ -1998,8 +1983,7 @@ public: } - virtual - ~CommandObjectPlatformProcess () + ~CommandObjectPlatformProcess () override { } @@ -2027,8 +2011,7 @@ public: { } - virtual - ~CommandOptions () + ~CommandOptions () override { } @@ -2038,15 +2021,15 @@ public: return 1; } - virtual const OptionDefinition* - GetDefinitions () + const OptionDefinition* + GetDefinitions () override { return g_option_table; } - virtual Error + Error SetOptionValue (uint32_t option_idx, - const char *option_value) + const char *option_value) override { Error error; @@ -2070,8 +2053,8 @@ public: return error; } - virtual void - OptionParsingStarting () + void + OptionParsingStarting () override { } @@ -2091,20 +2074,18 @@ public: { } - virtual - ~CommandObjectPlatformShell () + ~CommandObjectPlatformShell () override { } - virtual Options * - GetOptions () + GetOptions () override { return &m_options; } - virtual bool - DoExecute (const char *raw_command_line, CommandReturnObject &result) + bool + DoExecute (const char *raw_command_line, CommandReturnObject &result) override { m_options.NotifyOptionParsingStarting(); @@ -2218,13 +2199,12 @@ public: { } - virtual - ~CommandObjectPlatformInstall () + ~CommandObjectPlatformInstall () override { } - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { if (args.GetArgumentCount() != 2) { diff --git a/source/Commands/CommandObjectPlatform.h b/source/Commands/CommandObjectPlatform.h index f3bd75848649..023dff9f9827 100644 --- a/source/Commands/CommandObjectPlatform.h +++ b/source/Commands/CommandObjectPlatform.h @@ -28,13 +28,12 @@ class CommandObjectPlatform : public CommandObjectMultiword public: CommandObjectPlatform(CommandInterpreter &interpreter); - virtual - ~CommandObjectPlatform(); + ~CommandObjectPlatform() override; - private: +private: DISALLOW_COPY_AND_ASSIGN (CommandObjectPlatform); }; } // namespace lldb_private -#endif // liblldb_CommandObjectPlatform_h_ +#endif // liblldb_CommandObjectPlatform_h_ diff --git a/source/Commands/CommandObjectPlugin.cpp b/source/Commands/CommandObjectPlugin.cpp index 63fa4a82cf91..4c5a089dbcec 100644 --- a/source/Commands/CommandObjectPlugin.cpp +++ b/source/Commands/CommandObjectPlugin.cpp @@ -41,7 +41,7 @@ public: m_arguments.push_back (arg1); } - ~CommandObjectPluginLoad () + ~CommandObjectPluginLoad () override { } @@ -53,7 +53,7 @@ public: int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); @@ -71,7 +71,7 @@ public: protected: bool - DoExecute (Args& command, CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { size_t argc = command.GetArgumentCount(); diff --git a/source/Commands/CommandObjectPlugin.h b/source/Commands/CommandObjectPlugin.h index 9d0f0fcc1ed3..0a96041d2d31 100644 --- a/source/Commands/CommandObjectPlugin.h +++ b/source/Commands/CommandObjectPlugin.h @@ -13,7 +13,6 @@ // C Includes // C++ Includes - // Other libraries and framework includes // Project includes @@ -27,10 +26,9 @@ namespace lldb_private { public: CommandObjectPlugin (CommandInterpreter &interpreter); - virtual - ~CommandObjectPlugin (); + ~CommandObjectPlugin() override; }; } // namespace lldb_private -#endif // liblldb_CommandObjectPlugin_h_ +#endif // liblldb_CommandObjectPlugin_h_ diff --git a/source/Commands/CommandObjectProcess.cpp b/source/Commands/CommandObjectProcess.cpp index e587eadfa3d6..b7f894f6dcf5 100644 --- a/source/Commands/CommandObjectProcess.cpp +++ b/source/Commands/CommandObjectProcess.cpp @@ -47,7 +47,7 @@ public: CommandObjectParsed (interpreter, name, help, syntax, flags), m_new_process_action (new_process_action) {} - virtual ~CommandObjectProcessLaunchOrAttach () {} + ~CommandObjectProcessLaunchOrAttach () override {} protected: bool StopProcessIfNecessary (Process *process, StateType &state, CommandReturnObject &result) @@ -142,11 +142,11 @@ public: } - ~CommandObjectProcessLaunch () + ~CommandObjectProcessLaunch () override { } - virtual int + int HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, @@ -154,7 +154,7 @@ public: int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); @@ -171,12 +171,13 @@ public: } Options * - GetOptions () + GetOptions () override { return &m_options; } - virtual const char *GetRepeatCommand (Args ¤t_command_args, uint32_t index) + const char * + GetRepeatCommand (Args ¤t_command_args, uint32_t index) override { // No repeat for "process launch"... return ""; @@ -184,7 +185,7 @@ public: protected: bool - DoExecute (Args& launch_args, CommandReturnObject &result) + DoExecute (Args& launch_args, CommandReturnObject &result) override { Debugger &debugger = m_interpreter.GetDebugger(); Target *target = debugger.GetSelectedTarget().get(); @@ -338,12 +339,12 @@ public: OptionParsingStarting (); } - ~CommandOptions () + ~CommandOptions () override { } Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -392,18 +393,18 @@ public: } void - OptionParsingStarting () + OptionParsingStarting () override { attach_info.Clear(); } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } - virtual bool + bool HandleOptionArgumentCompletion (Args &input, int cursor_index, int char_pos, @@ -412,7 +413,7 @@ public: int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { int opt_arg_pos = opt_element_vector[opt_element_index].opt_arg_pos; int opt_defs_index = opt_element_vector[opt_element_index].opt_defs_index; @@ -476,20 +477,19 @@ public: { } - ~CommandObjectProcessAttach () + ~CommandObjectProcessAttach () override { } Options * - GetOptions () + GetOptions () override { return &m_options; } protected: bool - DoExecute (Args& command, - CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform()); @@ -646,7 +646,7 @@ public: } - ~CommandObjectProcessContinue () + ~CommandObjectProcessContinue () override { } @@ -663,12 +663,12 @@ protected: OptionParsingStarting (); } - ~CommandOptions () + ~CommandOptions () override { } Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -689,13 +689,13 @@ protected: } void - OptionParsingStarting () + OptionParsingStarting () override { m_ignore = 0; } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -708,7 +708,7 @@ protected: }; bool - DoExecute (Args& command, CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { Process *process = m_exe_ctx.GetProcessPtr(); bool synchronous_execution = m_interpreter.GetSynchronous (); @@ -807,7 +807,7 @@ protected: } Options * - GetOptions () + GetOptions () override { return &m_options; } @@ -842,12 +842,12 @@ public: OptionParsingStarting (); } - ~CommandOptions () + ~CommandOptions () override { } Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -876,13 +876,13 @@ public: } void - OptionParsingStarting () + OptionParsingStarting () override { m_keep_stopped = eLazyBoolCalculate; } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -907,12 +907,12 @@ public: { } - ~CommandObjectProcessDetach () + ~CommandObjectProcessDetach () override { } Options * - GetOptions () + GetOptions () override { return &m_options; } @@ -920,7 +920,7 @@ public: protected: bool - DoExecute (Args& command, CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { Process *process = m_exe_ctx.GetProcessPtr(); // FIXME: This will be a Command Option: @@ -982,12 +982,12 @@ public: OptionParsingStarting (); } - ~CommandOptions () + ~CommandOptions () override { } Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -1006,13 +1006,13 @@ public: } void - OptionParsingStarting () + OptionParsingStarting () override { plugin_name.clear(); } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -1036,94 +1036,61 @@ public: { } - ~CommandObjectProcessConnect () + ~CommandObjectProcessConnect () override { } Options * - GetOptions () + GetOptions () override { return &m_options; } protected: bool - DoExecute (Args& command, - CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { - - TargetSP target_sp (m_interpreter.GetDebugger().GetSelectedTarget()); - Error error; - Process *process = m_exe_ctx.GetProcessPtr(); - if (process) + if (command.GetArgumentCount() != 1) { - if (process->IsAlive()) - { - result.AppendErrorWithFormat ("Process %" PRIu64 " is currently being debugged, kill the process before connecting.\n", - process->GetID()); - result.SetStatus (eReturnStatusFailed); - return false; - } + result.AppendErrorWithFormat ("'%s' takes exactly one argument:\nUsage: %s\n", + m_cmd_name.c_str(), + m_cmd_syntax.c_str()); + result.SetStatus (eReturnStatusFailed); + return false; } + - if (!target_sp) + Process *process = m_exe_ctx.GetProcessPtr(); + if (process && process->IsAlive()) { - // If there isn't a current target create one. - - error = m_interpreter.GetDebugger().GetTargetList().CreateTarget (m_interpreter.GetDebugger(), - NULL, - NULL, - false, - NULL, // No platform options - target_sp); - if (!target_sp || error.Fail()) - { - result.AppendError(error.AsCString("Error creating target")); - result.SetStatus (eReturnStatusFailed); - return false; - } - m_interpreter.GetDebugger().GetTargetList().SetSelectedTarget(target_sp.get()); + result.AppendErrorWithFormat ("Process %" PRIu64 " is currently being debugged, kill the process before connecting.\n", + process->GetID()); + result.SetStatus (eReturnStatusFailed); + return false; } - - if (command.GetArgumentCount() == 1) - { - const char *plugin_name = NULL; - if (!m_options.plugin_name.empty()) - plugin_name = m_options.plugin_name.c_str(); - const char *remote_url = command.GetArgumentAtIndex(0); - process = target_sp->CreateProcess (m_interpreter.GetDebugger().GetListener(), plugin_name, NULL).get(); - - if (process) - { - error = process->ConnectRemote (process->GetTarget().GetDebugger().GetOutputFile().get(), remote_url); + const char *plugin_name = nullptr; + if (!m_options.plugin_name.empty()) + plugin_name = m_options.plugin_name.c_str(); - if (error.Fail()) - { - result.AppendError(error.AsCString("Remote connect failed")); - result.SetStatus (eReturnStatusFailed); - target_sp->DeleteCurrentProcess(); - return false; - } - } - else - { - result.AppendErrorWithFormat ("Unable to find process plug-in for remote URL '%s'.\nPlease specify a process plug-in name with the --plugin option, or specify an object file using the \"file\" command.\n", - remote_url); - result.SetStatus (eReturnStatusFailed); - } - } - else + Error error; + Debugger& debugger = m_interpreter.GetDebugger(); + PlatformSP platform_sp = m_interpreter.GetPlatform(true); + ProcessSP process_sp = platform_sp->ConnectProcess(command.GetArgumentAtIndex(0), + plugin_name, + debugger, + debugger.GetSelectedTarget().get(), + error); + if (error.Fail() || process_sp == nullptr) { - result.AppendErrorWithFormat ("'%s' takes exactly one argument:\nUsage: %s\n", - m_cmd_name.c_str(), - m_cmd_syntax.c_str()); + result.AppendError(error.AsCString("Error connecting to the process")); result.SetStatus (eReturnStatusFailed); + return false; } - return result.Succeeded(); + return true; } - + CommandOptions m_options; }; @@ -1152,12 +1119,12 @@ public: { } - ~CommandObjectProcessPlugin () + ~CommandObjectProcessPlugin () override { } - virtual CommandObject * - GetProxyCommandObject() + CommandObject * + GetProxyCommandObject() override { Process *process = m_interpreter.GetExecutionContext().GetProcessPtr(); if (process) @@ -1175,6 +1142,57 @@ public: class CommandObjectProcessLoad : public CommandObjectParsed { public: + class CommandOptions : public Options + { + public: + CommandOptions (CommandInterpreter &interpreter) : + Options(interpreter) + { + // Keep default values of all options in one place: OptionParsingStarting () + OptionParsingStarting (); + } + + ~CommandOptions () override = default; + + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override + { + Error error; + const int short_option = m_getopt_table[option_idx].val; + switch (short_option) + { + case 'i': + do_install = true; + if (option_arg && option_arg[0]) + install_path.SetFile(option_arg, false); + break; + default: + error.SetErrorStringWithFormat("invalid short option character '%c'", short_option); + break; + } + return error; + } + + void + OptionParsingStarting () override + { + do_install = false; + install_path.Clear(); + } + + const OptionDefinition* + GetDefinitions () override + { + return g_option_table; + } + + // Options table: Required for subclasses of Options. + static OptionDefinition g_option_table[]; + + // Instance variables to hold the values for command options. + bool do_install; + FileSpec install_path; + }; CommandObjectProcessLoad (CommandInterpreter &interpreter) : CommandObjectParsed (interpreter, @@ -1184,33 +1202,54 @@ public: eCommandRequiresProcess | eCommandTryTargetAPILock | eCommandProcessMustBeLaunched | - eCommandProcessMustBePaused ) + eCommandProcessMustBePaused ), + m_options (interpreter) { } - ~CommandObjectProcessLoad () + ~CommandObjectProcessLoad () override = default; + + Options * + GetOptions () override { + return &m_options; } protected: bool - DoExecute (Args& command, - CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { Process *process = m_exe_ctx.GetProcessPtr(); const size_t argc = command.GetArgumentCount(); - for (uint32_t i=0; i<argc; ++i) { Error error; + PlatformSP platform = process->GetTarget().GetPlatform(); const char *image_path = command.GetArgumentAtIndex(i); - FileSpec image_spec (image_path, false); - process->GetTarget().GetPlatform()->ResolveRemotePath(image_spec, image_spec); - uint32_t image_token = process->LoadImage(image_spec, error); + uint32_t image_token = LLDB_INVALID_IMAGE_TOKEN; + + if (!m_options.do_install) + { + FileSpec image_spec (image_path, false); + platform->ResolveRemotePath(image_spec, image_spec); + image_token = platform->LoadImage(process, FileSpec(), image_spec, error); + } + else if (m_options.install_path) + { + FileSpec image_spec (image_path, true); + platform->ResolveRemotePath(m_options.install_path, m_options.install_path); + image_token = platform->LoadImage(process, image_spec, m_options.install_path, error); + } + else + { + FileSpec image_spec (image_path, true); + image_token = platform->LoadImage(process, image_spec, FileSpec(), error); + } + if (image_token != LLDB_INVALID_IMAGE_TOKEN) { - result.AppendMessageWithFormat ("Loading \"%s\"...ok\nImage %u loaded.\n", image_path, image_token); + result.AppendMessageWithFormat ("Loading \"%s\"...ok\nImage %u loaded.\n", image_path, image_token); result.SetStatus (eReturnStatusSuccessFinishResult); } else @@ -1221,8 +1260,16 @@ protected: } return result.Succeeded(); } + + CommandOptions m_options; }; +OptionDefinition +CommandObjectProcessLoad::CommandOptions::g_option_table[] = +{ + { LLDB_OPT_SET_ALL, false, "install", 'i', OptionParser::eOptionalArgument, nullptr, nullptr, 0, eArgTypePath, "Install the shared library to the target. If specified without an argument then the library will installed in the current working directory."}, + { 0, false, nullptr, 0 , 0, nullptr, nullptr, 0, eArgTypeNone, nullptr } +}; //------------------------------------------------------------------------- // CommandObjectProcessUnload @@ -1245,14 +1292,13 @@ public: { } - ~CommandObjectProcessUnload () + ~CommandObjectProcessUnload () override { } protected: bool - DoExecute (Args& command, - CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { Process *process = m_exe_ctx.GetProcessPtr(); @@ -1270,7 +1316,7 @@ protected: } else { - Error error (process->UnloadImage(image_token)); + Error error (process->GetTarget().GetPlatform()->UnloadImage(process, image_token)); if (error.Success()) { result.AppendMessageWithFormat ("Unloading shared library with index %u...ok\n", image_token); @@ -1318,14 +1364,13 @@ public: m_arguments.push_back (arg); } - ~CommandObjectProcessSignal () + ~CommandObjectProcessSignal () override { } protected: bool - DoExecute (Args& command, - CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { Process *process = m_exe_ctx.GetProcessPtr(); @@ -1390,14 +1435,13 @@ public: { } - ~CommandObjectProcessInterrupt () + ~CommandObjectProcessInterrupt () override { } protected: bool - DoExecute (Args& command, - CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { Process *process = m_exe_ctx.GetProcessPtr(); if (process == NULL) @@ -1452,14 +1496,13 @@ public: { } - ~CommandObjectProcessKill () + ~CommandObjectProcessKill () override { } protected: bool - DoExecute (Args& command, - CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { Process *process = m_exe_ctx.GetProcessPtr(); if (process == NULL) @@ -1513,14 +1556,14 @@ public: { } - ~CommandObjectProcessSaveCore () + ~CommandObjectProcessSaveCore () override { } protected: bool DoExecute (Args& command, - CommandReturnObject &result) + CommandReturnObject &result) override { ProcessSP process_sp = m_exe_ctx.GetProcessSP(); if (process_sp) @@ -1575,13 +1618,13 @@ public: { } - ~CommandObjectProcessStatus() + ~CommandObjectProcessStatus() override { } bool - DoExecute (Args& command, CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { Stream &strm = result.GetOutputStream(); result.SetStatus (eReturnStatusSuccessFinishNoResult); @@ -1620,12 +1663,12 @@ public: OptionParsingStarting (); } - ~CommandOptions () + ~CommandOptions () override { } Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -1649,7 +1692,7 @@ public: } void - OptionParsingStarting () + OptionParsingStarting () override { stop.clear(); notify.clear(); @@ -1657,7 +1700,7 @@ public: } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -1694,12 +1737,12 @@ public: m_arguments.push_back (arg); } - ~CommandObjectProcessHandle () + ~CommandObjectProcessHandle () override { } Options * - GetOptions () + GetOptions () override { return &m_options; } @@ -1781,7 +1824,7 @@ public: protected: bool - DoExecute (Args &signal_args, CommandReturnObject &result) + DoExecute (Args &signal_args, CommandReturnObject &result) override { TargetSP target_sp = m_interpreter.GetDebugger().GetSelectedTarget(); diff --git a/source/Commands/CommandObjectProcess.h b/source/Commands/CommandObjectProcess.h index 0aaa74d28a07..804c34261bad 100644 --- a/source/Commands/CommandObjectProcess.h +++ b/source/Commands/CommandObjectProcess.h @@ -27,11 +27,9 @@ class CommandObjectMultiwordProcess : public CommandObjectMultiword public: CommandObjectMultiwordProcess (CommandInterpreter &interpreter); - virtual - ~CommandObjectMultiwordProcess (); - + ~CommandObjectMultiwordProcess() override; }; } // namespace lldb_private -#endif // liblldb_CommandObjectProcess_h_ +#endif // liblldb_CommandObjectProcess_h_ diff --git a/source/Commands/CommandObjectQuit.h b/source/Commands/CommandObjectQuit.h index aab0e26cce59..df9216b7e7e3 100644 --- a/source/Commands/CommandObjectQuit.h +++ b/source/Commands/CommandObjectQuit.h @@ -28,19 +28,17 @@ public: CommandObjectQuit (CommandInterpreter &interpreter); - virtual - ~CommandObjectQuit (); + ~CommandObjectQuit() override; protected: - virtual bool - DoExecute (Args& args, - CommandReturnObject &result); + bool + DoExecute(Args& args, + CommandReturnObject &result) override; bool ShouldAskForConfirmation (bool& is_a_detach); - }; } // namespace lldb_private -#endif // liblldb_CommandObjectQuit_h_ +#endif // liblldb_CommandObjectQuit_h_ diff --git a/source/Commands/CommandObjectRegister.cpp b/source/Commands/CommandObjectRegister.cpp index fae5af42f405..23a215763738 100644 --- a/source/Commands/CommandObjectRegister.cpp +++ b/source/Commands/CommandObjectRegister.cpp @@ -74,13 +74,12 @@ public: } - virtual - ~CommandObjectRegisterRead () + ~CommandObjectRegisterRead () override { } Options * - GetOptions () + GetOptions () override { return &m_option_group; } @@ -170,8 +169,8 @@ public: } protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { Stream &strm = result.GetOutputStream(); RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext (); @@ -271,33 +270,32 @@ protected: { } - virtual - ~CommandOptions () + ~CommandOptions () override { } - virtual uint32_t - GetNumDefinitions (); + uint32_t + GetNumDefinitions () override; - virtual const OptionDefinition* - GetDefinitions () + const OptionDefinition* + GetDefinitions () override { return g_option_table; } - virtual void - OptionParsingStarting (CommandInterpreter &interpreter) + void + OptionParsingStarting (CommandInterpreter &interpreter) override { set_indexes.Clear(); dump_all_sets.Clear(); alternate_name.Clear(); } - virtual Error + Error SetOptionValue (CommandInterpreter &interpreter, uint32_t option_idx, - const char *option_value) + const char *option_value) override { Error error; const int short_option = g_option_table[option_idx].short_option; @@ -404,14 +402,13 @@ public: m_arguments.push_back (arg2); } - virtual - ~CommandObjectRegisterWrite () + ~CommandObjectRegisterWrite () override { } protected: - virtual bool - DoExecute(Args& command, CommandReturnObject &result) + bool + DoExecute(Args& command, CommandReturnObject &result) override { DataExtractor reg_data; RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext (); diff --git a/source/Commands/CommandObjectRegister.h b/source/Commands/CommandObjectRegister.h index 7f856c2de529..e7b6974bc998 100644 --- a/source/Commands/CommandObjectRegister.h +++ b/source/Commands/CommandObjectRegister.h @@ -30,8 +30,7 @@ public: //------------------------------------------------------------------ CommandObjectRegister(CommandInterpreter &interpreter); - virtual - ~CommandObjectRegister(); + ~CommandObjectRegister() override; private: //------------------------------------------------------------------ @@ -42,4 +41,4 @@ private: } // namespace lldb_private -#endif // liblldb_CommandObjectRegister_h_ +#endif // liblldb_CommandObjectRegister_h_ diff --git a/source/Commands/CommandObjectSettings.cpp b/source/Commands/CommandObjectSettings.cpp index 8ed783b211f6..890d77028a99 100644 --- a/source/Commands/CommandObjectSettings.cpp +++ b/source/Commands/CommandObjectSettings.cpp @@ -83,15 +83,14 @@ insert-before or insert-after." } - virtual - ~CommandObjectSettingsSet () {} + ~CommandObjectSettingsSet () override {} // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString. - virtual bool - WantsCompletion() { return true; } + bool + WantsCompletion() override { return true; } - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_options; } @@ -106,11 +105,10 @@ insert-before or insert-after." { } - virtual - ~CommandOptions () {} + ~CommandOptions () override {} - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -129,13 +127,13 @@ insert-before or insert-after." } void - OptionParsingStarting () + OptionParsingStarting () override { m_global = false; } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -149,7 +147,7 @@ insert-before or insert-after." bool m_global; }; - virtual int + int HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, @@ -157,7 +155,7 @@ insert-before or insert-after." int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position); @@ -215,8 +213,8 @@ insert-before or insert-after." } protected: - virtual bool - DoExecute (const char *command, CommandReturnObject &result) + bool + DoExecute (const char *command, CommandReturnObject &result) override { Args cmd_args(command); @@ -321,11 +319,10 @@ public: m_arguments.push_back (arg1); } - virtual - ~CommandObjectSettingsShow () {} + ~CommandObjectSettingsShow () override {} - virtual int + int HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, @@ -333,7 +330,7 @@ public: int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position); @@ -349,8 +346,8 @@ public: } protected: - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { result.SetStatus (eReturnStatusSuccessFinishResult); @@ -414,10 +411,9 @@ public: m_arguments.push_back (arg); } - virtual - ~CommandObjectSettingsList () {} + ~CommandObjectSettingsList () override {} - virtual int + int HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, @@ -425,7 +421,7 @@ public: int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position); @@ -441,8 +437,8 @@ public: } protected: - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { result.SetStatus (eReturnStatusSuccessFinishResult); @@ -521,10 +517,9 @@ public: m_arguments.push_back (arg2); } - virtual - ~CommandObjectSettingsRemove () {} + ~CommandObjectSettingsRemove () override {} - virtual int + int HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, @@ -532,7 +527,7 @@ public: int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position); @@ -551,8 +546,8 @@ public: } protected: - virtual bool - DoExecute (const char *command, CommandReturnObject &result) + bool + DoExecute (const char *command, CommandReturnObject &result) override { result.SetStatus (eReturnStatusSuccessFinishNoResult); @@ -652,14 +647,13 @@ public: } - virtual - ~CommandObjectSettingsReplace () {} + ~CommandObjectSettingsReplace () override {} // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString. - virtual bool - WantsCompletion() { return true; } + bool + WantsCompletion() override { return true; } - virtual int + int HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, @@ -667,7 +661,7 @@ public: int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position); @@ -686,8 +680,8 @@ public: } protected: - virtual bool - DoExecute (const char *command, CommandReturnObject &result) + bool + DoExecute (const char *command, CommandReturnObject &result) override { result.SetStatus (eReturnStatusSuccessFinishNoResult); @@ -773,14 +767,13 @@ public: m_arguments.push_back (arg3); } - virtual - ~CommandObjectSettingsInsertBefore () {} + ~CommandObjectSettingsInsertBefore () override {} // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString. - virtual bool - WantsCompletion() { return true; } + bool + WantsCompletion() override { return true; } - virtual int + int HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, @@ -788,7 +781,7 @@ public: int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position); @@ -807,8 +800,8 @@ public: } protected: - virtual bool - DoExecute (const char *command, CommandReturnObject &result) + bool + DoExecute (const char *command, CommandReturnObject &result) override { result.SetStatus (eReturnStatusSuccessFinishNoResult); @@ -897,14 +890,13 @@ public: m_arguments.push_back (arg3); } - virtual - ~CommandObjectSettingsInsertAfter () {} + ~CommandObjectSettingsInsertAfter () override {} // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString. - virtual bool - WantsCompletion() { return true; } + bool + WantsCompletion() override { return true; } - virtual int + int HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, @@ -912,7 +904,7 @@ public: int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position); @@ -931,8 +923,8 @@ public: } protected: - virtual bool - DoExecute (const char *command, CommandReturnObject &result) + bool + DoExecute (const char *command, CommandReturnObject &result) override { result.SetStatus (eReturnStatusSuccessFinishNoResult); @@ -1011,14 +1003,13 @@ public: m_arguments.push_back (arg2); } - virtual - ~CommandObjectSettingsAppend () {} + ~CommandObjectSettingsAppend () override {} // Overrides base class's behavior where WantsCompletion = !WantsRawCommandString. - virtual bool - WantsCompletion() { return true; } + bool + WantsCompletion() override { return true; } - virtual int + int HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, @@ -1026,7 +1017,7 @@ public: int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position); @@ -1045,8 +1036,8 @@ public: } protected: - virtual bool - DoExecute (const char *command, CommandReturnObject &result) + bool + DoExecute (const char *command, CommandReturnObject &result) override { result.SetStatus (eReturnStatusSuccessFinishNoResult); Args cmd_args(command); @@ -1117,10 +1108,9 @@ public: m_arguments.push_back (arg); } - virtual - ~CommandObjectSettingsClear () {} + ~CommandObjectSettingsClear () override {} - virtual int + int HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, @@ -1128,7 +1118,7 @@ public: int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { std::string completion_str (input.GetArgumentAtIndex (cursor_index), cursor_char_position); @@ -1147,8 +1137,8 @@ public: } protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { result.SetStatus (eReturnStatusSuccessFinishNoResult); const size_t argc = command.GetArgumentCount (); diff --git a/source/Commands/CommandObjectSettings.h b/source/Commands/CommandObjectSettings.h index eca7adeea76f..93ee91981c10 100644 --- a/source/Commands/CommandObjectSettings.h +++ b/source/Commands/CommandObjectSettings.h @@ -31,11 +31,9 @@ public: CommandObjectMultiwordSettings (CommandInterpreter &interpreter); - virtual - ~CommandObjectMultiwordSettings (); - + ~CommandObjectMultiwordSettings() override; }; } // namespace lldb_private -#endif // liblldb_CommandObjectSettings_h_ +#endif // liblldb_CommandObjectSettings_h_ diff --git a/source/Commands/CommandObjectSource.cpp b/source/Commands/CommandObjectSource.cpp index 7c5f127cb51a..08c8d46d1ee0 100644 --- a/source/Commands/CommandObjectSource.cpp +++ b/source/Commands/CommandObjectSource.cpp @@ -49,12 +49,12 @@ class CommandObjectSourceInfo : public CommandObjectParsed { } - ~CommandOptions () + ~CommandOptions () override { } Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = g_option_table[option_idx].short_option; @@ -79,7 +79,7 @@ class CommandObjectSourceInfo : public CommandObjectParsed } void - OptionParsingStarting () + OptionParsingStarting () override { file_spec.Clear(); file_name.clear(); @@ -87,7 +87,7 @@ class CommandObjectSourceInfo : public CommandObjectParsed } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -110,20 +110,20 @@ public: { } - ~CommandObjectSourceInfo () + ~CommandObjectSourceInfo () override { } Options * - GetOptions () + GetOptions () override { return &m_options; } protected: bool - DoExecute (Args& command, CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { result.AppendError ("Not yet implemented"); result.SetStatus (eReturnStatusFailed); @@ -157,12 +157,12 @@ class CommandObjectSourceList : public CommandObjectParsed { } - ~CommandOptions () + ~CommandOptions () override { } Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = g_option_table[option_idx].short_option; @@ -213,7 +213,7 @@ class CommandObjectSourceList : public CommandObjectParsed } void - OptionParsingStarting () + OptionParsingStarting () override { file_spec.Clear(); file_name.clear(); @@ -227,7 +227,7 @@ class CommandObjectSourceList : public CommandObjectParsed } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -256,19 +256,19 @@ public: { } - ~CommandObjectSourceList () + ~CommandObjectSourceList () override { } Options * - GetOptions () + GetOptions () override { return &m_options; } - virtual const char * - GetRepeatCommand (Args ¤t_command_args, uint32_t index) + const char * + GetRepeatCommand (Args ¤t_command_args, uint32_t index) override { // This is kind of gross, but the command hasn't been parsed yet so we can't look at the option // values for this invocation... I have to scan the arguments directly. @@ -507,7 +507,7 @@ protected: } bool - DoExecute (Args& command, CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { const size_t argc = command.GetArgumentCount(); diff --git a/source/Commands/CommandObjectSource.h b/source/Commands/CommandObjectSource.h index 0daef1385860..7ed08cdc9591 100644 --- a/source/Commands/CommandObjectSource.h +++ b/source/Commands/CommandObjectSource.h @@ -30,11 +30,9 @@ public: CommandObjectMultiwordSource (CommandInterpreter &interpreter); - virtual - ~CommandObjectMultiwordSource (); - + ~CommandObjectMultiwordSource() override; }; } // namespace lldb_private -#endif // liblldb_CommandObjectSource.h_h_ +#endif // liblldb_CommandObjectSource_h_ diff --git a/source/Commands/CommandObjectSyntax.h b/source/Commands/CommandObjectSyntax.h index 47bf85f8549e..1a3e4e04f01a 100644 --- a/source/Commands/CommandObjectSyntax.h +++ b/source/Commands/CommandObjectSyntax.h @@ -28,17 +28,14 @@ public: CommandObjectSyntax (CommandInterpreter &interpreter); - virtual - ~CommandObjectSyntax (); + ~CommandObjectSyntax() override; protected: - virtual bool - DoExecute (Args& command, - CommandReturnObject &result); - - + bool + DoExecute(Args& command, + CommandReturnObject &result) override; }; } // namespace lldb_private -#endif // liblldb_CommandObjectSyntax_h_ +#endif // liblldb_CommandObjectSyntax_h_ diff --git a/source/Commands/CommandObjectTarget.cpp b/source/Commands/CommandObjectTarget.cpp index 448da0ede245..026ae3570854 100644 --- a/source/Commands/CommandObjectTarget.cpp +++ b/source/Commands/CommandObjectTarget.cpp @@ -79,7 +79,8 @@ DumpTargetInfo (uint32_t target_idx, Target *target, const char *prefix_cstr, bo uint32_t properties = 0; if (target_arch.IsValid()) { - strm.Printf ("%sarch=%s", properties++ > 0 ? ", " : " ( ", target_arch.GetTriple().str().c_str()); + strm.Printf ("%sarch=", properties++ > 0 ? ", " : " ( "); + target_arch.DumpTriple (strm); properties++; } PlatformSP platform_sp (target->GetPlatform()); @@ -187,17 +188,17 @@ public: m_option_group.Finalize(); } - ~CommandObjectTargetCreate () + ~CommandObjectTargetCreate () override { } Options * - GetOptions () + GetOptions () override { return &m_option_group; } - virtual int + int HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, @@ -205,7 +206,7 @@ public: int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); @@ -223,7 +224,7 @@ public: protected: bool - DoExecute (Args& command, CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { const size_t argc = command.GetArgumentCount(); FileSpec core_file (m_core_file.GetOptionValue().GetCurrentValue()); @@ -255,7 +256,7 @@ protected: { if (!symfile.Readable()) { - result.AppendErrorWithFormat("symbol file '%s' is not readable", core_file.GetPath().c_str()); + result.AppendErrorWithFormat("symbol file '%s' is not readable", symfile.GetPath().c_str()); result.SetStatus (eReturnStatusFailed); return false; } @@ -401,7 +402,7 @@ protected: if (process_sp) { - // Seems wierd that we Launch a core file, but that is + // Seems weird that we Launch a core file, but that is // what we do! error = process_sp->LoadCore(); @@ -477,14 +478,13 @@ public: { } - virtual - ~CommandObjectTargetList () + ~CommandObjectTargetList () override { } protected: - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { if (args.GetArgumentCount() == 0) { @@ -525,14 +525,13 @@ public: { } - virtual - ~CommandObjectTargetSelect () + ~CommandObjectTargetSelect () override { } protected: - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { if (args.GetArgumentCount() == 1) { @@ -622,20 +621,19 @@ public: m_option_group.Finalize(); } - virtual - ~CommandObjectTargetDelete () + ~CommandObjectTargetDelete () override { } Options * - GetOptions () + GetOptions () override { return &m_option_group; } protected: - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { const size_t argc = args.GetArgumentCount(); std::vector<TargetSP> delete_target_list; @@ -777,8 +775,7 @@ public: m_option_group.Finalize(); } - virtual - ~CommandObjectTargetVariable () + ~CommandObjectTargetVariable () override { } @@ -850,7 +847,7 @@ public: } Options * - GetOptions () + GetOptions () override { return &m_option_group; } @@ -896,8 +893,8 @@ protected: } } - virtual bool - DoExecute (Args& args, CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { Target *target = m_exe_ctx.GetTargetPtr(); const size_t argc = args.GetArgumentCount(); @@ -1134,14 +1131,13 @@ public: m_arguments.push_back (arg); } - ~CommandObjectTargetModulesSearchPathsAdd () + ~CommandObjectTargetModulesSearchPathsAdd () override { } protected: bool - DoExecute (Args& command, - CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target) @@ -1161,6 +1157,12 @@ protected: if (from[0] && to[0]) { + Log *log = lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_HOST); + if (log) + { + log->Printf ("target modules search path adding ImageSearchPath pair: '%s' -> '%s'", + from, to); + } bool last_pair = ((argc - i) == 2); target->GetImageSearchPathList().Append (ConstString(from), ConstString(to), @@ -1201,14 +1203,13 @@ public: { } - ~CommandObjectTargetModulesSearchPathsClear () + ~CommandObjectTargetModulesSearchPathsClear () override { } protected: bool - DoExecute (Args& command, - CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target) @@ -1271,20 +1272,19 @@ public: m_arguments.push_back (arg2); } - ~CommandObjectTargetModulesSearchPathsInsert () + ~CommandObjectTargetModulesSearchPathsInsert () override { } protected: bool - DoExecute (Args& command, - CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target) { size_t argc = command.GetArgumentCount(); - // check for at least 3 arguments and an odd nubmer of parameters + // check for at least 3 arguments and an odd number of parameters if (argc >= 3 && argc & 1) { bool success = false; @@ -1360,14 +1360,13 @@ public: { } - ~CommandObjectTargetModulesSearchPathsList () + ~CommandObjectTargetModulesSearchPathsList () override { } protected: bool - DoExecute (Args& command, - CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target) @@ -1417,14 +1416,13 @@ public: m_arguments.push_back (arg); } - ~CommandObjectTargetModulesSearchPathsQuery () + ~CommandObjectTargetModulesSearchPathsQuery () override { } protected: bool - DoExecute (Args& command, - CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target) @@ -1462,15 +1460,18 @@ DumpModuleArchitecture (Stream &strm, Module *module, bool full_triple, uint32_t { if (module) { - const char *arch_cstr; + StreamString arch_strm; + if (full_triple) - arch_cstr = module->GetArchitecture().GetTriple().str().c_str(); + module->GetArchitecture().DumpTriple(arch_strm); else - arch_cstr = module->GetArchitecture().GetArchitectureName(); + arch_strm.PutCString(module->GetArchitecture().GetArchitectureName()); + std::string arch_str = arch_strm.GetString(); + if (width) - strm.Printf("%-*s", width, arch_cstr); + strm.Printf("%-*s", width, arch_str.c_str()); else - strm.PutCString(arch_cstr); + strm.PutCString(arch_str.c_str()); } } @@ -1865,7 +1866,7 @@ LookupTypeInModule (CommandInterpreter &interpreter, { // Resolve the clang type so that any forward references // to types that haven't yet been parsed will get parsed. - type_sp->GetClangFullType (); + type_sp->GetFullCompilerType (); type_sp->GetDescription (&strm, eDescriptionLevelFull, true); // Print all typedef chains TypeSP typedef_type_sp (type_sp); @@ -1874,7 +1875,7 @@ LookupTypeInModule (CommandInterpreter &interpreter, { strm.EOL(); strm.Printf(" typedef '%s': ", typedef_type_sp->GetName().GetCString()); - typedefed_type_sp->GetClangFullType (); + typedefed_type_sp->GetFullCompilerType (); typedefed_type_sp->GetDescription (&strm, eDescriptionLevelFull, true); typedef_type_sp = typedefed_type_sp; typedefed_type_sp = typedef_type_sp->GetTypedefType(); @@ -1918,7 +1919,7 @@ LookupTypeHere (CommandInterpreter &interpreter, { // Resolve the clang type so that any forward references // to types that haven't yet been parsed will get parsed. - type_sp->GetClangFullType (); + type_sp->GetFullCompilerType (); type_sp->GetDescription (&strm, eDescriptionLevelFull, true); // Print all typedef chains TypeSP typedef_type_sp (type_sp); @@ -1927,7 +1928,7 @@ LookupTypeHere (CommandInterpreter &interpreter, { strm.EOL(); strm.Printf(" typedef '%s': ", typedef_type_sp->GetName().GetCString()); - typedefed_type_sp->GetClangFullType (); + typedefed_type_sp->GetFullCompilerType (); typedefed_type_sp->GetDescription (&strm, eDescriptionLevelFull, true); typedef_type_sp = typedefed_type_sp; typedefed_type_sp = typedef_type_sp->GetTypedefType(); @@ -2056,12 +2057,11 @@ public: m_arguments.push_back (arg); } - virtual - ~CommandObjectTargetModulesModuleAutoComplete () + ~CommandObjectTargetModulesModuleAutoComplete () override { } - virtual int + int HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, @@ -2069,7 +2069,7 @@ public: int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { // Arguments are the standard module completer. std::string completion_str (input.GetArgumentAtIndex(cursor_index)); @@ -2118,12 +2118,11 @@ public: m_arguments.push_back (arg); } - virtual - ~CommandObjectTargetModulesSourceFileAutoComplete () + ~CommandObjectTargetModulesSourceFileAutoComplete () override { } - virtual int + int HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, @@ -2131,7 +2130,7 @@ public: int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { // Arguments are the standard source file completer. std::string completion_str (input.GetArgumentAtIndex(cursor_index)); @@ -2165,13 +2164,12 @@ public: { } - virtual - ~CommandObjectTargetModulesDumpSymtab () + ~CommandObjectTargetModulesDumpSymtab () override { } - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_options; } @@ -2185,13 +2183,12 @@ public: { } - virtual - ~CommandOptions () + ~CommandOptions () override { } - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -2214,13 +2211,13 @@ public: } void - OptionParsingStarting () + OptionParsingStarting () override { m_sort_order = eSortOrderNone; } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -2232,9 +2229,8 @@ public: }; protected: - virtual bool - DoExecute (Args& command, - CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) @@ -2359,15 +2355,13 @@ public: { } - virtual - ~CommandObjectTargetModulesDumpSections () + ~CommandObjectTargetModulesDumpSections () override { } protected: - virtual bool - DoExecute (Args& command, - CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) @@ -2465,15 +2459,13 @@ public: { } - virtual - ~CommandObjectTargetModulesDumpSymfile () + ~CommandObjectTargetModulesDumpSymfile () override { } protected: - virtual bool - DoExecute (Args& command, - CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) @@ -2568,15 +2560,13 @@ public: { } - virtual - ~CommandObjectTargetModulesDumpLineTable () + ~CommandObjectTargetModulesDumpLineTable () override { } protected: - virtual bool - DoExecute (Args& command, - CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = m_exe_ctx.GetTargetPtr(); uint32_t total_num_dumped = 0; @@ -2657,8 +2647,7 @@ public: LoadSubCommand ("line-table", CommandObjectSP (new CommandObjectTargetModulesDumpLineTable (interpreter))); } - virtual - ~CommandObjectTargetModulesDump() + ~CommandObjectTargetModulesDump() override { } }; @@ -2679,18 +2668,17 @@ public: m_option_group.Finalize(); } - virtual - ~CommandObjectTargetModulesAdd () + ~CommandObjectTargetModulesAdd () override { } - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_option_group; } - virtual int + int HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, @@ -2698,7 +2686,7 @@ public: int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); @@ -2719,9 +2707,8 @@ protected: OptionGroupUUID m_uuid_option_group; OptionGroupFile m_symbol_file; - virtual bool - DoExecute (Args& args, - CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) @@ -2882,21 +2869,19 @@ public: m_option_group.Finalize(); } - virtual - ~CommandObjectTargetModulesLoad () + ~CommandObjectTargetModulesLoad () override { } - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_option_group; } protected: - virtual bool - DoExecute (Args& args, - CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) @@ -3139,13 +3124,12 @@ public: { } - virtual - ~CommandOptions () + ~CommandOptions () override { } - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; @@ -3170,7 +3154,7 @@ public: } void - OptionParsingStarting () + OptionParsingStarting () override { m_format_array.clear(); m_use_global_module_list = false; @@ -3178,7 +3162,7 @@ public: } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -3203,22 +3187,19 @@ public: { } - virtual - ~CommandObjectTargetModulesList () + ~CommandObjectTargetModulesList () override { } - virtual Options * - GetOptions () + GetOptions () override { return &m_options; } protected: - virtual bool - DoExecute (Args& command, - CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); const bool use_global_module_list = m_options.m_use_global_module_list; @@ -3584,13 +3565,12 @@ public: { } - virtual - ~CommandOptions () + ~CommandOptions () override { } - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; @@ -3625,7 +3605,7 @@ public: } void - OptionParsingStarting () + OptionParsingStarting () override { m_type = eLookupTypeInvalid; m_str.clear(); @@ -3633,7 +3613,7 @@ public: } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -3662,22 +3642,19 @@ public: { } - virtual - ~CommandObjectTargetModulesShowUnwind () + ~CommandObjectTargetModulesShowUnwind () override { } - virtual Options * - GetOptions () + GetOptions () override { return &m_options; } protected: bool - DoExecute (Args& command, - CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = m_exe_ctx.GetTargetPtr(); Process *process = m_exe_ctx.GetProcessPtr(); @@ -3813,6 +3790,14 @@ protected: result.GetOutputStream().Printf("\n"); } + UnwindPlanSP arm_unwind_sp = func_unwinders_sp->GetArmUnwindUnwindPlan(*target, 0); + if (arm_unwind_sp) + { + result.GetOutputStream().Printf("ARM.exidx unwind UnwindPlan:\n"); + arm_unwind_sp->Dump(result.GetOutputStream(), thread.get(), LLDB_INVALID_ADDRESS); + result.GetOutputStream().Printf("\n"); + } + UnwindPlanSP compact_unwind_sp = func_unwinders_sp->GetCompactUnwindUnwindPlan(*target, 0); if (compact_unwind_sp) { @@ -3891,13 +3876,12 @@ public: OptionParsingStarting(); } - virtual - ~CommandOptions () + ~CommandOptions () override { } - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; @@ -3974,7 +3958,7 @@ public: } void - OptionParsingStarting () + OptionParsingStarting () override { m_type = eLookupTypeInvalid; m_str.clear(); @@ -3989,7 +3973,7 @@ public: } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -4031,13 +4015,12 @@ public: m_arguments.push_back (arg); } - virtual - ~CommandObjectTargetModulesLookup () + ~CommandObjectTargetModulesLookup () override { } - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_options; } @@ -4191,9 +4174,8 @@ public: } protected: - virtual bool - DoExecute (Args& command, - CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get(); if (target == NULL) @@ -4339,7 +4321,7 @@ public: LoadSubCommand ("query", CommandObjectSP (new CommandObjectTargetModulesSearchPathsQuery (interpreter))); } - ~CommandObjectTargetModulesImageSearchPaths() + ~CommandObjectTargetModulesImageSearchPaths() override { } }; @@ -4373,8 +4355,8 @@ public: LoadSubCommand ("show-unwind", CommandObjectSP (new CommandObjectTargetModulesShowUnwind (interpreter))); } - virtual - ~CommandObjectTargetModules() + + ~CommandObjectTargetModules() override { } @@ -4406,12 +4388,11 @@ public: m_option_group.Finalize(); } - virtual - ~CommandObjectTargetSymbolsAdd () + ~CommandObjectTargetSymbolsAdd () override { } - virtual int + int HandleArgumentCompletion (Args &input, int &cursor_index, int &cursor_char_position, @@ -4419,7 +4400,7 @@ public: int match_start_point, int max_return_elements, bool &word_complete, - StringList &matches) + StringList &matches) override { std::string completion_str (input.GetArgumentAtIndex(cursor_index)); completion_str.erase (cursor_char_position); @@ -4435,8 +4416,8 @@ public: return matches.GetSize(); } - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_option_group; } @@ -4614,9 +4595,8 @@ protected: return false; } - virtual bool - DoExecute (Args& args, - CommandReturnObject &result) + bool + DoExecute (Args& args, CommandReturnObject &result) override { Target *target = m_exe_ctx.GetTargetPtr(); result.SetStatus (eReturnStatusFailed); @@ -4834,8 +4814,8 @@ public: LoadSubCommand ("add", CommandObjectSP (new CommandObjectTargetSymbolsAdd (interpreter))); } - virtual - ~CommandObjectTargetSymbols() + + ~CommandObjectTargetSymbols() override { } @@ -4874,16 +4854,16 @@ public: { } - ~CommandOptions () {} + ~CommandOptions () override {} const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -4970,7 +4950,7 @@ public: } void - OptionParsingStarting () + OptionParsingStarting () override { m_class_name.clear(); m_function_name.clear(); @@ -5015,7 +4995,7 @@ public: }; Options * - GetOptions () + GetOptions () override { return &m_options; } @@ -5030,13 +5010,13 @@ public: { } - ~CommandObjectTargetStopHookAdd () + ~CommandObjectTargetStopHookAdd () override { } protected: - virtual void - IOHandlerActivated (IOHandler &io_handler) + void + IOHandlerActivated (IOHandler &io_handler) override { StreamFileSP output_sp(io_handler.GetOutputStreamFile()); if (output_sp) @@ -5046,8 +5026,8 @@ protected: } } - virtual void - IOHandlerInputComplete (IOHandler &io_handler, std::string &line) + void + IOHandlerInputComplete (IOHandler &io_handler, std::string &line) override { if (m_stop_hook_sp) { @@ -5079,7 +5059,7 @@ protected: } bool - DoExecute (Args& command, CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { m_stop_hook_sp.reset(); @@ -5227,13 +5207,13 @@ public: { } - ~CommandObjectTargetStopHookDelete () + ~CommandObjectTargetStopHookDelete () override { } protected: bool - DoExecute (Args& command, CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = GetSelectedOrDummyTarget(); if (target) @@ -5303,13 +5283,13 @@ public: { } - ~CommandObjectTargetStopHookEnableDisable () + ~CommandObjectTargetStopHookEnableDisable () override { } protected: bool - DoExecute (Args& command, CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = GetSelectedOrDummyTarget(); if (target) @@ -5373,13 +5353,13 @@ public: { } - ~CommandObjectTargetStopHookList () + ~CommandObjectTargetStopHookList () override { } protected: bool - DoExecute (Args& command, CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { Target *target = GetSelectedOrDummyTarget(); if (!target) @@ -5439,7 +5419,7 @@ public: LoadSubCommand ("list", CommandObjectSP (new CommandObjectTargetStopHookList (interpreter))); } - ~CommandObjectMultiwordTargetStopHooks() + ~CommandObjectMultiwordTargetStopHooks() override { } }; diff --git a/source/Commands/CommandObjectTarget.h b/source/Commands/CommandObjectTarget.h index 7b6637812c4c..d99a2b07f9a7 100644 --- a/source/Commands/CommandObjectTarget.h +++ b/source/Commands/CommandObjectTarget.h @@ -30,12 +30,9 @@ public: CommandObjectMultiwordTarget (CommandInterpreter &interpreter); - virtual - ~CommandObjectMultiwordTarget (); - - + ~CommandObjectMultiwordTarget() override; }; } // namespace lldb_private -#endif // liblldb_CommandObjectTarget_h_ +#endif // liblldb_CommandObjectTarget_h_ diff --git a/source/Commands/CommandObjectThread.cpp b/source/Commands/CommandObjectThread.cpp index 5f38ad4900d6..e932c9d96c35 100644 --- a/source/Commands/CommandObjectThread.cpp +++ b/source/Commands/CommandObjectThread.cpp @@ -58,9 +58,10 @@ public: { } - virtual ~CommandObjectIterateOverThreads() {} - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + ~CommandObjectIterateOverThreads() override {} + + bool + DoExecute (Args& command, CommandReturnObject &result) override { result.SetStatus (m_success_return); @@ -162,13 +163,12 @@ public: OptionParsingStarting (); } - virtual - ~CommandOptions () + ~CommandOptions () override { } - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -211,7 +211,7 @@ public: } void - OptionParsingStarting () + OptionParsingStarting () override { m_count = UINT32_MAX; m_start = 0; @@ -219,7 +219,7 @@ public: } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -248,12 +248,12 @@ public: { } - ~CommandObjectThreadBacktrace() + ~CommandObjectThreadBacktrace() override { } - virtual Options * - GetOptions () + Options * + GetOptions () override { return &m_options; } @@ -285,8 +285,8 @@ protected: } } - virtual bool - HandleOneThread (Thread &thread, CommandReturnObject &result) + bool + HandleOneThread (Thread &thread, CommandReturnObject &result) override { Stream &strm = result.GetOutputStream(); @@ -343,13 +343,12 @@ public: OptionParsingStarting (); } - virtual - ~CommandOptions () + ~CommandOptions () override { } - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -426,7 +425,7 @@ public: } void - OptionParsingStarting () + OptionParsingStarting () override { m_step_in_avoid_no_debug = eLazyBoolCalculate; m_step_out_avoid_no_debug = eLazyBoolCalculate; @@ -444,7 +443,7 @@ public: } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -493,21 +492,19 @@ public: m_arguments.push_back (arg); } - virtual - ~CommandObjectThreadStepWithTypeAndScope () + ~CommandObjectThreadStepWithTypeAndScope () override { } - virtual Options * - GetOptions () + GetOptions () override { return &m_options; } protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { Process *process = m_exe_ctx.GetProcessPtr(); bool synchronous_execution = m_interpreter.GetSynchronous(); @@ -589,7 +586,7 @@ protected: if (frame->HasDebugInformation ()) { new_plan_sp = thread->QueueThreadPlanForStepInRange (abort_other_plans, - frame->GetSymbolContext(eSymbolContextEverything).line_entry.range, + frame->GetSymbolContext(eSymbolContextEverything).line_entry, frame->GetSymbolContext(eSymbolContextEverything), m_options.m_step_in_target.c_str(), stop_other_threads, @@ -612,7 +609,7 @@ protected: if (frame->HasDebugInformation()) new_plan_sp = thread->QueueThreadPlanForStepOverRange (abort_other_plans, - frame->GetSymbolContext(eSymbolContextEverything).line_entry.range, + frame->GetSymbolContext(eSymbolContextEverything).line_entry, frame->GetSymbolContext(eSymbolContextEverything), stop_other_threads, m_options.m_step_out_avoid_no_debug); @@ -780,13 +777,12 @@ public: } - virtual - ~CommandObjectThreadContinue () + ~CommandObjectThreadContinue () override { } - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { bool synchronous_execution = m_interpreter.GetSynchronous (); @@ -980,13 +976,12 @@ public: OptionParsingStarting (); } - virtual - ~CommandOptions () + ~CommandOptions () override { } - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { Error error; const int short_option = m_getopt_table[option_idx].val; @@ -1042,7 +1037,7 @@ public: } void - OptionParsingStarting () + OptionParsingStarting () override { m_thread_idx = LLDB_INVALID_THREAD_ID; m_frame_idx = 0; @@ -1051,7 +1046,7 @@ public: } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -1093,21 +1088,19 @@ public: } - virtual - ~CommandObjectThreadUntil () + ~CommandObjectThreadUntil () override { } - virtual Options * - GetOptions () + GetOptions () override { return &m_options; } protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { bool synchronous_execution = m_interpreter.GetSynchronous (); @@ -1371,14 +1364,13 @@ public: } - virtual - ~CommandObjectThreadSelect () + ~CommandObjectThreadSelect () override { } protected: - virtual bool - DoExecute (Args& command, CommandReturnObject &result) + bool + DoExecute (Args& command, CommandReturnObject &result) override { Process *process = m_exe_ctx.GetProcessPtr(); if (process == NULL) @@ -1434,13 +1426,13 @@ public: { } - ~CommandObjectThreadList() + ~CommandObjectThreadList() override { } protected: bool - DoExecute (Args& command, CommandReturnObject &result) + DoExecute (Args& command, CommandReturnObject &result) override { Stream &strm = result.GetOutputStream(); result.SetStatus (eReturnStatusSuccessFinishNoResult); @@ -1492,19 +1484,18 @@ public: } void - OptionParsingStarting () + OptionParsingStarting () override { m_json_thread = false; m_json_stopinfo = false; } - virtual - ~CommandOptions () + ~CommandOptions () override { } - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_arg) override { const int short_option = m_getopt_table[option_idx].val; Error error; @@ -1527,7 +1518,7 @@ public: } const OptionDefinition* - GetDefinitions () + GetDefinitions () override { return g_option_table; } @@ -1538,21 +1529,18 @@ public: static OptionDefinition g_option_table[]; }; - virtual Options * - GetOptions () + GetOptions () override { return &m_options; } - - virtual - ~CommandObjectThreadInfo () + ~CommandObjectThreadInfo () override { } - virtual bool - HandleOneThread (Thread &thread, CommandReturnObject &result) + bool + HandleOneThread (Thread &thread, CommandReturnObject &result) override { Stream &strm = result.GetOutputStream(); if (!thread.GetDescription (strm, eDescriptionLevelFull, m_options.m_json_thread, m_options.m_json_stopinfo)) @@ -1597,13 +1585,12 @@ public: OptionParsingStarting (); } - virtual - ~CommandOptions () + ~CommandOptions () override { } - virtual Error - SetOptionValue (uint32_t option_idx, const char *option_arg) + Error + SetOptionValue (uint32_t option_idx, const char *option_a |