Search in sources :

Example 1 with InstanceRef

use of org.dartlang.vm.service.element.InstanceRef in project flutter-intellij by flutter.

the class CanonicalBreakpoint method computeStackFrames.

public void computeStackFrames(@NotNull final String isolateId, final int firstFrameIndex, @NotNull final XExecutionStack.XStackFrameContainer container, @Nullable final InstanceRef exception) {
    addRequest(() -> myVmService.getStack(isolateId, new GetStackConsumer() {

        @Override
        public void received(final Stack vmStack) {
            ApplicationManager.getApplication().executeOnPooledThread(() -> {
                InstanceRef exceptionToAddToFrame = exception;
                // Check for async causal frames; fall back to using regular sync frames.
                ElementList<Frame> elementList = vmStack.getAsyncCausalFrames();
                if (elementList == null) {
                    elementList = vmStack.getFrames();
                }
                final List<Frame> vmFrames = Lists.newArrayList(elementList);
                final List<XStackFrame> xStackFrames = new ArrayList<>(vmFrames.size());
                for (final Frame vmFrame : vmFrames) {
                    if (vmFrame.getKind() == FrameKind.AsyncSuspensionMarker) {
                        // Render an asynchronous gap.
                        final XStackFrame markerFrame = new DartAsyncMarkerFrame();
                        xStackFrames.add(markerFrame);
                    } else {
                        final DartVmServiceStackFrame stackFrame = new DartVmServiceStackFrame(myDebugProcess, isolateId, vmFrame, vmFrames, exceptionToAddToFrame);
                        stackFrame.setIsDroppableFrame(vmFrame.getKind() == FrameKind.Regular);
                        xStackFrames.add(stackFrame);
                        if (!stackFrame.isInDartSdkPatchFile()) {
                            // The exception (if any) is added to the frame where debugger stops and to the upper frames.
                            exceptionToAddToFrame = null;
                        }
                    }
                }
                container.addStackFrames(firstFrameIndex == 0 ? xStackFrames : xStackFrames.subList(firstFrameIndex, xStackFrames.size()), true);
            });
        }

        @Override
        public void onError(final RPCError error) {
            container.errorOccurred(error.getMessage());
        }

        @Override
        public void received(Sentinel response) {
            container.errorOccurred(response.getValueAsString());
        }
    }));
}
Also used : InstanceRef(org.dartlang.vm.service.element.InstanceRef) GetStackConsumer(org.dartlang.vm.service.consumer.GetStackConsumer) Frame(org.dartlang.vm.service.element.Frame) DartVmServiceStackFrame(io.flutter.vmService.frame.DartVmServiceStackFrame) XStackFrame(com.intellij.xdebugger.frame.XStackFrame) DartAsyncMarkerFrame(io.flutter.vmService.frame.DartAsyncMarkerFrame) Sentinel(org.dartlang.vm.service.element.Sentinel) ArrayList(java.util.ArrayList) RPCError(org.dartlang.vm.service.element.RPCError) XStackFrame(com.intellij.xdebugger.frame.XStackFrame) XExecutionStack(com.intellij.xdebugger.frame.XExecutionStack) Stack(org.dartlang.vm.service.element.Stack) DartVmServiceStackFrame(io.flutter.vmService.frame.DartVmServiceStackFrame) DartAsyncMarkerFrame(io.flutter.vmService.frame.DartAsyncMarkerFrame)

Example 2 with InstanceRef

use of org.dartlang.vm.service.element.InstanceRef in project flutter-intellij by flutter.

the class CanonicalBreakpoint method handleDebuggerConnected.

public void handleDebuggerConnected() {
    streamListen(VmService.DEBUG_STREAM_ID, new VmServiceConsumers.SuccessConsumerWrapper() {

        @Override
        public void received(final Success success) {
            myVmServiceReceiverThreadId = Thread.currentThread().getId();
            streamListen(VmService.ISOLATE_STREAM_ID, new VmServiceConsumers.SuccessConsumerWrapper() {

                @Override
                public void received(final Success success) {
                    getVm(new VmServiceConsumers.VmConsumerWrapper() {

                        @Override
                        public void received(final VM vm) {
                            for (final IsolateRef isolateRef : vm.getIsolates()) {
                                getIsolate(isolateRef.getId(), new VmServiceConsumers.GetIsolateConsumerWrapper() {

                                    @Override
                                    public void received(final Isolate isolate) {
                                        final Event event = isolate.getPauseEvent();
                                        final EventKind eventKind = event.getKind();
                                        // yet, and we'll get lifecycle events for them later.
                                        if (eventKind == EventKind.None) {
                                            return;
                                        }
                                        // This is the entry point for attaching a debugger to a running app.
                                        if (eventKind == EventKind.Resume) {
                                            attachIsolate(isolateRef, isolate);
                                            return;
                                        }
                                        // if event is not PauseStart it means that PauseStart event will follow later and will be handled by listener
                                        handleIsolate(isolateRef, eventKind == EventKind.PauseStart);
                                        // Handle the case of isolates paused when we connect (this can come up in remote debugging).
                                        if (eventKind == EventKind.PauseBreakpoint || eventKind == EventKind.PauseException || eventKind == EventKind.PauseInterrupted) {
                                            myDebugProcess.isolateSuspended(isolateRef);
                                            ApplicationManager.getApplication().executeOnPooledThread(() -> {
                                                final ElementList<Breakpoint> breakpoints = eventKind == EventKind.PauseBreakpoint ? event.getPauseBreakpoints() : null;
                                                final InstanceRef exception = eventKind == EventKind.PauseException ? event.getException() : null;
                                                myVmServiceListener.onIsolatePaused(isolateRef, breakpoints, exception, event.getTopFrame(), event.getAtAsyncSuspension());
                                            });
                                        }
                                    }
                                });
                            }
                        }
                    });
                }
            });
        }
    });
}
Also used : XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) Breakpoint(org.dartlang.vm.service.element.Breakpoint) InstanceRef(org.dartlang.vm.service.element.InstanceRef) IsolateRef(org.dartlang.vm.service.element.IsolateRef) EventKind(org.dartlang.vm.service.element.EventKind) Success(org.dartlang.vm.service.element.Success) VM(org.dartlang.vm.service.element.VM) Isolate(org.dartlang.vm.service.element.Isolate) Event(org.dartlang.vm.service.element.Event)

Aggregations

InstanceRef (org.dartlang.vm.service.element.InstanceRef)2 XLineBreakpoint (com.intellij.xdebugger.breakpoints.XLineBreakpoint)1 XExecutionStack (com.intellij.xdebugger.frame.XExecutionStack)1 XStackFrame (com.intellij.xdebugger.frame.XStackFrame)1 DartAsyncMarkerFrame (io.flutter.vmService.frame.DartAsyncMarkerFrame)1 DartVmServiceStackFrame (io.flutter.vmService.frame.DartVmServiceStackFrame)1 ArrayList (java.util.ArrayList)1 GetStackConsumer (org.dartlang.vm.service.consumer.GetStackConsumer)1 Breakpoint (org.dartlang.vm.service.element.Breakpoint)1 Event (org.dartlang.vm.service.element.Event)1 EventKind (org.dartlang.vm.service.element.EventKind)1 Frame (org.dartlang.vm.service.element.Frame)1 Isolate (org.dartlang.vm.service.element.Isolate)1 IsolateRef (org.dartlang.vm.service.element.IsolateRef)1 RPCError (org.dartlang.vm.service.element.RPCError)1 Sentinel (org.dartlang.vm.service.element.Sentinel)1 Stack (org.dartlang.vm.service.element.Stack)1 Success (org.dartlang.vm.service.element.Success)1 VM (org.dartlang.vm.service.element.VM)1