1 // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 //! Unsafe debugging functions for inspecting values.
13 use core::cast::transmute;
21 pub unsafe fn debug_tydesc(td: *sys::TypeDesc);
22 pub unsafe fn debug_opaque(td: *sys::TypeDesc, x: *());
23 pub unsafe fn debug_box(td: *sys::TypeDesc, x: *());
24 pub unsafe fn debug_tag(td: *sys::TypeDesc, x: *());
25 pub unsafe fn debug_fn(td: *sys::TypeDesc, x: *());
26 pub unsafe fn debug_ptrcast(td: *sys::TypeDesc, x: *()) -> *();
27 pub unsafe fn rust_dbg_breakpoint();
31 pub fn debug_tydesc<T>() {
33 rustrt::debug_tydesc(sys::get_type_desc::<T>());
37 pub fn debug_opaque<T>(x: T) {
39 rustrt::debug_opaque(sys::get_type_desc::<T>(), transmute(&x));
43 pub fn debug_box<T>(x: @T) {
45 rustrt::debug_box(sys::get_type_desc::<T>(), transmute(&x));
49 pub fn debug_tag<T>(x: T) {
51 rustrt::debug_tag(sys::get_type_desc::<T>(), transmute(&x));
55 pub fn debug_fn<T>(x: T) {
57 rustrt::debug_fn(sys::get_type_desc::<T>(), transmute(&x));
61 pub unsafe fn ptr_cast<T, U>(x: @T) -> @U {
63 rustrt::debug_ptrcast(sys::get_type_desc::<T>(), transmute(x)))
66 /// Triggers a debugger breakpoint
69 rustrt::rust_dbg_breakpoint();
74 fn test_breakpoint_should_not_abort_process_when_not_under_gdb() {
75 // Triggering a breakpoint involves raising SIGTRAP, which terminates
76 // the process under normal circumstances