From 445d3fe39cbe6b56b72fd08065e3569d73aeb10b Mon Sep 17 00:00:00 2001 From: Roy Frostig Date: Thu, 12 Aug 2010 13:11:49 -0700 Subject: Add vec debugging utility to _vec module. --- src/rt/rust_builtin.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/rt/rust_builtin.cpp') diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 596a05cc31b..5b1f7ae2947 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -82,7 +82,7 @@ extern "C" CDECL rust_vec* vec_alloc(rust_task *task, type_desc *t, type_desc *elem_t, size_t n_elts) { rust_dom *dom = task->dom; - task->log(rust_log::MEM, + task->log(rust_log::MEM | rust_log::STDLIB, "vec_alloc %" PRIdPTR " elements of size %" PRIdPTR, n_elts, elem_t->size); size_t fill = n_elts * elem_t->size; @@ -108,6 +108,23 @@ vec_len(rust_task *task, type_desc *ty, rust_vec *v) return v->fill / ty->size; } +extern "C" CDECL void +vec_print_debug_info(rust_task *task, type_desc *ty, rust_vec *v) +{ + task->log(rust_log::STDLIB, + "vec_print_debug_info(%" PRIxPTR ")" + " with tydesc %" PRIxPTR + " (size = %" PRIdPTR ", align = %" PRIdPTR ")" + " alloc = %" PRIdPTR ", fill = %" PRIdPTR + " , data = ...", v, ty, ty->size, ty->align, v->alloc, v->fill); + + for (size_t i = 0; i < v->fill; ++i) { + task->log(rust_log::STDLIB, + " %" PRIdPTR ": 0x%" PRIxPTR, + i, v->data[i]); + } +} + /* Helper for str_alloc and str_from_vec. Returns NULL as failure. */ static rust_str * str_alloc_with_data(rust_task *task, -- cgit 1.4.1-3-g733a5