aboutsummaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/lib/_vec.rs5
-rw-r--r--src/rt/rust_builtin.cpp19
-rw-r--r--src/rt/rust_log.cpp1
-rw-r--r--src/rt/rust_log.h1
4 files changed, 25 insertions, 1 deletions
diff --git a/src/lib/_vec.rs b/src/lib/_vec.rs
index bd6553ce..bb6b337e 100644
--- a/src/lib/_vec.rs
+++ b/src/lib/_vec.rs
@@ -10,6 +10,7 @@ native "rust" mod rustrt {
* want to invoke this as vec_alloc[vec[U], U]. */
fn vec_alloc[T, U](uint n_elts) -> vec[U];
fn refcount[T](vec[T] v) -> uint;
+ fn vec_print_debug_info[T](vec[T] v);
}
fn alloc[T](uint n_elts) -> vec[T] {
@@ -58,6 +59,10 @@ fn buf_off[T](vec[T] v, uint offset) -> vbuf {
ret rustrt.vec_buf[T](v, offset);
}
+fn print_debug_info[T](vec[T] v) {
+ rustrt.vec_print_debug_info[T](v);
+}
+
// Returns elements from [start..end) from v.
fn slice[T](vec[T] v, int start, int end) -> vec[T] {
check(0 <= start);
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,
diff --git a/src/rt/rust_log.cpp b/src/rt/rust_log.cpp
index 50a107d5..c2a1bbe3 100644
--- a/src/rt/rust_log.cpp
+++ b/src/rt/rust_log.cpp
@@ -26,6 +26,7 @@ read_type_bit_mask() {
bits |= strstr(env_str, "cache") ? rust_log::CACHE : 0;
bits |= strstr(env_str, "timer") ? rust_log::TIMER : 0;
bits |= strstr(env_str, "gc") ? rust_log::GC : 0;
+ bits |= strstr(env_str, "stdlib") ? rust_log::STDLIB : 0;
bits |= strstr(env_str, "all") ? rust_log::ALL : 0;
bits = strstr(env_str, "none") ? 0 : bits;
}
diff --git a/src/rt/rust_log.h b/src/rt/rust_log.h
index 29c85e70..58b36f8d 100644
--- a/src/rt/rust_log.h
+++ b/src/rt/rust_log.h
@@ -41,6 +41,7 @@ public:
UPCALL = 0x200,
TIMER = 0x400,
GC = 0x800,
+ STDLIB = 0x1000,
ALL = 0xffffffff
};