LinesForFile() fails to get the source lines for binaries built with Cygwin tools.
An incorrect path is returned from EnsureProperPathSeparators():
|
private async Task<SourceLineMap> LinesForFile(string file) |
|
{ |
|
string cmd = "-symbol-list-lines " + _process.EnsureProperPathSeparators(file); |
This is because EnsureProperPathSeparators() calls MapWindowsToCygwin() when debugging with a Cygwin gdb:
|
internal string EnsureProperPathSeparators(string path, bool isRemote = false, bool ignoreSpaces = false) |
|
{ |
|
if (IsCygwin) |
|
{ |
|
path = CygwinFilePathMapper.MapWindowsToCygwin(path); |
MapWindowsToCygwin() calls UnixPathToWindowsPath() and this is the actual mistake that leads to the incorrect result:
|
string windowsPath = PlatformUtilities.UnixPathToWindowsPath(origWindowsPath); |
UnixPathToWindowsPath() replaces the slashes with backslashes:
|
return unixPath.Replace('/', '\\'); |
When LaunchCygPathAndReadResult() receives the "Windows" path, it doesn't look like an absolute path anymore, so it prepends the current working drive.
|
if (!LaunchCygPathAndReadResult(windowsPath, localLaunchOptions.MIDebuggerPath, convertToWindowsPath: false, out string cygwinPath)) |
This fails if, for example, a breakpoint is created, GetBoundBreakpoint() gets called, and the fullname contains a Cygwin path.
Expected result for EnsureProperPathSeparators():
Input: /c/src/a.cpp
Conversion: /c/src/a.cpp -> /c/src/a.cpp -> /c/src/a.cpp
Output: /c/src/a.cpp
Actual result for EnsureProperPathSeparators():
Input: /c/src/a.cpp
Conversion: /c/src/a.cpp -> \c\src\a.cpp -> /c/c/src/a.cpp
Output: /c/c/src/a.cpp
LinesForFile()fails to get the source lines for binaries built with Cygwin tools.An incorrect path is returned from
EnsureProperPathSeparators():MIEngine/src/MIDebugEngine/Engine.Impl/SourceLine.cs
Lines 93 to 95 in ad8e28a
This is because
EnsureProperPathSeparators()callsMapWindowsToCygwin()when debugging with a Cygwin gdb:MIEngine/src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs
Lines 1525 to 1529 in ad8e28a
MapWindowsToCygwin()callsUnixPathToWindowsPath()and this is the actual mistake that leads to the incorrect result:MIEngine/src/MIDebugEngine/Engine.Impl/CygwinFileMapper.cs
Line 78 in ad8e28a
UnixPathToWindowsPath()replaces the slashes with backslashes:MIEngine/src/MICore/PlatformUtilities.cs
Line 92 in ad8e28a
When
LaunchCygPathAndReadResult()receives the "Windows" path, it doesn't look like an absolute path anymore, so it prepends the current working drive.MIEngine/src/MIDebugEngine/Engine.Impl/CygwinFileMapper.cs
Line 80 in ad8e28a
This fails if, for example, a breakpoint is created,
GetBoundBreakpoint()gets called, and thefullnamecontains a Cygwin path.Expected result for
EnsureProperPathSeparators():Input:
/c/src/a.cppConversion:
/c/src/a.cpp->/c/src/a.cpp->/c/src/a.cppOutput:
/c/src/a.cppActual result for
EnsureProperPathSeparators():Input:
/c/src/a.cppConversion:
/c/src/a.cpp->\c\src\a.cpp->/c/c/src/a.cppOutput:
/c/c/src/a.cpp