diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-02-09 12:14:22 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-02-09 12:14:22 -0500 |
| commit | 7bd0da7e89faea251e77215ec70f7a5b2c26a3f8 (patch) | |
| tree | 146b55f34ea8d1aaf56f662ddd4c4c98d3e2f999 | |
| parent | 711b95f6b129e13dbbc6a8f9dbf649275bcad25e (diff) | |
| parent | d113b39fbf089621c3985af9d50a888cd02dd432 (diff) | |
| download | rust-7bd0da7e89faea251e77215ec70f7a5b2c26a3f8.tar.gz rust-7bd0da7e89faea251e77215ec70f7a5b2c26a3f8.zip | |
Rollup merge of #39678 - vadimcn:top-level-expn, r=michaelwoerister
Exclude top-level macro expansions from source location override. It occurred to me that a simple heuristic can address the issue #36382: any macros that expand into items (including `include!()`) don't need to be stepped over because there's not code to step through above a function scope level. r? @michaelwoerister
| -rw-r--r-- | src/librustc_trans/mir/mod.rs | 9 | ||||
| -rw-r--r-- | src/test/debuginfo/macro-stepping.inc | 17 | ||||
| -rw-r--r-- | src/test/debuginfo/macro-stepping.rs | 26 |
3 files changed, 51 insertions, 1 deletions
diff --git a/src/librustc_trans/mir/mod.rs b/src/librustc_trans/mir/mod.rs index e017c8f2532..0cfc2c8d163 100644 --- a/src/librustc_trans/mir/mod.rs +++ b/src/librustc_trans/mir/mod.rs @@ -138,13 +138,20 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { while span.expn_id != NO_EXPANSION && span.expn_id != COMMAND_LINE_EXPN { if let Some(callsite_span) = cm.with_expn_info(span.expn_id, |ei| ei.map(|ei| ei.call_site.clone())) { + // When the current function itself is a result of macro expansion, + // we stop at the function body level because no line stepping can occurr + // at the level above that. + if self.mir.span.expn_id != NO_EXPANSION && + span.expn_id == self.mir.span.expn_id { + break; + } span = callsite_span; } else { break; } } let scope = self.scope_metadata_for_loc(source_info.scope, span.lo); - // Use span of the outermost call site, while keeping the original lexical scope + // Use span of the outermost expansion site, while keeping the original lexical scope. (scope, span) } } diff --git a/src/test/debuginfo/macro-stepping.inc b/src/test/debuginfo/macro-stepping.inc new file mode 100644 index 00000000000..6aaf7ed421e --- /dev/null +++ b/src/test/debuginfo/macro-stepping.inc @@ -0,0 +1,17 @@ +// Copyright 2013-2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn included() { + foo!(); // #inc-loc1 + + foo2!(); // #inc-loc2 + + zzz(); // #inc-loc3 +} diff --git a/src/test/debuginfo/macro-stepping.rs b/src/test/debuginfo/macro-stepping.rs index 37355ed377b..ca2c1e0c8f0 100644 --- a/src/test/debuginfo/macro-stepping.rs +++ b/src/test/debuginfo/macro-stepping.rs @@ -44,6 +44,17 @@ extern crate macro_stepping; // exports new_scope!() // gdb-command:frame // gdb-check:[...]#loc6[...] +// gdb-command:continue +// gdb-command:step +// gdb-command:frame +// gdb-check:[...]#inc-loc1[...] +// gdb-command:next +// gdb-command:frame +// gdb-check:[...]#inc-loc2[...] +// gdb-command:next +// gdb-command:frame +// gdb-check:[...]#inc-loc3[...] + // === LLDB TESTS ================================================================================== // lldb-command:set set stop-line-count-before 0 @@ -68,6 +79,17 @@ extern crate macro_stepping; // exports new_scope!() // lldb-command:frame select // lldb-check:[...]#loc5[...] +// lldb-command:continue +// lldb-command:step +// lldb-command:frame select +// lldb-check:[...]#inc-loc1[...] +// lldb-command:next +// lldb-command:frame select +// lldb-check:[...]#inc-loc2[...] +// lldb-command:next +// lldb-command:frame select +// lldb-check:[...]#inc-loc3[...] + macro_rules! foo { () => { let a = 1; @@ -99,6 +121,10 @@ fn main() { "world"); zzz(); // #loc6 + + included(); // #break } fn zzz() {()} + +include!("macro-stepping.inc"); |
