diff options
Diffstat (limited to 'contrib/llvm/tools/lldb/source/API')
-rw-r--r-- | contrib/llvm/tools/lldb/source/API/SBBreakpoint.cpp | 1 | ||||
-rw-r--r-- | contrib/llvm/tools/lldb/source/API/SBCommandInterpreter.cpp | 16 | ||||
-rw-r--r-- | contrib/llvm/tools/lldb/source/API/SBDebugger.cpp | 112 | ||||
-rw-r--r-- | contrib/llvm/tools/lldb/source/API/SBFrame.cpp | 52 | ||||
-rw-r--r-- | contrib/llvm/tools/lldb/source/API/SBInputReader.cpp | 216 | ||||
-rw-r--r-- | contrib/llvm/tools/lldb/source/API/SBModule.cpp | 19 | ||||
-rw-r--r-- | contrib/llvm/tools/lldb/source/API/SBProcess.cpp | 47 | ||||
-rw-r--r-- | contrib/llvm/tools/lldb/source/API/SBQueue.cpp | 368 | ||||
-rw-r--r-- | contrib/llvm/tools/lldb/source/API/SBQueueItem.cpp | 120 | ||||
-rw-r--r-- | contrib/llvm/tools/lldb/source/API/SBTarget.cpp | 185 | ||||
-rw-r--r-- | contrib/llvm/tools/lldb/source/API/SBType.cpp | 8 | ||||
-rw-r--r-- | contrib/llvm/tools/lldb/source/API/SBTypeCategory.cpp | 56 | ||||
-rw-r--r-- | contrib/llvm/tools/lldb/source/API/SBTypeFormat.cpp | 56 | ||||
-rw-r--r-- | contrib/llvm/tools/lldb/source/API/SBValue.cpp | 23 |
14 files changed, 833 insertions, 446 deletions
diff --git a/contrib/llvm/tools/lldb/source/API/SBBreakpoint.cpp b/contrib/llvm/tools/lldb/source/API/SBBreakpoint.cpp index 11ad149..fbdc0e3 100644 --- a/contrib/llvm/tools/lldb/source/API/SBBreakpoint.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBBreakpoint.cpp @@ -23,6 +23,7 @@ #include "lldb/Core/Stream.h" #include "lldb/Core/StreamFile.h" #include "lldb/Target/Process.h" +#include "lldb/Target/SectionLoadList.h" #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadSpec.h" diff --git a/contrib/llvm/tools/lldb/source/API/SBCommandInterpreter.cpp b/contrib/llvm/tools/lldb/source/API/SBCommandInterpreter.cpp index ac77e2e..f1faa13 100644 --- a/contrib/llvm/tools/lldb/source/API/SBCommandInterpreter.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBCommandInterpreter.cpp @@ -107,6 +107,22 @@ SBCommandInterpreter::AliasExists (const char *cmd) return false; } +bool +SBCommandInterpreter::IsActive () +{ + if (m_opaque_ptr) + return m_opaque_ptr->IsActive (); + return false; +} + +const char * +SBCommandInterpreter::GetIOHandlerControlSequence(char ch) +{ + if (m_opaque_ptr) + return m_opaque_ptr->GetDebugger().GetTopIOHandlerControlSequence (ch).GetCString(); + return NULL; +} + lldb::ReturnStatus SBCommandInterpreter::HandleCommand (const char *command_line, SBCommandReturnObject &result, bool add_to_history) { diff --git a/contrib/llvm/tools/lldb/source/API/SBDebugger.cpp b/contrib/llvm/tools/lldb/source/API/SBDebugger.cpp index 10c0b7d..8d6887a 100644 --- a/contrib/llvm/tools/lldb/source/API/SBDebugger.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBDebugger.cpp @@ -20,7 +20,6 @@ #include "lldb/API/SBError.h" #include "lldb/API/SBEvent.h" #include "lldb/API/SBFrame.h" -#include "lldb/API/SBInputReader.h" #include "lldb/API/SBProcess.h" #include "lldb/API/SBSourceManager.h" #include "lldb/API/SBStream.h" @@ -37,6 +36,7 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/State.h" +#include "lldb/Core/StreamFile.h" #include "lldb/DataFormatters/DataVisualization.h" #include "lldb/Host/DynamicLibrary.h" #include "lldb/Interpreter/Args.h" @@ -49,6 +49,29 @@ using namespace lldb; using namespace lldb_private; +SBInputReader::SBInputReader() +{ +} +SBInputReader::~SBInputReader() +{ +} + +SBError +SBInputReader::Initialize(lldb::SBDebugger& sb_debugger, unsigned long (*)(void*, lldb::SBInputReader*, lldb::InputReaderAction, char const*, unsigned long), void*, lldb::InputReaderGranularity, char const*, char const*, bool) +{ + return SBError(); +} + +void +SBInputReader::SetIsDone(bool) +{ +} +bool +SBInputReader::IsActive() const +{ + return false; +} + static lldb::DynamicLibrarySP LoadPlugin (const lldb::DebuggerSP &debugger_sp, const FileSpec& spec, Error& error) { @@ -111,7 +134,7 @@ SBDebugger::Clear () log->Printf ("SBDebugger(%p)::Clear ()", m_opaque_sp.get()); if (m_opaque_sp) - m_opaque_sp->CleanUpInputReaders (); + m_opaque_sp->ClearIOHandlers (); m_opaque_sp.reset(); } @@ -309,7 +332,11 @@ FILE * SBDebugger::GetInputFileHandle () { if (m_opaque_sp) - return m_opaque_sp->GetInputFile().GetStream(); + { + StreamFileSP stream_file_sp (m_opaque_sp->GetInputFile()); + if (stream_file_sp) + return stream_file_sp->GetFile().GetStream(); + } return NULL; } @@ -317,7 +344,11 @@ FILE * SBDebugger::GetOutputFileHandle () { if (m_opaque_sp) - return m_opaque_sp->GetOutputFile().GetStream(); + { + StreamFileSP stream_file_sp (m_opaque_sp->GetOutputFile()); + if (stream_file_sp) + return stream_file_sp->GetFile().GetStream(); + } return NULL; } @@ -325,7 +356,12 @@ FILE * SBDebugger::GetErrorFileHandle () { if (m_opaque_sp) - return m_opaque_sp->GetErrorFile().GetStream(); + if (m_opaque_sp) + { + StreamFileSP stream_file_sp (m_opaque_sp->GetErrorFile()); + if (stream_file_sp) + return stream_file_sp->GetFile().GetStream(); + } return NULL; } @@ -885,17 +921,17 @@ SBDebugger::DispatchInput (void* baton, const void *data, size_t data_len) void SBDebugger::DispatchInput (const void *data, size_t data_len) { - Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - - if (log) - log->Printf ("SBDebugger(%p)::DispatchInput (data=\"%.*s\", size_t=%" PRIu64 ")", - m_opaque_sp.get(), - (int) data_len, - (const char *) data, - (uint64_t)data_len); - - if (m_opaque_sp) - m_opaque_sp->DispatchInput ((const char *) data, data_len); +// Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); +// +// if (log) +// log->Printf ("SBDebugger(%p)::DispatchInput (data=\"%.*s\", size_t=%" PRIu64 ")", +// m_opaque_sp.get(), +// (int) data_len, +// (const char *) data, +// (uint64_t)data_len); +// +// if (m_opaque_sp) +// m_opaque_sp->DispatchInput ((const char *) data, data_len); } void @@ -911,54 +947,18 @@ SBDebugger::DispatchInputEndOfFile () if (m_opaque_sp) m_opaque_sp->DispatchInputEndOfFile (); } - -bool -SBDebugger::InputReaderIsTopReader (const lldb::SBInputReader &reader) -{ - Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - - if (log) - log->Printf ("SBDebugger(%p)::InputReaderIsTopReader (SBInputReader(%p))", m_opaque_sp.get(), &reader); - - if (m_opaque_sp && reader.IsValid()) - { - InputReaderSP reader_sp (*reader); - return m_opaque_sp->InputReaderIsTopReader (reader_sp); - } - - return false; -} - void SBDebugger::PushInputReader (SBInputReader &reader) { - Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - - if (log) - log->Printf ("SBDebugger(%p)::PushInputReader (SBInputReader(%p))", m_opaque_sp.get(), &reader); - - if (m_opaque_sp && reader.IsValid()) - { - TargetSP target_sp (m_opaque_sp->GetSelectedTarget()); - Mutex::Locker api_locker; - if (target_sp) - api_locker.Lock(target_sp->GetAPIMutex()); - InputReaderSP reader_sp(*reader); - m_opaque_sp->PushInputReader (reader_sp); - } } void -SBDebugger::NotifyTopInputReader (InputReaderAction notification) +SBDebugger::RunCommandInterpreter (bool auto_handle_events, + bool spawn_thread) { - Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - - if (log) - log->Printf ("SBDebugger(%p)::NotifyTopInputReader (%d)", m_opaque_sp.get(), notification); - if (m_opaque_sp) - m_opaque_sp->NotifyTopInputReader (notification); + m_opaque_sp->GetCommandInterpreter().RunCommandInterpreter(auto_handle_events, spawn_thread); } void @@ -1050,7 +1050,7 @@ SBDebugger::GetInternalVariableValue (const char *var_name, const char *debugger if (!value_str.empty()) { StringList string_list; - string_list.SplitIntoLines(value_str.c_str(), value_str.size()); + string_list.SplitIntoLines(value_str); return SBStringList(&string_list); } } diff --git a/contrib/llvm/tools/lldb/source/API/SBFrame.cpp b/contrib/llvm/tools/lldb/source/API/SBFrame.cpp index 1a1a63b..44fc654 100644 --- a/contrib/llvm/tools/lldb/source/API/SBFrame.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBFrame.cpp @@ -845,6 +845,8 @@ SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueTy frame = exe_ctx.GetFramePtr(); if (frame) { + VariableList variable_list; + switch (value_type) { case eValueTypeVariableGlobal: // global variable @@ -852,8 +854,7 @@ SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueTy case eValueTypeVariableArgument: // function argument variables case eValueTypeVariableLocal: // function local variables { - VariableList *variable_list = frame->GetVariableList(true); - + SymbolContext sc (frame->GetSymbolContext (eSymbolContextBlock)); const bool can_create = true; @@ -863,21 +864,22 @@ SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueTy if (sc.block && sc.block->AppendVariables (can_create, get_parent_variables, stop_if_block_is_inlined_function, - variable_list)) + &variable_list)) { + if (value_type == eValueTypeVariableGlobal) + { + const bool get_file_globals = true; + VariableList* frame_vars = frame->GetVariableList(get_file_globals); + if (frame_vars) + frame_vars->AppendVariablesIfUnique(variable_list); + } ConstString const_name(name); - const uint32_t num_variables = variable_list->GetSize(); - for (uint32_t i = 0; i < num_variables; ++i) + VariableSP variable_sp(variable_list.FindVariable(const_name,value_type)); + if (variable_sp) { - VariableSP variable_sp (variable_list->GetVariableAtIndex(i)); - if (variable_sp && - variable_sp->GetScope() == value_type && - variable_sp->GetName() == const_name) - { - value_sp = frame->GetValueObjectForFrameVariable (variable_sp, eNoDynamicValues); - sb_value.SetSP (value_sp, use_dynamic); - break; - } + value_sp = frame->GetValueObjectForFrameVariable (variable_sp, eNoDynamicValues); + sb_value.SetSP (value_sp, use_dynamic); + break; } } } @@ -1386,20 +1388,22 @@ SBFrame::EvaluateExpression (const char *expr, const SBExpressionOptions &option frame = exe_ctx.GetFramePtr(); if (frame) { -#ifdef LLDB_CONFIGURATION_DEBUG - StreamString frame_description; - frame->DumpUsingSettingsFormat (&frame_description); - Host::SetCrashDescriptionWithFormat ("SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s", - expr, options.GetFetchDynamicValue(), frame_description.GetString().c_str()); -#endif - exe_results = target->EvaluateExpression (expr, + if (target->GetDisplayExpressionsInCrashlogs()) + { + StreamString frame_description; + frame->DumpUsingSettingsFormat (&frame_description); + Host::SetCrashDescriptionWithFormat ("SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s", + expr, options.GetFetchDynamicValue(), frame_description.GetString().c_str()); + } + + exe_results = target->EvaluateExpression (expr, frame, expr_value_sp, options.ref()); expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue()); -#ifdef LLDB_CONFIGURATION_DEBUG - Host::SetCrashDescription (NULL); -#endif + + if (target->GetDisplayExpressionsInCrashlogs()) + Host::SetCrashDescription (NULL); } else { diff --git a/contrib/llvm/tools/lldb/source/API/SBInputReader.cpp b/contrib/llvm/tools/lldb/source/API/SBInputReader.cpp deleted file mode 100644 index 82b75c8..0000000 --- a/contrib/llvm/tools/lldb/source/API/SBInputReader.cpp +++ /dev/null @@ -1,216 +0,0 @@ -//===-- SBInputReader.cpp ---------------------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - - -#include "lldb/lldb-enumerations.h" - -#include "lldb/API/SBDebugger.h" -#include "lldb/API/SBError.h" -#include "lldb/API/SBInputReader.h" -#include "lldb/API/SBStream.h" -#include "lldb/API/SBStringList.h" -#include "lldb/Core/InputReader.h" -#include "lldb/Core/Log.h" - - -using namespace lldb; -using namespace lldb_private; - -SBInputReader::SBInputReader () : - m_opaque_sp (), - m_callback_function (NULL), - m_callback_baton (NULL) - -{ -} - -SBInputReader::SBInputReader (const lldb::InputReaderSP &reader_sp) : - m_opaque_sp (reader_sp) -{ - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - - if (log) - log->Printf ("SBInputReader::SBInputReader (reader_sp=%p) => SBInputReader(%p)", reader_sp.get(), - m_opaque_sp.get()); -} - -SBInputReader::SBInputReader (const SBInputReader &rhs) : - m_opaque_sp (rhs.m_opaque_sp) -{ - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - - if (log) - log->Printf("SBInputReader::SBInputReader (rhs.sp=%p) => SBInputReader(%p)", - rhs.m_opaque_sp.get(), m_opaque_sp.get()); -} - -SBInputReader::~SBInputReader () -{ -} - -size_t -SBInputReader::PrivateCallback -( - void *baton, - InputReader &reader, - lldb::InputReaderAction notification, - const char *bytes, - size_t bytes_len -) -{ - SBInputReader *sb_reader = (SBInputReader *)baton; - return sb_reader->m_callback_function (sb_reader->m_callback_baton, - sb_reader, - notification, - bytes, - bytes_len); -} - -SBError -SBInputReader::Initialize -( - SBDebugger &debugger, - Callback callback_function, - void *callback_baton, - lldb::InputReaderGranularity granularity, - const char *end_token, - const char *prompt, - bool echo -) -{ - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - - if (log) - log->Printf("SBInputReader(%p)::Initialize (SBDebugger(%p), callback_function=%p, callback_baton=%p, " - "granularity=%s, end_token=\"%s\", prompt=\"%s\", echo=%i)", - m_opaque_sp.get(), - debugger.get(), - callback_function, - callback_baton, - InputReader::GranularityAsCString (granularity), end_token, prompt, - echo); - - SBError sb_error; - m_opaque_sp.reset (new InputReader (debugger.ref())); - - m_callback_function = callback_function; - m_callback_baton = callback_baton; - - if (m_opaque_sp) - { - sb_error.SetError (m_opaque_sp->Initialize (SBInputReader::PrivateCallback, - this, - granularity, - end_token, - prompt, - echo)); - } - - if (sb_error.Fail()) - { - m_opaque_sp.reset (); - m_callback_function = NULL; - m_callback_baton = NULL; - } - - if (log) - { - SBStream sstr; - sb_error.GetDescription (sstr); - log->Printf ("SBInputReader(%p)::Initialize (...) => SBError(%p): %s", m_opaque_sp.get(), - sb_error.get(), sstr.GetData()); - } - - return sb_error; -} - -bool -SBInputReader::IsValid () const -{ - return (m_opaque_sp.get() != NULL); -} - -const SBInputReader & -SBInputReader::operator = (const SBInputReader &rhs) -{ - if (this != &rhs) - m_opaque_sp = rhs.m_opaque_sp; - return *this; -} - -InputReader * -SBInputReader::operator->() const -{ - return m_opaque_sp.get(); -} - -lldb::InputReaderSP & -SBInputReader::operator *() -{ - return m_opaque_sp; -} - -const lldb::InputReaderSP & -SBInputReader::operator *() const -{ - return m_opaque_sp; -} - -InputReader * -SBInputReader::get() const -{ - return m_opaque_sp.get(); -} - -InputReader & -SBInputReader::ref() const -{ - assert (m_opaque_sp.get()); - return *m_opaque_sp; -} - -bool -SBInputReader::IsDone () const -{ - if (m_opaque_sp) - return m_opaque_sp->IsDone(); - else - return true; -} - -void -SBInputReader::SetIsDone (bool value) -{ - if (m_opaque_sp) - m_opaque_sp->SetIsDone (value); -} - -bool -SBInputReader::IsActive () const -{ - Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); - - bool ret_value = false; - if (m_opaque_sp) - ret_value = m_opaque_sp->IsActive(); - - if (log) - log->Printf ("SBInputReader(%p)::IsActive () => %i", m_opaque_sp.get(), ret_value); - - return ret_value; -} - -InputReaderGranularity -SBInputReader::GetGranularity () -{ - if (m_opaque_sp) - return m_opaque_sp->GetGranularity(); - else - return eInputReaderGranularityInvalid; -} diff --git a/contrib/llvm/tools/lldb/source/API/SBModule.cpp b/contrib/llvm/tools/lldb/source/API/SBModule.cpp index 0285cf3..c8543d4 100644 --- a/contrib/llvm/tools/lldb/source/API/SBModule.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBModule.cpp @@ -69,7 +69,7 @@ SBModule::SBModule (lldb::SBProcess &process, lldb::addr_t header_addr) : { Target &target = process_sp->GetTarget(); bool changed = false; - m_opaque_sp->SetLoadAddress(target, 0, changed); + m_opaque_sp->SetLoadAddress(target, 0, true, changed); target.GetImages().Append(m_opaque_sp); } } @@ -579,6 +579,23 @@ SBModule::FindTypes (const char *type) return retval; } +lldb::SBType +SBModule::GetTypeByID (lldb::user_id_t uid) +{ + ModuleSP module_sp (GetSP ()); + if (module_sp) + { + SymbolVendor* vendor = module_sp->GetSymbolVendor(); + if (vendor) + { + Type *type_ptr = vendor->ResolveTypeUID(uid); + if (type_ptr) + return SBType(type_ptr->shared_from_this()); + } + } + return SBType(); +} + lldb::SBTypeList SBModule::GetTypes (uint32_t type_mask) { diff --git a/contrib/llvm/tools/lldb/source/API/SBProcess.cpp b/contrib/llvm/tools/lldb/source/API/SBProcess.cpp index 557006f..235388b 100644 --- a/contrib/llvm/tools/lldb/source/API/SBProcess.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBProcess.cpp @@ -535,6 +535,53 @@ SBProcess::GetThreadAtIndex (size_t index) } uint32_t +SBProcess::GetNumQueues () +{ + Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + + uint32_t num_queues = 0; + ProcessSP process_sp(GetSP()); + if (process_sp) + { + Process::StopLocker stop_locker; + + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + num_queues = process_sp->GetQueueList().GetSize(); + } + + if (log) + log->Printf ("SBProcess(%p)::GetNumQueues () => %d", process_sp.get(), num_queues); + + return num_queues; +} + +SBQueue +SBProcess::GetQueueAtIndex (size_t index) +{ + Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + + SBQueue sb_queue; + QueueSP queue_sp; + ProcessSP process_sp(GetSP()); + if (process_sp) + { + Process::StopLocker stop_locker; + Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex()); + queue_sp = process_sp->GetQueueList().GetQueueAtIndex(index); + sb_queue.SetQueue (queue_sp); + } + + if (log) + { + log->Printf ("SBProcess(%p)::GetQueueAtIndex (index=%d) => SBQueue(%p)", + process_sp.get(), (uint32_t) index, queue_sp.get()); + } + + return sb_queue; +} + + +uint32_t SBProcess::GetStopID(bool include_expression_stops) { ProcessSP process_sp(GetSP()); diff --git a/contrib/llvm/tools/lldb/source/API/SBQueue.cpp b/contrib/llvm/tools/lldb/source/API/SBQueue.cpp new file mode 100644 index 0000000..8d67a48 --- /dev/null +++ b/contrib/llvm/tools/lldb/source/API/SBQueue.cpp @@ -0,0 +1,368 @@ +//===-- SBQueue.cpp ---------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/lldb-python.h" + +#include "lldb/API/SBQueue.h" + +#include "lldb/API/SBProcess.h" +#include "lldb/API/SBThread.h" +#include "lldb/Core/Log.h" +#include "lldb/Target/Process.h" +#include "lldb/Target/Queue.h" +#include "lldb/Target/QueueItem.h" +#include "lldb/Target/Thread.h" + +using namespace lldb; +using namespace lldb_private; + +namespace lldb_private +{ + + class QueueImpl + { + public: + QueueImpl () : + m_queue_wp(), + m_threads(), + m_thread_list_fetched(false), + m_pending_items(), + m_pending_items_fetched(false) + { + } + + QueueImpl (const lldb::QueueSP &queue_sp) : + m_queue_wp(), + m_threads(), + m_thread_list_fetched(false), + m_pending_items(), + m_pending_items_fetched(false) + { + m_queue_wp = queue_sp; + } + + QueueImpl (const QueueImpl &rhs) + { + if (&rhs == this) + return; + m_queue_wp = rhs.m_queue_wp; + m_threads = rhs.m_threads; + m_thread_list_fetched = rhs.m_thread_list_fetched; + m_pending_items = rhs.m_pending_items; + m_pending_items_fetched = rhs.m_pending_items_fetched; + } + + ~QueueImpl () + { + } + + bool + IsValid () + { + return m_queue_wp.lock() != NULL; + } + + void + Clear () + { + m_queue_wp.reset(); + m_thread_list_fetched = false; + m_threads.clear(); + m_pending_items_fetched = false; + m_pending_items.clear(); + } + + void + SetQueue (const lldb::QueueSP &queue_sp) + { + Clear(); + m_queue_wp = queue_sp; + } + + lldb::queue_id_t + GetQueueID () const + { + lldb::queue_id_t result = LLDB_INVALID_QUEUE_ID; + lldb::QueueSP queue_sp = m_queue_wp.lock(); + if (queue_sp) + { + result = queue_sp->GetID(); + } + Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + log->Printf ("SBQueue(%p)::GetQueueID () => 0x%" PRIx64, this, result); + return result; + } + + uint32_t + GetIndexID () const + { + uint32_t result = LLDB_INVALID_INDEX32; + lldb::QueueSP queue_sp = m_queue_wp.lock(); + if (queue_sp) + { + result = queue_sp->GetIndexID(); + } + Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + log->Printf ("SBQueueImpl(%p)::GetIndexID () => %d", this, result); + return result; + } + + const char * + GetName () const + { + const char *name = NULL; + lldb::QueueSP queue_sp = m_queue_wp.lock (); + if (queue_sp.get()) + { + name = queue_sp->GetName(); + } + + Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + if (log) + log->Printf ("SBQueueImpl(%p)::GetName () => %s", this, name ? name : "NULL"); + + return name; + } + + void + FetchThreads () + { + if (m_thread_list_fetched == false) + { + lldb::QueueSP queue_sp = m_queue_wp.lock(); + if (queue_sp) + { + Process::StopLocker stop_locker; + if (stop_locker.TryLock (&queue_sp->GetProcess()->GetRunLock())) + { + const std::vector<ThreadSP> thread_list(queue_sp->GetThreads()); + m_thread_list_fetched = true; + const uint32_t num_threads = thread_list.size(); + for (uint32_t idx = 0; idx < num_threads; ++idx) + { + ThreadSP thread_sp = thread_list[idx]; + if (thread_sp && thread_sp->IsValid()) + { + m_threads.push_back (thread_sp); + } + } + } + } + } + } + + void + FetchItems () + { + if (m_pending_items_fetched == false) + { + QueueSP queue_sp = m_queue_wp.lock(); + if (queue_sp) + { + Process::StopLocker stop_locker; + if (stop_locker.TryLock (&queue_sp->GetProcess()->GetRunLock())) + { + const std::vector<QueueItemSP> queue_items(queue_sp->GetPendingItems()); + m_pending_items_fetched = true; + const uint32_t num_pending_items = queue_items.size(); + for (uint32_t idx = 0; idx < num_pending_items; ++idx) + { + QueueItemSP item = queue_items[idx]; + if (item && item->IsValid()) + { + m_pending_items.push_back (item); + } + } + } + } + } + } + + uint32_t + GetNumThreads () + { + uint32_t result = 0; + + FetchThreads(); + if (m_thread_list_fetched) + { + result = m_threads.size(); + } + return result; + } + + lldb::SBThread + GetThreadAtIndex (uint32_t idx) + { + FetchThreads(); + + SBThread sb_thread; + QueueSP queue_sp = m_queue_wp.lock(); + if (queue_sp && idx < m_threads.size()) + { + ProcessSP process_sp = queue_sp->GetProcess(); + if (process_sp) + { + ThreadSP thread_sp = m_threads[idx].lock(); + if (thread_sp) + { + sb_thread.SetThread (thread_sp); + } + } + } + return sb_thread; + } + + + uint32_t + GetNumPendingItems () + { + uint32_t result = 0; + FetchItems(); + + if (m_pending_items_fetched) + { + result = m_pending_items.size(); + } + return result; + } + + lldb::SBQueueItem + GetPendingItemAtIndex (uint32_t idx) + { + SBQueueItem result; + FetchItems(); + if (m_pending_items_fetched && idx < m_pending_items.size()) + { + result.SetQueueItem (m_pending_items[idx]); + } + return result; + } + + lldb::SBProcess + GetProcess () + { + SBProcess result; + QueueSP queue_sp = m_queue_wp.lock(); + if (queue_sp) + { + result.SetSP (queue_sp->GetProcess()); + } + return result; + } + + private: + lldb::QueueWP m_queue_wp; + std::vector<lldb::ThreadWP> m_threads; // threads currently executing this queue's items + bool m_thread_list_fetched; // have we tried to fetch the threads list already? + std::vector<lldb::QueueItemSP> m_pending_items; // items currently enqueued + bool m_pending_items_fetched; // have we tried to fetch the item list already? + }; + +} + +SBQueue::SBQueue () : + m_opaque_sp (new QueueImpl()) +{ +} + +SBQueue::SBQueue (const QueueSP& queue_sp) : + m_opaque_sp (new QueueImpl (queue_sp)) +{ +} + +SBQueue::SBQueue (const SBQueue &rhs) +{ + if (&rhs == this) + return; + + m_opaque_sp = rhs.m_opaque_sp; +} + +const lldb::SBQueue & +SBQueue::operator = (const lldb::SBQueue &rhs) +{ + m_opaque_sp = rhs.m_opaque_sp; + return *this; +} + +SBQueue::~SBQueue() +{ +} + +bool +SBQueue::IsValid() const +{ + return m_opaque_sp->IsValid(); +} + + +void +SBQueue::Clear () +{ + m_opaque_sp->Clear(); +} + + +void +SBQueue::SetQueue (const QueueSP& queue_sp) +{ + m_opaque_sp->SetQueue (queue_sp); +} + +lldb::queue_id_t +SBQueue::GetQueueID () const +{ + return m_opaque_sp->GetQueueID (); +} + +uint32_t +SBQueue::GetIndexID () const +{ + return m_opaque_sp->GetIndexID (); +} + +const char * +SBQueue::GetName () const +{ + return m_opaque_sp->GetName (); +} + +uint32_t +SBQueue::GetNumThreads () +{ + return m_opaque_sp->GetNumThreads (); +} + +SBThread +SBQueue::GetThreadAtIndex (uint32_t idx) +{ + return m_opaque_sp->GetThreadAtIndex (idx); +} + + +uint32_t +SBQueue::GetNumPendingItems () +{ + return m_opaque_sp->GetNumPendingItems (); +} + +SBQueueItem +SBQueue::GetPendingItemAtIndex (uint32_t idx) +{ + return m_opaque_sp->GetPendingItemAtIndex (idx); +} + +SBProcess +SBQueue::GetProcess () +{ + return m_opaque_sp->GetProcess(); +} diff --git a/contrib/llvm/tools/lldb/source/API/SBQueueItem.cpp b/contrib/llvm/tools/lldb/source/API/SBQueueItem.cpp new file mode 100644 index 0000000..481d51e --- /dev/null +++ b/contrib/llvm/tools/lldb/source/API/SBQueueItem.cpp @@ -0,0 +1,120 @@ +//===-- SBQueueItem.cpp -----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/lldb-python.h" +#include "lldb/lldb-forward.h" + +#include "lldb/API/SBAddress.h" +#include "lldb/API/SBQueueItem.h" +#include "lldb/API/SBThread.h" +#include "lldb/Core/Address.h" +#include "lldb/Target/QueueItem.h" +#include "lldb/Target/Thread.h" + +using namespace lldb; +using namespace lldb_private; + +//---------------------------------------------------------------------- +// Constructors +//---------------------------------------------------------------------- +SBQueueItem::SBQueueItem () : + m_queue_item_sp() +{ +} + +SBQueueItem::SBQueueItem (const QueueItemSP& queue_item_sp) : + m_queue_item_sp (queue_item_sp) +{ +} + +//---------------------------------------------------------------------- +// Destructor +//---------------------------------------------------------------------- +SBQueueItem::~SBQueueItem() +{ + m_queue_item_sp.reset(); +} + +bool +SBQueueItem::IsValid() const +{ + return m_queue_item_sp.get() != NULL; +} + + +void +SBQueueItem::Clear () +{ + m_queue_item_sp.reset(); +} + + +void +SBQueueItem::SetQueueItem (const QueueItemSP& queue_item_sp) +{ + m_queue_item_sp = queue_item_sp; +} + + +lldb::QueueItemKind +SBQueueItem::GetKind () const +{ + QueueItemKind result = eQueueItemKindUnknown; + if (m_queue_item_sp) + { + result = m_queue_item_sp->GetKind (); + } + return result; +} + +void +SBQueueItem::SetKind (lldb::QueueItemKind kind) +{ + if (m_queue_item_sp) + { + m_queue_item_sp->SetKind (kind); + } +} + +SBAddress +SBQueueItem::GetAddress () const +{ + SBAddress result; + if (m_queue_item_sp) + { + result.SetAddress (&m_queue_item_sp->GetAddress()); + } + return result; +} + +void +SBQueueItem::SetAddress (SBAddress addr) +{ + if (m_queue_item_sp) + { + m_queue_item_sp->SetAddress (addr.ref()); + } +} + +SBThread +SBQueueItem::GetExtendedBacktraceThread (const char *type) +{ + SBThread result; + if (m_queue_item_sp) + { + ThreadSP thread_sp; + ConstString type_const (type); + thread_sp = m_queue_item_sp->GetExtendedBacktraceThread (type_const); + if (thread_sp) + { + result.SetThread (thread_sp); + } + } + return result; +} diff --git a/contrib/llvm/tools/lldb/source/API/SBTarget.cpp b/contrib/llvm/tools/lldb/source/API/SBTarget.cpp index c8bc217..224349c 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/VariableList.h" #include "lldb/Target/LanguageRuntime.h" #include "lldb/Target/Process.h" + #include "lldb/Target/Target.h" #include "lldb/Target/TargetList.h" @@ -688,57 +689,26 @@ SBTarget::Launch return sb_process; } } - else - { - if (listener.IsValid()) - process_sp = target_sp->CreateProcess (listener.ref(), NULL, NULL); - else - process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), NULL, NULL); - } - if (process_sp) - { - sb_process.SetSP (process_sp); - if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO")) - launch_flags |= eLaunchFlagDisableSTDIO; + if (getenv("LLDB_LAUNCH_FLAG_DISABLE_STDIO")) + launch_flags |= eLaunchFlagDisableSTDIO; - ProcessLaunchInfo launch_info (stdin_path, stdout_path, stderr_path, working_directory, launch_flags); - - Module *exe_module = target_sp->GetExecutableModulePointer(); - if (exe_module) - launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true); - if (argv) - launch_info.GetArguments().AppendArguments (argv); - if (envp) - launch_info.GetEnvironmentEntries ().SetArguments (envp); - - error.SetError (process_sp->Launch (launch_info)); - if (error.Success()) - { - // We we are stopping at the entry point, we can return now! - if (stop_at_entry) - return sb_process; - - // Make sure we are stopped at the entry - StateType state = process_sp->WaitForProcessToStop (NULL); - if (state == eStateStopped) - { - // resume the process to skip the entry point - error.SetError (process_sp->Resume()); - if (error.Success()) - { - // If we are doing synchronous mode, then wait for the - // process to stop yet again! - if (target_sp->GetDebugger().GetAsyncExecution () == false) - process_sp->WaitForProcessToStop (NULL); - } - } - } - } + ProcessLaunchInfo launch_info (stdin_path, stdout_path, stderr_path, working_directory, launch_flags); + + Module *exe_module = target_sp->GetExecutableModulePointer(); + if (exe_module) + launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true); + if (argv) + launch_info.GetArguments().AppendArguments (argv); + if (envp) + launch_info.GetEnvironmentEntries ().SetArguments (envp); + + if (listener.IsValid()) + error.SetError (target_sp->Launch(listener.ref(), launch_info)); else - { - error.SetErrorString ("unable to create lldb_private::Process"); - } + error.SetError (target_sp->Launch(target_sp->GetDebugger().GetListener(), launch_info)); + + sb_process.SetSP(target_sp->GetProcessSP()); } else { @@ -749,7 +719,7 @@ SBTarget::Launch if (log) { log->Printf ("SBTarget(%p)::Launch (...) => SBProcess(%p)", - target_sp.get(), process_sp.get()); + target_sp.get(), sb_process.GetSP().get()); } return sb_process; @@ -761,7 +731,6 @@ SBTarget::Launch (SBLaunchInfo &sb_launch_info, SBError& error) Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); SBProcess sb_process; - ProcessSP process_sp; TargetSP target_sp(GetSP()); if (log) @@ -773,7 +742,8 @@ SBTarget::Launch (SBLaunchInfo &sb_launch_info, SBError& error) { Mutex::Locker api_locker (target_sp->GetAPIMutex()); StateType state = eStateInvalid; - process_sp = target_sp->GetProcessSP(); + { + ProcessSP process_sp = target_sp->GetProcessSP(); if (process_sp) { state = process_sp->GetState(); @@ -787,58 +757,20 @@ SBTarget::Launch (SBLaunchInfo &sb_launch_info, SBError& error) return sb_process; } } - - if (state != eStateConnected) - process_sp = target_sp->CreateProcess (target_sp->GetDebugger().GetListener(), NULL, NULL); - - if (process_sp) - { - sb_process.SetSP (process_sp); - lldb_private::ProcessLaunchInfo &launch_info = sb_launch_info.ref(); + } - Module *exe_module = target_sp->GetExecutableModulePointer(); - if (exe_module) - launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true); + lldb_private::ProcessLaunchInfo &launch_info = sb_launch_info.ref(); - const ArchSpec &arch_spec = target_sp->GetArchitecture(); - if (arch_spec.IsValid()) - launch_info.GetArchitecture () = arch_spec; - - error.SetError (process_sp->Launch (launch_info)); - const bool synchronous_execution = target_sp->GetDebugger().GetAsyncExecution () == false; - if (error.Success()) - { - if (launch_info.GetFlags().Test(eLaunchFlagStopAtEntry)) - { - // If we are doing synchronous mode, then wait for the initial - // stop to happen, else, return and let the caller watch for - // the stop - if (synchronous_execution) - process_sp->WaitForProcessToStop (NULL); - // We we are stopping at the entry point, we can return now! - return sb_process; - } - - // Make sure we are stopped at the entry - StateType state = process_sp->WaitForProcessToStop (NULL); - if (state == eStateStopped) - { - // resume the process to skip the entry point - error.SetError (process_sp->Resume()); - if (error.Success()) - { - // If we are doing synchronous mode, then wait for the - // process to stop yet again! - if (synchronous_execution) - process_sp->WaitForProcessToStop (NULL); - } - } - } - } - else - { - error.SetErrorString ("unable to create lldb_private::Process"); - } + Module *exe_module = target_sp->GetExecutableModulePointer(); + if (exe_module) + launch_info.SetExecutableFile(exe_module->GetPlatformFileSpec(), true); + + const ArchSpec &arch_spec = target_sp->GetArchitecture(); + if (arch_spec.IsValid()) + launch_info.GetArchitecture () = arch_spec; + + error.SetError (target_sp->Launch (target_sp->GetDebugger().GetListener(), launch_info)); + sb_process.SetSP(target_sp->GetProcessSP()); } else { @@ -848,8 +780,8 @@ SBTarget::Launch (SBLaunchInfo &sb_launch_info, SBError& error) log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API); if (log) { - log->Printf ("SBTarget(%p)::Launch (...) => SBProcess(%p)", - target_sp.get(), process_sp.get()); + log->Printf ("SBTarget(%p)::Launch (...) => SBProcess(%p)", + target_sp.get(), sb_process.GetSP().get()); } return sb_process; @@ -1263,7 +1195,7 @@ SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr) if (target_sp) { Mutex::Locker api_locker (target_sp->GetAPIMutex()); - if (target_sp->GetSectionLoadList().ResolveLoadAddress (vm_addr, addr)) + if (target_sp->ResolveLoadAddress (vm_addr, addr)) return sb_addr; } @@ -1273,6 +1205,26 @@ SBTarget::ResolveLoadAddress (lldb::addr_t vm_addr) return sb_addr; } + +lldb::SBAddress +SBTarget::ResolvePastLoadAddress (uint32_t stop_id, lldb::addr_t vm_addr) +{ + lldb::SBAddress sb_addr; + Address &addr = sb_addr.ref(); + TargetSP target_sp(GetSP()); + if (target_sp) + { + Mutex::Locker api_locker (target_sp->GetAPIMutex()); + if (target_sp->ResolveLoadAddress (vm_addr, addr)) + return sb_addr; + } + + // We have a load address that isn't in a section, just return an address + // with the offset filled in (the address) and the section set to NULL + addr.SetRawAddress(vm_addr); + return sb_addr; +} + SBSymbolContext SBTarget::ResolveSymbolContextForAddress (const SBAddress& addr, uint32_t resolve_scope) @@ -2479,10 +2431,14 @@ SBTarget::SetSectionLoadAddress (lldb::SBSection section, } else { - if (target_sp->GetSectionLoadList().SetSectionLoadAddress (section_sp, section_base_addr)) + ProcessSP process_sp (target_sp->GetProcessSP()); + uint32_t stop_id = 0; + if (process_sp) + stop_id = process_sp->GetStopID(); + + if (target_sp->SetSectionLoadAddress (section_sp, section_base_addr)) { // Flush info in the process (stack frames, etc) - ProcessSP process_sp (target_sp->GetProcessSP()); if (process_sp) process_sp->Flush(); } @@ -2511,10 +2467,14 @@ SBTarget::ClearSectionLoadAddress (lldb::SBSection section) } else { - if (target_sp->GetSectionLoadList().SetSectionUnloaded (section.GetSP())) + ProcessSP process_sp (target_sp->GetProcessSP()); + uint32_t stop_id = 0; + if (process_sp) + stop_id = process_sp->GetStopID(); + + if (target_sp->SetSectionUnloaded (section.GetSP())) { // Flush info in the process (stack frames, etc) - ProcessSP process_sp (target_sp->GetProcessSP()); if (process_sp) process_sp->Flush(); } @@ -2539,7 +2499,7 @@ SBTarget::SetModuleLoadAddress (lldb::SBModule module, int64_t slide_offset) if (module_sp) { bool changed = false; - if (module_sp->SetLoadAddress (*target_sp, slide_offset, changed)) + if (module_sp->SetLoadAddress (*target_sp, slide_offset, true, changed)) { // The load was successful, make sure that at least some sections // changed before we notify that our module was loaded. @@ -2586,13 +2546,18 @@ SBTarget::ClearModuleLoadAddress (lldb::SBModule module) SectionList *section_list = objfile->GetSectionList(); if (section_list) { + ProcessSP process_sp (target_sp->GetProcessSP()); + uint32_t stop_id = 0; + if (process_sp) + stop_id = process_sp->GetStopID(); + bool changed = false; const size_t num_sections = section_list->GetSize(); for (size_t sect_idx = 0; sect_idx < num_sections; ++sect_idx) { SectionSP section_sp (section_list->GetSectionAtIndex(sect_idx)); if (section_sp) - changed |= target_sp->GetSectionLoadList().SetSectionUnloaded (section_sp) > 0; + changed |= target_sp->SetSectionUnloaded (section_sp) > 0; } if (changed) { diff --git a/contrib/llvm/tools/lldb/source/API/SBType.cpp b/contrib/llvm/tools/lldb/source/API/SBType.cpp index 3055c27..5ca7ddf 100644 --- a/contrib/llvm/tools/lldb/source/API/SBType.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBType.cpp @@ -186,6 +186,14 @@ SBType::GetReferenceType() } SBType +SBType::GetTypedefedType() +{ + if (!IsValid()) + return SBType(); + return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetTypedefedType()))); +} + +SBType SBType::GetDereferencedType() { if (!IsValid()) diff --git a/contrib/llvm/tools/lldb/source/API/SBTypeCategory.cpp b/contrib/llvm/tools/lldb/source/API/SBTypeCategory.cpp index 08fdefa..9fe4dad 100644 --- a/contrib/llvm/tools/lldb/source/API/SBTypeCategory.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBTypeCategory.cpp @@ -87,7 +87,7 @@ SBTypeCategory::GetNumFormats () if (!IsValid()) return 0; - return m_opaque_sp->GetValueNavigator()->GetCount() + m_opaque_sp->GetRegexValueNavigator()->GetCount(); + return m_opaque_sp->GetTypeFormatsContainer()->GetCount() + m_opaque_sp->GetRegexTypeFormatsContainer()->GetCount(); } uint32_t @@ -95,7 +95,7 @@ SBTypeCategory::GetNumSummaries () { if (!IsValid()) return 0; - return m_opaque_sp->GetSummaryNavigator()->GetCount() + m_opaque_sp->GetRegexSummaryNavigator()->GetCount(); + return m_opaque_sp->GetTypeSummariesContainer()->GetCount() + m_opaque_sp->GetRegexTypeSummariesContainer()->GetCount(); } uint32_t @@ -103,7 +103,7 @@ SBTypeCategory::GetNumFilters () { if (!IsValid()) return 0; - return m_opaque_sp->GetFilterNavigator()->GetCount() + m_opaque_sp->GetRegexFilterNavigator()->GetCount(); + return m_opaque_sp->GetTypeFiltersContainer()->GetCount() + m_opaque_sp->GetRegexTypeFiltersContainer()->GetCount(); } #ifndef LLDB_DISABLE_PYTHON @@ -112,7 +112,7 @@ SBTypeCategory::GetNumSynthetics () { if (!IsValid()) return 0; - return m_opaque_sp->GetSyntheticNavigator()->GetCount() + m_opaque_sp->GetRegexSyntheticNavigator()->GetCount(); + return m_opaque_sp->GetTypeSyntheticsContainer()->GetCount() + m_opaque_sp->GetRegexTypeSyntheticsContainer()->GetCount(); } #endif @@ -162,9 +162,9 @@ SBTypeCategory::GetFilterForType (SBTypeNameSpecifier spec) lldb::SyntheticChildrenSP children_sp; if (spec.IsRegex()) - m_opaque_sp->GetRegexFilterNavigator()->GetExact(ConstString(spec.GetName()), children_sp); + m_opaque_sp->GetRegexTypeFiltersContainer()->GetExact(ConstString(spec.GetName()), children_sp); else - m_opaque_sp->GetFilterNavigator()->GetExact(ConstString(spec.GetName()), children_sp); + m_opaque_sp->GetTypeFiltersContainer()->GetExact(ConstString(spec.GetName()), children_sp); if (!children_sp) return lldb::SBTypeFilter(); @@ -186,9 +186,9 @@ SBTypeCategory::GetFormatForType (SBTypeNameSpecifier spec) lldb::TypeFormatImplSP format_sp; if (spec.IsRegex()) - m_opaque_sp->GetRegexValueNavigator()->GetExact(ConstString(spec.GetName()), format_sp); + m_opaque_sp->GetRegexTypeFormatsContainer()->GetExact(ConstString(spec.GetName()), format_sp); else - m_opaque_sp->GetValueNavigator()->GetExact(ConstString(spec.GetName()), format_sp); + m_opaque_sp->GetTypeFormatsContainer()->GetExact(ConstString(spec.GetName()), format_sp); if (!format_sp) return lldb::SBTypeFormat(); @@ -209,9 +209,9 @@ SBTypeCategory::GetSummaryForType (SBTypeNameSpecifier spec) lldb::TypeSummaryImplSP summary_sp; if (spec.IsRegex()) - m_opaque_sp->GetRegexSummaryNavigator()->GetExact(ConstString(spec.GetName()), summary_sp); + m_opaque_sp->GetRegexTypeSummariesContainer()->GetExact(ConstString(spec.GetName()), summary_sp); else - m_opaque_sp->GetSummaryNavigator()->GetExact(ConstString(spec.GetName()), summary_sp); + m_opaque_sp->GetTypeSummariesContainer()->GetExact(ConstString(spec.GetName()), summary_sp); if (!summary_sp) return lldb::SBTypeSummary(); @@ -233,9 +233,9 @@ SBTypeCategory::GetSyntheticForType (SBTypeNameSpecifier spec) lldb::SyntheticChildrenSP children_sp; if (spec.IsRegex()) - m_opaque_sp->GetRegexSyntheticNavigator()->GetExact(ConstString(spec.GetName()), children_sp); + m_opaque_sp->GetRegexTypeSyntheticsContainer()->GetExact(ConstString(spec.GetName()), children_sp); else - m_opaque_sp->GetSyntheticNavigator()->GetExact(ConstString(spec.GetName()), children_sp); + m_opaque_sp->GetTypeSyntheticsContainer()->GetExact(ConstString(spec.GetName()), children_sp); if (!children_sp) return lldb::SBTypeSynthetic(); @@ -312,9 +312,9 @@ SBTypeCategory::AddTypeFormat (SBTypeNameSpecifier type_name, return false; if (type_name.IsRegex()) - m_opaque_sp->GetRegexValueNavigator()->Add(lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())), format.GetSP()); + m_opaque_sp->GetRegexTypeFormatsContainer()->Add(lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())), format.GetSP()); else - m_opaque_sp->GetValueNavigator()->Add(ConstString(type_name.GetName()), format.GetSP()); + m_opaque_sp->GetTypeFormatsContainer()->Add(ConstString(type_name.GetName()), format.GetSP()); return true; } @@ -329,9 +329,9 @@ SBTypeCategory::DeleteTypeFormat (SBTypeNameSpecifier type_name) return false; if (type_name.IsRegex()) - return m_opaque_sp->GetRegexValueNavigator()->Delete(ConstString(type_name.GetName())); + return m_opaque_sp->GetRegexTypeFormatsContainer()->Delete(ConstString(type_name.GetName())); else - return m_opaque_sp->GetValueNavigator()->Delete(ConstString(type_name.GetName())); + return m_opaque_sp->GetTypeFormatsContainer()->Delete(ConstString(type_name.GetName())); } #ifndef LLDB_DISABLE_PYTHON @@ -383,9 +383,9 @@ SBTypeCategory::AddTypeSummary (SBTypeNameSpecifier type_name, } if (type_name.IsRegex()) - m_opaque_sp->GetRegexSummaryNavigator()->Add(lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())), summary.GetSP()); + m_opaque_sp->GetRegexTypeSummariesContainer()->Add(lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())), summary.GetSP()); else - m_opaque_sp->GetSummaryNavigator()->Add(ConstString(type_name.GetName()), summary.GetSP()); + m_opaque_sp->GetTypeSummariesContainer()->Add(ConstString(type_name.GetName()), summary.GetSP()); return true; } @@ -401,9 +401,9 @@ SBTypeCategory::DeleteTypeSummary (SBTypeNameSpecifier type_name) return false; if (type_name.IsRegex()) - return m_opaque_sp->GetRegexSummaryNavigator()->Delete(ConstString(type_name.GetName())); + return m_opaque_sp->GetRegexTypeSummariesContainer()->Delete(ConstString(type_name.GetName())); else - return m_opaque_sp->GetSummaryNavigator()->Delete(ConstString(type_name.GetName())); + return m_opaque_sp->GetTypeSummariesContainer()->Delete(ConstString(type_name.GetName())); } bool @@ -420,9 +420,9 @@ SBTypeCategory::AddTypeFilter (SBTypeNameSpecifier type_name, return false; if (type_name.IsRegex()) - m_opaque_sp->GetRegexFilterNavigator()->Add(lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())), filter.GetSP()); + m_opaque_sp->GetRegexTypeFiltersContainer()->Add(lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())), filter.GetSP()); else - m_opaque_sp->GetFilterNavigator()->Add(ConstString(type_name.GetName()), filter.GetSP()); + m_opaque_sp->GetTypeFiltersContainer()->Add(ConstString(type_name.GetName()), filter.GetSP()); return true; } @@ -437,9 +437,9 @@ SBTypeCategory::DeleteTypeFilter (SBTypeNameSpecifier type_name) return false; if (type_name.IsRegex()) - return m_opaque_sp->GetRegexFilterNavigator()->Delete(ConstString(type_name.GetName())); + return m_opaque_sp->GetRegexTypeFiltersContainer()->Delete(ConstString(type_name.GetName())); else - return m_opaque_sp->GetFilterNavigator()->Delete(ConstString(type_name.GetName())); + return m_opaque_sp->GetTypeFiltersContainer()->Delete(ConstString(type_name.GetName())); } #ifndef LLDB_DISABLE_PYTHON @@ -491,9 +491,9 @@ SBTypeCategory::AddTypeSynthetic (SBTypeNameSpecifier type_name, } if (type_name.IsRegex()) - m_opaque_sp->GetRegexSyntheticNavigator()->Add(lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())), synth.GetSP()); + m_opaque_sp->GetRegexTypeSyntheticsContainer()->Add(lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())), synth.GetSP()); else - m_opaque_sp->GetSyntheticNavigator()->Add(ConstString(type_name.GetName()), synth.GetSP()); + m_opaque_sp->GetTypeSyntheticsContainer()->Add(ConstString(type_name.GetName()), synth.GetSP()); return true; } @@ -508,9 +508,9 @@ SBTypeCategory::DeleteTypeSynthetic (SBTypeNameSpecifier type_name) return false; if (type_name.IsRegex()) - return m_opaque_sp->GetRegexSyntheticNavigator()->Delete(ConstString(type_name.GetName())); + return m_opaque_sp->GetRegexTypeSyntheticsContainer()->Delete(ConstString(type_name.GetName())); else - return m_opaque_sp->GetSyntheticNavigator()->Delete(ConstString(type_name.GetName())); + return m_opaque_sp->GetTypeSyntheticsContainer()->Delete(ConstString(type_name.GetName())); } #endif // LLDB_DISABLE_PYTHON diff --git a/contrib/llvm/tools/lldb/source/API/SBTypeFormat.cpp b/contrib/llvm/tools/lldb/source/API/SBTypeFormat.cpp index 34ab404..d3ec9bc 100644 --- a/contrib/llvm/tools/lldb/source/API/SBTypeFormat.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBTypeFormat.cpp @@ -25,7 +25,13 @@ m_opaque_sp() SBTypeFormat::SBTypeFormat (lldb::Format format, uint32_t options) -: m_opaque_sp(TypeFormatImplSP(new TypeFormatImpl(format,options))) +: m_opaque_sp(TypeFormatImplSP(new TypeFormatImpl_Format(format,options))) +{ +} + +SBTypeFormat::SBTypeFormat (const char* type, + uint32_t options) +: m_opaque_sp(TypeFormatImplSP(new TypeFormatImpl_EnumType(ConstString(type ? type : ""),options))) { } @@ -47,11 +53,19 @@ SBTypeFormat::IsValid() const lldb::Format SBTypeFormat::GetFormat () { - if (IsValid()) - return m_opaque_sp->GetFormat(); + if (IsValid() && m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeFormat) + return ((TypeFormatImpl_Format*)m_opaque_sp.get())->GetFormat(); return lldb::eFormatInvalid; } +const char* +SBTypeFormat::GetTypeName () +{ + if (IsValid() && m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeEnum) + return ((TypeFormatImpl_EnumType*)m_opaque_sp.get())->GetTypeName().AsCString(""); + return ""; +} + uint32_t SBTypeFormat::GetOptions() { @@ -63,14 +77,21 @@ SBTypeFormat::GetOptions() void SBTypeFormat::SetFormat (lldb::Format fmt) { - if (CopyOnWrite_Impl()) - m_opaque_sp->SetFormat(fmt); + if (CopyOnWrite_Impl(Type::eTypeFormat)) + ((TypeFormatImpl_Format*)m_opaque_sp.get())->SetFormat(fmt); +} + +void +SBTypeFormat::SetTypeName (const char* type) +{ + if (CopyOnWrite_Impl(Type::eTypeEnum)) + ((TypeFormatImpl_EnumType*)m_opaque_sp.get())->SetTypeName(ConstString(type ? type : "")); } void SBTypeFormat::SetOptions (uint32_t value) { - if (CopyOnWrite_Impl()) + if (CopyOnWrite_Impl(Type::eTypeKeepSame)) m_opaque_sp->SetOptions(value); } @@ -143,13 +164,30 @@ SBTypeFormat::SBTypeFormat (const lldb::TypeFormatImplSP &typeformat_impl_sp) : } bool -SBTypeFormat::CopyOnWrite_Impl() +SBTypeFormat::CopyOnWrite_Impl(Type type) { if (!IsValid()) return false; - if (m_opaque_sp.unique()) + + if (m_opaque_sp.unique() && + ((type == Type::eTypeKeepSame) || + (type == Type::eTypeFormat && m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeFormat) || + (type == Type::eTypeEnum && m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeEnum)) + ) return true; - SetSP(TypeFormatImplSP(new TypeFormatImpl(GetFormat(),GetOptions()))); + if (type == Type::eTypeKeepSame) + { + if (m_opaque_sp->GetType() == TypeFormatImpl::Type::eTypeFormat) + type = Type::eTypeFormat; + else + type = Type::eTypeEnum; + } + + if (type == Type::eTypeFormat) + SetSP(TypeFormatImplSP(new TypeFormatImpl_Format(GetFormat(),GetOptions()))); + else + SetSP(TypeFormatImplSP(new TypeFormatImpl_EnumType(ConstString(GetTypeName()),GetOptions()))); + return true; } diff --git a/contrib/llvm/tools/lldb/source/API/SBValue.cpp b/contrib/llvm/tools/lldb/source/API/SBValue.cpp index 51b6790..4bd0183 100644 --- a/contrib/llvm/tools/lldb/source/API/SBValue.cpp +++ b/contrib/llvm/tools/lldb/source/API/SBValue.cpp @@ -96,7 +96,24 @@ public: bool IsValid () { - return m_valobj_sp.get() != NULL; + if (m_valobj_sp.get() == NULL) + return false; + else + { + // FIXME: This check is necessary but not sufficient. We for sure don't want to touch SBValues whose owning + // targets have gone away. This check is a little weak in that it enforces that restriction when you call + // IsValid, but since IsValid doesn't lock the target, you have no guarantee that the SBValue won't go + // invalid after you call this... + // Also, an SBValue could depend on data from one of the modules in the target, and those could go away + // independently of the target, for instance if a module is unloaded. But right now, neither SBValues + // nor ValueObjects know which modules they depend on. So I have no good way to make that check without + // tracking that in all the ValueObject subclasses. + TargetSP target_sp = m_valobj_sp->GetTargetSP(); + if (target_sp && target_sp->IsValid()) + return true; + else + return false; + } } lldb::ValueObjectSP @@ -120,6 +137,8 @@ public: Target *target = value_sp->GetTargetSP().get(); if (target) api_locker.Lock(target->GetAPIMutex()); + else + return ValueObjectSP(); ProcessSP process_sp(value_sp->GetProcessSP()); if (process_sp && !stop_locker.TryLock (&process_sp->GetRunLock())) @@ -276,7 +295,7 @@ SBValue::IsValid () // If this function ever changes to anything that does more than just // check if the opaque shared pointer is non NULL, then we need to update // all "if (m_opaque_sp)" code in this file. - return m_opaque_sp.get() != NULL && m_opaque_sp->GetRootSP().get() != NULL; + return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid() && m_opaque_sp->GetRootSP().get() != NULL; } void |