Пример #1
0
 /// <summary>
 /// Default ctor
 /// </summary>
 internal DebugProgram(DebugProcess process, DebuggerLib.Debugger debugger, string apkPath, MapFile mapFile, EngineEventCallback eventCallback)
     : base(debugger, mapFile)
 {
     this.process = process;
     this.apkPath = apkPath;
     this.eventCallback = eventCallback;
     programGuid = Guid.NewGuid();
     modules.Add(new DebugModule());
 }
Пример #2
0
        /// <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);
                //}
            }
        }
Пример #3
0
        /// <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);
        }
Пример #4
0
 /// <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;
 }
Пример #5
0
        /// <summary>
        /// Process the given exception event.
        /// </summary>
        protected override void OnExceptionEvent(DebuggerLib.Events.Jdwp.Exception @event, DalvikThread thread)
        {
            base.OnExceptionEvent(@event, thread);

            // Get information about the exception
            var exceptionTypeId = Debugger.ObjectReference.ReferenceTypeAsync(@event.ExceptionObject.Object).Await(DalvikProcess.VmTimeout);
            var exceptionType = Process.ReferenceTypeManager[exceptionTypeId];

            // Prepare VS event
            var info = new EXCEPTION_INFO();
            info.bstrExceptionName = exceptionType.GetNameAsync().Await(DalvikProcess.VmTimeout);
            var caught = @event.IsCaught;
            info.dwState = caught
                               ? enum_EXCEPTION_STATE.EXCEPTION_STOP_FIRST_CHANCE
                               : enum_EXCEPTION_STATE.EXCEPTION_STOP_USER_UNCAUGHT;
            program.GetName(out info.bstrProgramName);
            info.pProgram = program;
            info.guidType = GuidList.Guids.guidDot42DebuggerId;

            // Send VS event
            var vsEvent = new ExceptionEvent(info, info.bstrExceptionName, false);
            Send((DebugThread) thread, vsEvent);
        }
Пример #6
0
 /// <summary>
 /// Create an instance representing the given reference type.
 /// </summary>
 protected override DalvikThread CreateThread(DebuggerLib.ThreadId id)
 {
     return new DebugThread(program, eventCallback, this, id, lastTid++);
 }
Пример #7
0
 /// <summary>
 /// This breakpoint is reached.
 /// </summary>
 protected override void OnTrigger(DebuggerLib.Events.Jdwp.Breakpoint @event)
 {
     // Notify VS
     boundBreakpoint.OnTrigger(@event);
 }