Index: lldb/include/lldb/Core/StructuredDataImpl.h =================================================================== --- lldb/include/lldb/Core/StructuredDataImpl.h +++ lldb/include/lldb/Core/StructuredDataImpl.h @@ -80,7 +80,7 @@ error.SetErrorString("No data to describe."); return error; } - m_data_sp->Dump(stream, true); + m_data_sp->GetDescription(stream); return error; } // Get the data's description. Index: lldb/include/lldb/Utility/StructuredData.h =================================================================== --- lldb/include/lldb/Utility/StructuredData.h +++ lldb/include/lldb/Utility/StructuredData.h @@ -158,6 +158,12 @@ Serialize(jso); } + virtual void GetDescription(lldb_private::Stream &s) const { + s.IndentMore(); + Dump(s, false); + s.IndentLess(); + } + private: lldb::StructuredDataType m_type; }; @@ -277,6 +283,8 @@ void Serialize(llvm::json::OStream &s) const override; + void GetDescription(lldb_private::Stream &s) const override; + protected: typedef std::vector collection; collection m_items; @@ -295,6 +303,8 @@ void Serialize(llvm::json::OStream &s) const override; + void GetDescription(lldb_private::Stream &s) const override; + protected: uint64_t m_value; }; @@ -312,6 +322,8 @@ void Serialize(llvm::json::OStream &s) const override; + void GetDescription(lldb_private::Stream &s) const override; + protected: double m_value; }; @@ -329,6 +341,8 @@ void Serialize(llvm::json::OStream &s) const override; + void GetDescription(lldb_private::Stream &s) const override; + protected: bool m_value; }; @@ -345,6 +359,8 @@ void Serialize(llvm::json::OStream &s) const override; + void GetDescription(lldb_private::Stream &s) const override; + protected: std::string m_value; }; @@ -524,6 +540,8 @@ void Serialize(llvm::json::OStream &s) const override; + void GetDescription(lldb_private::Stream &s) const override; + protected: typedef std::map collection; collection m_dict; @@ -538,6 +556,8 @@ bool IsValid() const override { return false; } void Serialize(llvm::json::OStream &s) const override; + + void GetDescription(lldb_private::Stream &s) const override; }; class Generic : public Object { @@ -553,6 +573,8 @@ void Serialize(llvm::json::OStream &s) const override; + void GetDescription(lldb_private::Stream &s) const override; + private: void *m_object; }; Index: lldb/source/Commands/CommandObjectProcess.cpp =================================================================== --- lldb/source/Commands/CommandObjectProcess.cpp +++ lldb/source/Commands/CommandObjectProcess.cpp @@ -1537,8 +1537,9 @@ StructuredData::DictionarySP crash_info_sp = *expected_crash_info; if (crash_info_sp) { + strm.EOL(); strm.PutCString("Extended Crash Information:\n"); - crash_info_sp->Dump(strm); + crash_info_sp->GetDescription(strm); } } Index: lldb/source/Utility/StructuredData.cpp =================================================================== --- lldb/source/Utility/StructuredData.cpp +++ lldb/source/Utility/StructuredData.cpp @@ -172,3 +172,62 @@ void StructuredData::Generic::Serialize(json::OStream &s) const { s.value(llvm::formatv("{0:X}", m_object)); } + +void StructuredData::Array::GetDescription(lldb_private::Stream &s) const { + s.EOL(); + s.IndentMore(); + s.Indent(); + for (const auto &item_sp : m_items) { + item_sp->GetDescription(s); + s.PutChar(','); + s.EOL(); + } + s.IndentLess(); + s.EOL(); + s.Indent(); +} + +void StructuredData::Integer::GetDescription(lldb_private::Stream &s) const { + printf("%" PRId64, static_cast(m_value)); +} + +void StructuredData::Float::GetDescription(lldb_private::Stream &s) const { + printf("%f", m_value); +} + +void StructuredData::Boolean::GetDescription(lldb_private::Stream &s) const { + s.Printf(m_value ? "True" : "False"); +} + +void StructuredData::String::GetDescription(lldb_private::Stream &s) const { + s.Printf("%s", m_value.c_str()); +} + +void StructuredData::Dictionary::GetDescription(lldb_private::Stream &s) const { + s.EOL(); + s.IndentMore(); + + for (const auto &pair : m_dict) { + if (pair.first.IsNull() || pair.first.IsEmpty() || !pair.second) + continue; + s.Indent(); + s.Printf("%s : ", pair.first.AsCString()); + pair.second->GetDescription(s); + if (pair != *(--m_dict.end())) { + s.PutChar(','); + s.EOL(); + } + } + + s.IndentLess(); + s.EOL(); + s.Indent(); +} + +void StructuredData::Null::GetDescription(lldb_private::Stream &s) const { + s.Printf("NULL"); +} + +void StructuredData::Generic::GetDescription(lldb_private::Stream &s) const { + s.Printf("%p", m_object); +}