diff options
Diffstat (limited to 'contrib/llvm/tools/lldb/source/API')
24 files changed, 845 insertions, 619 deletions
diff --git a/contrib/llvm/tools/lldb/source/API/SBAttachInfo.cpp b/contrib/llvm/tools/lldb/source/API/SBAttachInfo.cpp index 07446df..0f2ab7a 100644 --- a/contrib/llvm/tools/lldb/source/API/SBAttachInfo.cpp +++ b/contrib/llvm/tools/lldb/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/contrib/llvm/tools/lldb/source/API/SBBreakpoint.cpp b/contrib/llvm/tools/lldb/source/API/SBBreakpoint.cpp index dd4c80c..1f58ddb 100644 --- a/contrib/llvm/tools/lldb/source/API/SBBreakpoint.cpp +++ b/contrib/llvm/tools/lldb/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/contrib/llvm/tools/lldb/source/API/SBCommandInterpreter.cpp b/contrib/llvm/tools/lldb/source/API/SBCommandInterpreter.cpp index d901e72..21f431d 100644 --- a/contrib/llvm/tools/lldb/source/API/SBCommandInterpreter.cpp +++ b/contrib/llvm/tools/lldb/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/contrib/llvm/tools/lldb/source/API/SBCommandReturnObject.cpp b/contrib/llvm/tools/lldb/source/API/SBCommandReturnObject.cpp index 1ae2df7..a2ed4d6 100644 --- a/contrib/llvm/tools/lldb/source/API/SBCommandReturnObject.cpp +++ b/contrib/llvm/tools/lldb/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/contrib/llvm/tools/lldb/source/API/SBDebugger.cpp b/contrib/llvm/tools/lldb/source/API/SBDebugger.cpp index df2019f..1645294 100644 --- a/contrib/llvm/tools/lldb/source/API/SBDebugger.cpp +++ b/contrib/llvm/tools/lldb/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/contrib/llvm/tools/lldb/source/API/SBFrame.cpp b/contrib/llvm/tools/lldb/source/API/SBFrame.cpp index 08a5822..02a215b 100644 --- a/contrib/llvm/tools/lldb/source/API/SBFrame.cpp +++ b/contrib/llvm/tools/lldb/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/contrib/llvm/tools/lldb/source/API/SBFunction.cpp b/contrib/llvm/tools/lldb/source/API/SBFunction.cpp index 2ec6072..2d03d53 100644 --- a/contrib/llvm/tools/lldb/source/API/SBFunction.cpp +++ b/contrib/llvm/tools/lldb/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/contrib/llvm/tools/lldb/source/API/SBLanguageRuntime.cpp b/contrib/llvm/tools/lldb/source/API/SBLanguageRuntime.cpp index 93a54cd..743343e 100644 --- a/contrib/llvm/tools/lldb/source/API/SBLanguageRuntime.cpp +++ b/contrib/llvm/tools/lldb/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/contrib/llvm/tools/lldb/source/API/SBModule.cpp b/contrib/llvm/tools/lldb/source/API/SBModule.cpp index 0249a7e..a810940 100644 --- a/contrib/llvm/tools/lldb/source/API/SBModule.cpp +++ b/contrib/llvm/tools/lldb/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/contrib/llvm/tools/lldb/source/API/SBPlatform.cpp b/contrib/llvm/tools/lldb/source/API/SBPlatform.cpp index 97ffcf1..b8dc01b 100644 --- a/contrib/llvm/tools/lldb/source/API/SBPlatform.cpp +++ b/contrib/llvm/tools/lldb/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/contrib/llvm/tools/lldb/source/API/SBProcess.cpp b/contrib/llvm/tools/lldb/source/API/SBProcess.cpp index 01bfaf9..4255472 100644 --- a/contrib/llvm/tools/lldb/source/API/SBProcess.cpp +++ b/contrib/llvm/tools/lldb/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), @@ -994,7 +995,14 @@ SBProcess::GetStateFromEvent (const SBEvent &event) bool SBProcess::GetRestartedFromEvent (const SBEvent &event) { - return Process::ProcessEventData::GetRestartedFromEvent (event.get()); + Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + + bool ret_val = Process::ProcessEventData::GetRestartedFromEvent (event.get()); + + if (log) + log->Printf ("SBProcess::%s (event.sp=%p) => %d", __FUNCTION__, event.get(), ret_val); + + return ret_val; } size_t @@ -1287,7 +1295,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 +1312,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 +1341,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 +1446,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/contrib/llvm/tools/lldb/source/API/SBStream.cpp b/contrib/llvm/tools/lldb/source/API/SBStream.cpp index f50334f..f3be3be 100644 --- a/contrib/llvm/tools/lldb/source/API/SBStream.cpp +++ b/contrib/llvm/tools/lldb/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/contrib/llvm/tools/lldb/source/API/SBTarget.cpp b/contrib/llvm/tools/lldb/source/API/SBTarget.cpp index 6597d4e..c7595c3 100644 --- a/contrib/llvm/tools/lldb/source/API/SBTarget.cpp +++ b/contrib/llvm/tools/lldb/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/contrib/llvm/tools/lldb/source/API/SBThread.cpp b/contrib/llvm/tools/lldb/source/API/SBThread.cpp index 42b5c9a..2f3887e 100644 --- a/contrib/llvm/tools/lldb/source/API/SBThread.cpp +++ b/contrib/llvm/tools/lldb/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/contrib/llvm/tools/lldb/source/API/SBType.cpp b/contrib/llvm/tools/lldb/source/API/SBType.cpp index 31a4eba..4922b49 100644 --- a/contrib/llvm/tools/lldb/source/API/SBType.cpp +++ b/contrib/llvm/tools/lldb/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/contrib/llvm/tools/lldb/source/API/SBTypeCategory.cpp b/contrib/llvm/tools/lldb/source/API/SBTypeCategory.cpp index ee9553c..33dada8 100644 --- a/contrib/llvm/tools/lldb/source/API/SBTypeCategory.cpp +++ b/contrib/llvm/tools/lldb/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/contrib/llvm/tools/lldb/source/API/SBTypeEnumMember.cpp b/contrib/llvm/tools/lldb/source/API/SBTypeEnumMember.cpp index 47c57dd..c23f7ea 100644 --- a/contrib/llvm/tools/lldb/source/API/SBTypeEnumMember.cpp +++ b/contrib/llvm/tools/lldb/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/contrib/llvm/tools/lldb/source/API/SBTypeNameSpecifier.cpp b/contrib/llvm/tools/lldb/source/API/SBTypeNameSpecifier.cpp index c587471..6f68010 100644 --- a/contrib/llvm/tools/lldb/source/API/SBTypeNameSpecifier.cpp +++ b/contrib/llvm/tools/lldb/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/contrib/llvm/tools/lldb/source/API/SBTypeSummary.cpp b/contrib/llvm/tools/lldb/source/API/SBTypeSummary.cpp index 2c11454..2985b76 100644 --- a/contrib/llvm/tools/lldb/source/API/SBTypeSummary.cpp +++ b/contrib/llvm/tools/lldb/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/contrib/llvm/tools/lldb/source/API/SBValue.cpp b/contrib/llvm/tools/lldb/source/API/SBValue.cpp index ef62c30..a8584c5 100644 --- a/contrib/llvm/tools/lldb/source/API/SBValue.cpp +++ b/contrib/llvm/tools/lldb/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/contrib/llvm/tools/lldb/source/API/SBValueList.cpp b/contrib/llvm/tools/lldb/source/API/SBValueList.cpp index 71fabe0..5461b05 100644 --- a/contrib/llvm/tools/lldb/source/API/SBValueList.cpp +++ b/contrib/llvm/tools/lldb/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/contrib/llvm/tools/lldb/source/API/SystemInitializerFull.cpp b/contrib/llvm/tools/lldb/source/API/SystemInitializerFull.cpp index 80a87d4..1616b47 100644 --- a/contrib/llvm/tools/lldb/source/API/SystemInitializerFull.cpp +++ b/contrib/llvm/tools/lldb/source/API/SystemInitializerFull.cpp @@ -7,12 +7,25 @@ // //===----------------------------------------------------------------------===// +#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/SysV-arm/ABISysV_arm.h" #include "Plugins/ABI/SysV-arm64/ABISysV_arm64.h" @@ -27,11 +40,13 @@ #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/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.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" @@ -42,6 +57,10 @@ #if defined(__APPLE__) #include "Plugins/Process/mach-core/ProcessMachCore.h" #include "Plugins/Process/MacOSX-Kernel/ProcessKDP.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__) @@ -50,11 +69,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" @@ -66,9 +82,19 @@ using namespace lldb_private; #ifndef LLDB_DISABLE_PYTHON // Defined in the SWIG source file -extern "C" void +#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 @@ -116,7 +142,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); @@ -213,9 +239,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(); @@ -223,6 +257,9 @@ SystemInitializerFull::Initialize() llvm::InitializeAllTargetMCs(); llvm::InitializeAllDisassemblers(); + ClangASTContext::Initialize(); + GoASTContext::Initialize(); + ABISysV_arm::Initialize(); ABISysV_arm64::Initialize(); ABISysV_i386::Initialize(); @@ -235,6 +272,9 @@ SystemInitializerFull::Initialize() JITLoaderGDB::Initialize(); ProcessElfCore::Initialize(); +#if defined(_MSC_VER) + ProcessWinMiniDump::Initialize(); +#endif MemoryHistoryASan::Initialize(); AddressSanitizerRuntime::Initialize(); @@ -247,8 +287,10 @@ SystemInitializerFull::Initialize() SymbolFileDWARFDebugMap::Initialize(); ItaniumABILanguageRuntime::Initialize(); + CPlusPlusLanguage::Initialize(); + #if defined(_MSC_VER) - ProcessWindows::Initialize(); + ProcessWindowsLive::Initialize(); #endif #if defined(__FreeBSD__) ProcessFreeBSD::Initialize(); @@ -257,6 +299,10 @@ SystemInitializerFull::Initialize() SymbolVendorMacOSX::Initialize(); ProcessKDP::Initialize(); ProcessMachCore::Initialize(); + PlatformAppleTVSimulator::Initialize(); + PlatformAppleWatchSimulator::Initialize(); + PlatformRemoteAppleTV::Initialize(); + PlatformRemoteAppleWatch::Initialize(); #endif //---------------------------------------------------------------------- // Platform agnostic plugins @@ -279,7 +325,7 @@ void SystemInitializerFull::InitializeSWIG() { #if !defined(LLDB_DISABLE_PYTHON) ScriptInterpreterPython::InitializeInterpreter( - init_lldb, + LLDBSwigPyInit, LLDBSwigPythonBreakpointCallbackFunction, LLDBSwigPythonWatchpointCallbackFunction, LLDBSwigPythonCallTypeScript, @@ -317,6 +363,10 @@ SystemInitializerFull::Terminate() // Terminate and unload and loaded system or user LLDB plug-ins PluginManager::Terminate(); + + ClangASTContext::Terminate(); + GoASTContext::Terminate(); + ABISysV_arm::Terminate(); ABISysV_arm64::Terminate(); ABISysV_i386::Terminate(); @@ -329,6 +379,9 @@ SystemInitializerFull::Terminate() JITLoaderGDB::Terminate(); ProcessElfCore::Terminate(); +#if defined(_MSC_VER) + ProcessWinMiniDump::Terminate(); +#endif MemoryHistoryASan::Terminate(); AddressSanitizerRuntime::Terminate(); SymbolVendorELF::Terminate(); @@ -340,10 +393,16 @@ SystemInitializerFull::Terminate() SymbolFileDWARFDebugMap::Terminate(); ItaniumABILanguageRuntime::Terminate(); + CPlusPlusLanguage::Terminate(); + #if defined(__APPLE__) ProcessMachCore::Terminate(); ProcessKDP::Terminate(); SymbolVendorMacOSX::Terminate(); + PlatformAppleTVSimulator::Terminate(); + PlatformAppleWatchSimulator::Terminate(); + PlatformRemoteAppleTV::Terminate(); + PlatformRemoteAppleWatch::Terminate(); #endif #if defined(__FreeBSD__) @@ -358,8 +417,3 @@ SystemInitializerFull::Terminate() // Now shutdown the common parts, in reverse order. SystemInitializerCommon::Terminate(); } - -void SystemInitializerFull::TerminateSWIG() -{ - -} diff --git a/contrib/llvm/tools/lldb/source/API/liblldb.exports b/contrib/llvm/tools/lldb/source/API/liblldb.exports new file mode 100644 index 0000000..fd234d1 --- /dev/null +++ b/contrib/llvm/tools/lldb/source/API/liblldb.exports @@ -0,0 +1,3 @@ +_ZN4lldb* +_ZNK4lldb* +init_lld* diff --git a/contrib/llvm/tools/lldb/source/API/liblldb.xcode.exports b/contrib/llvm/tools/lldb/source/API/liblldb.xcode.exports new file mode 100644 index 0000000..9c194fa --- /dev/null +++ b/contrib/llvm/tools/lldb/source/API/liblldb.xcode.exports @@ -0,0 +1,3 @@ +__ZN4lldb* +__ZNK4lldb* +_init_lld* |