public void SetStarted(ValueReference startInfo, int id, EvaluationContext ctx) { // This is called after the process is launched. // Store the process ID. It will be used by TargetProcessLauncher to get a reference to the process. processId = id; // Assign the original exe and arguments to the start info object startInfo.GetChild("Arguments", ctx.Options).SetRawValue(arguments, ctx.Options); startInfo.GetChild("FileName", ctx.Options).SetRawValue(exe, ctx.Options); // Signal TargetProcessLauncher that the process has started and the process ID is available. startedEvent.Set(); }
public bool CreateSession(ValueReference startInfo, EvaluationOptions ops) { // Get the exe and arguments from the start info and store them this.arguments = (string)startInfo.GetChild("Arguments", ops).GetRawValue(ops); this.exe = (string)startInfo.GetChild("FileName", ops).GetRawValue(ops); // Create the new session and custom start arguments. // The actual arguments don't matter much since we'll use a custom launcher for the process. newSession = new SoftDebuggerSession(); var startArgs = new SoftDebuggerLaunchArgs(null, new Dictionary <string, string> ()); var dsi = new SoftDebuggerStartInfo(startArgs); // A mono process can be launched either by providing "mono" as launcher and then the assembly name as argument, // or by providing the assembly name directly as file to launch. bool explicitMonoLaunch = IsMonoLauncher(exe); if (explicitMonoLaunch) { // Try to get the assembly name from the command line. The debug session uses what's provided // in the Command property as process name. Without this, all mono processes launched in this // way would show up as "mono" in the IDE. var cmd = GetExeName(arguments); if (cmd != null) { dsi.Command = cmd; } // The new session will add additional runtime arguments to the start info. // We'll use the _ARG_START_ marker to know where those arguments end. dsi.RuntimeArguments = ArgStartMarker; } else { dsi.Command = exe; dsi.Arguments = arguments; } startArgs.CustomProcessLauncher = TargetProcessLauncher; // Start the session. This will run asynchronously, and will at some point call the custom launcher specified just above. newSession.Run(dsi, softDebuggerSession.Options); // Wait for the session to ask for the process to be launched launchingEvent.WaitOne(); if (shutdown) { return(false); } // The custom launcher will store the debugger agent configuration args in debuggerStartInfo. // No the original startInfo object is patched to include the debugger agent args if (explicitMonoLaunch) { // Prepend the debugger args to the original arguments int i = debuggerStartInfo.Arguments.IndexOf(ArgStartMarker); var debuggerArgs = debuggerStartInfo.Arguments.Substring(0, i); startInfo.GetChild("Arguments", ops).SetRawValue(debuggerArgs + " " + arguments, ops); } else { startInfo.GetChild("Arguments", ops).SetRawValue(debuggerStartInfo.Arguments, ops); startInfo.GetChild("FileName", ops).SetRawValue(debuggerStartInfo.FileName, ops); } return(true); }