示例#1
0
        public void IsNaClPluginProcessTest()
        {
            PluginDebuggerGDB_Accessor target = new PluginDebuggerGDB_Accessor(dte_, properties_);

            ProcessInfo badProc = new ProcessInfo(
                1, 1, string.Empty, Strings.ChromeRendererFlag, Strings.NaClProcessName);
            ProcessInfo goodProc = new ProcessInfo(
                1, 1, string.Empty, Strings.NaClLoaderFlag, Strings.NaClProcessName);

            string goodMainChromeFlags = Strings.NaClDebugFlag;
            string badMainChromeFlags  = string.Format(
                Strings.PepperProcessPluginFlagFormat, target.targetNexe_);

            Assert.IsTrue(target.IsPluginProcess(goodProc, goodMainChromeFlags));
            Assert.IsFalse(target.IsPluginProcess(goodProc, badMainChromeFlags));
            Assert.IsFalse(target.IsPluginProcess(badProc, goodMainChromeFlags));
        }
示例#2
0
        public void DisposeTest()
        {
            PluginDebuggerGDB_Accessor target = new PluginDebuggerGDB_Accessor(dte_, properties_);

            string existingGDB = "DisposeTest_GDB";

            try
            {
                target.gdbProcess_ = TestUtilities.StartProcessForKilling(existingGDB, 20);
                string existingInitFileName = Path.GetTempFileName();
                target.gdbInitFileName_ = existingInitFileName;

                target.Dispose();

                // Check that the pre-existing gdb process was killed and its init file cleaned up.
                Assert.IsFalse(
                    TestUtilities.DoesProcessExist("python.exe", existingGDB),
                    "Failed to kill existing GDB process");
                Assert.IsFalse(
                    File.Exists(existingInitFileName),
                    "Failed to delete existing temp gdb init file");
            }
            finally
            {
                // Clean up file if not erased.
                if (!string.IsNullOrEmpty(target.gdbInitFileName_) && File.Exists(target.gdbInitFileName_))
                {
                    File.Delete(target.gdbInitFileName_);
                }

                // Kill the gdb process if not killed.
                if (target.gdbProcess_ != null && !target.gdbProcess_.HasExited)
                {
                    target.gdbProcess_.Kill();
                    target.gdbProcess_.Dispose();
                }
            }
        }
示例#3
0
        public void AttachNaClGDBTest()
        {
            PluginDebuggerGDB_Accessor target = new PluginDebuggerGDB_Accessor(dte_, properties_);

            string existingGDB = "AttachNaClGDBTest_existingGDB";

            try
            {
                target.gdbProcess_ = TestUtilities.StartProcessForKilling(existingGDB, 20);
                string existingInitFileName = Path.GetTempFileName();
                target.gdbInitFileName_ = existingInitFileName;

                // Visual studio won't allow adding a breakpoint unless it is associated with
                // an existing file and valid line number, so use BlankValidSolution.
                dte_.Solution.Open(naclSolution);
                string fileName     = "main.cpp";
                string functionName = "NaClProjectInstance::HandleMessage";
                int    lineNumber   = 39;
                dte_.Debugger.Breakpoints.Add(Function: functionName);
                dte_.Debugger.Breakpoints.Add(Line: lineNumber, File: fileName);

                target.Attach(null, new PluginDebuggerBase.PluginFoundEventArgs(0));

                Assert.IsTrue(File.Exists(target.gdbInitFileName_), "Init file not written");

                var gdbCommands = new List <string>(File.ReadAllLines(target.gdbInitFileName_));

                // Validate that the commands contain what we specified.
                // The syntax itself is not validated since this add-in is not responsible for
                // the syntax and it could change.
                Assert.IsTrue(
                    gdbCommands.Exists(s => s.Contains(fileName) && s.Contains(lineNumber.ToString())),
                    "Line breakpoint not properly set");
                Assert.IsTrue(
                    gdbCommands.Exists(s => s.Contains(functionName)),
                    "Function breakpoint not properly set");

                // Note fake assembly string should be double escaped when passed to gdb.
                Assert.IsTrue(
                    gdbCommands.Exists(s => s.Contains(functionName)),
                    @"fake\\Assembly\\String");

                // Check that the pre-existing gdb process was killed and its init file cleaned up.
                Assert.IsFalse(
                    TestUtilities.DoesProcessExist("python.exe", existingGDB),
                    "Failed to kill existing GDB process");
                Assert.IsFalse(
                    File.Exists(existingInitFileName),
                    "Failed to delete existing temp gdb init file");
            }
            finally
            {
                if (dte_.Debugger.Breakpoints != null)
                {
                    // Remove all breakpoints.
                    foreach (EnvDTE.Breakpoint bp in dte_.Debugger.Breakpoints)
                    {
                        bp.Delete();
                    }
                }

                // Clean up file if not erased.
                if (!string.IsNullOrEmpty(target.gdbInitFileName_) && File.Exists(target.gdbInitFileName_))
                {
                    File.Delete(target.gdbInitFileName_);
                }

                // Kill the gdb process if not killed.
                if (target.gdbProcess_ != null && !target.gdbProcess_.HasExited)
                {
                    target.gdbProcess_.Kill();
                    target.gdbProcess_.Dispose();
                }
            }
        }
    public void IsNaClPluginProcessTest()
    {
      PluginDebuggerGDB_Accessor target = new PluginDebuggerGDB_Accessor(dte_, properties_);

      ProcessInfo badProc = new ProcessInfo(
          1, 1, string.Empty, Strings.ChromeRendererFlag, Strings.NaClProcessName);
      ProcessInfo goodProc = new ProcessInfo(
          1, 1, string.Empty, Strings.NaClLoaderFlag, Strings.NaClProcessName);

      string goodMainChromeFlags = Strings.NaClDebugFlag;
      string badMainChromeFlags = string.Format(
          Strings.PepperProcessPluginFlagFormat, target.targetNexe_);

      Assert.IsTrue(target.IsPluginProcess(goodProc, goodMainChromeFlags));
      Assert.IsFalse(target.IsPluginProcess(goodProc, badMainChromeFlags));
      Assert.IsFalse(target.IsPluginProcess(badProc, goodMainChromeFlags));
    }
    public void DisposeTest()
    {
      PluginDebuggerGDB_Accessor target = new PluginDebuggerGDB_Accessor(dte_, properties_);

      string existingGDB = "DisposeTest_GDB";
      try
      {
        target.gdbProcess_ = TestUtilities.StartProcessForKilling(existingGDB, 20);
        string existingInitFileName = Path.GetTempFileName();
        target.gdbInitFileName_ = existingInitFileName;

        target.Dispose();

        // Check that the pre-existing gdb process was killed and its init file cleaned up.
        Assert.IsFalse(
            TestUtilities.DoesProcessExist("python.exe", existingGDB),
            "Failed to kill existing GDB process");
        Assert.IsFalse(
            File.Exists(existingInitFileName),
            "Failed to delete existing temp gdb init file");
      }
      finally
      {
        // Clean up file if not erased.
        if (!string.IsNullOrEmpty(target.gdbInitFileName_) && File.Exists(target.gdbInitFileName_))
        {
          File.Delete(target.gdbInitFileName_);
        }

        // Kill the gdb process if not killed.
        if (target.gdbProcess_ != null && !target.gdbProcess_.HasExited)
        {
          target.gdbProcess_.Kill();
          target.gdbProcess_.Dispose();
        }
      }
    }
    public void AttachNaClGDBTest()
    {
      PluginDebuggerGDB_Accessor target = new PluginDebuggerGDB_Accessor(dte_, properties_);

      string existingGDB = "AttachNaClGDBTest_existingGDB";
      try
      {
        target.gdbProcess_ = TestUtilities.StartProcessForKilling(existingGDB, 20);
        string existingInitFileName = Path.GetTempFileName();
        target.gdbInitFileName_ = existingInitFileName;

        // Visual studio won't allow adding a breakpoint unless it is associated with
        // an existing file and valid line number, so use BlankValidSolution.
        dte_.Solution.Open(naclSolution);
        string fileName = "main.cpp";
        string functionName = "NaClProjectInstance::HandleMessage";
        int lineNumber = 39;
        dte_.Debugger.Breakpoints.Add(Function: functionName);
        dte_.Debugger.Breakpoints.Add(Line: lineNumber, File: fileName);

        target.Attach(null, new PluginDebuggerBase.PluginFoundEventArgs(0));

        Assert.IsTrue(File.Exists(target.gdbInitFileName_), "Init file not written");

        var gdbCommands = new List<string>(File.ReadAllLines(target.gdbInitFileName_));

        // Validate that the commands contain what we specified.
        // The syntax itself is not validated since this add-in is not responsible for
        // the syntax and it could change.
        Assert.IsTrue(
            gdbCommands.Exists(s => s.Contains(fileName) && s.Contains(lineNumber.ToString())),
            "Line breakpoint not properly set");
        Assert.IsTrue(
            gdbCommands.Exists(s => s.Contains(functionName)),
            "Function breakpoint not properly set");

        // Note fake assembly string should be double escaped when passed to gdb.
        Assert.IsTrue(
          gdbCommands.Exists(s => s.Contains(functionName)),
          @"fake\\Assembly\\String");

        // Check that the pre-existing gdb process was killed and its init file cleaned up.
        Assert.IsFalse(
            TestUtilities.DoesProcessExist("python.exe", existingGDB),
            "Failed to kill existing GDB process");
        Assert.IsFalse(
            File.Exists(existingInitFileName),
            "Failed to delete existing temp gdb init file");
      }
      finally
      {
        if (dte_.Debugger.Breakpoints != null)
        {
          // Remove all breakpoints.
          foreach (EnvDTE.Breakpoint bp in dte_.Debugger.Breakpoints)
          {
            bp.Delete();
          }
        }

        // Clean up file if not erased.
        if (!string.IsNullOrEmpty(target.gdbInitFileName_) && File.Exists(target.gdbInitFileName_))
        {
          File.Delete(target.gdbInitFileName_);
        }

        // Kill the gdb process if not killed.
        if (target.gdbProcess_ != null && !target.gdbProcess_.HasExited)
        {
          target.gdbProcess_.Kill();
          target.gdbProcess_.Dispose();
        }
      }
    }