Skip to content

Commit

Permalink
debuginfo: Improved stepping for if-expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwoerister committed Nov 18, 2013
1 parent 4dded43 commit d0872eb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/librustc/middle/trans/controlflow.rs
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
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

5 comments on commit d0872eb

@bors
Copy link
Contributor

@bors bors commented on d0872eb Nov 18, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from brson
at michaelwoerister@d0872eb

@bors
Copy link
Contributor

@bors bors commented on d0872eb Nov 18, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging michaelwoerister/rust/ifstepping = d0872eb into auto

@bors
Copy link
Contributor

@bors bors commented on d0872eb Nov 18, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

michaelwoerister/rust/ifstepping = d0872eb merged ok, testing candidate = 9062988

@bors
Copy link
Contributor

@bors bors commented on d0872eb Nov 19, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on d0872eb Nov 19, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 9062988

Please sign in to comment.