コード例 #1
0
    public static void SetUpTestEnvironment()
    {
        if (testProcess == null || testProcessInfo == null || debugger == null || testProcess.HasExited)
        {
            Console.WriteLine("Starting the unit test helper from " + testProgram + " ...");
            testProcess = Process.Start(testProgram, "");

            //wait for program to finish initializing
            while (true)
            {
                try
                {
                    if (File.Exists(testFile))
                    {
                        debugger        = new CorDebugger(CorDebugger.GetDefaultDebuggerVersion());
                        testProcessInfo = new ProcessInfo(testProcess, debugger);
                        File.Delete(testFile);
                        break;
                    }
                }
                catch (Exception e)
                {
                    Console.Error.WriteLine(e.ToString());
                    throw;
                }
            }
        }
    }
コード例 #2
0
        //////////////////////////////////////////////////////////////////////////////////
        //
        // Controlling Commands
        //
        //////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// creates a new debugged process.
        /// </summary>
        /// <param name="commandLine">The command to run.</param>
        /// <param name="commandArguments">The arguments for the command.</param>
        /// <param name="debugMode">The debug mode to run with.</param>
        /// <param name="deeVersion">The version of debugging interfaces that should be used for
        ///   debugging of the started program. If this value is null, the default (latest) version
        ///   of interface is used.
        /// </param>
        /// <returns>The resulting MDbgProcess.</returns>
        public MDbgProcess CreateProcess(string commandLine, string commandArguments,
                                         DebugModeFlag debugMode, string deeVersion)
        {
            CorDebugger debugger;

            if (deeVersion == null)
            {
                debugger = new CorDebugger(CorDebugger.GetDefaultDebuggerVersion());
            }
            else
            {
                debugger = new CorDebugger(deeVersion);
            }
            MDbgProcess p = m_processMgr.CreateLocalProcess(debugger);

            p.DebugMode = debugMode;
            p.CreateProcess(commandLine, commandArguments);
            return(p);
        }
コード例 #3
0
ファイル: Mdbg.cs プロジェクト: VE-2016/VE-2016
        protected virtual void PrintStartupLogo()
        {
            string myVersion = GetBinaryVersion();

            IO.WriteOutput(MDbgOutputConstants.StdOutput,
                           "MDbg (Managed debugger) v" + myVersion + " started.\n");
            IO.WriteOutput(MDbgOutputConstants.StdOutput,
                           "Copyright (C) Microsoft Corporation. All rights reserved.\n");
            IO.WriteOutput(MDbgOutputConstants.StdOutput,
                           "\nFor information about commands type \"help\";\nto exit program type \"quit\".\n\n");

            // Check for and output any debugging warnings
            try
            {
                (new CorDebugger(CorDebugger.GetDefaultDebuggerVersion())).CanLaunchOrAttach(0, false);
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                IO.WriteOutput(MDbgOutputConstants.StdOutput, "WARNING: " + e.Message + "\n\n");
            }
        }
コード例 #4
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();
        }