Exemplo n.º 1
0
        static void _Mrdebug_Run()
        {
            ShellCtrl sh = new ShellCtrl("mrdebug mrdebugee.exe -xdebug", true);

            sh.WriteLine("cont");
            int           GotProcessStart = 0, GotFirst = 0, GotProcessExit = 0;
            int           LineNumber = 0;
            StringBuilder sboutput   = new StringBuilder();
            Exception     exception  = null;

            try
            {
                for (; ;)
                {
                    string line = _timely_ReadLine(sh);
                    if (null == line)
                    {
                        break;
                    }
                    sboutput.AppendLine(line);
                    LineNumber++;
                    if (0 == GotProcessStart &&
                        "STOP: Breakpoint Hit" == line)
                    {
                        GotProcessStart = LineNumber;
                        Console.Write('.');
                    }
                    if (-1 != line.IndexOf("*FIRST*"))
                    {
                        GotFirst = LineNumber;
                        Console.Write('.');
                    }
                    if (0 == GotProcessExit &&
                        "Process exited." == line)
                    {
                        GotProcessExit = LineNumber;
                        Console.Write('.');
                        sh.WriteLine("quit");
                    }
                }
                Console.WriteLine("Done");
            }
            catch (Exception e)
            {
                exception = e;
                Console.WriteLine("Exception: {0}", e.ToString());
            }
            if (null != exception ||
                (!(GotProcessStart > 0 &&
                   GotFirst > GotProcessStart &&
                   GotProcessExit > GotFirst)))
            {
                Console.WriteLine("*** Failure. Debugger output: {0}", sboutput.ToString());
                throw new Exception("Debugee process start and end did not occur correctly");
            }
        }
Exemplo n.º 2
0
 static void _Mrdebug_StepOver()
 {
     ShellCtrl sh = new ShellCtrl("mrdebug mrdebugee.exe -xdebug", true);
     sh.WriteLine("b Program.cs:41");
     sh.WriteLine("cont");
     int GotProcessStart = 0, GotFirst = 0, GotProcessExit = 0;
     int LineNumber = 0;
     bool StillStepping = true;
     StringBuilder sboutput = new StringBuilder();
     Exception exception = null;
     try
     {
         for (; ; )
         {
             string line = _timely_ReadLine(sh);
             if (null == line)
             {
                 break;
             }
             sboutput.AppendLine(line);
             LineNumber++;
             if (0 == GotProcessStart
                 && "STOP: Breakpoint Hit" == line)
             {
                 GotProcessStart = LineNumber;
                 Console.Write('.');
                 StillStepping = true;
             }
             if (-1 != line.IndexOf("*FIRST*"))
             {
                 GotFirst = LineNumber;
                 Console.Write('.');
             }
             if (0 == GotProcessExit
                 && "Process exited." == line)
             {
                 GotProcessExit = LineNumber;
                 Console.Write('.');
                 StillStepping = false;
                 sh.WriteLine("quit");
             }
             if (StillStepping)
             {
                 int codeline = _mrdebug_codeline(line);
                 if (codeline >= 0)
                 {
                     Console.Write("{0},", codeline);
                     sh.WriteLine("so"); // Step over.
                 }
             }
         }
         Console.WriteLine("Done");
     }
     catch (Exception e)
     {
         exception = e;
         Console.WriteLine("Exception: {0}", e.ToString());
     }
     if (null != exception
         || (!(GotProcessStart > 0
         && GotFirst > GotProcessStart
         && GotProcessExit > GotFirst)))
     {
         Console.WriteLine("*** Failure. Debugger output: {0}", sboutput.ToString());
         throw new Exception("Debugee process start and end did not occur correctly");
     }
 }
Exemplo n.º 3
0
 static void _Mrdebug_Breakpoint(bool ManyBreakpoints)
 {
     ShellCtrl sh = new ShellCtrl("mrdebug mrdebugee.exe -xdebug", true);
     sh.WriteLine("b Program.cs:83"); // Always the first one, even if ManyBreakpoints.
     if (ManyBreakpoints)
     {
         sh.WriteLine("b Program.cs:95");
         sh.WriteLine("b Program.cs:141");
         sh.WriteLine("b Program.cs:147");
         sh.WriteLine("b Program.cs:153");
         sh.WriteLine("b Program.cs:178");
         sh.WriteLine("b Program.cs:184");
     }
     sh.WriteLine("cont");
     int GotProcessStart = 0, GotFirst = 0, GotBeforeBp = 0, GotBp = 0, GotAfterBp = 0, GotProcessExit = 0;
     int LineNumber = 0;
     StringBuilder sboutput = new StringBuilder();
     Exception exception = null;
     try
     {
         for (; ; )
         {
             string line = _timely_ReadLine(sh);
             if (null == line)
             {
                 break;
             }
             sboutput.AppendLine(line);
             LineNumber++;
             if (0 == GotProcessStart
                 && "STOP: Breakpoint Hit" == line)
             {
                 GotProcessStart = LineNumber;
                 Console.Write('.');
             }
             if (-1 != line.IndexOf("*FIRST*"))
             {
                 GotFirst = LineNumber;
                 Console.Write('.');
             }
             if (0 == GotBeforeBp
                 && -1 != line.IndexOf("{8339B895-EFA5-476b-865B-6FE4B77268E4}before"))
             {
                 GotBeforeBp = LineNumber;
                 Console.Write('.');
             }
             if (-1 != line.IndexOf("break at #"))
             {
                 Console.Write('.');
                 if (!ManyBreakpoints || 0 == GotBp)
                 {
                     if (0 != GotBp)
                     {
                         throw new Exception("Got too many breakpoints");
                     }
                     GotBp = LineNumber;
                     if (0 == GotBeforeBp)
                     {
                         throw new Exception("Expected magic before- GUID before breakpoint");
                     }
                     if (0 != GotAfterBp)
                     {
                         throw new Exception("Did not expect magic after- GUID before breakpoint");
                     }
                 }
                 if (ManyBreakpoints)
                 {
                     // Keep adding this one on a breakpoint.
                     sh.WriteLine("b Program.cs:190");
                 }
                 sh.WriteLine("cont");
             }
             if (0 == GotAfterBp
                 && -1 != line.IndexOf("{8339B895-EFA5-476b-865B-6FE4B77268E4}after"))
             {
                 GotAfterBp = LineNumber;
                 Console.Write('.');
             }
             if (0 == GotProcessExit
                 && "Process exited." == line)
             {
                 GotProcessExit = LineNumber;
                 Console.Write('.');
                 sh.WriteLine("quit");
             }
         }
         Console.WriteLine("Done");
     }
     catch (Exception e)
     {
         exception = e;
         Console.WriteLine("Exception: {0}", e.ToString());
     }
     if (null != exception
         || (!(GotProcessStart > 0
         && GotFirst > GotProcessStart
         && GotBeforeBp > GotProcessStart
         && GotBp > GotBeforeBp
         && GotAfterBp > GotBp
         && GotProcessExit > GotAfterBp)))
     {
         Console.WriteLine("*** Failure. Debugger output: {0}", sboutput.ToString());
         throw new Exception("Debugee process events did not occur correctly");
     }
 }
Exemplo n.º 4
0
        static void _Mrdebug_Breakpoint(bool ManyBreakpoints)
        {
            ShellCtrl sh = new ShellCtrl("mrdebug mrdebugee.exe -xdebug", true);

            sh.WriteLine("b Program.cs:83"); // Always the first one, even if ManyBreakpoints.
            if (ManyBreakpoints)
            {
                sh.WriteLine("b Program.cs:95");
                sh.WriteLine("b Program.cs:141");
                sh.WriteLine("b Program.cs:147");
                sh.WriteLine("b Program.cs:153");
                sh.WriteLine("b Program.cs:178");
                sh.WriteLine("b Program.cs:184");
            }
            sh.WriteLine("cont");
            int           GotProcessStart = 0, GotFirst = 0, GotBeforeBp = 0, GotBp = 0, GotAfterBp = 0, GotProcessExit = 0;
            int           LineNumber = 0;
            StringBuilder sboutput   = new StringBuilder();
            Exception     exception  = null;

            try
            {
                for (; ;)
                {
                    string line = _timely_ReadLine(sh);
                    if (null == line)
                    {
                        break;
                    }
                    sboutput.AppendLine(line);
                    LineNumber++;
                    if (0 == GotProcessStart &&
                        "STOP: Breakpoint Hit" == line)
                    {
                        GotProcessStart = LineNumber;
                        Console.Write('.');
                    }
                    if (-1 != line.IndexOf("*FIRST*"))
                    {
                        GotFirst = LineNumber;
                        Console.Write('.');
                    }
                    if (0 == GotBeforeBp &&
                        -1 != line.IndexOf("{8339B895-EFA5-476b-865B-6FE4B77268E4}before"))
                    {
                        GotBeforeBp = LineNumber;
                        Console.Write('.');
                    }
                    if (-1 != line.IndexOf("break at #"))
                    {
                        Console.Write('.');
                        if (!ManyBreakpoints || 0 == GotBp)
                        {
                            if (0 != GotBp)
                            {
                                throw new Exception("Got too many breakpoints");
                            }
                            GotBp = LineNumber;
                            if (0 == GotBeforeBp)
                            {
                                throw new Exception("Expected magic before- GUID before breakpoint");
                            }
                            if (0 != GotAfterBp)
                            {
                                throw new Exception("Did not expect magic after- GUID before breakpoint");
                            }
                        }
                        if (ManyBreakpoints)
                        {
                            // Keep adding this one on a breakpoint.
                            sh.WriteLine("b Program.cs:190");
                        }
                        sh.WriteLine("cont");
                    }
                    if (0 == GotAfterBp &&
                        -1 != line.IndexOf("{8339B895-EFA5-476b-865B-6FE4B77268E4}after"))
                    {
                        GotAfterBp = LineNumber;
                        Console.Write('.');
                    }
                    if (0 == GotProcessExit &&
                        "Process exited." == line)
                    {
                        GotProcessExit = LineNumber;
                        Console.Write('.');
                        sh.WriteLine("quit");
                    }
                }
                Console.WriteLine("Done");
            }
            catch (Exception e)
            {
                exception = e;
                Console.WriteLine("Exception: {0}", e.ToString());
            }
            if (null != exception ||
                (!(GotProcessStart > 0 &&
                   GotFirst > GotProcessStart &&
                   GotBeforeBp > GotProcessStart &&
                   GotBp > GotBeforeBp &&
                   GotAfterBp > GotBp &&
                   GotProcessExit > GotAfterBp)))
            {
                Console.WriteLine("*** Failure. Debugger output: {0}", sboutput.ToString());
                throw new Exception("Debugee process events did not occur correctly");
            }
        }