Commit graph

39 commits

Author SHA1 Message Date
Ben Konyi 2a2d83e9e9 [ VM / Service ] Add support for enabling/disabling breakpoints
This change adds a `setBreakpointState` RPC which allows for breakpoints
to be enabled or disabled without needing to remove and recreate
breakpoints.

Fixes https://github.com/dart-lang/sdk/issues/45336.

TEST=set_breakpoint_state_test.dart

Change-Id: I1a04e6028d4e4560fdb8d3d26420c9a05da06b4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193896
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2021-04-06 22:16:06 +00:00
Martin Kustermann 5b4349de54 [vm/concurrency] Make main hot-reload implementation independent of current isolate
Since hot-reloading will affect all isolates within a group, there
should be nothing isolate-specific inside it. We therefore add a
NoActiveIsolateScope to the main part of the reloading
implementation.

Issue https://github.com/dart-lang/sdk/issues/36097

TEST=Refactoring of existing implementation.

Change-Id: I1c8db00e6a016c77c68c2c04448de056a76d42c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184782
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2021-02-17 09:38:29 +00:00
Martin Kustermann 0f76981bb1 [vm/concurrency] Change references to class_table/object_store/heap from Isolate to IsolateGroup
As part of making the compiler and other subsystems independent
of `Isolate` we have to move various state from `Isolate` to
`IsolateGroup`.

The class_table and object_store were already moved to `IsolateGroup`.

This CL only replaces usages of `Isolate::{object_store,class_table}`
with the equivalent in `IsolateGroup`.

Issue https://github.com/dart-lang/sdk/issues/36097

TEST=Pure refactoring - relying on existing test coverage.

Change-Id: I34a0682d715b054d6c5faff077a513980f59a348
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177126
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2021-01-06 15:22:11 +00:00
Ben Konyi c9ab5c4681 [ VM / Service ] Added TimelineStreamSubscriptionsChanged event
The `TimelineStreamSubscriptionsChanged` event is sent when
`setVMTimelineFlags` is invoked, notifying `Timeline` subscribers that
the set of recorded timeline streams has changed.

Fixes https://github.com/dart-lang/sdk/issues/41822

Change-Id: Ic1545eefea8cf3deeefba97bd1ea2695d1c35016
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/147681
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2020-05-12 19:22:41 +00:00
Ben Konyi 9cfe19d38b [ VM / Service ] Remove _spawnUri RPC from VM service
This code doesn't appear to be used anywhere in the Dart SDK or Flutter.

Fixes https://github.com/dart-lang/sdk/issues/41751

Change-Id: Iad8537f3187caa7b2304ee2ec2aaaa8b6ba2b35c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146480
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2020-05-05 00:47:37 +00:00
Ben Konyi babefb8c01 [ VM / Service ] Added VMFlagUpdated event to VM stream
Fixes https://github.com/dart-lang/sdk/issues/37557

Change-Id: I129c60a4ac8f42e2f338e6bd15f7fa6fcfe7f54a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109721
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2019-07-23 15:24:28 +00:00
Ryan Macnak 8da46d35f5 [vm] Move heap-related code to its own subdirectory (cf. compiler).
Remove some dead includes.

Change-Id: I31f3e739e5ee46dcbba5d6a2f091491b46402943
Reviewed-on: https://dart-review.googlesource.com/60146
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2018-06-20 00:39:49 +00:00
Carlo Bernaschina df8bf384eb Introduce external services registration
A new RPC is introduced `_registerService` which allow clients to
register new services that are accessible from all the other clients.

Each registered endpoint is identified by 3 strings:

 - `service`
   a non empty string which identifies the provided service
   (e.g. `HotReload`, `OpenFile`)
 - `alias`
   an alias for that particular endpoint used by clients to identify it
   (e.g. `Flutter`, `IntelliJ`)
 - `method` __generated__
   the RPC method that should be invoked from a client to request it

A new _stream_ `_Service` is introduce, and two related events:

 - `ServiceRegistered`
   which is triggered when a new client is registered.
   All the related information (`service`, `alias`, `method`) are sent.

 - `ServiceUnregistered`
   which is triggered when a client, which previously registered a
   service, disconnects.
   Just `service` and `method` are sent.

Related https://github.com/dart-lang/sdk/issues/30023

R=asiva@google.com, bkonyi@google.com

Review-Url: https://codereview.chromium.org/2980733003 .
2017-07-13 18:18:51 -07:00
Carlo Bernaschina 0d86f5f3c5 Added Editor stream and sendObjectToEditor RPC into Service Protocol
Related=https://github.com/dart-lang/sdk/issues/30023

R=rmacnak@google.com

Review-Url: https://codereview.chromium.org/2962593002 .
2017-06-29 10:08:12 -07:00
Zachary Anderson a1bcf051d8 clang-format runtime/vm
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2481873005 .
2016-11-08 13:54:47 -08:00
Zachary Anderson 103881d01c Make header include guards great again
i.e. #ifndef VM_WHATEVER -> #ifndef RUNTIME_VM_WHATEVER

This lets us remove a hack from the PRESUBMIT.py script that existed
for reasons that are no longer valid, and sets us up to add some
presubmit checks for the GN build.

R=asiva@google.com, rmacnak@google.com

Review URL: https://codereview.chromium.org/2450713004 .
2016-10-26 00:26:03 -07:00
John McCutchan 2d0a08baf9 Make reloadSources service RPC public
- [x] Make `reloadSources` RPC public.
- [x] Add an optional 'pause' parameter to `reloadSources`. When set to true, the isolate will enter the debug pause loop immediately after reloading sources and before resuming execution. This makes it possible for debugger clients to set breakpoints before resuming.
- [x] Add reload_sources_test which tests pausing after reload.
- [x] Fix a bug in `GetVarDescriptors` where a null code object could be used.

R=turnidge@google.com

Review URL: https://codereview.chromium.org/2411153002 .
2016-10-13 07:45:56 -07:00
Todd Turnidge 3a51fceaba First cut at _spawnUri rpc in the vm service.
BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/2072543002 .
2016-07-11 14:25:27 -07:00
John McCutchan 48c8ffa7f3 Initial isolate reload support
This is a cut of the work that Todd and I collaborated on in the reload branch.

In this CL, we've dropped the loader port hacks, in other words, on stack reloading in the standalone embedder does not work yet.

- [x] Support for hot reloading of isolate source code
- [x] Unit test harness and many tests
- [x] Service protocol and Observatory support
- [x] Product build does not include support for hot reloading.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1965823002 .
2016-05-17 12:19:06 -07:00
Todd Turnidge 6b28b4f7ef Remove DebuggerEvent. Refactor remaining code.
BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1978603002 .
2016-05-13 09:49:31 -07:00
John McCutchan 32abe2ce55 Stream blocks of timeline events over the service protocol. Can be used to monitor long running programs without buffering all events inside the VM.
- Rename TimelineEventStreamingRecorder to TimelineEventCallbackRecorder. Note that this should only be used for tests.

- Add 'Timeline' service event stream.
- Send a 'TimelineEvents' event on the 'Timeline' stream whenever a TimelineEventBlock is finished and the 'Timeline' stream is subscribed to.

- Simple service protocol test.

R=turnidge@google.com

Review URL: https://codereview.chromium.org/1765563002 .
2016-03-04 12:30:50 -08:00
John McCutchan 49dc7e557b Fix some service protocol isolate life cycle races that were discovered by the Flutter testing tool.
Fixes #25902

Issue #1

Assuming --pause-isolates-on-start, there is a window of time after an isolate is made runnable and before it pauses at the first message that we say the isolate is "resumed".

- Fix issue #1 by claiming the isolate is paused on start if it will eventually pause on start.
- Also, handle the resume command for this state by clearing the 'should pause on start' bit.

Issue #2

Before an isolate is made runnable we say the isolate is "resumed".

- Fix issue #2 by introducing a new pause event "None".

R=turnidge@google.com

Review URL: https://codereview.chromium.org/1756393002 .
2016-03-03 11:30:41 -08:00
John McCutchan 5c8d79c55a Add step OverAwait to service protocol
Additions to service protocol:

- PauseEvent includes an "atAsyncContinuation" boolean value.
- Resume command can take an 'OverAsyncContinuation' step mode.
- Breakpoints have an optional 'isSyntheticAsyncContinuation' boolean value.

Added low level step_over_await_test.

Issuing the OverAsyncContinuation resume command does the following:

- Adds a synthetic breakpoint (#1) to the async closure.
- Resumes the isolate.
- When we hit #1, the VM issues a StepOver and then reports us paused at #1.

At the next resume command, the VM will remove #1.

R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1699153002 .
2016-02-17 11:02:55 -08:00
Todd Turnidge 0f1d73fd07 Add --warn-on-pause-with-no-debugger flag. Add this to --observe behavior.
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org/1649843002 .
2016-01-29 12:19:33 -08:00
John McCutchan 89c49b9e87 Add dart:developer.postEvent for posting events to the service protocol from Dart code
- Add dart:developer.postEvent for posting events to the service protocol.
- Add 'Extension' service protocol event stream.
- Unit test.
- Update service.md

- Bug fix for logging stream.

R=turnidge@google.com

Review URL: https://codereview.chromium.org/1537523002 .
2015-12-17 09:34:52 -08:00
John McCutchan f3ee772308 Provide list of service protocol extensions in isolate and emit an event when one is registered.
- Doc improvements.
- Type annotation improvements.
- Isolate includes list of currently registered extensions.
- New event kind on isolate stream emitted whenever an extension is registered (IsolateServiceExtensionRegistered).

Fixes https://dartbug.com/25208
Fixes https://dartbug.com/25257

R=turnidge@google.com

Review URL: https://codereview.chromium.org/1527793004 .
2015-12-16 13:49:37 -08:00
Todd Turnidge 435bcdbe6c We can now name the current VM using the service protocol.
Adds a 'VM' stream and a 'VMUpdate' event.

Makes Event.isolate optional in service.md.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org/1398823002 .
2015-10-08 15:37:49 -07:00
John McCutchan d0882dd363 Remember when an isolate was paused and subtly display it in Obseravatory
- Display paused time as tooltip over "paused" word.
- Send a timestamp with every ServiceEvent.
- Unit tests verifying that paused on start, exit, and breakpoint timestamps are stable.
- Remember the pause time in DebuggerEvent.
- Remember the pause time in MessageHandler.
- Updated service protocol documentation.

R=turnidge@google.com

Review URL: https://codereview.chromium.org//1311503004 .
2015-08-26 10:57:59 -07:00
Todd Turnidge 7e8bb130f2 Add an IsolateRunnable event to the service protocol. Improve service docs.
Closes #24140

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1293383011 .
2015-08-21 10:25:38 -07:00
Ryan Macnak 07b6dad1f5 Automagically change the meaning of 'next' to 'async-next' when paused at an async function at await/yield.
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1299083002 .
2015-08-18 15:36:13 -07:00
John McCutchan f818f9dc0f Support piping log data over the service protocol
BUG=
R=rmacnak@google.com

Review URL: https://codereview.chromium.org//1241683005 .
2015-07-21 07:54:46 -07:00
Ryan Macnak 0979a7b23e Async-step, first cut.
Also fix inclusion of internal variables from outer scopes in var descriptors.

R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1241673003 .
2015-07-16 13:05:37 -07:00
Todd Turnidge e4684c7627 Provide stdout and stderr output in the Observatory debugger.
Implement two new streams, 'Stdout' and 'Stderr' in the service protocol.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1232193003 .
2015-07-14 12:54:07 -07:00
Ryan Macnak 392a83221f Allow setting break-on-exceptions option over the service protocol. Add command to Observatory's debugger.
Decide whether to cache service objects based on the fixedId property.

Be more tolerant of eval scripts and functions.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1174313002.
2015-06-15 12:05:23 -07:00
Todd Turnidge 996f012707 2nd attempt at adding streamListen/streamCancel to the service protocol.
This time I am committing the protocol changes first and saving the
Observatory changes for a second cl.

------

We currently support 5 streams: Isolate, Debug, GC, _Echo, and _Graph.

Only generate events when at least one client is listening to the
corresponding event stream.

Only send events to the clients that actually request them.

BUG=
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1166433008
2015-06-04 09:57:22 -07:00
Ryan Macnak 74dfae69e3 Reapply "Per-closure breakpoints; restructure breakpoint implementation to keep a list of conditions."
Fix copying breakpoints over to a new location when a latent location is resolved.

Fix bad assumption that BreakpointLocationAtLine always returns non-null result.

Review URL: https://codereview.chromium.org//1149983003
2015-05-27 09:59:33 -07:00
Todd Turnidge 8d24372339 Revert "Add the streamListen and streamCancel rpcs to the vm service."
This reverts commit 0967b63073.

Conflicts:
	runtime/observatory/tests/service/graph_test.dart
	runtime/vm/service.cc

BUG=

Review URL: https://codereview.chromium.org//1152283005
2015-05-26 15:22:39 -07:00
Todd Turnidge 0967b63073 Add the streamListen and streamCancel rpcs to the vm service.
We currently support 5 streams: Isolate, Debug, GC, _Echo, and _Graph.

    Only generate events when at least one client is listening to the
    corresponding event stream.

    Only send events to the clients that actually request them.

    Implement this all as Dart streams in the service lib.

    Update tests.  Fix a race in async_generator_..._test that was biting me.

Review URL: https://codereview.chromium.org//1143783003
2015-05-26 13:52:35 -07:00
Ryan Macnak e674f0dc62 Revert "Per-closure breakpoints; restructure breakpoint implementation to keep a list of conditions."
This reverts commit d37149ad3b.

Review URL: https://codereview.chromium.org//1145053004
2015-05-21 17:20:57 -07:00
Ryan Macnak d37149ad3b Per-closure breakpoints; restructure breakpoint implementation to keep a list of conditions.
BUG=
R=hausner@google.com

Review URL: https://codereview.chromium.org//1146173003
2015-05-21 16:52:08 -07:00
rmacnak@google.com 016214f002 Add Debugger.inspect. 1976 here we come!
R=johnmccutchan@google.com

Review URL: https://codereview.chromium.org//1132153002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45664 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-08 22:18:43 +00:00
turnidge@google.com d9f65329c3 Do not JSON encode the 'result' of a service rpc.
Before a response looked like this...

{ result:<string> id:* }

...where result was always a json encoded string.  This meant that
users of the service protocol had to json decode both the outer
message and the result, which was silly.

Now a response looks like this:

{ result:<map> id:* }

This means that users of the service protocol only need to decode once.

We have changed event formats as well.  Previously, an event looked like this:

{ result:<string> }

(Essentially a result without an id.)  The result was json encoded,
requiring the user to double-decode.

Now an event looks like this:

{ event:<map> }

This allows us to distinguish events from rpc results and avoids
double-decoding.  It also avoids having an id-less rpc result mistaken
for an event.

------------

Some details and associated changes:

- Unify GCEvent and ServiceEvent in the VM.

- Move sequence number handling out of dart code and into JSONStream
  in the VM.  Plumbing.  I needed to do this to avoid double-encoding.
  Some of the dart code gets a bit simpler.

- Update C++ tests to have a sequence number.

- Change format of method/params used in Error responses to be more json-y.

- Strip out double decoding in the service lib.

- Improvements to tests.  I was running into some races and other issues.

- Fail fast when we run into a message decoding problem.  Instead of
  returning a service exception, we now disconnect from the vm.

- VMDisconnected => ConnectionClosed.

- Add some support for a reason string when disconnecting from the vm
  in the service library.

Review URL: https://codereview.chromium.org//1093043004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45378 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-23 17:55:08 +00:00
turnidge@google.com 140a071acb Allow Observatory debugger to switch isolates.
- Add the "isolate" command which allows the user to switch isolate by name or number.  Supports completion.

- Add the "isolate name" command which allows the user to rename an isolate.  Add the "setName" method to the service protocol to support this.  Isolates now have a debugger_name() in the vm.

- The new IsolateUpdate event notifies the client when an isolate name changes.

- When an isolate is updated, update the page's isolate too, so the navbar is accurate.

- Update isolate summary to display isolate number.

- Rework how the isolate's name is computed because we were getting garbagey names in the IsolateStart event (SpawnState was not yet set).

- Make sure that the debugger doesn't subscribe to events multiple times.

- "info isolates" is now "isolate list".

- Rework reporting of vm and isolate startTime in the service protocol and in Observatory.

- Fix bug in command completion when subcommands and other completions share common prefixes.

- Rework isolate accounting in the VM object in Observatory.  We now create Isolates in getFromMap rather than from IsolateStart events, per se.  Rewrite the isolate updating code.

- IsolateStart and IsolateExit events are now owned by the Isolate itself, rather than the vm.

- Return the actual result in pause/resume/etc.

- Add assertion in JSONStream::PrintProperty64 that the result fits in a javascript double.  Sigh.

- Stop sending GC events for the service isolate.  Add assertions to guard against this happening in the future.

- Misc improvements in error reporting.

Review URL: https://codereview.chromium.org//1007863003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44718 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-26 19:06:18 +00:00
turnidge@google.com f9f2d9c017 Major rework of vm service events
--------
VM

Add a new ServiceEvent class in the vm.  Rework the event type names.

Add BreakpointAdded, BreakpointResolved, and BreakpointRemoved
service events.

Record the top frame for kIsolateInterrupted and kExceptionThrown
debugger events.

Send a top frame in more Pause* events.

Send breakpoint list with the Isolate response.  Remove the
getBreakpoints method from the vm service.

Move Resume events into debugger.cc.

Rework MessageHandler a bit so that we can send PauseStart and
PauseExit notifications.

--------
Observatory

Move some event handler from Application to Isolate.

Rewrite breakpoint tracking code to use the new breakpoint events.

Change run state tracking in Isolate.

Change getFromMap so that it applies updates if the map isn't a ref.

Use getFromMap instead of new ServiceObject in invokeRpc.  This
fixes some duplicate ServiceObject problems.

Review URL: https://codereview.chromium.org//979823003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@44268 260f80e4-7a28-3924-810f-c04153c831b5
2015-03-05 19:02:42 +00:00