Beispiel #1
0
        public static RemoteDebugApplication ConsoleSelectDebugProcess()
        {
            MachineDebugManager mdm     = new MachineDebugManager();
            var processes               = mdm.GetRemoteDebugApplications();
            RemoteDebugApplication proc = null;

            while (proc == null)
            {
                Console.Clear();
                Console.WriteLine("Please select a process to debug...");
                ListProcesses(processes);
                Console.WriteLine("X: CACNEL");
                Console.WriteLine("R: REFRESH");
                string selection = Console.ReadLine().ToUpperInvariant();
                if (selection == "X")
                {
                    break;
                }
                else if (selection == "R")
                {
                    continue;
                }
                else
                {
                    int  selectedProcess = -1;
                    bool success         = int.TryParse(selection, out selectedProcess);
                    if (success && selectedProcess >= 0 && selectedProcess < processes.Length)
                    {
                        proc = processes[selectedProcess];
                    }
                }
            }

            return(proc);
        }
Beispiel #2
0
        private static void DebuDebugger()
        {
            cscriptProc = ConsoleSelectDebugProcess();

            if (cscriptProc == null)
            {
                return;
            }

            var ad = new ApplicationDebugger();

            Console.WriteLine("Connecting...");
            cscriptProc.ConnectDebugger(ad);
            Console.WriteLine("Connected to " + cscriptProc.GetName());
            // TODO: make the breakpoint thing more event based;
            //       so extend ApplicationDebugger by some events and register an event which just resumes on a key press

            ad.BreakPoint += Handle_BreakPoint;

            ad.Close += Handle_Close;

            Console.WriteLine("Waiting for BreakPoint...");

            try
            {
                while (Connected)
                {
                    while (breakPoints.Any())
                    {
                        var bp = breakPoints.Pop();
                        Console.WriteLine("I: StepIn");
                        Console.WriteLine("O: StepOver");
                        Console.WriteLine("P: StepOut");
                        Console.WriteLine("ENTER: Continue");
                        switch (Console.ReadKey().Key)
                        {
                        case ConsoleKey.I:
                            cscriptProc.StepIn(bp);
                            break;

                        case ConsoleKey.O:
                            cscriptProc.StepOver(bp);
                            break;

                        case ConsoleKey.P:
                            cscriptProc.StepOut(bp);
                            break;

                        case ConsoleKey.Enter:
                            cscriptProc.Continue(bp);
                            break;
                        }
                    }

                    Thread.Sleep(300);
                }
            }
            finally
            {
                ad = null;
            }
        }