From 61d55bff877d99a248417bfd6d4cc912a203c5d9 Mon Sep 17 00:00:00 2001 From: Andreas Hollandt Date: Fri, 11 Sep 2020 13:11:27 +0200 Subject: [PATCH] cleanup --- src/MIDebugEngine/AD7.Impl/AD7StackFrame.cs | 8 +-- .../Engine.Impl/DebuggedProcess.cs | 57 +++++++++---------- 2 files changed, 30 insertions(+), 35 deletions(-) diff --git a/src/MIDebugEngine/AD7.Impl/AD7StackFrame.cs b/src/MIDebugEngine/AD7.Impl/AD7StackFrame.cs index ef14d2282..5fcde5908 100644 --- a/src/MIDebugEngine/AD7.Impl/AD7StackFrame.cs +++ b/src/MIDebugEngine/AD7.Impl/AD7StackFrame.cs @@ -14,7 +14,7 @@ namespace Microsoft.MIDebugEngine { // Represents a logical stack frame on the thread stack. // Also implements the IDebugExpressionContext interface, which allows expression evaluation and watch windows. - internal class AD7StackFrame : IDebugStackFrame2, IDebugExpressionContext2 + internal sealed class AD7StackFrame : IDebugStackFrame2, IDebugExpressionContext2 { public AD7Engine Engine { get; private set; } public AD7Thread Thread { get; private set; } @@ -53,11 +53,7 @@ public AD7StackFrame(AD7Engine engine, AD7Thread thread, ThreadContext threadCon if (_textPosition != null) { _documentCxt = new AD7DocumentContext(_textPosition, _codeCxt, this.Engine.DebuggedProcess); - - if (_codeCxt != null) - { - _codeCxt.SetDocumentContext(_documentCxt); - } + _codeCxt?.SetDocumentContext(_documentCxt); } } diff --git a/src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs b/src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs index bc7c33482..6a45e7c0d 100755 --- a/src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs +++ b/src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs @@ -2264,38 +2264,37 @@ private Task ResetConsole() public bool MapCurrentSrcToCompileTimeSrc(string currentSrc, out string compilerSrc) { - if (_launchOptions.SourceMap != null) + if (_launchOptions.SourceMap == null) { - StringComparison comp = PlatformUtilities.IsWindows() ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; - foreach (var e in _launchOptions.SourceMap) + compilerSrc = currentSrc; + return false; + } + + StringComparison comp = PlatformUtilities.IsWindows() ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal; + foreach (var e in _launchOptions.SourceMap) + { + if (!e.UseForBreakpoints || !currentSrc.StartsWith(e.EditorPath, comp)) + continue; + + var file = currentSrc.Substring(e.EditorPath.Length); + if (string.IsNullOrEmpty(file)) // matched the whole string { - if (e.UseForBreakpoints && currentSrc.StartsWith(e.EditorPath, comp)) - { - var file = currentSrc.Substring(e.EditorPath.Length); - if (string.IsNullOrEmpty(file)) // matched the whole string - { - compilerSrc = e.CompileTimePath; // return the matches compile time path - return true; - } - // must do the path break at a directory boundry, i.e. at a '\' or '/' char - char firstFilechar = file[0]; - char lastDirectoryChar = e.EditorPath[e.EditorPath.Length - 1]; - if (firstFilechar == Path.DirectorySeparatorChar || firstFilechar == Path.AltDirectorySeparatorChar) - { - file = file.Trim(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }); // Trim the directory separator(s) - } - else if (lastDirectoryChar != Path.DirectorySeparatorChar && lastDirectoryChar != Path.AltDirectorySeparatorChar) - { - continue; // match didn't end at a directory separator, not actually a match - } - compilerSrc = Path.Combine(e.CompileTimePath, file); // map to the compiled location - if (compilerSrc.IndexOf('\\') > 0) - { - compilerSrc = compilerSrc.Replace('\\', '/'); // use Unix notation for the compiled path - } - return true; - } + compilerSrc = e.CompileTimePath; // return the matches compile time path + return true; } + // must do the path break at a directory boundry, i.e. at a '\' or '/' char + char firstFilechar = file[0]; + char lastDirectoryChar = e.EditorPath[e.EditorPath.Length - 1]; + if (firstFilechar == Path.DirectorySeparatorChar || firstFilechar == Path.AltDirectorySeparatorChar) + file = file.Trim(new char[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }); // Trim the directory separator(s) + else if (lastDirectoryChar != Path.DirectorySeparatorChar && lastDirectoryChar != Path.AltDirectorySeparatorChar) + continue; // match didn't end at a directory separator, not actually a match + + compilerSrc = Path.Combine(e.CompileTimePath, file); // map to the compiled location + if (compilerSrc.IndexOf('\\') > 0) + compilerSrc = compilerSrc.Replace('\\', '/'); // use Unix notation for the compiled path + + return true; } compilerSrc = currentSrc; return false;