Skip to content

Commit 544a8b5

Browse files
committed
---
yaml --- r: 10351 b: refs/heads/snap-stage3 c: c816eea h: refs/heads/master i: 10349: f8afd0e 10347: 100bc36 10343: 3fa6bd5 10335: 92498a5 v: v3
1 parent d4f61b4 commit 544a8b5

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 2898dcc5d97da9427ac367542382b6239d9c0bbf
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 469ff08e646d4f56403a8d6dbd97d146bd8eeefb
4+
refs/heads/snap-stage3: c816eea000f56e250bb251dc1a1d357efd5a0438
55
refs/heads/try: 2898dcc5d97da9427ac367542382b6239d9c0bbf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/snap-stage3/src/libstd/dbg.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export debug_tag;
99
export debug_fn;
1010
export ptr_cast;
1111
export refcount;
12+
export breakpoint;
1213

1314
#[abi = "cdecl"]
1415
native mod rustrt {
@@ -18,6 +19,7 @@ native mod rustrt {
1819
fn debug_tag(td: *sys::type_desc, x: *());
1920
fn debug_fn(td: *sys::type_desc, x: *());
2021
fn debug_ptrcast(td: *sys::type_desc, x: *()) -> *();
22+
fn rust_dbg_breakpoint();
2123
}
2224

2325
fn debug_tydesc<T>() {
@@ -51,6 +53,18 @@ fn refcount<T>(a: @T) -> uint unsafe {
5153
ret *p;
5254
}
5355

56+
#[doc = "Triggers a debugger breakpoint"]
57+
fn breakpoint() {
58+
rustrt::rust_dbg_breakpoint();
59+
}
60+
61+
#[test]
62+
fn test_breakpoint_should_not_abort_process_when_not_under_gdb() {
63+
// Triggering a breakpoint involves raising SIGTRAP, which terminates
64+
// the process under normal circumstances
65+
breakpoint();
66+
}
67+
5468
// Local Variables:
5569
// mode: rust;
5670
// fill-column: 78;

branches/snap-stage3/src/rt/rust_builtin.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,11 @@ rust_dbg_call(dbg_callback cb, void *data) {
805805
return cb(data);
806806
}
807807

808+
extern "C" CDECL void
809+
rust_dbg_breakpoint() {
810+
BREAKPOINT_AWESOME;
811+
}
812+
808813
extern "C" CDECL rust_sched_id
809814
rust_osmain_sched_id() {
810815
rust_task *task = rust_get_current_task();

branches/snap-stage3/src/rt/rust_debug.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@
77
#include <string>
88
#include <cstdlib>
99

10+
#ifndef _WIN32
11+
12+
#include <signal.h>
13+
#define BREAKPOINT_AWESOME \
14+
do { \
15+
signal(SIGTRAP, SIG_IGN); \
16+
raise(SIGTRAP); \
17+
} while (0)
18+
19+
#else
20+
#define BREAKPOINT_AWESOME
21+
#endif
22+
1023
struct rust_task;
1124

1225
namespace debug {

branches/snap-stage3/src/rt/rustrt.def.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ rust_dbg_lock_unlock
151151
rust_dbg_lock_wait
152152
rust_dbg_lock_signal
153153
rust_dbg_call
154+
rust_dbg_breakpoint
154155
rust_osmain_sched_id
155156
rust_compare_and_swap_ptr
156157
rust_atomic_increment

0 commit comments

Comments
 (0)