Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Unified Diff: runtime/vm/json_stream.cc

Issue 19870006: Support stacktrace and objecthistogram service commands (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/json_stream.cc
diff --git a/runtime/vm/json_stream.cc b/runtime/vm/json_stream.cc
index df60bc52992e42f6acfe551d15959bbb36ab9b2d..045fced739376162c3f6017e002182b4a179a67f 100644
--- a/runtime/vm/json_stream.cc
+++ b/runtime/vm/json_stream.cc
@@ -84,6 +84,23 @@ void JSONStream::PrintValue(const char* s) {
}
+void JSONStream::PrintfValue(const char* format, ...) {
+ PrintCommaIfNeeded();
+
+ va_list args;
+ va_start(args, format);
+ intptr_t len = OS::VSNPrint(NULL, 0, format, args);
+ va_end(args);
+ char* p = reinterpret_cast<char*>(malloc(len+1));
+ va_start(args, format);
+ intptr_t len2 = OS::VSNPrint(p, len+1, format, args);
+ va_end(args);
+ ASSERT(len == len2);
+ buffer_->Printf("\"%s\"", p);
+ free(p);
+}
+
+
void JSONStream::PrintValue(const Object& o, bool ref) {
PrintCommaIfNeeded();
o.PrintToJSONStream(this, ref);
@@ -114,6 +131,22 @@ void JSONStream::PrintProperty(const char* name, const char* s) {
}
+void JSONStream::PrintfProperty(const char* name, const char* format, ...) {
+ PrintPropertyName(name);
+ va_list args;
+ va_start(args, format);
+ intptr_t len = OS::VSNPrint(NULL, 0, format, args);
+ va_end(args);
+ char* p = reinterpret_cast<char*>(malloc(len+1));
+ va_start(args, format);
+ intptr_t len2 = OS::VSNPrint(p, len+1, format, args);
+ va_end(args);
+ ASSERT(len == len2);
+ buffer_->Printf("\"%s\"", p);
+ free(p);
+}
+
+
void JSONStream::PrintProperty(const char* name, const Object& o, bool ref) {
PrintPropertyName(name);
PrintValue(o, ref);

Powered by Google App Engine
This is Rietveld 408576698