[Lldb-commits] [PATCH] D135031: [lldb] [llgs] Move client-server communication into a separate thread (WIP)

2022-10-09 Thread Michał Górny via Phabricator via lldb-commits
mgorny added a comment.

For the record, I'm still hitting a lot of problems with this, including comm 
hanging sometimes (especially under load), some Python tests segfaulting with 
completely useless backtrace (pretty normal for Python backtraces), lots of 
pexpect-based test failures that also tend not to provide any useful output. 
@labath, if you happen to have an idea what could be wrong (besides what's 
marked TODO), I'd appreciate some suggestions. I am somewhat suspicious that 
the broadcaster/listener logic may not be bulletproof too.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135031/new/

https://reviews.llvm.org/D135031

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D135547: [lldb/Utility] Add GetDescription(Stream&) to StructureData::*

2022-10-09 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib created this revision.
mib added reviewers: jingham, JDevlieghere.
mib added a project: LLDB.
Herald added a project: All.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

This patch improves the StructuredData classes to provide a
GetDescription(lldb_private::Stream&) affordance.

This is very convenient compared to the Dump method because this try to
pretty print the structure instead of just serializing it into a JSON.

This patch also updates some parts of lldb (i.e. extended crash info) to
use this new affordance instead of StructuredData::Dump.

Signed-off-by: Med Ismail Bennani 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D135547

Files:
  lldb/include/lldb/Core/StructuredDataImpl.h
  lldb/include/lldb/Utility/StructuredData.h
  lldb/source/Commands/CommandObjectProcess.cpp
  lldb/source/Utility/StructuredData.cpp

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);
+}
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/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; }
 
 vo