Skip to content

Commit 5ee89f3

Browse files
committed
add an option to the final cc so that it prints out/logs unreclaimed ptrs
1 parent acb129c commit 5ee89f3

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/rt/rust_cc.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <set>
1313
#include <vector>
1414
#include <stdint.h>
15+
#include <ios>
1516

1617
// The number of allocations Rust code performs before performing cycle
1718
// collection.
@@ -20,6 +21,8 @@
2021
// defined in rust_upcall.cpp:
2122
void upcall_s_free_shared_type_desc(type_desc *td);
2223

24+
using namespace std;
25+
2326
namespace cc {
2427

2528
// Internal reference count computation
@@ -659,6 +662,25 @@ do_cc(rust_task *task) {
659662
sweep::do_sweep(task, marked);
660663
}
661664

665+
void
666+
do_final_cc(rust_task *task) {
667+
do_cc(task);
668+
669+
boxed_region *boxed = &task->boxed;
670+
for (rust_opaque_box *box = boxed->first_live_alloc();
671+
box != NULL;
672+
box = box->next) {
673+
cerr << "Unreclaimed object found at " << (void*) box << ": ";
674+
const type_desc *td = box->td;
675+
shape::arena arena;
676+
shape::type_param *params = shape::type_param::from_tydesc(td, arena);
677+
shape::log log(task, true, td->shape, params, td->shape_tables,
678+
(uint8_t*)box_body(box), cerr);
679+
log.walk();
680+
cerr << "\n";
681+
}
682+
}
683+
662684
void
663685
maybe_cc(rust_task *task) {
664686
static debug::flag zeal("RUST_CC_ZEAL");

src/rt/rust_cc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ struct rust_task;
99
namespace cc {
1010

1111
void do_cc(rust_task *task);
12+
13+
// performs a cycle coll then asserts that there is nothing left
14+
void do_final_cc(rust_task *task);
15+
1216
void maybe_cc(rust_task *task);
1317

1418
} // end namespace cc

src/rt/rust_task.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ cleanup_task(cleanup_args *args) {
149149
bool threw_exception = args->threw_exception;
150150
rust_task *task = a->task;
151151

152-
cc::do_cc(task);
152+
cc::do_final_cc(task);
153153

154154
task->die();
155155

0 commit comments

Comments
 (0)