about summary refs log tree commit diff
path: root/src/libstd/dbg.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstd/dbg.rs')
-rw-r--r--src/libstd/dbg.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libstd/dbg.rs b/src/libstd/dbg.rs
index 6b8a4f36002..b0abd8cb73a 100644
--- a/src/libstd/dbg.rs
+++ b/src/libstd/dbg.rs
@@ -9,6 +9,7 @@ export debug_tag;
 export debug_fn;
 export ptr_cast;
 export refcount;
+export breakpoint;
 
 #[abi = "cdecl"]
 native mod rustrt {
@@ -18,6 +19,7 @@ native mod rustrt {
     fn debug_tag(td: *sys::type_desc, x: *());
     fn debug_fn(td: *sys::type_desc, x: *());
     fn debug_ptrcast(td: *sys::type_desc, x: *()) -> *();
+    fn rust_dbg_breakpoint();
 }
 
 fn debug_tydesc<T>() {
@@ -51,6 +53,18 @@ fn refcount<T>(a: @T) -> uint unsafe {
     ret *p;
 }
 
+#[doc = "Triggers a debugger breakpoint"]
+fn breakpoint() {
+    rustrt::rust_dbg_breakpoint();
+}
+
+#[test]
+fn test_breakpoint_should_not_abort_process_when_not_under_gdb() {
+    // Triggering a breakpoint involves raising SIGTRAP, which terminates
+    // the process under normal circumstances
+    breakpoint();
+}
+
 // Local Variables:
 // mode: rust;
 // fill-column: 78;