diff options
| author | Greg Clayton <gclayton@apple.com> | 2011-06-29 22:09:02 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2011-06-29 22:09:02 +0000 |
| commit | dea8cb4fe314fb772706e033e50c3258210007f5 (patch) | |
| tree | f48ad3ccc7229cc40cccc815e20e1b64fd8c01ea /lldb/source/API | |
| parent | 1c2d4f2feaf680df14b0a6a2f23e2d96589ac598 (diff) | |
| download | bcm5719-llvm-dea8cb4fe314fb772706e033e50c3258210007f5.tar.gz bcm5719-llvm-dea8cb4fe314fb772706e033e50c3258210007f5.zip | |
Added support for finding and global variables in the SBTarget and SBModule
level in the public API.
Also modified the ValueObject values to be able to display global variables
without having a valid running process. The globals will read themselves from
the object file section data if there is no process, and from the process if
there is one.
Also fixed an issue where modifications for dynamic types could cause child
values of ValueObjects to not show up if the value was unable to evaluate
itself (children of NULL pointer objects).
llvm-svn: 134102
Diffstat (limited to 'lldb/source/API')
| -rw-r--r-- | lldb/source/API/SBModule.cpp | 35 | ||||
| -rw-r--r-- | lldb/source/API/SBTarget.cpp | 47 | ||||
| -rw-r--r-- | lldb/source/API/SBValueList.cpp | 44 |
3 files changed, 107 insertions, 19 deletions
diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp index 0c4eba43e56..53172f349ca 100644 --- a/lldb/source/API/SBModule.cpp +++ b/lldb/source/API/SBModule.cpp @@ -15,6 +15,10 @@ #include "lldb/Core/Module.h" #include "lldb/Core/Log.h" #include "lldb/Core/StreamString.h" +#include "lldb/Core/ValueObjectList.h" +#include "lldb/Core/ValueObjectVariable.h" +#include "lldb/Symbol/VariableList.h" +#include "lldb/Target/Target.h" using namespace lldb; using namespace lldb_private; @@ -307,3 +311,34 @@ SBModule::FindFunctions (const char *name, return 0; } + +SBValueList +SBModule::FindGlobalVariables (SBTarget &target, const char *name, uint32_t max_matches) +{ + SBValueList sb_value_list; + if (m_opaque_sp) + { + VariableList variable_list; + const uint32_t match_count = m_opaque_sp->FindGlobalVariables (ConstString (name), + false, + max_matches, + variable_list); + + if (match_count > 0) + { + ValueObjectList &value_object_list = sb_value_list.ref(); + for (uint32_t i=0; i<match_count; ++i) + { + lldb::ValueObjectSP valobj_sp; + if (target.IsValid()) + valobj_sp = ValueObjectVariable::Create (target.get(), variable_list.GetVariableAtIndex(i)); + else + valobj_sp = ValueObjectVariable::Create (NULL, variable_list.GetVariableAtIndex(i)); + if (valobj_sp) + value_object_list.Append(valobj_sp); + } + } + } + + return sb_value_list; +} diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index 7098604b0ef..6a17bb4cc69 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -11,8 +11,12 @@ #include "lldb/lldb-public.h" +#include "lldb/API/SBDebugger.h" +#include "lldb/API/SBBreakpoint.h" #include "lldb/API/SBFileSpec.h" +#include "lldb/API/SBListener.h" #include "lldb/API/SBModule.h" +#include "lldb/API/SBProcess.h" #include "lldb/API/SBStream.h" #include "lldb/API/SBSymbolContextList.h" #include "lldb/Breakpoint/BreakpointID.h" @@ -22,16 +26,19 @@ #include "lldb/Core/Address.h" #include "lldb/Core/AddressResolver.h" #include "lldb/Core/AddressResolverName.h" -#include "lldb/Interpreter/Args.h" #include "lldb/Core/ArchSpec.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/Disassembler.h" -#include "lldb/Host/FileSpec.h" #include "lldb/Core/Log.h" #include "lldb/Core/RegularExpression.h" #include "lldb/Core/SearchFilter.h" #include "lldb/Core/STLUtils.h" +#include "lldb/Core/ValueObjectList.h" +#include "lldb/Core/ValueObjectVariable.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" +#include "lldb/Interpreter/Args.h" +#include "lldb/Symbol/VariableList.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Target/TargetList.h" @@ -39,10 +46,6 @@ #include "lldb/Interpreter/CommandReturnObject.h" #include "../source/Commands/CommandObjectBreakpoint.h" -#include "lldb/API/SBDebugger.h" -#include "lldb/API/SBProcess.h" -#include "lldb/API/SBListener.h" -#include "lldb/API/SBBreakpoint.h" using namespace lldb; using namespace lldb_private; @@ -872,3 +875,35 @@ SBTarget::FindFunctions (const char *name, return 0; } +SBValueList +SBTarget::FindGlobalVariables (const char *name, uint32_t max_matches) +{ + SBValueList sb_value_list; + + if (m_opaque_sp) + { + VariableList variable_list; + const bool append = true; + const uint32_t match_count = m_opaque_sp->GetImages().FindGlobalVariables (ConstString (name), + append, + max_matches, + variable_list); + + if (match_count > 0) + { + ExecutionContextScope *exe_scope = m_opaque_sp->GetProcessSP().get(); + if (exe_scope == NULL) + exe_scope = m_opaque_sp.get(); + ValueObjectList &value_object_list = sb_value_list.ref(); + for (uint32_t i=0; i<match_count; ++i) + { + lldb::ValueObjectSP valobj_sp (ValueObjectVariable::Create (exe_scope, variable_list.GetVariableAtIndex(i))); + if (valobj_sp) + value_object_list.Append(valobj_sp); + } + } + } + + return sb_value_list; +} + diff --git a/lldb/source/API/SBValueList.cpp b/lldb/source/API/SBValueList.cpp index bcddedfaf83..4e0fea5688c 100644 --- a/lldb/source/API/SBValueList.cpp +++ b/lldb/source/API/SBValueList.cpp @@ -25,10 +25,10 @@ SBValueList::SBValueList () : SBValueList::SBValueList (const SBValueList &rhs) : m_opaque_ap () { - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (rhs.IsValid()) - m_opaque_ap.reset (new lldb_private::ValueObjectList (*rhs)); + m_opaque_ap.reset (new ValueObjectList (*rhs)); if (log) { @@ -38,13 +38,13 @@ SBValueList::SBValueList (const SBValueList &rhs) : } } -SBValueList::SBValueList (const lldb_private::ValueObjectList *lldb_object_ptr) : +SBValueList::SBValueList (const ValueObjectList *lldb_object_ptr) : m_opaque_ap () { - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); if (lldb_object_ptr) - m_opaque_ap.reset (new lldb_private::ValueObjectList (*lldb_object_ptr)); + m_opaque_ap.reset (new ValueObjectList (*lldb_object_ptr)); if (log) { @@ -70,32 +70,32 @@ SBValueList::operator = (const SBValueList &rhs) if (this != &rhs) { if (rhs.IsValid()) - m_opaque_ap.reset (new lldb_private::ValueObjectList (*rhs)); + m_opaque_ap.reset (new ValueObjectList (*rhs)); else m_opaque_ap.reset (); } return *this; } -lldb_private::ValueObjectList * +ValueObjectList * SBValueList::operator->() { return m_opaque_ap.get(); } -lldb_private::ValueObjectList & +ValueObjectList & SBValueList::operator*() { return *m_opaque_ap; } -const lldb_private::ValueObjectList * +const ValueObjectList * SBValueList::operator->() const { return m_opaque_ap.get(); } -const lldb_private::ValueObjectList & +const ValueObjectList & SBValueList::operator*() const { return *m_opaque_ap; @@ -121,11 +121,21 @@ SBValueList::Append (lldb::ValueObjectSP& val_obj_sp) } } +void +SBValueList::Append (const lldb::SBValueList& value_list) +{ + if (value_list.IsValid()) + { + CreateIfNeeded (); + m_opaque_ap->Append (*value_list); + } +} + SBValue SBValueList::GetValueAtIndex (uint32_t idx) const { - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); //if (log) // log->Printf ("SBValueList::GetValueAtIndex (uint32_t idx) idx = %d", idx); @@ -148,7 +158,7 @@ SBValueList::GetValueAtIndex (uint32_t idx) const uint32_t SBValueList::GetSize () const { - LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); + LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); //if (log) // log->Printf ("SBValueList::GetSize ()"); @@ -180,9 +190,17 @@ SBValueList::FindValueObjectByUID (lldb::user_id_t uid) return sb_value; } -lldb_private::ValueObjectList * +ValueObjectList * SBValueList::get () { return m_opaque_ap.get(); } +ValueObjectList & +SBValueList::ref () +{ + CreateIfNeeded(); + return *m_opaque_ap.get(); +} + + |

