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

Unified Diff: runtime/bin/vmstats_impl.cc

Issue 13603002: Added ctrl-\ command that dumps isolate stacks to dart binary. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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
« no previous file with comments | « runtime/bin/vmstats_impl.h ('k') | runtime/bin/vmstats_impl_android.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/vmstats_impl.cc
===================================================================
--- runtime/bin/vmstats_impl.cc (revision 20932)
+++ runtime/bin/vmstats_impl.cc (working copy)
@@ -33,6 +33,15 @@
}
instance_ = new VmStats();
instance_monitor_ = new dart::Monitor();
+ Initialize();
+
+ if (port != 0) {
+ StartServer(port, root_dir);
+ }
+}
+
+
+void VmStats::StartServer(int port, const char* root_dir) {
VmStatusService::InitOnce();
Socket::Initialize();
@@ -68,7 +77,6 @@
}
}
-
void VmStats::Stop() {
ASSERT(instance_ != NULL);
MonitorLocker ml(instance_monitor_);
@@ -327,6 +335,67 @@
}
+// Advance the scanner to the value token of a specified name-value pair.
+void SeekNamedValue(const char* name, dart::JSONScanner* scanner) {
+ while (!scanner->EOM()) {
+ scanner->Scan();
+ if (scanner->IsStringLiteral(name)) {
+ scanner->Scan();
+ ASSERT(scanner->CurrentToken() == dart::JSONScanner::TokenColon);
+ scanner->Scan();
+ return;
+ }
+ }
+}
+
+void VmStats::DumpStack() {
+ Log::Print("Isolate dump:\n");
+ IsolateTable::iterator itr;
+ MonitorLocker ml(instance_monitor_);
siva 2013/04/05 15:55:09 This could lead to potential deadlocks if the sign
+ for (itr = instance_->isolate_table_.begin();
+ itr != instance_->isolate_table_.end(); ++itr) {
+ Dart_Isolate isolate = itr->second;
+
+ // Print isolate name and details.
+ static char buffer[512];
+ snprintf(buffer, sizeof(buffer),
+ "/isolate/0x%"Px, reinterpret_cast<intptr_t>(isolate));
+ char* isolate_details = VmStatusService::GetVmStatus(buffer);
+ if (isolate_details != NULL) {
+ dart::JSONScanner scanner(isolate_details);
+ SeekNamedValue("name", &scanner);
+ char* name = strndup(scanner.TokenChars(), scanner.TokenLen());
+ SeekNamedValue("port", &scanner);
+ char* port = strndup(scanner.TokenChars(), scanner.TokenLen());
+ Log::Print("\"%s\" port=%s\n", name, port);
+ free(isolate_details);
+ free(port);
+ free(name);
+ }
+
+ // Print stack trace.
+ snprintf(buffer, sizeof(buffer),
+ "/isolate/0x%"Px"/stacktrace",
+ reinterpret_cast<intptr_t>(isolate));
+ char* trace = VmStatusService::GetVmStatus(buffer);
siva 2013/04/05 15:55:09 I assume this schedules an interrupt on the isolat
+ if (trace != NULL) {
+ dart::JSONScanner scanner(trace);
+ SeekNamedValue("url", &scanner);
+ char* url = strndup(scanner.TokenChars(), scanner.TokenLen());
+ SeekNamedValue("line", &scanner);
+ char* line = strndup(scanner.TokenChars(), scanner.TokenLen());
+ SeekNamedValue("function", &scanner);
+ char* function = strndup(scanner.TokenChars(), scanner.TokenLen());
+ Log::Print(" at %s(%s:%s)\n", function, url, line);
+ free(trace);
+ free(url);
+ free(line);
+ free(function);
+ }
+ }
+}
+
+
// Global static pointer used to ensure a single instance of the class.
VmStatusService* VmStatusService::instance_ = NULL;
« no previous file with comments | « runtime/bin/vmstats_impl.h ('k') | runtime/bin/vmstats_impl_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698