Skip to content

Commit 21f74be

Browse files
committed
add a new runtime log (::rt::box) and make boxed_region use it
1 parent 8be944e commit 21f74be

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

src/rt/boxed_region.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ rust_opaque_box *boxed_region::malloc(type_desc *td) {
2020
if (live_allocs) live_allocs->prev = box;
2121
live_allocs = box;
2222

23-
# ifdef DUMP_BOXED_REGION
24-
fprintf(stderr, "Allocated box %p with td %p,"
25-
" size %lu==%lu+%lu, align %lu, prev %p, next %p\n",
26-
box, td, total_size, header_size, body_size, body_align,
27-
box->prev, box->next);
28-
# endif
23+
LOG(rust_get_current_task(), box,
24+
"@malloc()=%p with td %p, size %lu==%lu+%lu, "
25+
"align %lu, prev %p, next %p\n",
26+
box, td, total_size, header_size, body_size, body_align,
27+
box->prev, box->next);
2928

3029
return box;
3130
}
@@ -46,10 +45,9 @@ void boxed_region::free(rust_opaque_box *box) {
4645
// double frees (kind of).
4746
assert(box->td != NULL);
4847

49-
# ifdef DUMP_BOXED_REGION
50-
fprintf(stderr, "Freed box %p with td %p, prev %p, next %p\n",
51-
box, box->td, box->prev, box->next);
52-
# endif
48+
LOG(rust_get_current_task(), box,
49+
"@free(%p) with td %p, prev %p, next %p\n",
50+
box, box->td, box->prev, box->next);
5351

5452
if (box->prev) box->prev->next = box->next;
5553
if (box->next) box->next->prev = box->prev;

src/rt/rust_log.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ void print_crate_log_map(const cratemap* map) {
236236
// These are pseudo-modules used to control logging in the runtime.
237237

238238
uint32_t log_rt_mem;
239+
uint32_t log_rt_box;
239240
uint32_t log_rt_comm;
240241
uint32_t log_rt_task;
241242
uint32_t log_rt_dom;
@@ -251,6 +252,7 @@ uint32_t log_rt_callback;
251252

252253
static const mod_entry _rt_module_map[] =
253254
{{"::rt::mem", &log_rt_mem},
255+
{"::rt::box", &log_rt_box},
254256
{"::rt::comm", &log_rt_comm},
255257
{"::rt::task", &log_rt_task},
256258
{"::rt::dom", &log_rt_dom},

src/rt/rust_log.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class rust_log {
5858
void update_log_settings(void* crate_map, char* settings);
5959

6060
extern uint32_t log_rt_mem;
61+
extern uint32_t log_rt_box;
6162
extern uint32_t log_rt_comm;
6263
extern uint32_t log_rt_task;
6364
extern uint32_t log_rt_dom;

0 commit comments

Comments
 (0)