Start (false, args);
}
+ Diag.ProcessStartInfo CreateStartInfo (string[] args) {
+ var pi = new Diag.ProcessStartInfo ();
+
+ if (runtime != null) {
+ pi.FileName = runtime;
+ } else if (Path.DirectorySeparatorChar == '\\') {
+ string processExe = Diag.Process.GetCurrentProcess ().MainModule.FileName;
+ if (processExe != null) {
+ string fileName = Path.GetFileName (processExe);
+ if (fileName.StartsWith ("mono") && fileName.EndsWith (".exe"))
+ pi.FileName = processExe;
+ }
+ }
+ if (string.IsNullOrEmpty (pi.FileName))
+ pi.FileName = "mono";
+ pi.Arguments = String.Join (" ", args);
+ return pi;
+ }
+
void Start (bool forceExit, params string[] args) {
this.forceExit = forceExit;
if (!listening) {
- var pi = new Diag.ProcessStartInfo ();
-
- if (runtime != null) {
- pi.FileName = runtime;
- } else if (Path.DirectorySeparatorChar == '\\') {
- string processExe = Diag.Process.GetCurrentProcess ().MainModule.FileName;
- if (processExe != null) {
- string fileName = Path.GetFileName (processExe);
- if (fileName.StartsWith ("mono") && fileName.EndsWith (".exe"))
- pi.FileName = processExe;
- }
- }
- if (string.IsNullOrEmpty (pi.FileName))
- pi.FileName = "mono";
- pi.Arguments = String.Join (" ", args);
+ var pi = CreateStartInfo (args);
vm = VirtualMachineManager.Launch (pi, new LaunchOptions { AgentArgs = agent_args });
} else {
var ep = new IPEndPoint (IPAddress.Any, 10000);
m = s.Type.GetMethod ("ToString");
v = s.InvokeMethod (e.Thread, m, null);
+ // pass nullable as argument
+ m = t.GetMethod ("invoke_pass_nullable");
+ v = this_obj.InvokeMethod (e.Thread, m, new Value [] { s });
+ AssertValue (42, v);
+
// return nullable null
m = t.GetMethod ("invoke_return_nullable_null");
v = this_obj.InvokeMethod (e.Thread, m, null);
m = s.Type.GetMethod ("ToString");
v = s.InvokeMethod (e.Thread, m, null);
+ // pass nullable null as argument
+ m = t.GetMethod ("invoke_pass_nullable_null");
+ v = this_obj.InvokeMethod (e.Thread, m, new Value [] { s });
+ AssertValue (2, v);
+
+ return;
+
+ // string constructor
+ var stringType = vm.RootDomain.Corlib.GetType ("System.String");
+ var stringConstructor = stringType.GetMethods ().Single (c=>
+ c.Name == ".ctor" &&
+ c.GetParameters ().Length == 2 &&
+ c.GetParameters ()[0].ParameterType.Name == "Char" &&
+ c.GetParameters ()[1].ParameterType.Name == "Int32");
+ var str = stringType.NewInstance (e.Thread, stringConstructor, new Value [] { vm.CreateValue ('a'), vm.CreateValue (3)});
+
+ AssertValue("aaa", str);
+
// pass primitive
m = t.GetMethod ("invoke_pass_primitive");
Value[] args = new Value [] {
frames = thread.GetFrames ();
Assert.AreEqual (8, frames.Length, "#7");
- Assert.AreEqual ("WaitOne_internal", frames [0].Method.Name, "#8.0");
+ Assert.AreEqual ("Wait_internal", frames [0].Method.Name, "#8.0");
Assert.AreEqual ("WaitOneNative", frames [1].Method.Name, "#8.1");
Assert.AreEqual ("InternalWaitOne", frames [2].Method.Name, "#8.2");
Assert.AreEqual ("WaitOne", frames [3].Method.Name, "#8.3");
vm.SetBreakpoint (cctor, 0);
vm.Resume ();
- var e = vm.GetNextEvent ();
+ var e = GetNextEvent ();
Assert.IsTrue (e is BreakpointEvent);
var req = create_step (e);
e = step_out (); // leave threadpool_bp
e = step_out (); // leave threadpool_io
}
+
+ [Test]
+ // Uses a fixed port
+ [Category("NotWorking")]
+ public void Attach () {
+ vm.Exit (0);
+
+ // Launch the app using server=y,suspend=n
+ var pi = CreateStartInfo (new string[] { "--debugger-agent=transport=dt_socket,address=127.0.0.1:10000,server=y,suspend=n", "dtest-app.exe", "attach" });
+ var process = Diag.Process.Start (pi);
+
+ // Wait for the app to reach the Sleep () in attach ().
+ Thread.Sleep (1000);
+ var ep = new IPEndPoint (IPAddress.Loopback, 10000);
+ vm = VirtualMachineManager.Connect (ep);
+
+ var load_req = vm.CreateAssemblyLoadRequest ();
+ load_req.Enable ();
+ vm.EnableEvents (EventType.TypeLoad);
+
+ Event vmstart = GetNextEvent ();
+ Assert.AreEqual (EventType.VMStart, vmstart.EventType);
+
+ // Get collected events
+ bool assembly_load_found = false;
+ bool type_load_found = false;
+ while (true) {
+ Event e = GetNextEvent ();
+
+ // AssemblyLoad
+ if (e is AssemblyLoadEvent) {
+ var assemblyload = e as AssemblyLoadEvent;
+
+ var amirror = assemblyload.Assembly;
+
+ if (amirror.GetName ().Name == "System.Transactions") {
+ assembly_load_found = true;
+ Assert.AreEqual ("domain", amirror.Domain.FriendlyName);
+ }
+
+ if (amirror.GetName ().Name == "dtest-app")
+ // Set a bp so we can break the event loop
+ vm.SetBreakpoint (amirror.EntryPoint.DeclaringType.GetMethod ("attach_break"), 0);
+ }
+ if (e is TypeLoadEvent) {
+ var typeload = e as TypeLoadEvent;
+
+ if (typeload.Type.Name == "GCSettings") {
+ type_load_found = true;
+ Assert.AreEqual ("domain", typeload.Type.Assembly.Domain.FriendlyName);
+ }
+ }
+
+ if (e is BreakpointEvent)
+ break;
+ }
+ Assert.IsTrue (assembly_load_found);
+ Assert.IsTrue (type_load_found);
+
+ vm.Exit (0);
+ vm = null;
+ }
+
}
}