Пример #1
0
        int IDebugPendingBreakpoint2.Bind()
        {
            if (!CanBind())
            {
                // The breakpoint could not be bound. This may occur for many reasons such as an invalid location, an invalid expression, etc...
                // We may want to send an instance of IDebugBreakpointErrorEvent2 to the UI and return a valid instance of
                // IDebugErrorBreakpoint2 from IDebugPendingBreakpoint2::EnumErrorBreakpoints. The debugger will then
                // display information about why the breakpoint did not bind to the user.
                return(VSConstants.S_FALSE);
            }
            if (_boundBreakpoint != null)
            {
                throw new NotImplementedException(); // multiple bound breakpoints are not supported
            }
            IDebugDocumentPosition2 docPosition = (IDebugDocumentPosition2)
                                                  Marshal.GetObjectForIUnknown(_requestInfo.bpLocation.unionmember2);

            string documentName;

            TEXT_POSITION[] startPosition = new TEXT_POSITION[1];
            TEXT_POSITION[] endPosition   = new TEXT_POSITION[1];

            EngineUtils.RequireOk(docPosition.GetFileName(out documentName));
            EngineUtils.RequireOk(docPosition.GetRange(startPosition, endPosition));

            var resolution = _manager.ResolveBreakpoint(startPosition[0]);

            _boundBreakpoint = new BoundBreakpoint(_backend, this, resolution);
            _boundBreakpoint.CompleteBind();

            _callbacks.OnBreakpointBound(_boundBreakpoint);

            return(VSConstants.S_OK);
        }
Пример #2
0
        private void Send(IDebugEvent2 eventObject, string iidEvent)
        {
            uint attributes;
            Guid riidEvent = new Guid(iidEvent);

            EngineUtils.RequireOk(eventObject.GetAttributes(out attributes));
            EngineUtils.RequireOk(_ad7Callback.Event(_engine, _process, _program, _program, eventObject, ref riidEvent, attributes));
        }
Пример #3
0
        public PendingBreakpoint(BreakpointManager manager, BasmBreakpointBackend backend, EngineCallbacks callbacks, IDebugBreakpointRequest2 pBPRequest)
        {
            _manager   = manager;
            _backend   = backend;
            _callbacks = callbacks;
            _bpRequest = pBPRequest;

            BP_REQUEST_INFO[] requestInfo = new BP_REQUEST_INFO[1];
            EngineUtils.RequireOk(_bpRequest.GetRequestInfo(enum_BPREQI_FIELDS.BPREQI_BPLOCATION, requestInfo));
            _requestInfo = requestInfo[0];
        }
Пример #4
0
        public int ResumeProcess(IDebugProcess2 process)
        {
            IDebugPort2 port;

            EngineUtils.RequireOk(process.GetPort(out port));
            IDebugDefaultPort2 defaultPort = (IDebugDefaultPort2)port;

            IDebugPortNotify2 portNotify;

            EngineUtils.RequireOk(defaultPort.GetPortNotify(out portNotify));
            EngineUtils.RequireOk(portNotify.AddProgramNode(_program));

            Debug.WriteLine("IDebugEngineLaunch2.ResumeProcess: returning S_OK");
            return(VSConstants.S_OK);
        }
Пример #5
0
        // After engine initialization, SDM calls LaunchSuspended to start the debuggee in a suspended state.
        // ResumeProcess and Attach are invoked next.

        public int LaunchSuspended(string pszServer, IDebugPort2 port, string exe, string args, string dir, string env, string options, enum_LAUNCH_FLAGS launchFlags, uint hStdInput, uint hStdOutput, uint hStdError, IDebugEventCallback2 ad7Callback, out IDebugProcess2 process)
        {
            Debug.Assert(_program == null);

            var sourceFile = new SourceFile(Path.Combine(dir, exe));
            var runner     = new BasmRunner(sourceFile, OnProgramStop);
            var bpBackend  = new BasmBreakpointBackend(runner, OnProgramStepComplete, OnProgramBreakComplete);

            _program = new Program(runner, bpBackend, sourceFile);

            var processId = _program.StartBasmProcess();

            EngineUtils.RequireOk(port.GetProcess(processId, out process));

            _callbacks         = new EngineCallbacks(this, _program, process, ad7Callback);
            _breakpointManager = new BreakpointManager(_program, bpBackend, sourceFile, _callbacks);

            Debug.WriteLine("IDebugEngineLaunch2.LaunchSuspended: returning S_OK");
            return(VSConstants.S_OK);
        }
Пример #6
0
        public int Attach(IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes, uint celtPrograms, IDebugEventCallback2 ad7Callback, enum_ATTACH_REASON dwReason)
        {
            Debug.Assert(_program != null);

            IDebugProcess2 process;
            IDebugProgram2 program = rgpPrograms[0];

            EngineUtils.RequireOk(program.GetProcess(out process));

            Guid attachedGuid;

            EngineUtils.RequireOk(program.GetProgramId(out attachedGuid));
            _program.AttachDebugger(attachedGuid);

            Debug.WriteLine("IDebugEngine2.Attach: invoking load callbacks");
            // The SDM will invoke ContinueFromSynchronousEvent with AD7LoadCompleteEvent. At that point,
            // breakpoints from design mode will have already been placed, and the program can be launched.
            _callbacks.OnAttach();

            return(VSConstants.S_OK);
        }
Пример #7
0
 int IDebugEngine2.DestroyProgram(IDebugProgram2 program)
 {
     EngineUtils.RequireOk(program.Terminate());
     _callbacks.OnProgramTerminated();
     return(VSConstants.S_OK);
 }