public int Run()
{
if (has_target)
throw new TargetException (TargetError.AlreadyHaveTarget);
has_target = true;
IntPtr error;
string[] args = new string[start.CommandLineArguments.Length + 1];
Array.Copy(start.CommandLineArguments, args, start.CommandLineArguments.Length);
string[] env = new string[start.Environment.Length + 1];
Array.Copy(start.Environment, env, start.Environment.Length);
TargetError result = mono_debugger_server_spawn (
server_handle, start.WorkingDirectory, args,
env, start.RedirectOutput, out child_pid, out io_data, out error);
if (result != TargetError.None) {
string message = Marshal.PtrToStringAuto (error);
g_free (error);
throw new TargetException (
TargetError.CannotStartTarget, message);
}
if (start.RedirectOutput) {
ST.Thread io_thread = new ST.Thread (new ST.ThreadStart (io_thread_main));
io_thread.IsBackground = true;
io_thread.Start ();
}
initialized = true;
check_error (mono_debugger_server_initialize_process (server_handle));
SetupInferior ();
change_target_state (TargetState.Stopped, 0);
return child_pid;
}