diff --git a/lldb/include/lldb/API/SBStringList.h b/lldb/include/lldb/API/SBStringList.h --- a/lldb/include/lldb/API/SBStringList.h +++ b/lldb/include/lldb/API/SBStringList.h @@ -47,11 +47,14 @@ friend class SBBreakpoint; friend class SBBreakpointLocation; friend class SBBreakpointName; + friend class SBStructuredData; SBStringList(const lldb_private::StringList *lldb_strings); void AppendList(const lldb_private::StringList &strings); + lldb_private::StringList *operator->(); + const lldb_private::StringList *operator->() const; const lldb_private::StringList &operator*() const; diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -1399,9 +1399,9 @@ Log *log = GetLog(LLDBLog::API); - LLDB_LOGF(log, "SBDebugger(%p)::GetPrompt () => \"%s\"", - static_cast(m_opaque_sp.get()), - (m_opaque_sp ? m_opaque_sp->GetPrompt().str().c_str() : "")); + LLDB_LOG(log, "SBDebugger({0:x})::GetPrompt () => \"{1}\"", + static_cast(m_opaque_sp.get()), + (m_opaque_sp ? m_opaque_sp->GetPrompt() : "")); return (m_opaque_sp ? ConstString(m_opaque_sp->GetPrompt()).GetCString() : nullptr); diff --git a/lldb/source/API/SBStringList.cpp b/lldb/source/API/SBStringList.cpp --- a/lldb/source/API/SBStringList.cpp +++ b/lldb/source/API/SBStringList.cpp @@ -37,6 +37,13 @@ SBStringList::~SBStringList() = default; +lldb_private::StringList *SBStringList::operator->() { + if (!IsValid()) + m_opaque_up = std::make_unique(); + + return m_opaque_up.get(); +} + const lldb_private::StringList *SBStringList::operator->() const { return m_opaque_up.get(); } diff --git a/lldb/source/API/SBStructuredData.cpp b/lldb/source/API/SBStructuredData.cpp --- a/lldb/source/API/SBStructuredData.cpp +++ b/lldb/source/API/SBStructuredData.cpp @@ -16,6 +16,7 @@ #include "lldb/Utility/Event.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" +#include "lldb/Utility/StringList.h" #include "lldb/Utility/StructuredData.h" using namespace lldb; @@ -138,9 +139,9 @@ StructuredData::Array *key_arr = array_sp->GetAsArray(); assert(key_arr); - key_arr->ForEach([&keys] (StructuredData::Object *object) -> bool { + key_arr->ForEach([&keys](StructuredData::Object *object) -> bool { llvm::StringRef key = object->GetStringValue(""); - keys.AppendString(key.str().c_str()); + keys->AppendString(key); return true; }); return true; diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -457,7 +457,7 @@ info_root_sp->GetObjectForDotSeparatedPath(path); if (node) { if (node->GetType() == eStructuredDataTypeString) { - strm.Printf("%s", node->GetAsString()->GetValue().str().c_str()); + strm.ref() << node->GetAsString()->GetValue(); success = true; } if (node->GetType() == eStructuredDataTypeInteger) {