public void Send(IDebugEvent2 eventObject, string iidEvent, IDebugProgram2 program, IDebugThread2 thread) { uint attributes; var riidEvent = new Guid(iidEvent); EngineUtils.RequireOk(eventObject.GetAttributes(out attributes)); EngineUtils.RequireOk(m_ad7Callback.Event(m_engine, null, program, thread, eventObject, ref riidEvent, attributes)); }
/// <summary> /// Sends this callback to the specified engine. /// </summary> /// <param name="callback">The callback.</param> /// <param name="engine">The engine.</param> /// <param name="eventObject">The event object.</param> /// <param name="eventId">The event identifier.</param> /// <param name="program">The program.</param> /// <param name="thread">The thread.</param> public static void Send(this IDebugEventCallback2 callback, MonoEngine engine, IDebugEvent2 eventObject, string eventId, IDebugProgram2 program, IDebugThread2 thread) { uint attributes; var @event = new Guid(eventId); eventObject.GetAttributes(out attributes); callback.Event(engine, null, program, thread, eventObject, ref @event, attributes); }
private void SendInternal(EventModel model) { uint attributes; Guid riidEvent = new Guid(model.IidEvent); EngineUtils.RequireOk(model.EventObject.GetAttributes(out attributes)); EngineUtils.RequireOk(_eventCallback.Event(_engine, null, model.Program, model.Thread, model.EventObject, ref riidEvent, attributes)); model.Set(); }
public static int Event(this IDebugEventCallback2 callback, IDebugEngine2 engine, IDebugProcess2 process, IDebugProgram2 program, IDebugThread2 thread, DebugEvent debugEvent) { Contract.Requires <ArgumentNullException>(callback != null, "callback"); Contract.Requires <ArgumentNullException>(debugEvent != null, "debugEvent"); Contract.Requires <ArgumentNullException>(engine != null, "engine"); Guid guid = debugEvent.EventGuid; enum_EVENTATTRIBUTES attributes = debugEvent.Attributes; return(callback.Event(engine, process, program, thread, debugEvent, ref guid, (uint)attributes)); }
public void Send(IDebugEvent2 eventObject, string iidEvent, IDebugProgram2 program, IDebugThread2 thread) { uint attributes; Guid riidEvent = new Guid(iidEvent); if (!(eventObject is AD7OutputDebugStringEvent)) { _engine.Logger.WriteLine("Send Event {0}", eventObject.GetType().Name); } EngineUtils.RequireOk(eventObject.GetAttributes(out attributes)); EngineUtils.RequireOk(_eventCallback.Event(_engine, null, program, thread, eventObject, ref riidEvent, attributes)); }
/// <summary> /// Perform actual send /// </summary> private void Send(IDebugProcess2 process, IDebugProgram2 program, IDebugThread2 thread, BaseEvent @event) { var guid = @event.IID; DLog.Debug(DContext.VSDebuggerEvent, "DebugEngine Event {0} {1}", @event.GetType().Name, guid); var rc = callback.Event(engine, process, program, thread, @event, ref guid, (uint)@event.Attributes); if (!ErrorHandler.Succeeded(rc)) { DLog.Error(DContext.VSDebuggerEvent, "DebugEngine Event failed {0}", rc); } }
public int Event(IDebugEngine2 pEngine, IDebugProcess2 pProcess, IDebugProgram2 pProgram, IDebugThread2 pThread, IDebugEvent2 pEvent, ref Guid riidEvent, uint dwAttrib) { _taskContext.ThrowIfNotOnMainThread(); _logger.Trace($"Note right of VS: <IN> IDebugEventCallback2 {pEvent.GetType()}"); var result = _callback.Event(pEngine, pProcess, pProgram, pThread, pEvent, ref riidEvent, dwAttrib); _logger.Trace($"Note right of VS: <OUT> IDebugEventCallback2 {pEvent.GetType()}"); return(result); }
internal void Send(IDebugEvent2 eventObject, string iidEvent, IDebugProgram2 program, IDebugThread2 thread) { uint attributes; Guid riidEvent = new Guid(iidEvent); EngineUtils.RequireOk(eventObject.GetAttributes(out attributes)); Debug.WriteLine(String.Format("Sending Event: {0} {1}", eventObject.GetType(), iidEvent)); try { EngineUtils.RequireOk(_events.Event(this, null, program, thread, eventObject, ref riidEvent, attributes)); } catch (InvalidCastException) { // COM object has gone away } }
public int Attach(IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes, uint celtPrograms, IDebugEventCallback2 pCallback, enum_ATTACH_REASON dwReason) { if (celtPrograms == 0) { return(VSConstants.S_OK); } if (pCallback == null) { throw new ArgumentNullException("pCallback"); } if (rgpPrograms == null || rgpPrograms.Length < celtPrograms) { throw new ArgumentException(); } if (rgpProgramNodes == null || rgpProgramNodes.Length < celtPrograms) { throw new ArgumentException(); } if (celtPrograms > 1) { throw new NotImplementedException(); } if (dwReason != enum_ATTACH_REASON.ATTACH_REASON_LAUNCH) { throw new NotImplementedException(); } JavaDebugProgram program = rgpProgramNodes[0] as JavaDebugProgram; if (program == null) { throw new NotSupportedException(); } lock (_programs) { _programs.Add(program); } DebugEvent @event = new DebugEngineCreateEvent(enum_EVENTATTRIBUTES.EVENT_ASYNCHRONOUS, this); pCallback.Event(this, program.GetProcess(), program, null, @event); program.InitializeDebuggerChannel(this, pCallback); return(VSConstants.S_OK); }
private void CreateAndRegisterXamarinThread(Client.ThreadInfo threadInfo) { XamarinThread thread = new XamarinThread(this, threadInfo.Id, threadInfo.Name, threadInfo.Location, _session); uint attributes; Guid riidEvent = new Guid(XamarinThreadCreateEvent.IID); IDebugThreadCreateEvent2 evnt = new XamarinThreadCreateEvent(); IDebugEvent2 eventObject = evnt as IDebugEvent2; if (eventObject.GetAttributes(out attributes) != VisualStudioExtensionConstants.S_OK) { throw new InvalidOperationException("Failed to create and register a thread. The event object failed to get its attributes"); } if (_eventCallback.Event(_engine, null, _activeProgram, thread, eventObject, ref riidEvent, attributes) != VisualStudioExtensionConstants.S_OK) { throw new InvalidOperationException("Failed to create and register a thread. The event has not been sent succesfully"); } }
async Task <int> SendEventAsync(DebugEvent evnt, IGgpDebugProgram program, IDebugThread2 thread) { await _taskContext.Factory.SwitchToMainThreadAsync(); if (((IDebugEvent2)evnt).GetAttributes(out uint attributes) != VSConstants.S_OK) { Trace.WriteLine($"Could not get event attributes of event ({evnt})"); return(VSConstants.E_FAIL); } Guid eventIid = evnt.Iid; DebugLogSend(evnt, program, thread, attributes); return(_eventCallback.Event(_debugEngine, null, program, thread, evnt, ref eventIid, attributes)); }
private void SendEvaluationCompleteEvent(Task <IDebugProperty2> task, IDebugEventCallback2 callback) { var thread = _context.StackFrame.Thread; var program = thread.Program; var engine = program.DebugEngine; var process = program.Process; IDebugProperty2 property; if (task != null) { property = task.Result; } else { property = new JavaDebugProperty(null, new EvaluatedExpression("?", "?", default(IValue), false)); } DebugEvent debugEvent = new DebugExpressionEvaluationCompleteEvent(enum_EVENTATTRIBUTES.EVENT_ASYNCHRONOUS, this, property); callback.Event(engine, process, program, thread, debugEvent); }
int IDebugEventCallback2.Event(IDebugEngine2 engine, IDebugProcess2 process, IDebugProgram2 program, IDebugThread2 thread, IDebugEvent2 @event, ref Guid riidEvent, uint attribs) { IDebugEventCallback2 ad7EventCallback = GetAD7EventCallback(); return(ad7EventCallback.Event(engine, process, program, thread, @event, ref riidEvent, attribs)); }
/// <summary> /// Attach the debug engine to a program. (http://msdn.microsoft.com/en-us/library/bb145136.aspx) /// </summary> /// <param name="rgpPrograms"> Represent programs to be attached to. These are port programs. </param> /// <param name="rgpProgramNodes"> Represent program nodes, one for each program. The program nodes in this array represent /// the same programs as in pProgram. The program nodes are given so that the DE can identify the programs to attach to. </param> /// <param name="aCeltPrograms"> Number of programs and/or program nodes in the pProgram and rgpProgramNodes arrays. </param> /// <param name="ad7Callback"> The IDebugEventCallback2 object to be used to send debug events to the SDM. </param> /// <param name="dwReason"> A value from the ATTACH_REASON enumeration that specifies the reason for attaching these programs. </param> /// <returns> If successful, returns S_OK; otherwise, returns an error code. </returns> int IDebugEngine2.Attach(IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes, uint aCeltPrograms, IDebugEventCallback2 ad7Callback, enum_ATTACH_REASON dwReason) { if (aCeltPrograms != 1) { System.Diagnostics.Debug.Fail("VSNDK Debugger only supports one debug target at a time."); throw new ArgumentException(); } try { EngineUtils.RequireOk(rgpPrograms[0].GetProgramId(out m_programGUID)); m_program = rgpPrograms[0]; // It is NULL when the user attached the debugger to a running process (by using Attach to Process UI). When that // happens, some objects must be instantiated, as well as GDB must be launched. Those ones are instantiated/launched // by LaunchSuspended and ResumeProcess methods when debugging an open project. if (this.m_engineCallback == null) { VSNDK.Package.ControlDebugEngine.isDebugEngineRunning = true; m_engineCallback = new EngineCallback(this, ad7Callback); AD7ProgramNodeAttach pnt = (AD7ProgramNodeAttach)m_program; m_process = pnt.m_process; AD7Port port = pnt.m_process._portAttach; string publicKeyPath = Environment.GetEnvironmentVariable("AppData") + @"\BlackBerry\bbt_id_rsa.pub"; string progName = pnt.m_programName.Substring(pnt.m_programName.LastIndexOf('/') + 1); string exePath = ""; string processesPaths = ""; System.IO.StreamReader readProcessesPathsFile = null; // Read the file ProcessesPath.txt to try to get the file location of the executable file. try { readProcessesPathsFile = new System.IO.StreamReader(System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Research In Motion\ProcessesPath.txt"); processesPaths = readProcessesPathsFile.ReadToEnd(); readProcessesPathsFile.Close(); } catch (Exception e) { processesPaths = ""; } string searchProgName = progName + "_" + port.m_isSimulator; int begin = processesPaths.IndexOf(searchProgName + ":>"); if (begin != -1) { begin += searchProgName.Length + 2; int end = processesPaths.IndexOf("\r\n", begin); exePath = processesPaths.Substring(begin, end - begin) + progName; } else { exePath = "CannotAttachToRunningProcess"; } exePath = exePath.Replace("\\", "\\\\\\\\"); if (GDBParser.LaunchProcess(pnt.m_programID, exePath, port.m_IP, port.m_isSimulator, port.m_toolsPath, publicKeyPath, port.m_password)) { if (exePath == "CannotAttachToRunningProcess") { MessageBox.Show(progName + " is attached to the debugger. However, to be able to debug your application, you must build and deploy it from this computer first.", "No executable file with symbols found.", MessageBoxButtons.OK, MessageBoxIcon.Warning); } m_eventDispatcher = new EventDispatcher(this); m_module = new AD7Module(); m_progNode = new AD7ProgramNode(m_process._processGUID, m_process._processID, exePath, new Guid(AD7Engine.Id)); AddThreadsToProgram(); } else { GDBParser.exitGDB(); VSNDK.Package.ControlDebugEngine.isDebugEngineRunning = false; return VSConstants.E_FAIL; } } AD7EngineCreateEvent.Send(this); AD7ProgramCreateEvent.Send(this); AD7ModuleLoadEvent.Send(this, m_module, true); AD7LoadCompleteEvent.Send(this, currentThread()); // If the reason for attaching is ATTACH_REASON_LAUNCH, the DE needs to send the IDebugEntryPointEvent2 event. // See http://msdn.microsoft.com/en-us/library/bb145136%28v=vs.100%29.aspx if (dwReason == enum_ATTACH_REASON.ATTACH_REASON_LAUNCH) { AD7EntryPointEvent ad7Event = new AD7EntryPointEvent(); Guid riidEvent = new Guid(AD7EntryPointEvent.IID); uint attributes = (uint)enum_EVENTATTRIBUTES.EVENT_STOPPING | (uint)enum_EVENTATTRIBUTES.EVENT_SYNCHRONOUS; int rc = ad7Callback.Event(this, null, m_program, currentThread(), ad7Event, ref riidEvent, attributes); Debug.Assert(rc == VSConstants.S_OK); } } catch (Exception e) { return EngineUtils.UnexpectedException(e); } return VSConstants.S_OK; }
public int Attach(IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes, uint celtPrograms, IDebugEventCallback2 pCallback, enum_ATTACH_REASON dwReason) { if (celtPrograms == 0) return VSConstants.S_OK; if (pCallback == null) throw new ArgumentNullException("pCallback"); if (rgpPrograms == null || rgpPrograms.Length < celtPrograms) throw new ArgumentException(); if (rgpProgramNodes == null || rgpProgramNodes.Length < celtPrograms) throw new ArgumentException(); if (celtPrograms > 1) throw new NotImplementedException(); if (dwReason != enum_ATTACH_REASON.ATTACH_REASON_LAUNCH) throw new NotImplementedException(); JavaDebugProgram program = rgpProgramNodes[0] as JavaDebugProgram; if (program == null) throw new NotSupportedException(); lock (_programs) { _programs.Add(program); } DebugEvent @event = new DebugEngineCreateEvent(enum_EVENTATTRIBUTES.EVENT_ASYNCHRONOUS, this); pCallback.Event(this, program.GetProcess(), program, null, @event); program.InitializeDebuggerChannel(this, pCallback); return VSConstants.S_OK; }
public void EngineCreated() { Debug.WriteLine("Event EngineCreated"); Guid iid = new Guid(EngineCreateEvent.IID); _callback.Event(_engine, null, null, null, new EngineCreateEvent(_engine), ref iid, EngineCreateEvent.Attributes); }
/// <summary> /// Fires the event notifying the SDM that the debug engine has loaded. /// </summary> public void EngineCreated() { Log.Debug("EngineCreated"); var iid = new Guid(EngineCreateEvent.IID); _callback.Event(_engine, null, null, null, new EngineCreateEvent(_engine), ref iid, EngineCreateEvent.Attributes); }
public void OnProgramDestroyed(IDebugProgram2 program, uint exitCode) { _callback.Event(_engine, null, program, null, new DebugEventProgramDestory(exitCode), ref DebugEventProgramDestory.ID, DebugEventProgramDestory.Attributes); }
// Attach the debug engine to a program. int IDebugEngine2.Attach(IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes, uint aCeltPrograms, IDebugEventCallback2 ad7Callback, enum_ATTACH_REASON dwReason) { // Attach the debug engine to a program. // // Attach can either be called to attach to a new process, or to complete an attach // to a launched process. // So could we simplify and move code from LaunchSuspended to here and maybe even // eliminate the debughost? Although I supposed DebugHost has some other uses as well. if (aCeltPrograms != 1) { System.Diagnostics.Debug.Fail("Cosmos Debugger only supports one debug target at a time."); throw new ArgumentException(); } try { EngineUtils.RequireOk(rgpPrograms[0].GetProgramId(out m_programGUID)); m_program = rgpPrograms[0]; AD7EngineCreateEvent.Send(this); AD7ProgramCreateEvent.Send(this); AD7ModuleLoadEvent.Send(this, m_module, true); // Dummy main thread // We dont support threads yet, but the debugger expects threads. // So we create a dummy object to represente our only "thread". // m_thread = m_process._threads; // m_thread = new AD7Thread(this, m_process); AD7LoadCompleteEvent.Send(this, currentThread()); // If the reason for attaching is ATTACH_REASON_LAUNCH, the DE needs to send the IDebugEntryPointEvent2 event. // See http://msdn.microsoft.com/en-us/library/bb145136%28v=vs.100%29.aspx if (dwReason == enum_ATTACH_REASON.ATTACH_REASON_LAUNCH) { AD7EntryPointEvent ad7Event = new AD7EntryPointEvent(); Guid riidEvent = new Guid(AD7EntryPointEvent.IID); uint attributes = (uint)enum_EVENTATTRIBUTES.EVENT_STOPPING | (uint)enum_EVENTATTRIBUTES.EVENT_SYNCHRONOUS; int rc = ad7Callback.Event(this, null, m_program, currentThread(), ad7Event, ref riidEvent, attributes); Debug.Assert(rc == VSConstants.S_OK); } } catch (Exception e) { return EngineUtils.UnexpectedException(e); } return VSConstants.S_OK; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #region DebugEngineCallbackInterface Members //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public int Event(IDebugEngine2 pEngine, IDebugProcess2 pProcess, IDebugProgram2 pProgram, IDebugThread2 pThread, IDebugEvent2 pEvent, ref Guid riidEvent, uint dwAttrib) { LoggingUtils.Print("[DebugEngineCallback] Event: " + riidEvent.ToString()); // // Process any registered function handler before passing the event to AD7 callback. // int handle = Constants.E_NOTIMPL; try { DebuggerEventDelegate eventCallback; if (m_debuggerCallback.TryGetValue(riidEvent, out eventCallback)) { handle = eventCallback(pEngine, pProcess, pProgram, pThread, pEvent, ref riidEvent, dwAttrib); } if (handle != Constants.E_NOTIMPL) { LoggingUtils.RequireOk(handle); } } catch (Exception e) { LoggingUtils.HandleException(e); throw; } finally { try { handle = m_ad7EventCallback.Event(pEngine, pProcess, pProgram, pThread, pEvent, ref riidEvent, dwAttrib); if (handle != Constants.E_NOTIMPL) { LoggingUtils.RequireOk(handle); } } catch (Exception e) { LoggingUtils.HandleException(e); throw; } } // // (Managed Code) It is strongly advised that ReleaseComObject be invoked on the various interfaces that are passed to IDebugEventCallback2::Event. // #if false Marshal.ReleaseComObject(pEngine); Marshal.ReleaseComObject(pProcess); Marshal.ReleaseComObject(pProgram); Marshal.ReleaseComObject(pThread); Marshal.ReleaseComObject(pEvent); #endif return(handle); }
private void Send(IDebugEvent2 eventObject, Guid eventGuid) { ErrorHandler.ThrowOnFailure(eventObject.GetAttributes(out var attributes)); ErrorHandler.ThrowOnFailure(_ad7Callback.Event( _engine, _process, _program, _program, eventObject, eventGuid, attributes)); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public void Broadcast (IDebugEventCallback2 callback, IDebugEvent2 debugEvent, IDebugProgram2 program, IDebugThread2 thread) { LoggingUtils.PrintFunction (); if (callback == null) { throw new ArgumentNullException ("callback"); } Guid eventGuid = ComUtils.GuidOf (debugEvent); uint eventAttributes = 0; LoggingUtils.RequireOk (debugEvent.GetAttributes (out eventAttributes)); if (((eventAttributes & (uint) enum_EVENTATTRIBUTES.EVENT_STOPPING) != 0) && (thread == null)) { throw new ArgumentNullException ("thread", "For stopping events, this parameter cannot be a null value as the stack frame is obtained from this parameter."); } try { int handle = callback.Event (this, null, program, thread, debugEvent, ref eventGuid, eventAttributes); if (handle != Constants.E_NOTIMPL) { LoggingUtils.RequireOk (handle); } } catch (Exception e) { LoggingUtils.HandleException (e); throw; } finally { if ((eventAttributes & (uint) enum_EVENTATTRIBUTES.EVENT_SYNCHRONOUS) != 0) { while (!m_broadcastHandleLock.WaitOne (0)) { Thread.Sleep (100); } } } }
private void SendEvaluationCompleteEvent(Task<IDebugProperty2> task, IDebugEventCallback2 callback) { var thread = _context.StackFrame.Thread; var program = thread.Program; var engine = program.DebugEngine; var process = program.Process; IDebugProperty2 property; if (task != null) property = task.Result; else property = new JavaDebugProperty(null, new EvaluatedExpression("?", "?", default(IValue), false)); DebugEvent debugEvent = new DebugExpressionEvaluationCompleteEvent(enum_EVENTATTRIBUTES.EVENT_ASYNCHRONOUS, this, property); callback.Event(engine, process, program, thread, debugEvent); }