diff options
author | Jim Ingham <jingham@apple.com> | 2018-09-13 21:35:32 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2018-09-13 21:35:32 +0000 |
commit | 3815e702e751efb14188c0f0beeb10e343d8f053 (patch) | |
tree | 26247d7b8a0c3b3df344225d770ef7e6d553419c /lldb/source/API/SBStructuredData.cpp | |
parent | d2316d756e2f3827ec662aee05d786d039b3d568 (diff) | |
download | bcm5719-llvm-3815e702e751efb14188c0f0beeb10e343d8f053.tar.gz bcm5719-llvm-3815e702e751efb14188c0f0beeb10e343d8f053.zip |
Add a "scripted" breakpoint type to lldb.
This change allows you to write a new breakpoint type where the
logic for setting breakpoints is determined by a Python callback
written using the SB API's.
Differential Revision: https://reviews.llvm.org/D51830
llvm-svn: 342185
Diffstat (limited to 'lldb/source/API/SBStructuredData.cpp')
-rw-r--r-- | lldb/source/API/SBStructuredData.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lldb/source/API/SBStructuredData.cpp b/lldb/source/API/SBStructuredData.cpp index d506410f6d8..d901f915dad 100644 --- a/lldb/source/API/SBStructuredData.cpp +++ b/lldb/source/API/SBStructuredData.cpp @@ -10,6 +10,7 @@ #include "lldb/API/SBStructuredData.h" #include "lldb/API/SBStream.h" +#include "lldb/API/SBStringList.h" #include "lldb/Core/Event.h" #include "lldb/Core/StructuredDataImpl.h" #include "lldb/Target/StructuredDataPlugin.h" @@ -31,6 +32,9 @@ SBStructuredData::SBStructuredData(const lldb::SBStructuredData &rhs) SBStructuredData::SBStructuredData(const lldb::EventSP &event_sp) : m_impl_up(new StructuredDataImpl(event_sp)) {} +SBStructuredData::SBStructuredData(lldb_private::StructuredDataImpl *impl) + : m_impl_up(impl) {} + SBStructuredData::~SBStructuredData() {} SBStructuredData &SBStructuredData:: @@ -76,6 +80,33 @@ size_t SBStructuredData::GetSize() const { return (m_impl_up ? m_impl_up->GetSize() : 0); } +bool SBStructuredData::GetKeys(lldb::SBStringList &keys) const { + if (!m_impl_up) + return false; + + if (GetType() != eStructuredDataTypeDictionary) + return false; + + StructuredData::ObjectSP obj_sp = m_impl_up->GetObjectSP(); + if (!obj_sp) + return false; + + StructuredData::Dictionary *dict = obj_sp->GetAsDictionary(); + // We claimed we were a dictionary, so this can't be null. + assert(dict); + // The return kind of GetKeys is an Array: + StructuredData::ObjectSP array_sp = dict->GetKeys(); + StructuredData::Array *key_arr = array_sp->GetAsArray(); + assert(key_arr); + + key_arr->ForEach([&keys] (StructuredData::Object *object) -> bool { + llvm::StringRef key = object->GetStringValue(""); + keys.AppendString(key.str().c_str()); + return true; + }); + return true; +} + lldb::SBStructuredData SBStructuredData::GetValueForKey(const char *key) const { if (!m_impl_up) return SBStructuredData(); |