summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Core/StructuredData.h20
-rw-r--r--lldb/source/Core/StructuredData.cpp76
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp2
-rw-r--r--lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h2
4 files changed, 63 insertions, 37 deletions
diff --git a/lldb/include/lldb/Core/StructuredData.h b/lldb/include/lldb/Core/StructuredData.h
index 52f34521ef0..28fb80fb7ce 100644
--- a/lldb/include/lldb/Core/StructuredData.h
+++ b/lldb/include/lldb/Core/StructuredData.h
@@ -193,10 +193,10 @@ public:
ObjectSP
GetObjectForDotSeparatedPath (llvm::StringRef path);
- void DumpToStdout() const;
+ void DumpToStdout(bool pretty_print = true) const;
virtual void
- Dump (Stream &s) const = 0;
+ Dump (Stream &s, bool pretty_print = true) const = 0;
private:
Type m_type;
@@ -357,7 +357,7 @@ public:
m_items.push_back(item);
}
- void Dump(Stream &s) const override;
+ void Dump(Stream &s, bool pretty_print = true) const override;
protected:
typedef std::vector<ObjectSP> collection;
@@ -387,7 +387,7 @@ public:
return m_value;
}
- void Dump(Stream &s) const override;
+ void Dump(Stream &s, bool pretty_print = true) const override;
protected:
uint64_t m_value;
@@ -416,7 +416,7 @@ public:
return m_value;
}
- void Dump(Stream &s) const override;
+ void Dump(Stream &s, bool pretty_print = true) const override;
protected:
double m_value;
@@ -445,7 +445,7 @@ public:
return m_value;
}
- void Dump(Stream &s) const override;
+ void Dump(Stream &s, bool pretty_print = true) const override;
protected:
bool m_value;
@@ -486,7 +486,7 @@ public:
return m_value;
}
- void Dump(Stream &s) const override;
+ void Dump(Stream &s, bool pretty_print = true) const override;
protected:
std::string m_value;
@@ -697,7 +697,7 @@ public:
AddItem (key, ObjectSP (new Boolean(value)));
}
- void Dump(Stream &s) const override;
+ void Dump(Stream &s, bool pretty_print = true) const override;
protected:
typedef std::map<ConstString, ObjectSP> collection;
@@ -720,7 +720,7 @@ public:
return false;
}
- void Dump(Stream &s) const override;
+ void Dump(Stream &s, bool pretty_print = true) const override;
};
class Generic : public Object
@@ -750,7 +750,7 @@ public:
return m_object != nullptr;
}
- void Dump(Stream &s) const override;
+ void Dump(Stream &s, bool pretty_print = true) const override;
private:
void *m_object;
diff --git a/lldb/source/Core/StructuredData.cpp b/lldb/source/Core/StructuredData.cpp
index efc104f1f3e..000dacb5f57 100644
--- a/lldb/source/Core/StructuredData.cpp
+++ b/lldb/source/Core/StructuredData.cpp
@@ -203,50 +203,64 @@ StructuredData::Object::GetObjectForDotSeparatedPath (llvm::StringRef path)
}
void
-StructuredData::Object::DumpToStdout() const
+StructuredData::Object::DumpToStdout(bool pretty_print) const
{
StreamString stream;
- Dump(stream);
+ Dump(stream, pretty_print);
printf("%s\n", stream.GetString().c_str());
}
void
-StructuredData::Array::Dump(Stream &s) const
+StructuredData::Array::Dump(Stream &s, bool pretty_print) const
{
bool first = true;
- s << "[\n";
- s.IndentMore();
+ s << "[";
+ if (pretty_print)
+ {
+ s << "\n";
+ s.IndentMore();
+ }
for (const auto &item_sp : m_items)
{
if (first)
+ {
first = false;
+ }
else
- s << ",\n";
+ {
+ s << ",";
+ if (pretty_print)
+ s << "\n";
+ }
+ if (pretty_print)
+ s.Indent();
+ item_sp->Dump(s, pretty_print);
+ }
+ if (pretty_print)
+ {
+ s.IndentLess();
+ s.EOL();
s.Indent();
- item_sp->Dump(s);
}
- s.IndentLess();
- s.EOL();
- s.Indent();
s << "]";
}
void
-StructuredData::Integer::Dump (Stream &s) const
+StructuredData::Integer::Dump (Stream &s, bool pretty_print) const
{
s.Printf ("%" PRIu64, m_value);
}
void
-StructuredData::Float::Dump (Stream &s) const
+StructuredData::Float::Dump (Stream &s, bool pretty_print) const
{
s.Printf ("%lg", m_value);
}
void
-StructuredData::Boolean::Dump (Stream &s) const
+StructuredData::Boolean::Dump (Stream &s, bool pretty_print) const
{
if (m_value == true)
s.PutCString ("true");
@@ -256,7 +270,7 @@ StructuredData::Boolean::Dump (Stream &s) const
void
-StructuredData::String::Dump (Stream &s) const
+StructuredData::String::Dump (Stream &s, bool pretty_print) const
{
std::string quoted;
const size_t strsize = m_value.size();
@@ -271,35 +285,47 @@ StructuredData::String::Dump (Stream &s) const
}
void
-StructuredData::Dictionary::Dump (Stream &s) const
+StructuredData::Dictionary::Dump (Stream &s, bool pretty_print) const
{
bool first = true;
- s << "{\n";
- s.IndentMore();
+ s << "{";
+ if (pretty_print)
+ {
+ s << "{\n";
+ s.IndentMore();
+ }
for (const auto &pair : m_dict)
{
if (first)
first = false;
else
- s << ",\n";
- s.Indent();
+ {
+ s << ",";
+ if (pretty_print)
+ s << "\n";
+ }
+ if (pretty_print)
+ s.Indent();
s << "\"" << pair.first.AsCString() << "\" : ";
- pair.second->Dump(s);
+ pair.second->Dump(s, pretty_print);
+ }
+ if (pretty_print)
+ {
+ s.IndentLess();
+ s.EOL();
+ s.Indent();
}
- s.IndentLess();
- s.EOL();
- s.Indent();
s << "}";
}
void
-StructuredData::Null::Dump (Stream &s) const
+StructuredData::Null::Dump (Stream &s, bool pretty_print) const
{
s << "null";
}
void
-StructuredData::Generic::Dump(Stream &s) const
+StructuredData::Generic::Dump(Stream &s, bool pretty_print) const
{
s << "0x" << m_object;
}
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
index 1fdf4c70a5d..b460ab59c99 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.cpp
@@ -32,7 +32,7 @@ using namespace lldb_private;
using namespace lldb;
void
-StructuredPythonObject::Dump(Stream &s) const
+StructuredPythonObject::Dump(Stream &s, bool pretty_print) const
{
s << "Python Obj: 0x" << GetValue();
}
diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
index 78245a98d0b..fd77a34750f 100644
--- a/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
+++ b/lldb/source/Plugins/ScriptInterpreter/Python/PythonDataObjects.h
@@ -60,7 +60,7 @@ public:
return GetValue() && GetValue() != Py_None;
}
- void Dump(Stream &s) const override;
+ void Dump(Stream &s, bool pretty_print = true) const override;
private:
DISALLOW_COPY_AND_ASSIGN(StructuredPythonObject);
OpenPOWER on IntegriCloud