From c0d4e88428296b8da6f2616f47c760b32abf66ed Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Fri, 31 Dec 2010 10:35:39 -0800 Subject: [PATCH] Add std.dbg.trap(str msg) for help debugging. --- src/lib/dbg.rs | 5 +++++ src/rt/rust_builtin.cpp | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/src/lib/dbg.rs b/src/lib/dbg.rs index 51a31e07d13..774052dcaf5 100644 --- a/src/lib/dbg.rs +++ b/src/lib/dbg.rs @@ -18,6 +18,7 @@ native "rust" mod rustrt { fn debug_obj[T](&T x, uint nmethods, uint nbytes); fn debug_fn[T](&T x); fn debug_ptrcast[T, U](@T x) -> @U; + fn debug_trap(str msg); } fn debug_vec[T](vec[T] v) { @@ -61,6 +62,10 @@ fn ptr_cast[T, U](@T x) -> @U { ret rustrt.debug_ptrcast[T, U](x); } +fn trap(str s) { + rustrt.debug_trap(s); +} + // Local Variables: // mode: rust; // fill-column: 78; diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index cb16fbf067d..84111d826e7 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -363,6 +363,14 @@ debug_ptrcast(rust_task *task, return ptr; } +extern "C" CDECL void +debug_trap(rust_task *task, rust_str *s) +{ + task->log(rust_log::STDLIB, "trapping: %s", s->data); + // FIXME: x86-ism. + __asm__("int3"); +} + // // Local Variables: