Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
//
// AssemblyInfo.cs
//
// Author:
// Andreas Nahr (ClassDevelopment@A-SoftTech.com)
//
// (C) 2003 Ximian, Inc. http://www.ximian.com
// (C) 2004 Novell (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 System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyVersion (Consts.FxVersion)]
/* TODO COMPLETE INFORMATION
[assembly: AssemblyTitle ("")]
[assembly: AssemblyDescription ("")]
[assembly: CLSCompliant (true)]
[assembly: AssemblyFileVersion ("0.0.0.1")]
[assembly: ComVisible (false)]
*/
[assembly: AssemblyDelaySign (true)]
[assembly: AssemblyKeyFile ("../mono.pub")]

View File

@@ -0,0 +1,4 @@
2008-09-24 Zoltan Varga <vargaz@gmail.com>
* AssemblyInfo.cs ChangeLog: New files.

View File

@@ -0,0 +1,4 @@
2008-09-24 Zoltan Varga <vargaz@gmail.com>
* New assembly, currently contains the managed code to discover
mono processes and load managed agents into them.

View File

@@ -0,0 +1,10 @@
thisdir = class/Mono.Management
SUBDIRS =
include ../../build/rules.make
LIBRARY = Mono.Management.dll
LIB_MCS_FLAGS = /r:$(corlib) /r:System.dll /r:Mono.Posix.dll
NO_TEST = yes
include ../../build/library.make

View File

@@ -0,0 +1,8 @@
2008-09-27 Zoltan Varga <vargaz@gmail.com>
* VirtualMachine.cs (Attach): Delete the attach file in a finalizer.
2008-09-24 Zoltan Varga <vargaz@gmail.com>
* VirtualMachine.cs: New file.

View File

@@ -0,0 +1,149 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
using System.IO;
using System.Threading;
using System.Net;
using System.Net.Sockets;
using Mono.Unix;
using Mono.Unix.Native;
namespace Mono.Attach
{
/*
* Represents a running mono virtual machine.
*/
public class VirtualMachine {
long pid;
public VirtualMachine (long pid) {
// FIXME: Check for unix
this.pid = pid;
}
public long Pid {
get {
return pid;
}
}
public bool IsCurrent {
get {
return pid == Syscall.getpid ();
}
}
public string[] GetCommandLine () {
return File.OpenText ("/proc/" + pid + "/cmdline").ReadToEnd ().Split ('\0');
}
public string GetWorkingDirectory () {
return UnixPath.ReadLink ("/proc/" + pid + "/cwd");
}
/*
* Return the list of running mono vms owned by the current user. The
* result includes the current vm too.
*/
public static List<VirtualMachine> GetVirtualMachines () {
PerformanceCounterCategory p = new PerformanceCounterCategory (".NET CLR JIT");
string[] machines = p.GetInstanceNames ();
var res = new List<VirtualMachine> ();
foreach (string s in machines) {
// The names are in the form 'pid/name'
int pos = s.IndexOf ('/');
if (pos != -1)
res.Add (new VirtualMachine (Int32.Parse (s.Substring (0, pos))));
}
return res;
}
/*
* Loads the specific agent assembly into this vm.
*/
public void Attach (string agent, string args) {
string user = UnixUserInfo.GetRealUser ().UserName;
// Check whenever the attach socket exists
string socket_file = "/tmp/mono-" + user + "/.mono-" + pid;
if (!File.Exists (socket_file)) {
string trigger_file = "/tmp/.mono_attach_pid" + pid;
FileStream trigger = null;
try {
trigger = File.Create (trigger_file);
trigger.Close ();
// Ask the vm to start the attach mechanism
Syscall.kill ((int)pid, Signum.SIGQUIT);
// Wait for the socket file to materialize
int i;
for (i = 0; i < 10; ++i) {
if (File.Exists (socket_file))
break;
Thread.Sleep (100);
}
if (i == 10)
throw new Exception (String.Format ("Runtime failed to create attach socket '{0}'.", socket_file));
} finally {
File.Delete (trigger_file);
}
}
/*
* We communicate with the agent inside the runtime using a simlified
* version of the .net remoting protocol.
*/
string path = "/tmp/mono-" + user + "/.mono-" + pid;
UnixClient client = new UnixClient (path);
NetworkStream stream = client.GetStream ();
// Compose payload
MemoryStream ms = new MemoryStream ();
BinaryWriter writer = new BinaryWriter (ms);
write_string (writer, "attach");
write_string (writer, agent);
write_string (writer, args);
// Write header
byte[] magic = new byte [] { (byte)'M', (byte)'O', (byte)'N', (byte)'O', 1, 0 };
stream.Write (magic, 0, magic.Length);
// Write payload length
new BinaryWriter (stream).Write ((int)ms.Length);
// Write payload
stream.Write (ms.GetBuffer (), 0, (int)ms.Length);
}
enum PrimitiveType : byte {
PRIM_TYPE_NULL = 17,
PRIM_TYPE_STRING = 18
};
void write_string (BinaryWriter writer, string s) {
if (s == null)
writer.Write ((sbyte)PrimitiveType.PRIM_TYPE_NULL);
else {
writer.Write ((sbyte)PrimitiveType.PRIM_TYPE_STRING);
writer.Write (s);
}
}
public override string ToString () {
return "VirtualMachine (pid=" + pid + ")";
}
}
}

View File

@@ -0,0 +1,4 @@
Assembly/AssemblyInfo.cs
../../build/common/Consts.cs
../../build/common/Locale.cs
Mono.Attach/VirtualMachine.cs