Esempio n. 1
0
 protected override void OnContinue( )
 {
     ClearEvalStatus();
     ClearHandles();
     process.SetAllThreadsDebugState(CorDebugThreadState.THREAD_RUN, null);
     process.Continue(false);
 }
Esempio n. 2
0
 /// <summary>
 /// Continues the process and returns a waitHandle object which is signaled if the process
 /// is currently attached to a debugger
 /// </summary>
 /// <returns></returns>
 private WaitHandle Go()
 {
     try
     {
         debuggeeProcess.Continue(false);
     }
     catch (COMException)
     {
     }
     return(attachedCompletedProcessEvent);
 }
Esempio n. 3
0
        static void ProcessCommand(CorProcess process)
        {
            Task.Run(() =>
            {
                while (true)
                {
                    Console.Write("> ");
                    String command = Console.ReadLine();

                    if (command.StartsWith("set-break", StringComparison.Ordinal))
                    {
                        // setting breakpoint
                        command = command.Remove(0, "set-break".Length).Trim();

                        // try module!type.method location (simple regex used)
                        Match match = methodBreakpointRegex.Match(command);
                        if (match.Groups["method"].Length > 0)
                        {
                            Console.Write("Setting method breakpoint... ");

                            CorFunction func = process.ResolveFunctionName(match.Groups["module"].Value, match.Groups["class"].Value,
                                                                           match.Groups["method"].Value);
                            func.CreateBreakpoint().Activate(true);

                            Console.WriteLine("done.");
                            continue;
                        }
                        // try file code:line location
                        match = codeBreakpointRegex.Match(command);
                        if (match.Groups["filepath"].Length > 0)
                        {
                            Console.Write("Setting code breakpoint...");

                            int offset;
                            CorCode code = process.ResolveCodeLocation(match.Groups["filepath"].Value,
                                                                       Int32.Parse(match.Groups["linenum"].Value),
                                                                       out offset);
                            code.CreateBreakpoint(offset).Activate(true);

                            Console.WriteLine("done.");
                            continue;
                        }
                    }
                    else if (command.StartsWith("go", StringComparison.Ordinal))
                    {
                        process.Continue(false);
                        ProcessCommand(process);
                        break;
                    }
                }
            });
        }
Esempio n. 4
0
        protected override void OnRun(DebuggerStartInfo startInfo)
        {
            // Create the debugger

            string dversion = CorDebugger.GetDebuggerVersionFromFile(startInfo.Command);

            dbg = new CorDebugger(dversion);

            Dictionary <string, string> env = new Dictionary <string, string> ();

            foreach (DictionaryEntry de in Environment.GetEnvironmentVariables())
            {
                env[(string)de.Key] = (string)de.Value;
            }

            foreach (KeyValuePair <string, string> var in startInfo.EnvironmentVariables)
            {
                env[var.Key] = var.Value;
            }

            // The second parameter of CreateProcess is the command line, and it includes the application being launched
            string cmdLine = "\"" + startInfo.Command + "\" " + startInfo.Arguments;

            process   = dbg.CreateProcess(startInfo.Command, cmdLine, startInfo.WorkingDirectory, env);
            processId = process.Id;

            process.OnCreateProcess       += new CorProcessEventHandler(OnCreateProcess);
            process.OnCreateAppDomain     += new CorAppDomainEventHandler(OnCreateAppDomain);
            process.OnAssemblyLoad        += new CorAssemblyEventHandler(OnAssemblyLoad);
            process.OnAssemblyUnload      += new CorAssemblyEventHandler(OnAssemblyUnload);
            process.OnCreateThread        += new CorThreadEventHandler(OnCreateThread);
            process.OnThreadExit          += new CorThreadEventHandler(OnThreadExit);
            process.OnModuleLoad          += new CorModuleEventHandler(OnModuleLoad);
            process.OnModuleUnload        += new CorModuleEventHandler(OnModuleUnload);
            process.OnProcessExit         += new CorProcessEventHandler(OnProcessExit);
            process.OnUpdateModuleSymbols += new UpdateModuleSymbolsEventHandler(OnUpdateModuleSymbols);
            process.OnDebuggerError       += new DebuggerErrorEventHandler(OnDebuggerError);
            process.OnBreakpoint          += new BreakpointEventHandler(OnBreakpoint);
            process.OnStepComplete        += new StepCompleteEventHandler(OnStepComplete);
            process.OnBreak         += new CorThreadEventHandler(OnBreak);
            process.OnNameChange    += new CorThreadEventHandler(OnNameChange);
            process.OnEvalComplete  += new EvalEventHandler(OnEvalComplete);
            process.OnEvalException += new EvalEventHandler(OnEvalException);

            process.Continue(false);

            OnStarted();
        }
Esempio n. 5
0
        protected override void OnRun(DebuggerStartInfo startInfo)
        {
            // Create the debugger

            string dversion;

            try {
                dversion = CorDebugger.GetDebuggerVersionFromFile(startInfo.Command);
            }
            catch {
                dversion = CorDebugger.GetDefaultDebuggerVersion();
            }
            dbg = new CorDebugger(dversion);

            Dictionary <string, string> env = new Dictionary <string, string> ();

            foreach (DictionaryEntry de in Environment.GetEnvironmentVariables())
            {
                env[(string)de.Key] = (string)de.Value;
            }

            foreach (KeyValuePair <string, string> var in startInfo.EnvironmentVariables)
            {
                env[var.Key] = var.Value;
            }

            // The second parameter of CreateProcess is the command line, and it includes the application being launched
            string cmdLine = "\"" + startInfo.Command + "\" " + startInfo.Arguments;

            int flags = 0;

            if (!startInfo.UseExternalConsole)
            {
                flags  = 0x08000000;                /* CREATE_NO_WINDOW*/
                flags |= CorDebugger.CREATE_REDIRECT_STD;
            }

            process   = dbg.CreateProcess(startInfo.Command, cmdLine, startInfo.WorkingDirectory, env, flags);
            processId = process.Id;

            process.OnCreateProcess       += new CorProcessEventHandler(OnCreateProcess);
            process.OnCreateAppDomain     += new CorAppDomainEventHandler(OnCreateAppDomain);
            process.OnAssemblyLoad        += new CorAssemblyEventHandler(OnAssemblyLoad);
            process.OnAssemblyUnload      += new CorAssemblyEventHandler(OnAssemblyUnload);
            process.OnCreateThread        += new CorThreadEventHandler(OnCreateThread);
            process.OnThreadExit          += new CorThreadEventHandler(OnThreadExit);
            process.OnModuleLoad          += new CorModuleEventHandler(OnModuleLoad);
            process.OnModuleUnload        += new CorModuleEventHandler(OnModuleUnload);
            process.OnProcessExit         += new CorProcessEventHandler(OnProcessExit);
            process.OnUpdateModuleSymbols += new UpdateModuleSymbolsEventHandler(OnUpdateModuleSymbols);
            process.OnDebuggerError       += new DebuggerErrorEventHandler(OnDebuggerError);
            process.OnBreakpoint          += new BreakpointEventHandler(OnBreakpoint);
            process.OnStepComplete        += new StepCompleteEventHandler(OnStepComplete);
            process.OnBreak         += new CorThreadEventHandler(OnBreak);
            process.OnNameChange    += new CorThreadEventHandler(OnNameChange);
            process.OnEvalComplete  += new EvalEventHandler(OnEvalComplete);
            process.OnEvalException += new EvalEventHandler(OnEvalException);
            process.OnLogMessage    += new LogMessageEventHandler(OnLogMessage);
            process.OnStdOutput     += new CorTargetOutputEventHandler(OnStdOutput);
            process.OnException2    += new CorException2EventHandler(OnException2);

            process.Continue(false);

            OnStarted();
        }