Skip to content

Breakpoints in Dart SDK files fail to bind (greyed out) during debugging #9150

Open

Description

@helin24

Description

Setting a breakpoint inside a Dart SDK file (for example, iterable.dart in dart:core) while debugging a Flutter application fails and the breakpoint icon becomes greyed out.

Root Cause

  1. In VmServiceWrapper.addBreakpoint, getResolvedUri(position) converts the local file to a file:/// URI (e.g. file:///.../flutter/bin/cache/dart-sdk/lib/core/iterable.dart) and passes it to myVmService.lookupPackageUris.
  2. In Flutter, the Dart SDK platform kernel (platform_strong.dill) is compiled using org-dartlang-sdk:///... URIs rather than the host machine's file:///.../flutter/bin/cache/dart-sdk/... path, and the Dart SDK is not listed in .dart_tool/package_config.json.
  3. Consequently, lookupPackageUris returns [null] for file:/// paths inside the Dart SDK, causing VmServiceWrapper.addBreakpoint to report "Breakpoint could not be mapped to package URI" and mark the breakpoint as failed.

Potential Fix

Before (or when) calling getResolvedUri(position) / lookupPackageUris, check if DartUrlResolver.getDartUrlForFile(position.getFile()) resolves the file to a dart: URI (e.g. dart:core/iterable.dart), or fall back to myDebugProcess.getUrisForFile(position.getFile()) when lookupPackageUris returns null.

Note: Created by an AI agent (Gemini).

Activity

  1. helin24 commented on Oct 8, 2026

    @helin24
    MemberAuthor

    @DanTup does this work in VS Code? I'm not able to get a breakpoint in Dart SDK code there either, and I'm not sure if this is intended to work or not.

  2. DanTup commented on Oct 8, 2026

    @DanTup
    Contributor

    Yeah, that should work. It requires some additional mapping outside of what the VM is doing though.

    See this mapping in the Dart/base adapter:
    https://github.com/dart-lang/sdk/blob/e4dec8c8967cd7e85fcce91341778fb3305a9afa/pkg/dap_adapters/lib/src/adapters/dart.dart#L352

    And this mapping in the Flutter adapter:

    https://github.com/flutter/flutter/blob/9b5759043457c99e316507474dea424e15cfb0c0/packages/flutter_tools/lib/src/debug_adapters/flutter_base_adapter.dart#L120

    It looks like for Dart we'd expect the URIs to start org-dartlang-sdk:///sdk and for Flutter they would be org-dartlang-sdk:///flutter/third_party/dart/sdk.

    I don't know if all the assumptions in those mappings are still valid (or whether there are additional URIs we're not handling). If it's not working right in VS Code, that sounds like a bug (likely in DAP) that we should fix. Hopefully it would just be a simple change/fix to these mappings.

  3. added theissue type on Oct 8, 2026
  4. removed theissue type on Oct 8, 2026
  5. DanTup commented on Oct 9, 2026

    @DanTup
    Contributor

    @helin24 I did some testing in VS Code. In a Dart project, using:

    void main(List<String> arguments) {
      print(iterable().contains(''));
    }
    
    Iterable<String> iterable() sync* {
      yield '';
    }

    I Ctrl+Clicked on contains() and added a breakpoint:

    Image

    Which was correctly hit:

    Image

    I did the same thing in a Flutter app and it also worked (although both the navigation and the break location are now in pkg/sky_engine):

    Image

    So, as far as I can tell, things are working correctly in VS Code. However, I will note that it's easy to hit a situation where this appears to not work. For example given the code:

    print([].contains(''));

    If you Ctrl+Click here on contains, you end up in mixin class Iterable<E> and adding a breakpoint there appears not to work, but that's because at runtime this code goes into mixin class ListBase<E>'s implementation of contains(). I suspect this because the type of [] is List<E> which is an abstract class and the analyzer doesn't know which implementation the runtime is constructing and therefore can't take us to the implementation that would actually be used at runtime.

    I don't know if the case you tested was something like this though. If you think there's a case where it doesn't work that isn't this, please file a Dart-Code issue and I'll take a look (to avoid taking this one off-track). If this does solve your issue and therefore it works in VS Code, then you might need to reproduce the mapping linked above (and hopefully in the future we could migrate to DAP and have only one implementation).

  6. helin24 commented on Oct 9, 2026

    @helin24
    MemberAuthor

    Ah okay! I was able to get your example to work in VS Code. And I think I was experiencing the exact problem you noted when I originally set up an example.

    However, the same thing does not work in IntelliJ, so this is a real bug.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions