Add std.dbg.trap(str msg) for help debugging.

This commit is contained in:
Graydon Hoare 2010-12-31 10:35:39 -08:00
parent 065542378c
commit c0d4e88428
2 changed files with 13 additions and 0 deletions

View File

@ -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;

View File

@ -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: