/// <summary>Creates an empty process object. /// This object can be used to start a debugging session by calling /// CreateProcess or Attach method on it. /// </summary> /// <param name="engine">Root engine object that manages this process.</param> /// <param name="debugger">CorDebugger object that will be used to do an actual /// debugging</param> public MDbgProcess(MDbgEngine engine, CorDebug.CorDebugger debugger) { Debug.Assert(engine != null && debugger != null); if (engine == null) throw new ArgumentException("Value cannot be null.", "engine"); if (debugger == null) throw new ArgumentException("Value cannot be null.", "debugger"); m_engine = engine; m_threadMgr = new MDbgThreadCollection(this); m_appDomainMgr = new MDbgAppDomainCollection(this); m_moduleMgr = new MDbgModuleCollection(this); m_breakpointMgr = new MDbgBreakpointCollection(this); m_debuggerVarMgr = new MDbgDebuggerVarCollection(this); m_corDebugger = debugger; // we'll register as last code, so that other fields are already registered. m_number = engine.Processes.RegisterProcess(this); }
////////////////////////////////////////////////////////////////////////////////// // // Customization methods (to be overriden in aditional skins). // ////////////////////////////////////////////////////////////////////////////////// protected virtual void Init(string[] commandLineArguments) { string[] initialCommands = null; // process startup commands if (commandLineArguments.Length != 0) { var startupCommands = new ArrayList(); if (commandLineArguments[0].Length > 1 && commandLineArguments[0][0] == '!') { // ! commands on command line int i = 0; while (i < commandLineArguments.Length) { var sb = new StringBuilder(); Debug.Assert(commandLineArguments[i][0] == '!'); sb.Append(commandLineArguments[i].Substring(1)); ++i; while (i < commandLineArguments.Length && !(commandLineArguments[i].Length > 1 && commandLineArguments[i][0] == '!')) { sb.Append(' '); sb.Append(commandLineArguments[i]); ++i; } startupCommands.Add(sb.ToString()); } } else { // it is name of executable on the command line var sb = new StringBuilder("run"); for (int i = 0; i < commandLineArguments.Length; i++) { sb.Append(' '); string arg = commandLineArguments[i]; if (arg.IndexOf(' ') != -1) { // argument contains spaces, need to quote it sb.Append('\"').Append(arg).Append('\"'); } else { sb.Append(arg); } } startupCommands.Add(sb.ToString()); } initialCommands = (string[]) startupCommands.ToArray(typeof (string)); } IO = new MDbgIO(this, initialCommands); CommandBase.Shell = this; m_debugger = new MDbgEngine(); MdbgCommands.Initialize(); OnCommandExecuted += MdbgCommands.WhenHandler; LoadPlatformDependentExtension(); ProcessAutoExec(); }
internal MDbgProcessCollection(MDbgEngine engine) { m_engine = engine; }