Skip to content

Breakpoints are missed if path casing mismatches between rootLib and breakpoint uri #586

Closed

Description

@TomasLinhart

If I put a breakpoint in my file, it does not stop at it.

I have a folder with two files: main.dart and launch.json.

In main.dart I have:

main() {
  print("hello world");
}

And I have put a breakpoint on the print.

In my launch.json, I have:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Dart command line",
            "program": "${workspaceRoot}/main.dart",
            "request": "launch",
            "type": "dart-cli"
        }
    ]
}

When I press F5, it runs the app and I see hello world in DEBUG CONSOLE.

I use Visual Studio Code 1.20.1 and Dart-Code 2.8.2, and Dart is 1.24.3. I have Windows 10.

And this is my observatory.log.

Activity

  1. added this to the v2.9.0 milestone on Feb 17, 2018
  2. added
    in debugging
    on Feb 17, 2018
  3. DanTup commented on Feb 17, 2018

    @DanTup
    Member

    We seem to be sending the breakpoint only once with a URI that looks bad.

    "rootLib":{"uri":"file:\/\/\/C:\/HelloDart\/main.dart"}
    
    {"method":"addBreakpointWithScriptUri","params":{"scriptUri":"/c:/HelloDart/main.dart","line":2}}
    

    There was some refactoring around this a couple of releases back but it was supposed to improve things not make them worse! Should be an easy fix though.

  4. DanTup commented on Feb 19, 2018

    @DanTup
    Member

    Ok, scratch the above - this is actually caused by the drive letter casing being different. The VM treats file:\/\/\/C:\/HelloDart\/main.dart and /c:/HelloDart/main.dart differently. I have a workaround that I might use, but I'm gonna investigate why the paths (which both came from Code) have different casing.

    if (isWin) {
    	// Flip the casing of the drive letter since it's often different and the VM doesn't
    	// consider then the same.
    	uris.slice().forEach((uri) => {
    		if (uri.startsWith("/") && uri.substring(1, 2) === uri.substring(1, 2).toLowerCase())
    			uris.push("/" + uri.substring(1, 2).toUpperCase() + uri.substring(2));
    		if (uri.startsWith("/") && uri.substring(1, 2) === uri.substring(1, 2).toUpperCase())
    			uris.push("/" + uri.substring(1, 2).toLowerCase() + uri.substring(2));
    	});
    }
  5. changed the title [-]Dart-Code is not stopping at breakpoints[/-] [+]Breakpoints are missed if path casing mismatches between rootLib and breakpoint uri[/+] on Feb 19, 2018
  6. DanTup commented on Feb 19, 2018

    @DanTup
    Member

    I'm committing my workaround as a fix for this for now, though I've raised cases with Code and the Dart VM as they might be able to provide better fixes:

    microsoft/vscode#43959
    dart-lang/sdk#32222

  7. TomasLinhart commented on Feb 19, 2018

    @TomasLinhart
    Author

    Thank you for figuring out the issue and fixing it!

  8. DanTup commented on Feb 19, 2018

    @DanTup
    Member

    Ugh, so it turns out this changed in Code very recently! I was certain it all worked when I tested it only a few weeks ago; good to know I wasn't going mad.

    Related: microsoft/vscode#43959
    Changeset that changed it: microsoft/vscode@0d66fa0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    in debuggingis bugon windows

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions