From 21f74be2c1180e01ef4985d36b91130d0838da37 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 13 Apr 2012 17:52:36 -0700 Subject: [PATCH] add a new runtime log (::rt::box) and make boxed_region use it --- src/rt/boxed_region.cpp | 18 ++++++++---------- src/rt/rust_log.cpp | 2 ++ src/rt/rust_log.h | 1 + 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/rt/boxed_region.cpp b/src/rt/boxed_region.cpp index 5eec01730f4..2612d0f47b9 100644 --- a/src/rt/boxed_region.cpp +++ b/src/rt/boxed_region.cpp @@ -20,12 +20,11 @@ rust_opaque_box *boxed_region::malloc(type_desc *td) { if (live_allocs) live_allocs->prev = box; live_allocs = box; -# ifdef DUMP_BOXED_REGION - fprintf(stderr, "Allocated box %p with td %p," - " size %lu==%lu+%lu, align %lu, prev %p, next %p\n", - box, td, total_size, header_size, body_size, body_align, - box->prev, box->next); -# endif + LOG(rust_get_current_task(), box, + "@malloc()=%p with td %p, size %lu==%lu+%lu, " + "align %lu, prev %p, next %p\n", + box, td, total_size, header_size, body_size, body_align, + box->prev, box->next); return box; } @@ -46,10 +45,9 @@ void boxed_region::free(rust_opaque_box *box) { // double frees (kind of). assert(box->td != NULL); -# ifdef DUMP_BOXED_REGION - fprintf(stderr, "Freed box %p with td %p, prev %p, next %p\n", - box, box->td, box->prev, box->next); -# endif + LOG(rust_get_current_task(), box, + "@free(%p) with td %p, prev %p, next %p\n", + box, box->td, box->prev, box->next); if (box->prev) box->prev->next = box->next; if (box->next) box->next->prev = box->prev; diff --git a/src/rt/rust_log.cpp b/src/rt/rust_log.cpp index df1ae6fd47f..29d35e27c21 100644 --- a/src/rt/rust_log.cpp +++ b/src/rt/rust_log.cpp @@ -236,6 +236,7 @@ void print_crate_log_map(const cratemap* map) { // These are pseudo-modules used to control logging in the runtime. uint32_t log_rt_mem; +uint32_t log_rt_box; uint32_t log_rt_comm; uint32_t log_rt_task; uint32_t log_rt_dom; @@ -251,6 +252,7 @@ uint32_t log_rt_callback; static const mod_entry _rt_module_map[] = {{"::rt::mem", &log_rt_mem}, + {"::rt::box", &log_rt_box}, {"::rt::comm", &log_rt_comm}, {"::rt::task", &log_rt_task}, {"::rt::dom", &log_rt_dom}, diff --git a/src/rt/rust_log.h b/src/rt/rust_log.h index 423f66fa7cd..c66f65d00ab 100644 --- a/src/rt/rust_log.h +++ b/src/rt/rust_log.h @@ -58,6 +58,7 @@ private: void update_log_settings(void* crate_map, char* settings); extern uint32_t log_rt_mem; +extern uint32_t log_rt_box; extern uint32_t log_rt_comm; extern uint32_t log_rt_task; extern uint32_t log_rt_dom;