public NodeThreadContext(JObject frame, DebuggedProcess proc) { jObject = frame; index = (int)frame["index"]; func = new NodeFunc(proc.LookupRef(frame["func"])); script = proc.JsonToScript(proc.LookupRef(frame["script"])); line = (int)frame["line"]; column = (int)frame["column"]; Args = frame["arguments"].Select(x => new Property((JObject)x, proc)).ToArray(); Locals = frame["locals"].Select(x => new Property((JObject)x, proc)).ToArray(); }
public Property(JObject jObject, DebuggedProcess proc, string parentName = null) { this.jObject = jObject; this.proc = proc; m_name = (string)jObject["name"]; m_fullName = m_name; if (parentName != null) { m_fullName = parentName; if (Tools.IsValidIdentifier(m_name)) { m_fullName += "." + m_name; } else { m_fullName += "[" + JsonConvert.SerializeObject(m_name) + "]"; } } Attributes = (PropertyAttribute)(int)(jObject["attributes"] ?? new JValue(0)); Types = (PropertyType)(int)(jObject["propertyType"] ?? new JValue(0)); //m_name += "(" + Attributes + ") (" + Types + ")"; var value = jObject["value"] ?? proc.dbg.LookupRef((int)jObject["ref"], 300); if (value != null) FillValue((JObject)value); }
public void SetDebugProcess(DebuggedProcess debuggedProcess) { System.Diagnostics.Debug.Assert(m_debuggedProcess == null); m_debuggedProcess = debuggedProcess; }
// Launches a process by means of the debug engine. // Normally, Visual Studio launches a program using the IDebugPortEx2::LaunchSuspended method and then attaches the debugger // to the suspended program. However, there are circumstances in which the debug engine may need to launch a program // (for example, if the debug engine is part of an interpreter and the program being debugged is an interpreted language), // in which case Visual Studio uses the IDebugEngineLaunch2::LaunchSuspended method // The IDebugEngineLaunch2::ResumeProcess method is called to start the process after the process has been successfully launched in a suspended state. int IDebugEngineLaunch2.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(Worker.MainThreadId == Worker.CurrentThreadId); Debug.Assert(m_pollThread == null); Debug.Assert(m_engineCallback == null); Debug.Assert(m_debuggedProcess == null); Debug.Assert(m_ad7ProgramId == Guid.Empty); process = null; try { // We are being asked to debug a process when we currently aren't debugging anything m_pollThread = new WorkerThread(); m_engineCallback = new EngineCallback(this, ad7Callback); // Complete the win32 attach on the poll thread m_pollThread.RunOperation(() => m_debuggedProcess = new DebuggedProcess(exe, args, m_pollThread, Callback)); var adProcessId = new AD_PROCESS_ID { ProcessIdType = (uint)enum_AD_PROCESS_ID.AD_PROCESS_ID_SYSTEM, dwProcessId = (uint)m_debuggedProcess.Id }; EngineUtils.RequireOk(port.GetProcess(adProcessId, out process)); return Constants.S_OK; } catch (Exception e) { return EngineUtils.UnexpectedException(e); } }
// Called by the SDM to indicate that a synchronous debug event, previously sent by the DE to the SDM, // was received and processed. The only event the sample engine sends in this fashion is Program Destroy. // It responds to that event by shutting down the engine. int IDebugEngine2.ContinueFromSynchronousEvent(IDebugEvent2 eventObject) { //Debug.Assert(Worker.MainThreadId == Worker.CurrentThreadId); try { if (eventObject is AD7ProgramDestroyEvent) { var pollThread = m_pollThread; var debuggedProcess = m_debuggedProcess; m_engineCallback = null; m_debuggedProcess = null; m_pollThread = null; m_ad7ProgramId = Guid.Empty; debuggedProcess.Terminate(); pollThread.Close(); } else { Debug.Fail("Unknown syncronious event"); } } catch (Exception e) { return EngineUtils.UnexpectedException(e); } return Constants.S_OK; }