/// <summary> /// Default ctor /// </summary> internal DebugProgram(DebugProcess process, DebuggerLib.Debugger debugger, string apkPath, MapFile mapFile, EngineEventCallback eventCallback) : base(debugger, mapFile, apkPath) { this.process = process; this.apkPath = apkPath; this.eventCallback = eventCallback; programGuid = Guid.NewGuid(); modules.Add(new DebugModule()); }
/// <summary> /// Now launch the actualk VS debugger around the given debugger. /// </summary> internal static void LaunchVsDebugEngine(IIde ide, string apkPath, DebuggerLib.Debugger debugger, int launchFlags, Action <LauncherStates, string> stateUpdate) { // Save debugger var key = Guid.NewGuid(); lock (debuggersLock) { debuggers.Add(key, Tuple.Create(debugger, stateUpdate)); } // Now launch the IDE's debug engine ide.LaunchDebugEngine(apkPath, debugger, key, launchFlags, stateUpdate); }
/// <summary> /// Default ctor /// </summary> internal DebugProcess(DebugEngine engine, DebugPort port, DebuggerLib.Debugger debugger, int processId, Guid guid, string apkPath, MapFile mapFile, EngineEventCallback eventCallback) { this.engine = engine; this.port = port; this.debugger = debugger; this.processId = processId; this.guid = guid; this.apkPath = apkPath; this.eventCallback = eventCallback; creationDate = DateTime.Now; program = new DebugProgram(this, debugger, apkPath, mapFile, eventCallback); program.Terminated += OnProgramTerminated; }
/// <summary> /// Now launch the actual IDE debugger around the given debugger. /// </summary> public void LaunchDebugEngine(string apkPath, DebuggerLib.Debugger debugger, Guid debuggerGuid, int launchFlags, Action <LauncherStates, string> stateUpdate) { var info = new VsDebugTargetInfo2[1]; info[0].cbSize = (uint)Marshal.SizeOf(typeof(VsDebugTargetInfo2)); info[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; info[0].dwProcessId = 0; info[0].dwReserved = 0; info[0].bstrOptions = debuggerGuid.ToString("B"); info[0].bstrExe = Path.GetFullPath(apkPath); info[0].bstrEnv = ""; info[0].bstrArg = null; info[0].bstrCurDir = Path.GetDirectoryName(apkPath); //info[0].clsidCustom = new Guid(GuidList.items.guidDot42Debugger); info[0].LaunchFlags = (uint)launchFlags | (uint)__VSDBGLAUNCHFLAGS2.DBGLAUNCH_StopAtEntryPoint; info[0].fSendToOutputWindow = 0; info[0].bstrRemoteMachine = null; info[0].guidLaunchDebugEngine = new Guid(GuidList.Strings.guidDot42DebuggerId); info[0].bstrPortName = "Default Dot42 Port"; info[0].guidPortSupplier = new Guid(GuidList.Strings.guidDot42PortSupplierId); //info[0].guidProcessLanguage = new Guid("{3F5162F8-07C6-11D3-9053-00C04FA302A1}"); info[0].pDebugEngines = IntPtr.Zero; info[0].dwDebugEngineCount = 0; info[0].pUnknown = null; info[0].guidProcessLanguage = Guid.Empty; info[0].hStdError = 0; info[0].hStdInput = 0; info[0].hStdOutput = 0; //var engineGuid = new Guid(GuidList.Strings.guidDot42DebuggerId); //var engineArrPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(engineGuid)); //Marshal.StructureToPtr(engineGuid, engineArrPtr, false); //info[0].pDebugEngines = engineArrPtr; //info[0].dwDebugEngineCount = 1; var ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(VsDebugTargetInfo2))); Marshal.StructureToPtr(info[0], ptr, false); try { var d = Package.GetGlobalService(typeof(IVsDebugger)) as IVsDebugger2; if (d == null) { throw new InvalidOperationException("Cannot find IVsDebugger"); } var rc = d.LaunchDebugTargets2(1, ptr); ErrorHandler.ThrowOnFailure(rc); } finally { if (ptr != IntPtr.Zero) { Marshal.FreeHGlobal(ptr); } //if (engineArrPtr != IntPtr.Zero) //{ //Marshal.FreeCoTaskMem(engineArrPtr); //} } }