From 092cae12f9f5bb077f189a62ef03ef634a91edf4 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 14 Mar 2020 14:48:04 +0100 Subject: [PATCH] Dont single step into macros Fixes #782 --- src/debuginfo/line_info.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/debuginfo/line_info.rs b/src/debuginfo/line_info.rs index 7a3ac0991c4..7997ae33d0e 100644 --- a/src/debuginfo/line_info.rs +++ b/src/debuginfo/line_info.rs @@ -122,8 +122,23 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> { blocks.sort_by_key(|block| func.offsets[*block]); // Ensure inst offsets always increase let line_strings = &mut self.debug_context.dwarf.line_strings; + let function_span = self.mir.span; let mut last_file = None; let mut create_row_for_span = |line_program: &mut LineProgram, span: Span| { + // Based on https://github.com/rust-lang/rust/blob/e369d87b015a84653343032833d65d0545fd3f26/src/librustc_codegen_ssa/mir/mod.rs#L116-L131 + // In order to have a good line stepping behavior in debugger, we overwrite debug + // locations of macro expansions with that of the outermost expansion site + // (unless the crate is being compiled with `-Z debug-macros`). + let span = if !span.from_expansion() || + tcx.sess.opts.debugging_opts.debug_macros { + span + } else { + // Walk up the macro expansion chain until we reach a non-expanded span. + // We also stop at the function body level because no line stepping can occur + // at the level above that. + rustc_span::hygiene::walk_chain(span, function_span.ctxt()) + }; + let loc = tcx.sess.source_map().lookup_char_pos(span.lo()); // line_program_add_file is very slow.