1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203
|
//
// SoftDebuggerStartInfo.cs
//
// Author:
// Michael Hutchinson <mhutchinson@novell.com>
//
// Copyright (c) 2010 Novell, Inc. (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
using System;
using Mono.Debugging.Client;
using System.Collections.Generic;
using System.Reflection;
using System.IO;
using System.Net;
using Mono.Debugger.Soft;
namespace Mono.Debugging.Soft
{
public class SoftDebuggerStartInfo : DebuggerStartInfo
{
public SoftDebuggerStartInfo (string monoRuntimePrefix, Dictionary<string,string> monoRuntimeEnvironmentVariables)
: this (new SoftDebuggerLaunchArgs (monoRuntimePrefix, monoRuntimeEnvironmentVariables))
{
}
public SoftDebuggerStartInfo (SoftDebuggerStartArgs startArgs)
{
if (startArgs == null)
throw new ArgumentNullException ("startArgs");
this.StartArgs = startArgs;
}
/// <summary>
/// Names of assemblies that are user code.
/// </summary>
public List<AssemblyName> UserAssemblyNames { get; set; }
/// <summary>
/// A mapping of AssemblyNames to their paths.
/// </summary>
public Dictionary<string, string> AssemblyPathMap { get; set; }
/// <summary>
/// The session will output this to the debug log as soon as it starts. It can be used to log warnings from
/// creating the SoftDebuggerStartInfo
/// </summary>
public string LogMessage { get; set; }
/// <summary>
/// Args for starting the debugger connection.
/// </summary>
public SoftDebuggerStartArgs StartArgs { get; set; }
}
public interface ISoftDebuggerConnectionProvider
{
IAsyncResult BeginConnect (DebuggerStartInfo dsi, AsyncCallback callback);
void EndConnect (IAsyncResult result, out VirtualMachine vm, out string appName);
void CancelConnect (IAsyncResult result);
bool ShouldRetryConnection (Exception ex);
}
public abstract class SoftDebuggerStartArgs
{
public SoftDebuggerStartArgs ()
{
MaxConnectionAttempts = 1;
TimeBetweenConnectionAttempts = 500;
}
public abstract ISoftDebuggerConnectionProvider ConnectionProvider { get; }
/// <summary>
/// Maximum number of connection attempts. Zero or less means infinite attempts. Default is 1.
/// </summary>
public int MaxConnectionAttempts { get; set; }
/// <summary>
/// The time between connection attempts, in milliseconds. Default is 500.
/// </summary>
public int TimeBetweenConnectionAttempts { get; set; }
}
public abstract class SoftDebuggerRemoteArgs : SoftDebuggerStartArgs
{
public SoftDebuggerRemoteArgs (string appName, IPAddress address, int debugPort, int outputPort)
{
if (address == null)
throw new ArgumentNullException ("address");
if (debugPort < 0)
throw new ArgumentException ("Debug port cannot be less than zero", "debugPort");
this.AppName = appName;
this.Address = address;
this.DebugPort = debugPort;
this.OutputPort = outputPort;
}
/// <summary>
/// The IP address for the connection.
/// </summary>
public IPAddress Address { get; private set; }
/// <summary>
/// Port for the debugger connection. Zero means random port.
/// </summary>
public int DebugPort { get; private set; }
/// <summary>
/// Port for the console connection. Zero means random port, less than zero means that output is not redirected.
/// </summary>
public int OutputPort { get; private set; }
/// <summary>
/// Application name that will be shown in the debugger.
/// </summary>
public string AppName { get; private set; }
public bool RedirectOutput { get { return OutputPort >= 0; } }
}
/// <summary>
/// Args for the debugger to listen for an incoming connection from a debuggee.
/// </summary>
public sealed class SoftDebuggerListenArgs : SoftDebuggerRemoteArgs
{
public SoftDebuggerListenArgs (string appName, IPAddress address, int debugPort)
: this (appName, address, debugPort, -1) {}
public SoftDebuggerListenArgs (string appName, IPAddress address, int debugPort, int outputPort)
: base (appName, address, debugPort, outputPort)
{
}
public override ISoftDebuggerConnectionProvider ConnectionProvider { get { return null; } }
}
/// <summary>
/// Args for the debugger to connect to target that is listening.
/// </summary>
public sealed class SoftDebuggerConnectArgs : SoftDebuggerRemoteArgs
{
public SoftDebuggerConnectArgs (string appName, IPAddress address, int debugPort)
: this (appName, address, debugPort, -1) {}
public SoftDebuggerConnectArgs (string appName, IPAddress address, int debugPort, int outputPort)
: base (appName, address, debugPort, outputPort)
{
if (debugPort == 0)
throw new ArgumentException ("Debug port cannot be zero when connecting", "debugPort");
if (outputPort == 0)
throw new ArgumentException ("Output port cannot be zero when connecting", "outputPort");
}
public override ISoftDebuggerConnectionProvider ConnectionProvider { get { return null; } }
}
/// <summary>
/// Options for the debugger to start a process directly.
/// </summary>
public sealed class SoftDebuggerLaunchArgs : SoftDebuggerStartArgs
{
public SoftDebuggerLaunchArgs (string monoRuntimePrefix, Dictionary<string,string> monoRuntimeEnvironmentVariables)
{
this.MonoRuntimePrefix = monoRuntimePrefix;
this.MonoRuntimeEnvironmentVariables = monoRuntimeEnvironmentVariables;
}
/// <summary>
/// Prefix into which the target Mono runtime is installed.
/// </summary>
public string MonoRuntimePrefix { get; private set; }
/// <summary>
/// Environment variables for the Mono runtime.
/// </summary>
public Dictionary<string,string> MonoRuntimeEnvironmentVariables { get; private set; }
/// <summary>
/// Launcher for the external console. May be null if the app does not run on an external console.
/// </summary>
public Mono.Debugger.Soft.LaunchOptions.TargetProcessLauncher ExternalConsoleLauncher { get; set; }
public override ISoftDebuggerConnectionProvider ConnectionProvider { get { return null; } }
}
}
|