microsoft / microsoft/MIEngine
`EnsureProperPathSeparators()` causes wrong paths with Cygwin
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 859
- Forks
- 233
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 3
Description
LinesForFile() fails to get the source lines for binaries built with Cygwin tools.
An incorrect path is returned from EnsureProperPathSeparators():
https://github.com/microsoft/MIEngine/blob/ad8e28a50a206ab2beca7c77e6737f6a305f7c12/src/MIDebugEngine/Engine.Impl/SourceLine.cs#L93-L95
This is because EnsureProperPathSeparators() calls MapWindowsToCygwin() when debugging with a Cygwin gdb:
https://github.com/microsoft/MIEngine/blob/ad8e28a50a206ab2beca7c77e6737f6a305f7c12/src/MIDebugEngine/Engine.Impl/DebuggedProcess.cs#L1525-L1529
MapWindowsToCygwin() calls UnixPathToWindowsPath() and this is the actual mistake that leads to the incorrect result:
https://github.com/microsoft/MIEngine/blob/ad8e28a50a206ab2beca7c77e6737f6a305f7c12/src/MIDebugEngine/Engine.Impl/CygwinFileMapper.cs#L78
UnixPathToWindowsPath() replaces the slashes with backslashes:
https://github.com/microsoft/MIEngine/blob/ad8e28a50a206ab2beca7c77e6737f6a305f7c12/src/MICore/PlatformUtilities.cs#L92
When LaunchCygPathAndReadResult() receives the "Windows" path, it doesn't look like an absolute path anymore, so it prepends the current working drive.
https://github.com/microsoft/MIEngine/blob/ad8e28a50a206ab2beca7c77e6737f6a305f7c12/src/MIDebugEngine/Engine.Impl/CygwinFileMapper.cs#L80
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with EnsureProperPathSeparators() in src/MIDebugEngine/Engine.Impl/SourceLine.cs and trace its Cygwin path through MapWindowsToCygwin() and UnixPathToWindowsPath() in CygwinFileMapper.cs and PlatformUtilities.cs. Reproduce the breakpoint or GetBoundBreakpoint() case with Cygwin gdb; done means /c/src/a.cpp remains /c/src/a.cpp rather than becoming /c/c/src/a.cpp.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- devtools, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100