aboutsummaryrefslogtreecommitdiff
path: root/src/rt/rust_builtin.cpp
diff options
context:
space:
mode:
authorRoy Frostig <[email protected]>2010-08-12 13:11:49 -0700
committerRoy Frostig <[email protected]>2010-08-12 13:11:49 -0700
commit445d3fe39cbe6b56b72fd08065e3569d73aeb10b (patch)
tree48840896b8213eed99efae3ee6298465055f67b6 /src/rt/rust_builtin.cpp
parentAdd more LLVM library bindings to rustc. (diff)
downloadrust-445d3fe39cbe6b56b72fd08065e3569d73aeb10b.tar.xz
rust-445d3fe39cbe6b56b72fd08065e3569d73aeb10b.zip
Add vec debugging utility to _vec module.
Diffstat (limited to 'src/rt/rust_builtin.cpp')
-rw-r--r--src/rt/rust_builtin.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index 596a05cc..5b1f7ae2 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,