Пример #1
0
        /// <summary>
        /// We're done loading the initial threads.
        /// Notify the GUI that we're good to go.
        /// </summary>
        private void OnLoadThreadsDone(Dot42.DebuggerLib.Debugger debugger, DebugProcess debugProcess)
        {
            // Notify module
            //eventCallback.Send(program, new ModuleLoadEvent(program.MainModule, "Loading module", true));
            //eventCallback.Send(program, new SymbolSearchEvent(program.MainModule, "Symbols loaded", enum_MODULE_INFO_FLAGS.MIF_SYMBOLS_LOADED));

            var mainThread = debugProcess.ThreadManager.MainThread();

            if (mainThread != null)
            {
                // Threads loaded
                // Load complete
                //eventCallback.Send(mainThread, new LoadCompleteEvent());
                //eventCallback.Send(mainThread, new EntryPointEvent());

                // Resume now
                debugger.VirtualMachine.ResumeAsync();

                // Notify SD
                Action onDebugStarted = () => {
                    if (stateUpdate != null)
                    {
                        stateUpdate(LauncherStates.Attached, string.Empty);
                        stateUpdate = null;
                    }
                    DebugStarted.Fire(this);
                };
                Dot42Addin.InvokeAsyncAndForget(onDebugStarted);
            }
            else
            {
                DLog.Error(DContext.VSDebuggerLauncher, "No main thread found");
            }
        }
Пример #2
0
        public void LaunchDebugEngine(string apkPath, Dot42.DebuggerLib.Debugger debugger, Guid debuggerGuid, int launchFlags, Action <LauncherStates, string> stateUpdate)
        {
            var sdDebugger = DebuggerService.CurrentDebugger as Dot42Debugger;

            if (sdDebugger == null)
            {
                MessageBox.Show("Dot42 Debugger expected");
                return;
            }
            sdDebugger.Attach(apkPath, debugger, debuggerGuid);
        }
Пример #3
0
        /// <summary>
        /// Attach to the given debugger and start debugging.
        /// </summary>
        public void Attach(string apkPath, Dot42.DebuggerLib.Debugger debugger, Guid debuggerGuid)
        {
            // Cleanup static state
            Launcher.GetAndRemoveDebugger(debuggerGuid, out stateUpdate);

            // Notify SD
            Dot42Addin.InvokeAsyncAndForget(() => DebugStarting.Fire(this));

            // Load map file
            var mapFilePath = Path.ChangeExtension(apkPath, ".d42map");
            var mapFile     = File.Exists(mapFilePath) ? new MapFile(mapFilePath) : new MapFile();

            // Suspend and prepare the VM
            var suspend = debugger.VirtualMachine.SuspendAsync();
            var prepare = suspend.ContinueWith(t => {
                t.ForwardException();
                return(debugger.PrepareAsync());
            }).Unwrap();
            var debugProcess = new DebugProcess(debugger, mapFile);

            DebugProcess = debugProcess;
            var initializeBreakpoints = prepare.ContinueWith(t => {
                t.ForwardException();
                // Setup breakpoints
                Dot42Addin.Invoke(() => debugProcess.BreakpointManager.InitializeBreakpoints(DebuggerService.Breakpoints));
            });
            var loadThreads = initializeBreakpoints.ContinueWith(t => {
                t.ForwardException();
                return(debugProcess.ThreadManager.RefreshAsync());
            }).Unwrap();

            loadThreads.ContinueWith(t => {
                t.ForwardException();
                OnLoadThreadsDone(debugger, debugProcess);
            });
        }