WebFreak001 / code-debug

Native debugging for VSCode
The Unlicense
409 stars 115 forks source link

Backslashes on Linux #381

Closed abussy-aldebaran closed 1 year ago

abussy-aldebaran commented 2 years ago

Hi,

On the master branch, I observed a regression: paths use backslashes instead of slashes.

brownts commented 1 year ago

Adding my response here (from #382), as this seems the more appropriate location

Hi ! The path mappings are relative in my configuration. With absolute paths, detection of OS works correctly, but breakpoints don't. I used relative paths because, when pausing while my code is executed, the stacktrace shows relative paths. These paths are written in the binary by the compile right ? I guess that's why absolute paths won't work. However I found a way to make absolute paths work but there's a catch. Suppose my project structure is:

my-project/
  |-- my-exe/
    |-- main.cpp
  |-- my-lib/
    |-- src/
      |-- hello.cpp

and is installed in the folder /src on remote. In the stacktrace cpp files are referenced as ../my-exe/main.cpp and ../src/hello.cpp. Here's how the configuration would look like:

"ssh": {
  "cwd": "/src/my-project/my-exe",
  "sourceFileMap": {
    "/src/my-project/my-exe": "${workspaceRoot}/my-exe",
    "/src/my-project/my-lib/src": "${workspaceRoot}/my-project/my-lib/src",
  },
}

Breakpoints will work in main.cpp but not in hello.cpp. I think this is because "sourceFileMap"."/src/my-project/my-exe"/main.cpp = "cwd"/../my-exe/main.cpp whereas "sourceFileMap"."/src/my-project/my-lib/src"/hello.cpp != "cwd"/../src/hello.cpp

You can still get this to work with absolute paths by using the directory command to add the directory (or directories) not covered by cwd.

autorun: ["directory /src/my-project/my-lib/src"]

I'll soon be adding a fix though to properly support using relative paths. It will utilize ssh.cwd to determine the path kind of the remote and thus format the remote path accordingly. It only uses ssh.cwd to determine the path kind, thus it won't try and create an absolute path from it. This should support the situation above where you have two different paths and the cwd isn't applicable to both.

GitMensch commented 1 year ago

Sounds like a good time to release ;)