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

Support debugging Dart running in a Docker container #21067

Closed
sgjesse opened this issue Sep 24, 2014 · 5 comments
Closed

Support debugging Dart running in a Docker container #21067

sgjesse opened this issue Sep 24, 2014 · 5 comments
Labels

Comments

@sgjesse
Copy link
Contributor

sgjesse commented Sep 24, 2014

When using the Dart Docker images hosted on hub.docker.com (https://registry.hub.docker.com/search?q=google%2Fdart) it is currently not possible to use the Dart Editor to debug code running inside.

For the images google/dart-runtime and google/dart-hello enabling the debugger in the Dart VM can be done by passing the environment variable DBG_ENABLE when starting the container. So with a working docker installation (e.g. boot2docker) enabling the debugger for the google/dart-hello sample:

$ docker run -d -p 8080:8080 -p 5858:5858 --env DBG_ENABLE=1 google/dart-hello

(first time this is run a Docker images will be downloaded, so it will take some time).

This also prints out the container ID.

As expected this will stall the Dart VM in the container before main, so that application in the container is not running.

Check out https://github.com/dart-lang/dart_docker which have the source code to the application, and set a breakpoint in the server code in dart_docker/hello/bin/server.dart.

Now connect to the VM inside the Docker container using 'Run->Remote Connection...'. If using boot2docker witht eh default configuration

  Host: 192.168.59.103
  Port: 5858

The editor connects and the VM starts to run. One can check this

  $ curl http://192.168.59.103:8080/version

(again assuming boot2docker)

However the breakpoint set in the code is not hit.

As far as I can see this is caused by the mapping from the source path in the Dart Editor and the source path in the container. I have captures the communication between the Dart Editor and the VM in the container, and what caught my eye is the following:

{"id":1,"command":"getStackTrace","params":{"isolateId":383209362}}{ "id": 1, "result": {"callFrames" : [ {"functionName":"main","location": { "url":"file:///app/bin/server.dart","libraryId":13,"tokenOffset":24},"locals":[{"name":"webFiles","value":{"objectId":0,"kind":"object","text":"null"}}]}, ...

and

{"id":2,"command":"setBreakpoint","params":{"isolateId":383209362,"line":9,"url":"file:///usr/local/prj/dart/github/dart_docker/hello/bin/server.dart"}}{"id": 2, "error": "Error: Dart_SetBreakpoint: could not set breakpoint at line 9 in 'file:///usr/local/prj/dart/github/dart_docker/hello/bin/server.dart'"}

(Full capture below)

The file known by the Dart Editor as 'file:///usr/local/prj/dart/github/dart_docker/hello/bin/server.dart' is 'file:///app/bin/server.dart' in the container.

Is there any way of setting up a mapping from the path in the debugger to the path in the debugee?

The demo application google/dart-hello is based on https://registry.hub.docker.com/u/google/dart-runtime/dockerfile/, where the Dart application is installed in /app inside the container with the main entrypoint in /app/bin/server.dart.

Full trace of setting up the debugger connection:

{ "event": "isolate", "params": { "reason": "created", "id": 223000247 }}{ "event": "isolate", "params": { "reason": "created", "id": 383209362 }}{ "event": "paused", "params": { "reason": "breakpoint", "isolateId": 383209362,"location": { "url":"file:///app/bin/server.dart","libraryId":13,"tokenOffset":24}}}{"id":1,"command":"getStackTrace","params":{"isolateId":383209362}}{ "id": 1, "result": {"callFrames" : [ {"functionName":"main","location": { "url":"file:///app/bin/server.dart","libraryId":13,"tokenOffset":24},"locals":[{"name":"webFiles","value":{"objectId":0,"kind":"object","text":"null"}}]},{"functionName":"isolateStartHandler","location": { "url":"dart:isolate-patch/isolate_patch.dart","libraryId":1,"tokenOffset":1126},"locals":[{"name":"ignoreHandler","value":{"objectId":1,"kind":"function","name":"_startIsolate.ignoreHandler","signature":"(dynamic) => dynamic","location": { "url":"dart:isolate-patch/isolate_patch.dart","libraryId":1,"tokenOffset":948}}},{"name":"keepAlivePort","value":{"objectId":2,"kind":"object","classId":54,"text":"object of type _RawReceivePortImpl"}},{"name":"isSpawnUri","value":{"objectId":3,"kind":"boolean","text":"true"}},{"name":"entryPoint","value":{"objectId":4,"kind":"function","name":"main","signature":"() => void","location": { "url":"file:///app/bin/server.dart","libraryId":13,"tokenOffset":14}}},{"name":"message","value":{"objectId":5,"kind":"list","length":3,"text":"[null, [...], null]"}},{"name":"replyTo","value":{"objectId":0,"kind":"object","text":"null"}},{"name":"args","value":{"objectId":6,"kind":"list","length":0,"text":"[]"}},{"name":"isolateMessage","value":{"objectId":0,"kind":"object","text":"null"}}]},{"functionName":"_RawReceivePortImpl@709387912._handleMessage@709387912","location": { "url":"dart:isolate-patch/isolate_patch.dart","libraryId":1,"tokenOffset":608},"classId":54,"locals":[{"name":"handler","value":{"objectId":7,"kind":"function","name":"_startIsolate.isolateStartHandler","signature":"(dynamic) => dynamic","location": { "url":"dart:isolate-patch/isolate_patch.dart","libraryId":1,"tokenOffset":961}}},{"name":"message","value":{"objectId":5,"kind":"list","length":3,"text":"[null, [...], null]"}}]}]}}{"id":2,"command":"setBreakpoint","params":{"isolateId":383209362,"line":9,"url":"file:///usr/local/prj/dart/github/dart_docker/hello/bin/server.dart"}}{"id": 2, "error": "Error: Dart_SetBreakpoint: could not set breakpoint at line 9 in 'file:///usr/local/prj/dart/github/dart_docker/hello/bin/server.dart'"}{"id":3,"command":"getLibraries","params":{"isolateId":383209362}}{ "id": 3, "result": { "libraries": [{"id":0,"url":"dart:core"}, {"id":1,"url":"dart:isolate"}, {"id":2,"url":"dart:mirrors"}, {"id":3,"url":"dart:collection"}, {"id":4,"url":"dart:profiler"}, {"id":5,"url":"dart:nativewrappers"}, {"id":6,"url":"dart:typed_data"}, {"id":7,"url":"dart:async"}, {"id":8,"url":"dart:convert"}, {"id":9,"url":"dart:_internal"}, {"id":10,"url":"dart:math"}, {"id":11,"url":"dart:_builtin"}, {"id":12,"url":"dart:io"}, {"id":13,"url":"file:///app/bin/server.dart"}, {"id":14,"url":"package:http_server/http_server.dart"}, {"id":15,"url":"package:mime/mime.dart"}, {"id":16,"url":"package:path/path.dart"}, {"id":17,"url":"package:mime/src/mime_multipart_transformer.dart"}, {"id":18,"url":"package:mime/src/mime_shared.dart"}, {"id":19,"url":"package:mime/src/mime_type.dart"}, {"id":20,"url":"package:path/src/context.dart"}, {"id":21,"url":"package:path/src/style.dart"}, {"id":22,"url":"package:path/src/path_exception.dart"}, {"id":23,"url":"package:mime/src/bound_multipart_stream.dart"}, {"id":24,"url":"package:mime/src/char_code.dart"}, {"id":25,"url":"package:mime/src/default_extension_map.dart"}, {"id":26,"url":"package:mime/src/magic_number.dart"}, {"id":27,"url":"package:path/src/internal_style.dart"}, {"id":28,"url":"package:path/src/parsed_path.dart"}, {"id":29,"url":"package:path/src/style/posix.dart"}, {"id":30,"url":"package:path/src/style/url.dart"}, {"id":31,"url":"package:path/src/style/windows.dart"}, {"id":32,"url":"package:path/src/characters.dart"}, {"id":33,"url":"package:path/src/utils.dart"}]}}{"id":4,"command":"setLibraryProperties","params":{"libraryId":0,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":5,"command":"setLibraryProperties","params":{"libraryId":1,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":6,"command":"setLibraryProperties","params":{"libraryId":2,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":7,"command":"setLibraryProperties","params":{"libraryId":3,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":8,"command":"setLibraryProperties","params":{"libraryId":4,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":9,"command":"setLibraryProperties","params":{"libraryId":6,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":10,"command":"setLibraryProperties","params":{"libraryId":8,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":11,"command":"setLibraryProperties","params":{"libraryId":10,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":12,"command":"setLibraryProperties","params":{"libraryId":11,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":13,"command":"setLibraryProperties","params":{"libraryId":12,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":14,"command":"setLibraryProperties","params":{"libraryId":13,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":15,"command":"setLibraryProperties","params":{"libraryId":14,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":16,"command":"setLibraryProperties","params":{"libraryId":15,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":17,"command":"setLibraryProperties","params":{"libraryId":16,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":18,"command":"setLibraryProperties","params":{"libraryId":17,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":19,"command":"setLibraryProperties","params":{"libraryId":18,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":20,"command":"setLibraryProperties","params":{"libraryId":19,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":21,"command":"setLibraryProperties","params":{"libraryId":20,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":22,"command":"setLibraryProperties","params":{"libraryId":21,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":23,"command":"setLibraryProperties","params":{"libraryId":22,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":24,"command":"setLibraryProperties","params":{"libraryId":23,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":25,"command":"setLibraryProperties","params":{"libraryId":24,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":26,"command":"setLibraryProperties","params":{"libraryId":25,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":27,"command":"setLibraryProperties","params":{"libraryId":26,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":28,"command":"setLibraryProperties","params":{"libraryId":27,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":29,"command":"setLibraryProperties","params":{"libraryId":28,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":30,"command":"setLibraryProperties","params":{"libraryId":29,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":31,"command":"setLibraryProperties","params":{"libraryId":30,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":32,"command":"setLibraryProperties","params":{"libraryId":31,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":33,"command":"setLibraryProperties","params":{"libraryId":32,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":34,"command":"setLibraryProperties","params":{"libraryId":33,"isolateId":383209362,"debuggingEnabled":"true"}}{"id":35,"command":"setPauseOnException","params":{"exceptions":"unhandled","isolateId":383209362}}{"id":4, "result": {"debuggingEnabled": "true"}}{"id":5, "result": {"debuggingEnabled": "true"}}{"id":6, "result": {"debuggingEnabled": "true"}}{"id":7, "result": {"debuggingEnabled": "true"}}{"id":8, "result": {"debuggingEnabled": "true"}}{"id":9, "result": {"debuggingEnabled": "true"}}{"id":10, "result": {"debuggingEnabled": "true"}}{"id":11, "result": {"debuggingEnabled": "true"}}{"id":12, "result": {"debuggingEnabled": "true"}}{"id":13, "result": {"debuggingEnabled": "true"}}{"id":14, "result": {"debuggingEnabled": "true"}}{"id":15, "result": {"debuggingEnabled": "true"}}{"id":16, "result": {"debuggingEnabled": "true"}}{"id":17, "result": {"debuggingEnabled": "true"}}{"id":18, "result": {"debuggingEnabled": "true"}}{"id":19, "result": {"debuggingEnabled": "true"}}{"id":20, "result": {"debuggingEnabled": "true"}}{"id":21, "result": {"debuggingEnabled": "true"}}{"id":22, "result": {"debuggingEnabled": "true"}}{"id":23, "result": {"debuggingEnabled": "true"}}{"id":24, "result": {"debuggingEnabled": "true"}}{"id":25, "result": {"debuggingEnabled": "true"}}{"id":26, "result": {"debuggingEnabled": "true"}}{"id":27, "result": {"debuggingEnabled": "true"}}{"id":28, "result": {"debuggingEnabled": "true"}}{"id":29, "result": {"debuggingEnabled": "true"}}{"id":30, "result": {"debuggingEnabled": "true"}}{"id":31, "result": {"debuggingEnabled": "true"}}{"id":32, "result": {"debuggingEnabled": "true"}}{"id":33, "result": {"debuggingEnabled": "true"}}{"id":34, "result": {"debuggingEnabled": "true"}}{ "id": 35 }{"id":36,"command":"getLineNumberTable","params":{"libraryId":13,"isolateId":383209362,"url":"file:///app/bin/server.dart"}}{ "id": 36, "result": { "lines": [[1,0,1,1,8,2,20], [2,4,1,5,8,6,17], [4,9,1,10,8,11,46], [6,14,1,15,6,16,10,17,11,18,13], [7,20,3,21,7,22,16,23,18,24,22,25,38,26,39,27,44,28,45], [9,31,3,32,11,33,12,34,13,35,15], [10,37,5,38,15,39,16,40,20,41,21,42,30,43,32,44,36,45,37,46,38,48,42,49,43,50,44,52,50,53,52], [11,55,7,57,13,58,14,60,20,61,21,62,22,64,29,65,31], [12,67,11,68,14,69,15,71,22,72,23,74,26,75,27,77,32,78,35,80,38,81,40], [13,83,13,85,20,86,21,88,29,89,30,91,38,92,39,94,46,95,47,97,50,98,51,100,58,101,59,103,72,104,73,105,74], [14,107,11,108,13,109,18,110,21,111,22,113,29,114,30,116,33,117,34,119,39,120,42,122,52,123,54], [15,125,13,127,20,128,21,130,29,131,30,133,37,134,39,136,51,137,53,139,64,140,65,142,69], [16,144,13,146,20,147,21], [17,150,17,151,19,153,26,154,27,156,42,157,44,159,52,160,53,162,60,163,61,165,62], [18,167,17,168,19,170,26,171,27,173,45,174,47,176,55,177,56,179,66,180,67,182,68], [19,184,17,185,19,187,26,188,27], [20,191,27,193,28,194,30,196,38,197,39,199,58,200,59,202,60], [21,204,17,205,19,207,24,208,25,209,26], [22,211,11,212,13,213,18], [23,215,13,216,21,217,22,219,34,220,35,222,42,223,43], [24,225,11], [25,227,7,228,8,229,9], [26,231,5,232,6,233,7], [27,235,3,236,4], [28,238,3,240,10,241,12,242,13,244,14,245,16,247,26,248,28], [29,250,5,252,10,253,11,255,37,257,39,259,41,261,52,263,53,264,54], [30,266,3,267,4,268,5], [31,270,1]]}}{"id":37,"command":"resume","params":{"isolateId":383209362}}{ "id": 37 }

@clayberg
Copy link

cc @scheglov.
Set owner to @devoncarew.
Removed Priority-Unassigned label.
Added Priority-Medium label.

@devoncarew
Copy link
Member

I think this needs VM support before the editor can address the issue. We'd probably need support for setting breakpoints by regex, or perhaps support for setting breakpoints w/ a string that matches a suffix of a path. So sending in 'bin/server.dart' would match

file:///usr/local/prj/dart/github/dart_docker/hello/bin/server.dart


cc @turnidge.
cc @mhausner.
Removed the owner.
Removed Area-Editor label.
Added Area-VM label.

@DartBot
Copy link

DartBot commented Sep 24, 2014

This comment was originally written by @mhausner


I'll implement the suffix match.


Set owner to @mhausner.
Added Accepted label.

@DartBot
Copy link

DartBot commented Sep 26, 2014

This comment was originally written by @mhausner


Committed at r40736.

The debugger front-end can now request a breakpoint specifying a partial url, i.e. the last new parts of a path.


Added Fixed label.

@sgjesse
Copy link
Contributor Author

sgjesse commented Oct 9, 2014

Opened issue #21280 on adding suffox support to the Dart Editor.

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

No branches or pull requests

4 participants