about summary refs log tree commit diff
path: root/src/rt
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2012-02-24 11:03:23 -0800
committerNiko Matsakis <niko@alum.mit.edu>2012-02-24 20:46:27 -0800
commit5ee89f3f2adbc1b087820f6b929d1dbd3057a507 (patch)
tree4bf5adb90854547a17487b168904334cf19bc4b3 /src/rt
parentacb129c5412bdc4375bb3a31a192ea6e7f26ebcc (diff)
downloadrust-5ee89f3f2adbc1b087820f6b929d1dbd3057a507.tar.gz
rust-5ee89f3f2adbc1b087820f6b929d1dbd3057a507.zip
add an option to the final cc so that it prints out/logs unreclaimed ptrs
Diffstat (limited to 'src/rt')
-rw-r--r--src/rt/rust_cc.cpp22
-rw-r--r--src/rt/rust_cc.h4
-rw-r--r--src/rt/rust_task.cpp2
3 files changed, 27 insertions, 1 deletions
diff --git a/src/rt/rust_cc.cpp b/src/rt/rust_cc.cpp
index ec54b1ef181..eb99e28b2d0 100644
--- a/src/rt/rust_cc.cpp
+++ b/src/rt/rust_cc.cpp
@@ -12,6 +12,7 @@
 #include <set>
 #include <vector>
 #include <stdint.h>
+#include <ios>
 
 // The number of allocations Rust code performs before performing cycle
 // collection.
@@ -20,6 +21,8 @@
 // defined in rust_upcall.cpp:
 void upcall_s_free_shared_type_desc(type_desc *td);
 
+using namespace std;
+
 namespace cc {
 
 // Internal reference count computation
@@ -660,6 +663,25 @@ do_cc(rust_task *task) {
 }
 
 void
+do_final_cc(rust_task *task) {
+    do_cc(task);
+
+    boxed_region *boxed = &task->boxed;
+    for (rust_opaque_box *box = boxed->first_live_alloc();
+         box != NULL;
+         box = box->next) {
+        cerr << "Unreclaimed object found at " << (void*) box << ": ";
+        const type_desc *td = box->td;
+        shape::arena arena;
+        shape::type_param *params = shape::type_param::from_tydesc(td, arena);
+        shape::log log(task, true, td->shape, params, td->shape_tables,
+                       (uint8_t*)box_body(box), cerr);
+        log.walk();
+        cerr << "\n";
+    }
+}
+
+void
 maybe_cc(rust_task *task) {
     static debug::flag zeal("RUST_CC_ZEAL");
     if (*zeal) {
diff --git a/src/rt/rust_cc.h b/src/rt/rust_cc.h
index 991e69d5c31..2edab782d9c 100644
--- a/src/rt/rust_cc.h
+++ b/src/rt/rust_cc.h
@@ -9,6 +9,10 @@ struct rust_task;
 namespace cc {
 
 void do_cc(rust_task *task);
+
+// performs a cycle coll then asserts that there is nothing left
+void do_final_cc(rust_task *task);
+
 void maybe_cc(rust_task *task);
 
 }   // end namespace cc
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index a2887d986f5..9922e34f798 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -149,7 +149,7 @@ cleanup_task(cleanup_args *args) {
     bool threw_exception = args->threw_exception;
     rust_task *task = a->task;
 
-    cc::do_cc(task);
+    cc::do_final_cc(task);
 
     task->die();