Skip to content

debuginfo: Improved stepping for if-expressions #10552

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 19, 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
9 changes: 9 additions & 0 deletions src/librustc/middle/trans/controlflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use middle::trans::base::*;
use middle::trans::build::*;
use middle::trans::callee;
use middle::trans::common::*;
use middle::trans::debuginfo;
use middle::trans::expr;
use middle::ty;
use util::common::indenter;
Expand Down Expand Up @@ -75,6 +76,7 @@ pub fn trans_if(bcx: @mut Block,
// if true { .. } [else { .. }]
return do with_scope(bcx, thn.info(), "if_true_then") |bcx| {
let bcx_out = trans_block(bcx, thn, dest);
debuginfo::clear_source_location(bcx.fcx);
trans_block_cleanups(bcx_out, block_cleanups(bcx))
}
} else {
Expand All @@ -86,6 +88,7 @@ pub fn trans_if(bcx: @mut Block,
Some(elexpr) => {
return do with_scope(bcx, elexpr.info(), "if_false_then") |bcx| {
let bcx_out = trans_if_else(bcx, elexpr, dest);
debuginfo::clear_source_location(bcx.fcx);
trans_block_cleanups(bcx_out, block_cleanups(bcx))
}
}
Expand All @@ -98,6 +101,8 @@ pub fn trans_if(bcx: @mut Block,
let then_bcx_in = scope_block(bcx, thn.info(), "then");

let then_bcx_out = trans_block(then_bcx_in, thn, dest);

debuginfo::clear_source_location(bcx.fcx);
let then_bcx_out = trans_block_cleanups(then_bcx_out,
block_cleanups(then_bcx_in));

Expand All @@ -122,6 +127,9 @@ pub fn trans_if(bcx: @mut Block,
debug!("then_bcx_in={}, else_bcx_in={}",
then_bcx_in.to_str(), else_bcx_in.to_str());

// Clear the source location because it is still set to whatever has been translated
// right before.
debuginfo::clear_source_location(else_bcx_in.fcx);
CondBr(bcx, cond_val, then_bcx_in.llbb, else_bcx_in.llbb);
return next_bcx;

Expand All @@ -139,6 +147,7 @@ pub fn trans_if(bcx: @mut Block,
// would be nice to have a constraint on ifs
_ => else_bcx_in.tcx().sess.bug("strange alternative in if")
};
debuginfo::clear_source_location(else_bcx_in.fcx);
trans_block_cleanups(else_bcx_out, block_cleanups(else_bcx_in))
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/librustc/middle/trans/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,17 @@ pub fn set_source_location(fcx: &FunctionContext,
}
}

/// Clears the current debug location.
///
/// Instructions generated hereafter won't be assigned a source location.
pub fn clear_source_location(fcx: &FunctionContext) {
if fn_should_be_ignored(fcx) {
return;
}

set_debug_location(fcx.ccx, UnknownLocation);
}

/// Enables emitting source locations for the given functions.
///
/// Since we don't want source locations to be emitted for the function prelude, they are disabled
Expand Down