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

Breakpoints on Windows not set correctly #1138

Open
jshbrntt opened this issue Sep 10, 2024 · 1 comment
Open

Breakpoints on Windows not set correctly #1138

jshbrntt opened this issue Sep 10, 2024 · 1 comment

Comments

@jshbrntt
Copy link

jshbrntt commented Sep 10, 2024

OS: Windows 11 Version 23H2 (OS Build 22631.4037)
VSCode version: 1.92.2 (user setup)
CodeLLDB version: 1.10.1
Compiler: Ubuntu clang version 16.0.0 (1~exp5ubuntu3)
Debuggee: x86_64-windows-msvc

My launch.json is as follows.

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug: Racer (Windows)",
            "program": "${workspaceFolder}/build/windows/debug/racer.exe",
            "args": [],
            "cwd": "${workspaceFolder}/build/windows/debug",
            "sourceMap": {
                "/home/ubuntu/racer": "${workspaceFolder}"
            }
        }
    ]
}

The value of ${workspaceFolder} is as follows, logged using the following task from my tasks.json file.

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Print value of workspaceFolder",
            "command": "echo",
            "args": [
              "${env:USERNAME}",
              "workspaceFolder = ${workspaceFolder}"
            ],
            "type": "shell"
        }
    ]
}

Output (of above task)

 *  Executing task: echo Josh 'workspaceFolder = C:\Users\Josh\racer' 

Josh
workspaceFolder = C:\Users\Josh\racer
 *  Terminal will be reused by tasks, press any key to close it.

Therefore sourceMap in my launch.json should be the following.

"sourceMap": {
    "/home/ubuntu/racer": "C:\\Users\\Josh\\racer"
}

However, when I add a breakpoint in the editor I get the following output in the Debug Console.

Console is in 'commands' mode, prefix expressions with '?'.
Launching: C:\Users\Josh\racer\build\windows\debug\racer.exe
Launched process 239076
settings show target.source-map
target.source-map (path-map) =
[0] "\home\ubuntu\racer" -> "C:\Users\Josh\racer"

Could not resolve any locations for breakpoint at c:\Users\Josh\racer\src\racer\main.cpp:78, but found a valid location at \home\ubuntu\racer\src\racer\main.cpp:78

You can see the casing of the drive letter is not correct and does not match was was supplied in sourceMap.

c:\Users\Josh\racer\src\racer\main.cpp:78

If I set the breakpoint manually via the debug console with the path correctly cased, it resolves correctly.

breakpoint set --file C:\Users\Josh\racer\src\racer\main.cpp --line 78
Breakpoint 4: where = racer.exe`SDL_main + 1114 at main.cpp:78, address = 0x00007ff66579e25a
b
Current breakpoints:
1: Exception breakpoint (catch: off throw: on) using: names = {'__cxa_throw', '__cxa_rethrow'}

  Names:
    cpp_exception


2: file = 'c:\Users\Josh\racer\src\racer\main.cpp', line = 78, exact_match = 0, locations = 0 (pending)


4: file = '\home\ubuntu\racer\src\racer\main.cpp', line = 78, exact_match = 0, locations = 1, resolved = 1, hit count = 1
  4.1: where = racer.exe`SDL_main + 1114 at main.cpp:78, address = 0x00007ff66579e25a, resolved, hit count = 1 

Workaround

Hardcode my sourceMap to the incorrectly cased path in my launch.json.

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "lldb",
            "request": "launch",
            "name": "Debug: Racer (Windows)",
            "program": "${workspaceFolder}/build/windows/debug/racer.exe",
            "args": [],
            "cwd": "${workspaceFolder}/build/windows/debug",
            "sourceMap": {
                "/home/ubuntu/racer": "c:\\Users\\Josh\\racer"
            }
        }
    ]
}
@jshbrntt
Copy link
Author

It appears rust-analyzer had a similar problem caused by VSCode sending file paths with lowercased drive letters.

They fixed the issue by forcing them to be uppercase here.

https://github.com/rust-lang/rust-analyzer/pull/14689/files

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