Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Trass3r committed Sep 11, 2020
1 parent ce66883 commit 61d55bf
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 35 deletions.
8 changes: 2 additions & 6 deletions src/MIDebugEngine/AD7.Impl/AD7StackFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -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);
}
}

Expand Down
57 changes: 28 additions & 29 deletions src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2264,38 +2264,37 @@ private Task<string> 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;
Expand Down

0 comments on commit 61d55bf

Please sign in to comment.