about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMichael Bebenita <mbebenita@mozilla.com>2010-08-09 07:34:11 -0700
committerMichael Bebenita <mbebenita@mozilla.com>2010-08-09 07:34:11 -0700
commit56cd4e458a6c3cd40a8ee2ceb0a0fdab0352bf20 (patch)
treebdc9c70bf64dc46a9838c38afa42673198ed3c67 /src
parentc5744c8aefa1c9f74e779af2c5ceb852640b28b7 (diff)
downloadrust-56cd4e458a6c3cd40a8ee2ceb0a0fdab0352bf20.tar.gz
rust-56cd4e458a6c3cd40a8ee2ceb0a0fdab0352bf20.zip
Made the runtime keep track of all live domains and print their state.
Diffstat (limited to 'src')
-rw-r--r--src/rt/rust_dom.cpp15
-rw-r--r--src/rt/rust_dom.h1
2 files changed, 16 insertions, 0 deletions
diff --git a/src/rt/rust_dom.cpp b/src/rt/rust_dom.cpp
index 99aaddb2b15..97e327463c3 100644
--- a/src/rt/rust_dom.cpp
+++ b/src/rt/rust_dom.cpp
@@ -4,6 +4,8 @@
 
 template class ptr_vec<rust_task>;
 
+// Keeps track of all live domains, for debugging purposes.
+array_list<rust_dom*> _live_domains;
 
 rust_dom::rust_dom(rust_srv *srv, rust_crate const *root_crate) :
     interrupt_flag(0),
@@ -26,6 +28,10 @@ rust_dom::rust_dom(rust_srv *srv, rust_crate const *root_crate) :
     pthread_attr_setdetachstate(&attr, true);
 #endif
     root_task = new (this) rust_task(this, NULL);
+
+    if (_live_domains.replace(NULL, this) == false) {
+        _live_domains.append(this);
+    }
 }
 
 static void
@@ -73,6 +79,8 @@ rust_dom::~rust_dom() {
 #endif
     while (caches.length())
         delete caches.pop();
+
+    _live_domains.replace(this, NULL);
 }
 
 void
@@ -322,6 +330,13 @@ rust_dom::schedule_task()
 }
 
 void
+rust_dom::log_all_state() {
+    for (uint32_t i = 0; i < _live_domains.size(); i++) {
+        _live_domains[i]->log_state();
+    }
+}
+
+void
 rust_dom::log_state() {
     if (!running_tasks.is_empty()) {
         log(rust_log::TASK, "running tasks:");
diff --git a/src/rt/rust_dom.h b/src/rt/rust_dom.h
index 528790d56cc..4f3a91dcc4b 100644
--- a/src/rt/rust_dom.h
+++ b/src/rt/rust_dom.h
@@ -84,6 +84,7 @@ struct rust_dom
     int start_main_loop();
 
     void log_state();
+    static void log_all_state();
 };
 
 //