Beispiel #1
0
 private static void StartDebugging()
 {
     if (Environment.Is64BitProcess)
     {
         var ipdm64 = (Native.IProcessDebugManager64) new Native.ProcessDebugManager();
         Native.IDebugApplication64 ida64;
         ipdm64.GetDefaultApplication(out ida64);
         JavaScriptContext.StartDebugging(ida64);
     }
     else
     {
         var ipdm32 = (Native.IProcessDebugManager32) new Native.ProcessDebugManager();
         Native.IDebugApplication32 ida32;
         ipdm32.GetDefaultApplication(out ida32);
         JavaScriptContext.StartDebugging(ida32);
     }
 }
        private void StartDebuggingIfDebuggingIsEnabled()
        {
            if (_debuggerVsPid != -1)
            {
                if (Environment.Is64BitProcess)
                {
                    var ipdm64 = (Native.IProcessDebugManager64) new Native.ProcessDebugManager();
                    Native.IDebugApplication64 ida64;
                    ipdm64.GetDefaultApplication(out ida64);
                    JavaScriptContext.StartDebugging(ida64);
                }
                else
                {
                    var ipdm32 = (Native.IProcessDebugManager32) new Native.ProcessDebugManager();
                    Native.IDebugApplication32 ida32;
                    ipdm32.GetDefaultApplication(out ida32);
                    JavaScriptContext.StartDebugging(ida32);
                }

                if (!Process.GetProcesses().Any(p => p.Id == _debuggerVsPid))
                {
                    throw new Exception("Debugger process does not exist!");
                }

                var dte = Debugger.GetDTE(_debuggerVsPid);
                if (dte == null)
                {
                    throw new Exception("Could not attach to process");
                }

                var debugger = dte.Debugger as Debugger2;
                foreach (Process2 process in debugger.LocalProcesses)
                {
                    if (process.ProcessID == Process.GetCurrentProcess().Id&& !process.IsBeingDebugged)
                    {
                        Transport transport = debugger.Transports.Item("Default");
                        var       script    = transport.Engines.Item("Script");
                        process.Attach2(script);
                        Console.WriteLine("Debugger {0} attached.. Set breakpoints and Press any key to continue", _debuggerVsPid);
                        Console.ReadKey();
                    }
                }
            }
        }
 private void EvaluateScript(string script, string sourceUrl)
 {
     try
     {
         _context = JavaScriptSourceContext.Increment(_context);
         if (System.Diagnostics.Debugger.IsAttached)
         {
             JavaScriptContext.StartDebugging();
         }
         JavaScriptContext.RunScript(script, _context, sourceUrl);
     }
     catch (JavaScriptScriptException ex)
     {
         var jsonError  = JavaScriptValueToJTokenConverter.Convert(ex.Error);
         var message    = jsonError.Value <string>("message");
         var stackTrace = jsonError.Value <string>("stack");
         throw new Modules.Core.JavaScriptException(message ?? ex.Message, stackTrace, ex);
     }
 }
Beispiel #4
0
 private static void StartDebugging()
 {
     JavaScriptContext.StartDebugging();
 }