Skip to content

add a breakpoint intrinsic for debugging #10610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 22, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2759,6 +2759,7 @@ pub fn declare_intrinsics(llmod: ModuleRef) -> HashMap<&'static str, ValueRef> {
[i8p, Type::i8(), Type::i64(), Type::i32(), Type::i1()], Type::void());

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

ifn!(intrinsics, "llvm.powi.f32", [Type::f32(), Type::i32()], Type::f32());
Expand Down
5 changes: 5 additions & 0 deletions src/librustc/middle/trans/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ pub fn trans_intrinsic(ccx: @mut CrateContext,
Call(bcx, llfn, [], []);
Unreachable(bcx);
}
"breakpoint" => {
let llfn = bcx.ccx().intrinsics.get_copy(&("llvm.debugtrap"));
Call(bcx, llfn, [], []);
RetVoid(bcx);
}
"size_of" => {
let tp_ty = substs.tys[0];
let lltp_ty = type_of::type_of(ccx, tp_ty);
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/middle/typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3968,7 +3968,8 @@ pub fn check_intrinsic_type(ccx: @mut CrateCtxt, it: @ast::foreign_item) {

} else {
match name {
"abort" => (0, ~[], ty::mk_bot()),
"abort" => (0, ~[], ty::mk_bot()),
"breakpoint" => (0, ~[], ty::mk_nil()),
"size_of" |
"pref_align_of" | "min_align_of" => (1u, ~[], ty::mk_uint()),
"init" => (1u, ~[], param(ccx, 0u)),
Expand Down
4 changes: 4 additions & 0 deletions src/libstd/unstable/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ extern "rust-intrinsic" {
/// Abort the execution of the process.
pub fn abort() -> !;

/// Execute a breakpoint trap, for inspection by a debugger.
#[cfg(not(stage0))]
pub fn breakpoint();

/// Atomic compare and exchange, sequentially consistent.
pub fn atomic_cxchg(dst: &mut int, old: int, src: int) -> int;
/// Atomic compare and exchange, acquire ordering.
Expand Down