Skip to content

Commit f8c4f0e

Browse files
committed
auto merge of #8684 : michaelwoerister/rust/stepping_and_scope_fixes, r=jdm
This PR contains some code cleanup and the fix for issue #8670. ~~I am not sure about issue #8442 (could not reproduce it). @jdm, could check after this is merged and possibly close the issue then?~~ (closed now) Some interesting facts: With this commit, it should be possible to compile libstd with `-Zdebug-info` (it does not work yet with `-Zextra-debug-info` but we are getting there). Switching debug info on increases the compile time for libstd by about 2 seconds. @catamorphism I get one failing test in rustpkg: `package_script_with_default_build` says: `task <unnamed> failed at 'Couldn't copy file', /home/mw/rust/src/librustpkg/tests.rs:689` Would you have any idea what that is about? Seems be something wrong on my machine... Cheers, Michael Fixes #8670
2 parents 943f9aa + 0e8a640 commit f8c4f0e

File tree

3 files changed

+191
-136
lines changed

3 files changed

+191
-136
lines changed

src/librustc/middle/trans/base.rs

+21-5
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ fn fcx_has_nonzero_span(fcx: &FunctionContext) -> bool {
137137
}
138138
}
139139

140+
fn span_is_empty(opt_span: &Option<span>) -> bool {
141+
match *opt_span {
142+
None => true,
143+
Some(span) => *span.lo == 0 && *span.hi == 0
144+
}
145+
}
146+
140147
struct StatRecorder<'self> {
141148
ccx: @mut CrateContext,
142149
name: &'self str,
@@ -1624,6 +1631,13 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
16241631
}
16251632
};
16261633
let uses_outptr = type_of::return_uses_outptr(ccx.tcx, substd_output_type);
1634+
1635+
let debug_context = if id != -1 && ccx.sess.opts.debuginfo && !span_is_empty(&sp) {
1636+
Some(debuginfo::create_function_debug_context(ccx, id, param_substs, llfndecl))
1637+
} else {
1638+
None
1639+
};
1640+
16271641
let fcx = @mut FunctionContext {
16281642
llfn: llfndecl,
16291643
llenv: unsafe {
@@ -1644,7 +1658,7 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
16441658
span: sp,
16451659
path: path,
16461660
ccx: ccx,
1647-
debug_context: None,
1661+
debug_context: debug_context,
16481662
};
16491663
fcx.llenv = unsafe {
16501664
llvm::LLVMGetParam(llfndecl, fcx.env_arg_pos() as c_uint)
@@ -1877,6 +1891,7 @@ pub fn trans_closure(ccx: @mut CrateContext,
18771891
param_substs,
18781892
body.info(),
18791893
Some(body.span));
1894+
18801895
let raw_llargs = create_llargs_for_fn_args(fcx, self_arg, decl.inputs);
18811896

18821897
// Set the fixed stack segment flag if necessary.
@@ -1885,10 +1900,6 @@ pub fn trans_closure(ccx: @mut CrateContext,
18851900
set_fixed_stack_segment(fcx.llfn);
18861901
}
18871902

1888-
if ccx.sess.opts.debuginfo && fcx_has_nonzero_span(fcx) {
1889-
debuginfo::create_function_metadata(fcx);
1890-
}
1891-
18921903
// Create the first basic block in the function and keep a handle on it to
18931904
// pass to finish_fn later.
18941905
let bcx_top = fcx.entry_bcx.unwrap();
@@ -1900,6 +1911,11 @@ pub fn trans_closure(ccx: @mut CrateContext,
19001911

19011912
maybe_load_env(fcx);
19021913

1914+
// Up until here, IR instructions for this function have explicitly not been annotated with
1915+
// source code location, so we don't step into call setup code. From here on, source location
1916+
// emitting should be enabled.
1917+
debuginfo::start_emitting_source_locations(fcx);
1918+
19031919
// This call to trans_block is the place where we bridge between
19041920
// translation calls that don't have a return value (trans_crate,
19051921
// trans_mod, trans_item, et cetera) and those that do

0 commit comments

Comments
 (0)