Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EnsureProperPathSeparators() causes wrong paths with Cygwin #1418

Open
oold opened this issue Oct 6, 2023 · 0 comments
Open

EnsureProperPathSeparators() causes wrong paths with Cygwin #1418

oold opened this issue Oct 6, 2023 · 0 comments

Comments

@oold
Copy link

oold commented Oct 6, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant