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

Unified Diff: runtime/vm/disassembler.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/disassembler.cc
diff --git a/runtime/vm/disassembler.cc b/runtime/vm/disassembler.cc
index 4b1f381e9005b584917455d60b0b3d1b00d636fb..627f0de6bcf5f2d6f9450c3263f9ff36d450b425 100644
--- a/runtime/vm/disassembler.cc
+++ b/runtime/vm/disassembler.cc
@@ -7,6 +7,7 @@
#include "vm/assembler.h"
#include "vm/globals.h"
#include "vm/os.h"
+#include "vm/json_stream.h"
namespace dart {
@@ -36,4 +37,42 @@ void DisassembleToStdout::Print(const char* format, ...) {
va_end(args);
}
+
+void DisassembleToJSONStream::ConsumeInstruction(char* hex_buffer,
+ intptr_t hex_size,
+ char* human_buffer,
+ intptr_t human_size,
+ uword pc) {
+ uint8_t* pc_ptr = reinterpret_cast<uint8_t*>(pc);
+ stream_->OpenObject();
+ stream_->PrintProperty("type", "DisassembledInstruction");
+ stream_->PrintfProperty("pc", "%p", pc_ptr);
+ stream_->PrintProperty("hex", hex_buffer);
+ stream_->PrintProperty("human", human_buffer);
+ stream_->CloseObject();
+}
+
+
+void DisassembleToJSONStream::Print(const char* format, ...) {
+ 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, format, args);
+ va_end(args);
+ ASSERT(len == len2);
+ for (intptr_t i = 0; i < len; i++) {
+ if (p[i] == '\n' || p[i] == '\r') {
+ p[i] = ' ';
+ }
+ }
+ stream_->OpenObject();
+ stream_->PrintProperty("type", "DisassembledInstructionComment");
+ stream_->PrintProperty("comment", p);
+ stream_->CloseObject();
+ free(p);
+}
+
} // namespace dart

Powered by Google App Engine
This is Rietveld 408576698