Skip to content

Commit d3cb24b

Browse files
committed
auto merge of #10610 : thestinger/rust/breakpoint, r=pnkfelix
This can be used to grab the attention of a debugger, and unlike `abort` execution can be resumed.
2 parents cad1f89 + bf61641 commit d3cb24b

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

src/librustc/middle/trans/base.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2759,6 +2759,7 @@ pub fn declare_intrinsics(llmod: ModuleRef) -> HashMap<&'static str, ValueRef> {
27592759
[i8p, Type::i8(), Type::i64(), Type::i32(), Type::i1()], Type::void());
27602760

27612761
ifn!(intrinsics, "llvm.trap", [], Type::void());
2762+
ifn!(intrinsics, "llvm.debugtrap", [], Type::void());
27622763
ifn!(intrinsics, "llvm.frameaddress", [Type::i32()], i8p);
27632764

27642765
ifn!(intrinsics, "llvm.powi.f32", [Type::f32(), Type::i32()], Type::f32());

src/librustc/middle/trans/intrinsic.rs

+5
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ pub fn trans_intrinsic(ccx: @mut CrateContext,
228228
Call(bcx, llfn, [], []);
229229
Unreachable(bcx);
230230
}
231+
"breakpoint" => {
232+
let llfn = bcx.ccx().intrinsics.get_copy(&("llvm.debugtrap"));
233+
Call(bcx, llfn, [], []);
234+
RetVoid(bcx);
235+
}
231236
"size_of" => {
232237
let tp_ty = substs.tys[0];
233238
let lltp_ty = type_of::type_of(ccx, tp_ty);

src/librustc/middle/typeck/check/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3968,7 +3968,8 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) {
39683968

39693969
} else {
39703970
match name {
3971-
"abort" => (0, ~[], ty::mk_bot()),
3971+
"abort" => (0, ~[], ty::mk_bot()),
3972+
"breakpoint" => (0, ~[], ty::mk_nil()),
39723973
"size_of" |
39733974
"pref_align_of" | "min_align_of" => (1u, ~[], ty::mk_uint()),
39743975
"init" => (1u, ~[], param(ccx, 0u)),

src/libstd/unstable/intrinsics.rs

+4
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ extern "rust-intrinsic" {
176176
/// Abort the execution of the process.
177177
pub fn abort() -> !;
178178

179+
/// Execute a breakpoint trap, for inspection by a debugger.
180+
#[cfg(not(stage0))]
181+
pub fn breakpoint();
182+
179183
/// Atomic compare and exchange, sequentially consistent.
180184
pub fn atomic_cxchg(dst: &mut int, old: int, src: int) -> int;
181185
/// Atomic compare and exchange, acquire ordering.

0 commit comments

Comments
 (0)