about summary refs log tree commit diff
path: root/src/rt
diff options
context:
space:
mode:
authorEric Holk <eholk@mozilla.com>2011-07-27 16:33:31 -0700
committerEric Holk <eholk@mozilla.com>2011-07-28 10:47:28 -0700
commitb85dee8d5b223869c1b8c3917ed41b5373a29bb1 (patch)
tree4e4b1248272347ed741e3a89baa8ef501f9ea844 /src/rt
parent9ea8476faaa75fe9399d6124504d40edbc613eea (diff)
downloadrust-b85dee8d5b223869c1b8c3917ed41b5373a29bb1.tar.gz
rust-b85dee8d5b223869c1b8c3917ed41b5373a29bb1.zip
Resurrecting some of the logging in rust_chan.cpp
Diffstat (limited to 'src/rt')
-rw-r--r--src/rt/rust_chan.cpp24
-rw-r--r--src/rt/rust_kernel.cpp32
-rw-r--r--src/rt/rust_log.h9
3 files changed, 35 insertions, 30 deletions
diff --git a/src/rt/rust_chan.cpp b/src/rt/rust_chan.cpp
index dc6ea0fefdf..c32e6b6cc5b 100644
--- a/src/rt/rust_chan.cpp
+++ b/src/rt/rust_chan.cpp
@@ -13,14 +13,14 @@ rust_chan::rust_chan(rust_kernel *kernel, maybe_proxy<rust_port> *port,
     if (port) {
         associate(port);
     }
-    // DLOG(task->sched, comm, "new rust_chan(task=0x%" PRIxPTR
-    //     ", port=0x%" PRIxPTR ") -> chan=0x%" PRIxPTR,
-    //     (uintptr_t) task, (uintptr_t) port, (uintptr_t) this);
+    KLOG(kernel, comm, "new rust_chan(task=0x%" PRIxPTR
+        ", port=0x%" PRIxPTR ") -> chan=0x%" PRIxPTR,
+        (uintptr_t) task, (uintptr_t) port, (uintptr_t) this);
 }
 
 rust_chan::~rust_chan() {
-    // DLOG(kernel->sched, comm, "del rust_chan(task=0x%" PRIxPTR ")",
-    //      (uintptr_t) this);
+    KLOG(kernel, comm, "del rust_chan(task=0x%" PRIxPTR ")",
+         (uintptr_t) this);
 
     // A(kernel->sched, is_associated() == false,
     //   "Channel must be disassociated before being freed.");
@@ -33,9 +33,9 @@ void rust_chan::associate(maybe_proxy<rust_port> *port) {
     this->port = port;
     if (port->is_proxy() == false) {
         scoped_lock with(port->referent()->lock);
-        // DLOG(kernel->sched, task,
-        //     "associating chan: 0x%" PRIxPTR " with port: 0x%" PRIxPTR,
-        //     this, port);
+        KLOG(kernel, task,
+            "associating chan: 0x%" PRIxPTR " with port: 0x%" PRIxPTR,
+            this, port);
         ++this->ref_count;
         this->task = port->referent()->task;
         this->task->ref();
@@ -56,9 +56,9 @@ void rust_chan::disassociate() {
 
     if (port->is_proxy() == false) {
         scoped_lock with(port->referent()->lock);
-        // DLOG(kernel->sched, task,
-        //     "disassociating chan: 0x%" PRIxPTR " from port: 0x%" PRIxPTR,
-        //     this, port->referent());
+        KLOG(kernel, task,
+             "disassociating chan: 0x%" PRIxPTR " from port: 0x%" PRIxPTR,
+             this, port->referent());
         --this->ref_count;
         task->deref();
         this->task = NULL;
@@ -98,7 +98,7 @@ void rust_chan::send(void *sptr) {
         buffer.dequeue(NULL);
     } else {
         if (target_port->task->blocked_on(target_port)) {
-            // DLOG(sched, comm, "dequeued in rendezvous_ptr");
+            KLOG(kernel, comm, "dequeued in rendezvous_ptr");
             buffer.dequeue(target_port->task->rendezvous_ptr);
             target_port->task->rendezvous_ptr = 0;
             target_port->task->wakeup(target_port);
diff --git a/src/rt/rust_kernel.cpp b/src/rt/rust_kernel.cpp
index 896115c81ea..a1b101ae9d4 100644
--- a/src/rt/rust_kernel.cpp
+++ b/src/rt/rust_kernel.cpp
@@ -1,11 +1,7 @@
 #include "rust_internal.h"
 
-#define KLOG(...)                                          \
-  do {                                                     \
-      if (log_rt_kern >= log_note) {                       \
-          log(log_note, __VA_ARGS__);                      \
-      }                                                    \
-  } while (0)
+#define KLOG_(...) \
+    KLOG(this, kern, __VA_ARGS__)
 
 rust_kernel::rust_kernel(rust_srv *srv, size_t num_threads) :
     _region(srv, true),
@@ -32,8 +28,8 @@ rust_kernel::create_scheduler(int id) {
     rust_handle<rust_scheduler> *handle = internal_get_sched_handle(sched);
     message_queue->associate(handle);
     message_queues.append(message_queue);
-    KLOG("created scheduler: " PTR ", id: %d, index: %d",
-         sched, id, sched->list_index);
+    KLOG_("created scheduler: " PTR ", id: %d, index: %d",
+          sched, id, sched->list_index);
     _kernel_lock.signal_all();
     _kernel_lock.unlock();
     return sched;
@@ -42,7 +38,7 @@ rust_kernel::create_scheduler(int id) {
 void
 rust_kernel::destroy_scheduler(rust_scheduler *sched) {
     _kernel_lock.lock();
-    KLOG("deleting scheduler: " PTR ", name: %s, index: %d",
+    KLOG_("deleting scheduler: " PTR ", name: %s, index: %d",
         sched, sched->name, sched->list_index);
     sched->message_queue->disassociate();
     rust_srv *srv = sched->srv;
@@ -166,14 +162,14 @@ rust_kernel::start_kernel_loop() {
 
 void
 rust_kernel::run() {
-    KLOG("started kernel loop");
+    KLOG_("started kernel loop");
     start_kernel_loop();
-    KLOG("finished kernel loop");
+    KLOG_("finished kernel loop");
 }
 
 void
 rust_kernel::terminate_kernel_loop() {
-    KLOG("terminating kernel loop");
+    KLOG_("terminating kernel loop");
     _interrupt_kernel_loop = true;
     signal_kernel_lock();
     join();
@@ -190,16 +186,16 @@ rust_kernel::~rust_kernel() {
     // messages.
     pump_message_queues();
 
-    KLOG("freeing handles");
+    KLOG_("freeing handles");
 
     free_handles(_task_handles);
-    KLOG("..task handles freed");
+    KLOG_("..task handles freed");
     free_handles(_port_handles);
-    KLOG("..port handles freed");
+    KLOG_("..port handles freed");
     free_handles(_sched_handles);
-    KLOG("..sched handles freed");
+    KLOG_("..sched handles freed");
 
-    KLOG("freeing queues");
+    KLOG_("freeing queues");
 
     rust_message_queue *queue = NULL;
     while (message_queues.pop(&queue)) {
@@ -228,7 +224,7 @@ rust_kernel::free_handles(hash_map<T*, rust_handle<T>* > &map) {
     T* key;
     rust_handle<T> *value;
     while (map.pop(&key, &value)) {
-        KLOG("...freeing " PTR, value);
+        KLOG_("...freeing " PTR, value);
         delete value;
     }
 }
diff --git a/src/rt/rust_log.h b/src/rt/rust_log.h
index ce0d8f593ef..d14cb022bfd 100644
--- a/src/rt/rust_log.h
+++ b/src/rt/rust_log.h
@@ -23,6 +23,15 @@ const uint32_t log_note = 1;
         }                                                       \
     } while (0)
 
+#define KLOG(k, field, ...) \
+    KLOG_LVL(k, field, log_note, __VA_ARGS__)
+#define KLOG_LVL(k, field, lvl, ...)                          \
+    do {                                                      \
+        if (log_rt_##field >= lvl) {                          \
+            (k)->log(lvl, __VA_ARGS__);                       \
+        }                                                     \
+    } while (0)
+
 struct rust_scheduler;
 struct rust_task;