endif
-win32getdeps:
- wget http://www.go-mono.com/archive/pkgconfig-0.11-20020310.zip
- wget http://www.go-mono.com/archive/glib-2.0.4-20020703.zip
- wget http://www.go-mono.com/archive/glib-dev-2.0.4-20020703.zip
- wget http://www.go-mono.com/archive/libiconv-1.7.zip
- wget http://www.go-mono.com/archive/libiconv-dev-1.7.zip
- wget http://www.go-mono.com/archive/libintl-0.10.40-20020101.zip
- unzip -n -d / pkgconfig-0.11-20020310.zip
- unzip -n -d / glib-2.0.4-20020703.zip
- unzip -n -d / glib-dev-2.0.4-20020703.zip
- unzip -n -d / libiconv-1.7.zip
- unzip -n -d / libiconv-dev-1.7.zip
- unzip -n -d / libintl-0.10.40-20020101.zip
-
-win32setup:
- makensis /DMILESTONE=$(VERSION) /DSOURCE_INSTALL_DIR=$(SOURCE_INSTALL_DIR) /DBUILDNUM=$(BUILDNUM) monowiz.win32.nsi
-
update-csproj:
-rm msvc/scripts/order
-rm msvc/scripts/order.xml
# This can be reset to 0 when Mono's version number is bumped
# since it's part of the corlib version (the prefix '1' in the full
# version number is to ensure the number isn't treated as octal in C)
-MONO_CORLIB_COUNTER=0
-MONO_CORLIB_VERSION=`printf "1%02d%02d%02d%03d" $MONO_VERSION_MAJOR $MONO_VERSION_MINOR $MONO_VERSION_BUILD $MONO_CORLIB_COUNTER`
+MONO_CORLIB_COUNTER=1
+MONO_CORLIB_VERSION=`printf "1%02d%02d%02d%03d" $MONO_VERSION_MAJOR $MONO_VERSION_MINOR 0 $MONO_CORLIB_COUNTER`
AC_DEFINE_UNQUOTED(MONO_CORLIB_VERSION,$MONO_CORLIB_VERSION,[Version of the corlib-runtime interface])
AC_SUBST(MONO_CORLIB_VERSION)
AC_CHECK_FUNCS(getpwuid_r)
fi
+ AC_FUNC_STRERROR_R()
+
dnl ****************************************************************
dnl *** Check for sched_setaffinity from glibc versions before ***
dnl *** 2.3.4. The older versions of the function only take 2 ***
-Subproject commit bf03a7c5cf6b692fa662f1568ad66de35166b8ea
+Subproject commit 4dfe97ec246b7ebd2f7b4af378817abf436cf102
-Subproject commit 14e17dfbebf5651b5ce70c7fb317e388f8a3a271
+Subproject commit bc11f472954694ebd92ae4956f110c1036a7c2e0
-Subproject commit 305e0f60533d164676099c918fa4dd09c718017b
+Subproject commit 99354bf5c13b8055209cb082cddc50c8047ab088
-Subproject commit 690603bea98aae69fca9a65130d88591bc6cabee
+Subproject commit 5b29e610f4ac95afcb8108fdd6d0bb1936f6cc83
For a sample of how to write your own custom profiler look in the
Mono source tree for in the samples/profiler.c.
.SH CODE COVERAGE
-Mono ships with a code coverage module. This module is activated by
-using the Mono --profile=cov option. The format is:
-\fB--profile=cov[:assembly-name[/namespace]] test-suite.exe\fR
-.PP
-By default code coverage will default to all the assemblies loaded,
-you can limit this by specifying the assembly name, for example to
-perform code coverage in the routines of your program use, for example
-the following command line limits the code coverage to routines in the
-"demo" assembly:
-.nf
-
- mono --profile=cov:demo demo.exe
-
-.fi
-.PP
-Notice that the
-.I assembly-name
-does not include the extension.
-.PP
-You can further restrict the code coverage output by specifying a
-namespace:
-.nf
-
- mono --profile=cov:demo/My.Utilities demo.exe
-
-.fi
-.PP
-Which will only perform code coverage in the given assembly and
-namespace.
-.PP
-Typical output looks like this:
-.nf
-
- Not covered: Class:.ctor ()
- Not covered: Class:A ()
- Not covered: Driver:.ctor ()
- Not covered: Driver:method ()
- Partial coverage: Driver:Main ()
- offset 0x000a
-
-.fi
-.PP
-The offsets displayed are IL offsets.
-.PP
-A more powerful coverage tool is available in the module `monocov'.
-See the monocov(1) man page for details.
+Mono ships with a code coverage module in the \f[I]log\f[] profiler.
+Check the `coverage' option on the mprof-report(1) page for more details.
.SH AOT PROFILING
You can improve startup performance by using the AOT profiler.
.PP
http://www.mono-project.com
.SH SEE ALSO
.PP
-certmgr(1), cert-sync(1), csharp(1), gacutil(1), mcs(1), mdb(1), monocov(1), monodis(1),
+certmgr(1), cert-sync(1), csharp(1), gacutil(1), mcs(1), mdb(1), monodis(1),
mono-config(5), mprof-report(1), pdb2mdb(1), xsp(1), mod_mono(8).
.PP
For more information on AOT:
xunit-test-local: $(xunit_test_lib)
run-xunit-test-local: run-xunit-test-lib
-# ln -s is a HACK for xunit runner to require xunit.execution.desktop.dll file in local folder on .net only
+# cp -rf is a HACK for xunit runner to require xunit.execution.desktop.dll file in local folder on .net only
run-xunit-test-lib: xunit-test-local
- @ln -fs $(XTEST_HARNESS_PATH)/xunit.execution.desktop.dll xunit.execution.desktop.dll
+ @cp -rf $(XTEST_HARNESS_PATH)/xunit.execution.desktop.dll xunit.execution.desktop.dll
ok=:; \
PATH="$(TEST_RUNTIME_WRAPPERS_PATH):$(PATH)" $(TEST_RUNTIME) $(RUNTIME_FLAGS) $(AOT_RUN_FLAGS) $(XTEST_HARNESS) $(xunit_test_lib) $(XTEST_HARNESS_FLAGS) $(XTEST_TRAIT) || ok=false; \
$$ok
leave end
} filter {
+ castclass [mscorlib]System.Exception
call int32 class ExceptionFilterTest::Filter([mscorlib]System.Exception)
endfilter
} {
+ castclass [mscorlib]System.Exception
call void class ExceptionFilterTest::Handler([mscorlib]System.Exception)
leave end
}
Assert.AreEqual (0, frames [0].Location.ILOffset);
Assert.AreEqual (test_method.Name, frames [1].Location.Method.Name);
- Assert.AreEqual (37, frames [1].Location.LineNumber);
- Assert.AreEqual (0x0b, frames [1].Location.ILOffset);
+ Assert.AreEqual (38, frames [1].Location.LineNumber);
+ Assert.AreEqual (0x10, frames [1].Location.ILOffset);
Assert.AreEqual (test_method.Name, frames [2].Location.Method.Name);
Assert.AreEqual (33, frames [2].Location.LineNumber);
X509CertificateCollection certificates, bool wantsChain, ref X509Chain chain,
ref MonoSslPolicyErrors errors, ref int status11);
#endregion
+
+#region Misc
+
+ internal abstract bool SupportsCleanShutdown {
+ get;
+ }
+
+#endregion
+
}
}
get; set;
}
+ /*
+ * This is only supported if MonoTlsProvider.SupportsCleanShutdown is true.
+ */
+ internal bool SendCloseNotify {
+ get; set;
+ }
+
/*
* If you set this here, then it will override 'ServicePointManager.SecurityProtocol'.
*/
EnabledProtocols = other.EnabledProtocols;
EnabledCiphers = other.EnabledCiphers;
CertificateValidationTime = other.CertificateValidationTime;
+ SendCloseNotify = other.SendCloseNotify;
if (other.TrustAnchors != null)
TrustAnchors = new X509CertificateCollection (other.TrustAnchors);
if (other.CertificateSearchPaths != null) {
/// </summary>
public enum ImplAttr { IL, Native, Runtime = 0x03, Unmanaged = 0x04,
ForwardRef = 0x10, PreserveSig = 0x0080, InternalCall = 0x1000,
- Synchronised = 0x0020, Synchronized = 0x0020, NoInLining = 0x0008, NoOptimization = 0x0040, Optil = 0x0002}
+ Synchronised = 0x0020, Synchronized = 0x0020, NoInLining = 0x0008, NoOptimization = 0x0040, Optil = 0x0002,
+ AggressiveInlining = 0x0100
+ }
/// <summary>
/// Storage location for initial field data
public class ClassDef : Class {
Class superType;
+ bool setSuperType;
ArrayList fields = new ArrayList();
ArrayList methods = new ArrayList();
ArrayList events;
MetaData md) : base(nsName, name, md)
{
metaData = md;
- if (! ((nsName == "" && name == "<Module>") || (nsName == "System" && name == "Object")) ) {
- superType = metaData.mscorlib.GetSpecialSystemClass(PrimitiveType.Object);
- }
flags = (uint)attrSet;
tabIx = MDTable.TypeDef;
}
internal void SetSuper(Class sClass)
{
superType = sClass;
+ setSuperType = true;
if (! (sClass is GenericTypeInst))
typeIndexChecked = false;
}
else
superType = metaData.mscorlib.ValueType();
+ setSuperType = true;
typeIndex = PrimitiveType.ValueType.GetTypeIndex ();
}
public void SpecialNoSuper()
{
- superType = null;
+ setSuperType = true;
}
/// <summary>
internal sealed override void BuildTables(MetaData md)
{
- if (done) return;
- if ((flags & (uint)TypeAttr.Interface) != 0) { superType = null; }
+ if (done)
+ return;
+
+ if ((flags & (uint)TypeAttr.Interface) != 0) {
+ superType = null;
+ setSuperType = true;
+ }
// Console.WriteLine("Building tables for " + name);
if (layout != null) md.AddToTable(MDTable.ClassLayout,layout);
// Console.WriteLine("adding methods " + methods.Count);
((Property)properties[0]).Row,MDTable.Property));
}
// Console.WriteLine("End of building tables");
+
+ if (!setSuperType)
+ superType = metaData.mscorlib.GetSpecialSystemClass(PrimitiveType.Object);
+
done = true;
}
private byte heapSizes = 0;
MetaDataElement entryPoint;
BinaryWriter output;
- public MSCorLib mscorlib;
+ MSCorLib _mscorlib;
private TypeSpec[] systemTypeSpecs = new TypeSpec[PrimitiveType.NumSystemTypes];
long mdStart;
private ArrayList cattr_list;
for (int i=0; i < lgeCIx.Length; i++) {
lgeCIx[i] = false;
}
- mscorlib = new MSCorLib(this);
}
+ public MSCorLib mscorlib {
+ get {
+ return _mscorlib ?? (_mscorlib = new MSCorLib (this));
+ }
+ }
+
+
internal TypeSpec GetPrimitiveTypeSpec(int ix)
{
return systemTypeSpecs[ix];
+../../test-helpers/NetworkHelpers.cs
System.Net.Http/DelegatingHandlerTest.cs
System.Net.Http/ByteArrayContentTest.cs
System.Net.Http/FormUrlEncodedContentTest.cs
using System.Linq;
using System.IO;
+using MonoTests.Helpers;
+
namespace MonoTests.System.Net.Http
{
[TestFixture]
const int WaitTimeout = 5000;
- string TestHost, LocalServer;
- int port;
-
- [SetUp]
- public void SetupFixture ()
- {
- if (Environment.OSVersion.Platform == PlatformID.Win32NT) {
- port = 810;
- } else {
- port = 8810;
- }
-
- TestHost = "localhost:" + port;
- LocalServer = string.Format ("http://{0}/", TestHost);
- }
-
[Test]
public void Ctor_Default ()
{
public void Send_Complete_Default ()
{
bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
try {
var request = l.Request;
Assert.IsNull (request.ContentType, "#3");
Assert.AreEqual (0, request.Cookies.Count, "#4");
Assert.IsFalse (request.HasEntityBody, "#5");
- Assert.AreEqual (TestHost, request.Headers["Host"], "#6b");
+ Assert.AreEqual ($"localhost:{port}", request.Headers["Host"], "#6b");
Assert.AreEqual ("GET", request.HttpMethod, "#7");
Assert.IsFalse (request.IsAuthenticated, "#8");
Assert.IsTrue (request.IsLocal, "#9");
} catch {
failed = true;
}
- });
+ }, port);
try {
var client = new HttpClient ();
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
Assert.AreEqual ("", response.Content.ReadAsStringAsync ().Result, "#100");
{
bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
try {
var request = l.Request;
Assert.AreEqual (0, request.Cookies.Count, "#4");
Assert.IsFalse (request.HasEntityBody, "#5");
Assert.AreEqual (1, request.Headers.Count, "#6");
- Assert.AreEqual (TestHost, request.Headers["Host"], "#6a");
+ Assert.AreEqual ($"localhost:{port}", request.Headers["Host"], "#6a");
Assert.AreEqual ("GET", request.HttpMethod, "#7");
Assert.IsFalse (request.IsAuthenticated, "#8");
Assert.IsTrue (request.IsLocal, "#9");
} catch {
failed = true;
}
- });
+ }, port);
try {
var client = new HttpClient ();
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
request.Version = HttpVersion.Version10;
var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
{
bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
Assert.AreEqual (new Cookie ("mycookie", "vv"), request.Cookies[0], "#4a");
Assert.IsFalse (request.HasEntityBody, "#5");
Assert.AreEqual (4, request.Headers.Count, "#6");
- Assert.AreEqual (TestHost, request.Headers["Host"], "#6a");
+ Assert.AreEqual ($"localhost:{port}", request.Headers["Host"], "#6a");
Assert.AreEqual ("gzip", request.Headers["Accept-Encoding"], "#6b");
Assert.AreEqual ("mycookie=vv", request.Headers["Cookie"], "#6c");
Assert.AreEqual ("GET", request.HttpMethod, "#7");
} catch {
failed = true;
}
- });
+ }, port);
try {
var chandler = new HttpClientHandler ();
chandler.MaxAutomaticRedirections = 33;
chandler.MaxRequestContentBufferSize = 5555;
chandler.PreAuthenticate = true;
- chandler.CookieContainer.Add (new Uri (LocalServer), new Cookie ( "mycookie", "vv"));
+ chandler.CookieContainer.Add (new Uri ($"http://localhost:{port}/"), new Cookie ( "mycookie", "vv"));
chandler.UseCookies = true;
chandler.UseDefaultCredentials = true;
chandler.Proxy = new WebProxy ("ee");
chandler.UseProxy = true;
var client = new HttpClient (chandler);
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
request.Version = HttpVersion.Version10;
request.Headers.Add ("Keep-Alive", "false");
var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
{
bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
try {
} catch {
failed = true;
}
- });
+ }, port);
try {
var client = new HttpClient ();
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
Assert.IsTrue (request.Headers.TryAddWithoutValidation ("aa", "vv"), "#0");
var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
{
bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
} catch {
failed = true;
}
- });
+ }, port);
try {
var client = new HttpClient ();
client.DefaultRequestHeaders.Add("User-Agent", "MLK Android Phone 1.1.9");
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
public void Send_Complete_CustomHeaders_Host ()
{
bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
} catch {
failed = true;
}
- });
+ }, port);
try {
var client = new HttpClient ();
client.DefaultRequestHeaders.Add("Host", "customhost");
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
{
bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
try {
- Assert.AreEqual (1, request.Headers.Count, "#1");
+ Assert.AreEqual (2, request.Headers.Count, "#1");
+ Assert.AreEqual ("keep-alive", request.Headers ["Connection"], "#2");
failed = false;
- } catch {
+ } catch (Exception ex){
+ Console.WriteLine (ex);
+ Console.WriteLine (String.Join ("#", l.Request.Headers.AllKeys));
failed = true;
}
- });
+ }, port);
try {
var client = new HttpClient ();
client.DefaultRequestHeaders.TransferEncodingChunked = true;
- client.GetAsync (LocalServer).Wait ();
+ client.GetAsync ($"http://localhost:{port}/").Wait ();
Assert.AreEqual (false, failed, "#102");
} finally {
{
bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
failed = true;
- });
+ }, port);
try {
var client = new HttpClient ();
client.DefaultRequestHeaders.TransferEncoding.Add (new TransferCodingHeaderValue ("chunked2"));
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
try {
client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Wait ();
#endif
public void Send_Complete_Content ()
{
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
l.Response.OutputStream.WriteByte (55);
l.Response.OutputStream.WriteByte (75);
- });
+ }, port);
try {
var client = new HttpClient ();
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
Assert.IsTrue (request.Headers.TryAddWithoutValidation ("aa", "vv"), "#0");
var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
#endif
public void Send_Complete_Content_MaxResponseContentBufferSize ()
{
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
var b = new byte[4000];
l.Response.OutputStream.Write (b, 0, b.Length);
- });
+ }, port);
try {
var client = new HttpClient ();
client.MaxResponseContentBufferSize = 1000;
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
Assert.AreEqual (4000, response.Content.ReadAsStringAsync ().Result.Length, "#100");
#endif
public void Send_Complete_Content_MaxResponseContentBufferSize_Error ()
{
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
var b = new byte[4000];
l.Response.OutputStream.Write (b, 0, b.Length);
- });
+ }, port);
try {
var client = new HttpClient ();
client.MaxResponseContentBufferSize = 1000;
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
try {
client.SendAsync (request, HttpCompletionOption.ResponseContentRead).Wait (WaitTimeout);
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
- public void Send_Complete_NoContent ()
+ public void Send_Complete_NoContent_Post ()
+ {
+ Send_Complete_NoContent (HttpMethod.Post);
+ }
+
+ [Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
+ public void Send_Complete_NoContent_Put ()
{
- foreach (var method in new HttpMethod[] { HttpMethod.Post, HttpMethod.Put, HttpMethod.Delete }) {
- bool? failed = null;
- var listener = CreateListener (l => {
- try {
- var request = l.Request;
-
- Assert.AreEqual (2, request.Headers.Count, "#1");
- Assert.AreEqual ("0", request.Headers ["Content-Length"], "#1b");
- Assert.AreEqual (method.Method, request.HttpMethod, "#2");
- failed = false;
- } catch {
- failed = true;
- }
- });
+ Send_Complete_NoContent (HttpMethod.Put);
+ }
+
+ [Test]
+#if FEATURE_NO_BSD_SOCKETS
+ [ExpectedException (typeof (PlatformNotSupportedException))]
+#endif
+ public void Send_Complete_NoContent_Delete ()
+ {
+ Send_Complete_NoContent (HttpMethod.Delete);
+ }
+ void Send_Complete_NoContent (HttpMethod method)
+ {
+ bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
+ var listener = CreateListener (l => {
try {
- var client = new HttpClient ();
- var request = new HttpRequestMessage (method, LocalServer);
- var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
+ var request = l.Request;
- Assert.AreEqual ("", response.Content.ReadAsStringAsync ().Result, "#100");
- Assert.AreEqual (HttpStatusCode.OK, response.StatusCode, "#101");
- Assert.AreEqual (false, failed, "#102");
- } finally {
- listener.Close ();
+ Assert.AreEqual (3, request.Headers.Count, "#1");
+ Assert.AreEqual ("0", request.Headers ["Content-Length"], "#1b");
+ Assert.AreEqual ("keep-alive", request.Headers ["Connection"], "#1c");
+ Assert.AreEqual (method.Method, request.HttpMethod, "#2");
+ failed = false;
+ } catch (Exception ex){
+ Console.WriteLine (ex);
+ Console.WriteLine (String.Join ("#", l.Request.Headers.AllKeys));
+
+ failed = true;
}
+ }, port);
+
+ try {
+ var client = new HttpClient ();
+ var request = new HttpRequestMessage (method, $"http://localhost:{port}/");
+ var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
+
+ Assert.AreEqual ("", response.Content.ReadAsStringAsync ().Result, "#100");
+ Assert.AreEqual (HttpStatusCode.OK, response.StatusCode, "#101");
+ Assert.AreEqual (false, failed, "#102");
+ } finally {
+ listener.Close ();
}
}
#endif
public void Send_Complete_Error ()
{
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var response = l.Response;
response.StatusCode = 500;
- });
+ }, port);
try {
var client = new HttpClient ();
- var request = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var request = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
var response = client.SendAsync (request, HttpCompletionOption.ResponseHeadersRead).Result;
Assert.AreEqual ("", response.Content.ReadAsStringAsync ().Result, "#100");
#endif
public void Send_Content_Get ()
{
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
l.Response.OutputStream.WriteByte (72);
- });
+ }, port);
try {
var client = new HttpClient ();
- var r = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var r = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
var response = client.SendAsync (r).Result;
Assert.AreEqual ("H", response.Content.ReadAsStringAsync ().Result);
#endif
public void Send_Content_BomEncoding ()
{
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
str.WriteByte (0xBB);
str.WriteByte (0xBF);
str.WriteByte (71);
- });
+ }, port);
try {
var client = new HttpClient ();
- var r = new HttpRequestMessage (HttpMethod.Get, LocalServer);
+ var r = new HttpRequestMessage (HttpMethod.Get, $"http://localhost:{port}/");
var response = client.SendAsync (r).Result;
Assert.AreEqual ("G", response.Content.ReadAsStringAsync ().Result);
public void Send_Content_Put ()
{
bool passed = false;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
passed = 7 == request.ContentLength64;
passed &= request.ContentType == "text/plain; charset=utf-8";
passed &= request.InputStream.ReadByte () == 'm';
- });
+ }, port);
try {
var client = new HttpClient ();
- var r = new HttpRequestMessage (HttpMethod.Put, LocalServer);
+ var r = new HttpRequestMessage (HttpMethod.Put, $"http://localhost:{port}/");
r.Content = new StringContent ("my text");
var response = client.SendAsync (r).Result;
public void Send_Content_Put_CustomStream ()
{
bool passed = false;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
passed = 44 == request.ContentLength64;
passed &= request.ContentType == null;
- });
+ }, port);
try {
var client = new HttpClient ();
- var r = new HttpRequestMessage (HttpMethod.Put, LocalServer);
+ var r = new HttpRequestMessage (HttpMethod.Put, $"http://localhost:{port}/");
r.Content = new StreamContent (new CustomStream ());
var response = client.SendAsync (r).Result;
public void Post_TransferEncodingChunked ()
{
bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
try {
var request = l.Request;
Assert.IsNull (request.ContentType, "#3");
Assert.AreEqual (0, request.Cookies.Count, "#4");
Assert.IsTrue (request.HasEntityBody, "#5");
- Assert.AreEqual (TestHost, request.Headers ["Host"], "#6b");
+ Assert.AreEqual ($"localhost:{port}", request.Headers ["Host"], "#6b");
Assert.AreEqual ("POST", request.HttpMethod, "#7");
Assert.IsFalse (request.IsAuthenticated, "#8");
Assert.IsTrue (request.IsLocal, "#9");
failed = true;
Console.WriteLine (e);
}
- });
+ }, port);
try {
var client = new HttpClient ();
var imageContent = new StreamContent (new MemoryStream ());
- var response = client.PostAsync (LocalServer, imageContent).Result;
+ var response = client.PostAsync ($"http://localhost:{port}/", imageContent).Result;
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, "#101");
Assert.AreEqual(false, failed, "#102");
public void Post_StreamCaching ()
{
bool? failed = null;
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
try {
var request = l.Request;
Assert.IsNull (request.ContentType, "#3");
Assert.AreEqual (0, request.Cookies.Count, "#4");
Assert.IsFalse (request.HasEntityBody, "#5");
- Assert.AreEqual (TestHost, request.Headers ["Host"], "#6b");
+ Assert.AreEqual ($"localhost:{port}", request.Headers ["Host"], "#6b");
Assert.AreEqual ("POST", request.HttpMethod, "#7");
Assert.IsFalse (request.IsAuthenticated, "#8");
Assert.IsTrue (request.IsLocal, "#9");
failed = true;
Console.WriteLine (e);
}
- });
+ }, port);
try {
var client = new HttpClient ();
var imageContent = new StreamContent (new MemoryStream ());
- var response = client.PostAsync (LocalServer, imageContent).Result;
+ var response = client.PostAsync ($"http://localhost:{port}/", imageContent).Result;
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode, "#101");
Assert.AreEqual(false, failed, "#102");
response.OutputStream.WriteByte (0x6f);
};
- var listener = CreateListener (context); // creates a default request handler
+ var port = NetworkHelpers.FindFreePort ();
+ var listener = CreateListener (context, port); // creates a default request handler
AddListenerContext (listener, context); // add another request handler for the second request
try {
var client = new HttpClient ();
- var t1 = client.GetStringAsync (LocalServer);
- var t2 = client.GetStringAsync (LocalServer);
+ var t1 = client.GetStringAsync ($"http://localhost:{port}/");
+ var t2 = client.GetStringAsync ($"http://localhost:{port}/");
Assert.IsTrue (Task.WaitAll (new [] { t1, t2 }, WaitTimeout));
Assert.AreEqual ("hello", t1.Result, "#1");
Assert.AreEqual ("hello", t2.Result, "#2");
#endif
public void GetByteArray_ServerError ()
{
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var response = l.Response;
response.StatusCode = 500;
l.Response.OutputStream.WriteByte (72);
- });
+ }, port);
try {
var client = new HttpClient ();
try {
- client.GetByteArrayAsync (LocalServer).Wait (WaitTimeout);
+ client.GetByteArrayAsync ($"http://localhost:{port}/").Wait (WaitTimeout);
Assert.Fail ("#1");
} catch (AggregateException e) {
Assert.IsTrue (e.InnerException is HttpRequestException , "#2");
#endif
public void DisallowAutoRedirect ()
{
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var request = l.Request;
var response = l.Response;
response.StatusCode = (int)HttpStatusCode.Moved;
response.RedirectLocation = "http://xamarin.com/";
- });
+ }, port);
try {
var chandler = new HttpClientHandler ();
var client = new HttpClient (chandler);
try {
- client.GetStringAsync (LocalServer).Wait (WaitTimeout);
+ client.GetStringAsync ($"http://localhost:{port}/").Wait (WaitTimeout);
Assert.Fail ("#1");
} catch (AggregateException e) {
Assert.IsTrue (e.InnerException is HttpRequestException, "#2");
#endif
public void RequestUriAfterRedirect ()
{
+ var port = NetworkHelpers.FindFreePort ();
+ var redirectPort = NetworkHelpers.FindFreePort ();
+
var listener = CreateListener (l => {
var request = l.Request;
var response = l.Response;
response.StatusCode = (int)HttpStatusCode.Moved;
- response.RedirectLocation = "http://localhost:8811/";
- });
+ response.RedirectLocation = $"http://localhost:{redirectPort}/";
+ }, port);
var listener2 = CreateListener (l => {
var response = l.Response;
response.OutputStream.WriteByte (0x6c);
response.OutputStream.WriteByte (0x6c);
response.OutputStream.WriteByte (0x6f);
- }, 8811);
+ }, redirectPort);
try {
var chandler = new HttpClientHandler ();
chandler.AllowAutoRedirect = true;
var client = new HttpClient (chandler);
- var r = client.GetAsync (LocalServer);
+ var r = client.GetAsync ($"http://localhost:{port}/");
Assert.IsTrue (r.Wait (WaitTimeout), "#1");
var resp = r.Result;
- Assert.AreEqual ("http://localhost:8811/", resp.RequestMessage.RequestUri.AbsoluteUri, "#2");
+ Assert.AreEqual ($"http://localhost:{redirectPort}/", resp.RequestMessage.RequestUri.AbsoluteUri, "#2");
Assert.AreEqual ("hello", resp.Content.ReadAsStringAsync ().Result, "#3");
} finally {
listener.Abort ();
chandler.AllowAutoRedirect = true;
var client = new HttpClient (chandler, true);
+ var port = NetworkHelpers.FindFreePort ();
var listener = CreateListener (l => {
var response = l.Response;
response.StatusCode = 200;
response.OutputStream.WriteByte (55);
- });
+ }, port);
try {
- client.GetStringAsync (LocalServer).Wait (WaitTimeout);
+ client.GetStringAsync ($"http://localhost:{port}/").Wait (WaitTimeout);
try {
chandler.AllowAutoRedirect = false;
Assert.Fail ("#1");
ch.AllowAutoRedirect = false;
}
- HttpListener CreateListener (Action<HttpListenerContext> contextAssert)
- {
- return CreateListener (contextAssert, port);
- }
-
HttpListener CreateListener (Action<HttpListenerContext> contextAssert, int port)
{
var l = new HttpListener ();
../../test-helpers/NunitHelpers.cs
+../../test-helpers/NetworkHelpers.cs
System.Runtime.Remoting.Channels.Tcp/TcpChannelTest.cs
ServerObject.cs
ContextsTest.cs
using System.Runtime.Remoting.Channels.Http;
using NUnit.Framework;
+using MonoTests.Helpers;
+
namespace MonoTests.Remoting
{
[TestFixture]
AppDomain domain = BaseCallTest.CreateDomain ("testdomain_activation");
server = (ActivationServer) domain.CreateInstanceAndUnwrap(GetType().Assembly.FullName,"MonoTests.Remoting.ActivationServer");
- RemotingConfiguration.RegisterActivatedClientType (typeof(CaObject1), "tcp://localhost:9433");
- RemotingConfiguration.RegisterActivatedClientType (typeof(CaObject2), "http://localhost:9434");
- RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSinglecall1), "tcp://localhost:9433/wkoSingleCall1");
- RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSingleton1), "tcp://localhost:9433/wkoSingleton1");
- RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSinglecall2), "http://localhost:9434/wkoSingleCall2");
- RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSingleton2), "http://localhost:9434/wkoSingleton2");
+ var tcpUrlPrefix = $"tcp://localhost:{server.TcpPort}";
+ var httpUrlPrefix = $"http://localhost:{server.HttpPort}";
+ RemotingConfiguration.RegisterActivatedClientType (typeof(CaObject1), tcpUrlPrefix);
+ RemotingConfiguration.RegisterActivatedClientType (typeof(CaObject2), httpUrlPrefix);
+ RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSinglecall1), tcpUrlPrefix + "/wkoSingleCall1");
+ RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSingleton1), tcpUrlPrefix + "/wkoSingleton1");
+ RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSinglecall2), httpUrlPrefix + "/wkoSingleCall2");
+ RemotingConfiguration.RegisterWellKnownClientType (typeof(WkObjectSingleton2), httpUrlPrefix + "/wkoSingleton2");
}
catch (Exception ex)
{
public ActivationServer ()
{
- tcp = new TcpChannel (9433);
- http = new HttpChannel (9434);
+ TcpPort = NetworkHelpers.FindFreePort ();
+ HttpPort = NetworkHelpers.FindFreePort ();
+ tcp = new TcpChannel (TcpPort);
+ http = new HttpChannel (HttpPort);
ChannelServices.RegisterChannel (tcp);
ChannelServices.RegisterChannel (http);
ChannelServices.UnregisterChannel (tcp);
ChannelServices.UnregisterChannel (http);
}
+
+ public int TcpPort { get; private set; }
+ public int HttpPort { get; private set; }
}
public class BaseObject: MarshalByRefObject
using System.Threading;
using NUnit.Framework;
+using MonoTests.Helpers;
+
namespace MonoTests.Remoting
{
public interface INested
[Test]
public void TestTcpChannel ()
{
+ var port = NetworkHelpers.FindFreePort ();
IDictionary props = new Hashtable ();
props ["name"] = Guid.NewGuid ().ToString("N");
- props ["port"] = 18191;
+ props ["port"] = port;
TcpChannel chan = new TcpChannel (props, null, null);
ChannelServices.RegisterChannel (chan);
try {
Register <Server<object>> ("gentcptest.rem");
- RunTests (Connect <Server<object>> ("tcp://localhost:18191/gentcptest.rem"));
+ RunTests (Connect <Server<object>> ($"tcp://localhost:{port}/gentcptest.rem"));
} finally {
ChannelServices.UnregisterChannel (chan);
}
using System.Runtime.Remoting.Channels.Http;
using NUnit.Framework;
+using MonoTests.Helpers;
+
namespace MonoTests.Remoting.Http
{
//Test for Bug 324362 - SoapFormatter cannot deserialize the same MBR twice
[Test]
public void Main ()
{
- channel = new HttpChannel (3344);
+ var port = NetworkHelpers.FindFreePort ();
+ channel = new HttpChannel (port);
ChannelServices.RegisterChannel (channel);
RemotingConfiguration.RegisterWellKnownServiceType
(typeof (Bug321420),"Server.soap", WellKnownObjectMode.Singleton);
Bug321420 s = (Bug321420) Activator.GetObject (typeof
- (Bug321420), "http://localhost:3344/Server.soap");
+ (Bug321420), $"http://localhost:{port}/Server.soap");
// this works: s.Method ("a", "b");
s.Method ("a", "a");
public void Main ()
{
Foo foo = (Foo) Activator.GetObject (typeof (Foo),
- "http://localhost:4321/Test");
+ $"http://localhost:{server.HttpPort}/Test");
Bar bar = foo.Login ();
if (bar != null)
public void Start ()
{
- c = new HttpChannel (4321);
+ HttpPort = NetworkHelpers.FindFreePort ();
+ c = new HttpChannel (HttpPort);
ChannelServices.RegisterChannel (c);
Type t = typeof(Foo);
c.StopListening (null);
ChannelServices.UnregisterChannel (c);
}
+
+ public int HttpPort { get; private set; }
}
}
ChannelServices.RegisterChannel (channel);
MarshalByRefObject obj = (MarshalByRefObject) RemotingServices.Connect (
typeof (IFactorial),
- "http://localhost:60000/MyEndPoint");
+ $"http://localhost:{server.HttpPort}/MyEndPoint");
IFactorial cal = (IFactorial) obj;
Assert.AreEqual (cal.CalculateFactorial (4), 24);
}
public void Start ()
{
- c = new HttpChannel (60000);
+ HttpPort = NetworkHelpers.FindFreePort ();
+ c = new HttpChannel (HttpPort);
ChannelServices.RegisterChannel (c);
Type t = typeof(Calculator);
c.StopListening (null);
ChannelServices.UnregisterChannel (c);
}
+
+ public int HttpPort { get; private set; }
}
public class Calculator : MarshalByRefObject, IFactorial
using System.Runtime.Remoting.Channels;\r
using System.Runtime.Remoting.Channels.Tcp;\r
\r
+using MonoTests.Helpers;\r
+\r
namespace MonoTests.System.Runtime.Remoting.RemotingServicesInternal\r
{\r
// We need our own proxy to intercept messages to remote object\r
[Test]\r
public void Connect ()\r
{\r
+ var port = NetworkHelpers.FindFreePort ();\r
MarshalObject objMarshal = NewMarshalObject ();\r
\r
IDictionary props = new Hashtable ();\r
props ["name"] = objMarshal.Uri;\r
- props ["port"] = 1236;\r
+ props ["port"] = port;\r
TcpChannel chn = new TcpChannel (props, null, null);\r
ChannelServices.RegisterChannel (chn);\r
\r
try {\r
RemotingServices.Marshal (objMarshal, objMarshal.Uri);\r
- MarshalObject objRem = (MarshalObject) RemotingServices.Connect (typeof (MarshalObject), "tcp://localhost:1236/" + objMarshal.Uri);\r
+ MarshalObject objRem = (MarshalObject) RemotingServices.Connect (typeof (MarshalObject), $"tcp://localhost:{port}/" + objMarshal.Uri);\r
Assert.IsTrue (RemotingServices.IsTransparentProxy (objRem), "#A08");\r
} finally {\r
ChannelServices.UnregisterChannel (chn);\r
[Test]\r
public void MarshalThrowException ()\r
{\r
+ var port = NetworkHelpers.FindFreePort ();\r
MarshalObject objMarshal = NewMarshalObject ();\r
\r
IDictionary props = new Hashtable ();\r
props ["name"] = objMarshal.Uri;\r
- props ["port"] = 1237;\r
+ props ["port"] = port;\r
TcpChannel chn = new TcpChannel (props, null, null);\r
ChannelServices.RegisterChannel (chn);\r
\r
try {\r
RemotingServices.Marshal (objMarshal, objMarshal.Uri);\r
- MarshalObject objRem = (MarshalObject) RemotingServices.Connect (typeof (MarshalObject), "tcp://localhost:1237/" + objMarshal.Uri);\r
+ MarshalObject objRem = (MarshalObject) RemotingServices.Connect (typeof (MarshalObject), $"tcp://localhost:{port}/" + objMarshal.Uri);\r
// This line should throw a RemotingException\r
// It is forbidden to export an object which is not\r
// a real object\r
[Test]\r
public void ExecuteMessage ()\r
{\r
- TcpChannel chn = new TcpChannel (1235);\r
+ var port = NetworkHelpers.FindFreePort ();\r
+ TcpChannel chn = new TcpChannel (port);\r
ChannelServices.RegisterChannel (chn);\r
try {\r
MarshalObject objMarshal = NewMarshalObject ();\r
RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), objMarshal.Uri, WellKnownObjectMode.SingleCall);\r
\r
// use a proxy to catch the Message\r
- MyProxy proxy = new MyProxy (typeof (MarshalObject), (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1235/" + objMarshal.Uri));\r
+ MyProxy proxy = new MyProxy (typeof (MarshalObject), (MarshalObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/" + objMarshal.Uri));\r
\r
MarshalObject objRem = (MarshalObject) proxy.GetTransparentProxy ();\r
\r
[Test]\r
public void IsOneWay ()\r
{\r
- TcpChannel chn = new TcpChannel (1238);\r
+ var port = NetworkHelpers.FindFreePort ();\r
+ TcpChannel chn = new TcpChannel (port);\r
ChannelServices.RegisterChannel (chn);\r
try {\r
RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "MarshalObject.rem", WellKnownObjectMode.Singleton);\r
\r
- MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1238/MarshalObject.rem");\r
+ MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/MarshalObject.rem");\r
\r
Assert.IsTrue (RemotingServices.IsTransparentProxy (objRem), "#A10.1");\r
\r
[Test]\r
public void GetObjRefForProxy ()\r
{\r
- TcpChannel chn = new TcpChannel (1239);\r
+ var port = NetworkHelpers.FindFreePort ();\r
+ TcpChannel chn = new TcpChannel (port);\r
ChannelServices.RegisterChannel (chn);\r
try {\r
// Register le factory as a SAO\r
RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObjectFactory), "MonoTests.System.Runtime.Remoting.RemotingServicesTest.Factory.soap", WellKnownObjectMode.Singleton);\r
\r
- MarshalObjectFactory objFactory = (MarshalObjectFactory) Activator.GetObject (typeof (MarshalObjectFactory), "tcp://localhost:1239/MonoTests.System.Runtime.Remoting.RemotingServicesTest.Factory.soap");\r
+ MarshalObjectFactory objFactory = (MarshalObjectFactory) Activator.GetObject (typeof (MarshalObjectFactory), $"tcp://localhost:{port}/MonoTests.System.Runtime.Remoting.RemotingServicesTest.Factory.soap");\r
\r
// Get a new "CAO"\r
MarshalObject objRem = objFactory.GetNewMarshalObject ();\r
[Test]\r
public void GetRealProxy ()\r
{\r
- TcpChannel chn = new TcpChannel (1241);\r
+ var port = NetworkHelpers.FindFreePort ();\r
+ TcpChannel chn = new TcpChannel (port);\r
ChannelServices.RegisterChannel (chn);\r
try {\r
RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject.soap", WellKnownObjectMode.Singleton);\r
\r
- MyProxy proxy = new MyProxy (typeof (MarshalObject), (MarshalByRefObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1241/MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject.soap"));\r
+ MyProxy proxy = new MyProxy (typeof (MarshalObject), (MarshalByRefObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject.soap"));\r
MarshalObject objRem = (MarshalObject) proxy.GetTransparentProxy ();\r
\r
RealProxy rp = RemotingServices.GetRealProxy (objRem);\r
[Test]\r
public void SetObjectUriForMarshal ()\r
{\r
- TcpChannel chn = new TcpChannel (1242);\r
+ var port = NetworkHelpers.FindFreePort ();\r
+ TcpChannel chn = new TcpChannel (port);\r
ChannelServices.RegisterChannel (chn);\r
try {\r
MarshalObject objRem = NewMarshalObject ();\r
RemotingServices.SetObjectUriForMarshal (objRem, objRem.Uri);\r
RemotingServices.Marshal (objRem);\r
\r
- objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1242/" + objRem.Uri);\r
+ objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/" + objRem.Uri);\r
Assert.IsNotNull (objRem, "#A14");\r
} finally {\r
ChannelServices.UnregisterChannel (chn);\r
[Test]\r
public void GetServeurTypeForUri ()\r
{\r
- TcpChannel chn = new TcpChannel (1243);\r
+ var port = NetworkHelpers.FindFreePort ();\r
+ TcpChannel chn = new TcpChannel (port);\r
Type type = typeof (MarshalObject);\r
ChannelServices.RegisterChannel (chn);\r
try {\r
[Category ("NotWorking")]\r
public void IsObjectOutOf ()\r
{\r
- TcpChannel chn = new TcpChannel (1245);\r
+ var port = NetworkHelpers.FindFreePort ();\r
+ TcpChannel chn = new TcpChannel (port);\r
ChannelServices.RegisterChannel (chn);\r
try {\r
RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "MarshalObject2.rem", WellKnownObjectMode.Singleton);\r
\r
- MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1245/MarshalObject2.rem");\r
+ MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/MarshalObject2.rem");\r
\r
Assert.IsTrue (RemotingServices.IsObjectOutOfAppDomain (objRem), "#A16");\r
Assert.IsTrue (RemotingServices.IsObjectOutOfContext (objRem), "#A17");\r
[Test]\r
public void ApplicationNameTest ()\r
{\r
+ var port = NetworkHelpers.FindFreePort ();\r
RemotingConfiguration.ApplicationName = "app";\r
- TcpChannel chn = new TcpChannel (1246);\r
+ TcpChannel chn = new TcpChannel (port);\r
ChannelServices.RegisterChannel (chn);\r
try {\r
RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "obj3.rem", WellKnownObjectMode.Singleton);\r
\r
- MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1246/app/obj3.rem");\r
- MarshalObject objRem2 = (MarshalObject) Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1246/obj3.rem");\r
+ MarshalObject objRem = (MarshalObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/app/obj3.rem");\r
+ MarshalObject objRem2 = (MarshalObject) Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/obj3.rem");\r
\r
Assert.IsTrue (RemotingServices.IsTransparentProxy (objRem), "#AN1");\r
Assert.IsTrue (RemotingServices.IsTransparentProxy (objRem2), "#AN2");\r
[Test]\r
public void GetObjectWithChannelDataTest ()\r
{\r
- TcpChannel chn = new TcpChannel (1247);\r
+ var port = NetworkHelpers.FindFreePort ();\r
+ TcpChannel chn = new TcpChannel (port);\r
ChannelServices.RegisterChannel (chn);\r
try {\r
RemotingConfiguration.RegisterWellKnownServiceType (typeof (MarshalObject), "getobjectwithchanneldata.rem", WellKnownObjectMode.Singleton);\r
\r
string channelData = "test";\r
- Assert.IsNotNull (Activator.GetObject (typeof (MarshalObject), "tcp://localhost:1247/getobjectwithchanneldata.rem", channelData), "#01");\r
+ Assert.IsNotNull (Activator.GetObject (typeof (MarshalObject), $"tcp://localhost:{port}/getobjectwithchanneldata.rem", channelData), "#01");\r
} finally {\r
ChannelServices.UnregisterChannel (chn);\r
}\r
[Ignore ("We cannot test RemotingConfiguration.Configure() because it keeps channels registered. If we really need to test it, do it as a standalone case")]\r
public void ConnectProxyCast ()\r
{\r
+ var port = NetworkHelpers.FindFreePort ();\r
object o;\r
RemotingConfiguration.Configure (null);\r
\r
- o = RemotingServices.Connect (typeof (MarshalByRefObject), "tcp://localhost:3434/ff1.rem");\r
+ o = RemotingServices.Connect (typeof (MarshalByRefObject), $"tcp://localhost:{port}/ff1.rem");\r
Assert.IsInstanceOfType (typeof (DD), o, "#m1");\r
Assert.IsInstanceOfType (typeof (A), o, "#m2");\r
Assert.IsInstanceOfType (typeof (B), o, "#m3");\r
AssertHelper.IsNotInstanceOfType (typeof (CC), !(o is CC), "#m4");\r
\r
- o = RemotingServices.Connect (typeof (A), "tcp://localhost:3434/ff3.rem");\r
+ o = RemotingServices.Connect (typeof (A), $"tcp://localhost:{port}/ff3.rem");\r
Assert.IsInstanceOfType (typeof (DD), o, "#a1");\r
Assert.IsInstanceOfType (typeof (A), o, "#a2");\r
Assert.IsInstanceOfType (typeof (B), o, "#a3");\r
AssertHelper.IsNotInstanceOfType (typeof (CC), o, "#a4");\r
\r
- o = RemotingServices.Connect (typeof (DD), "tcp://localhost:3434/ff4.rem");\r
+ o = RemotingServices.Connect (typeof (DD), $"tcp://localhost:{port}/ff4.rem");\r
Assert.IsInstanceOfType (typeof (DD), o, "#d1");\r
Assert.IsInstanceOfType (typeof (A), o, "#d2");\r
Assert.IsInstanceOfType (typeof (B), o, "#d3");\r
AssertHelper.IsNotInstanceOfType (typeof (CC), o, "#d4");\r
\r
- o = RemotingServices.Connect (typeof (CC), "tcp://localhost:3434/ff5.rem");\r
+ o = RemotingServices.Connect (typeof (CC), $"tcp://localhost:{port}/ff5.rem");\r
AssertHelper.IsNotInstanceOfType (typeof (DD), o, "#c1");\r
Assert.IsInstanceOfType (typeof (A), o, "#c2");\r
Assert.IsInstanceOfType (typeof (B), o, "#c3");\r
using NUnit.Framework;
+using MonoTests.Helpers;
+
namespace MonoTests.Remoting
{
[TestFixture]
MarshalObject marshal = new MarshalObject ();
+ var port = NetworkHelpers.FindFreePort ();
IDictionary props = new Hashtable ();
props ["name"] = "marshal channel";
- props ["port"] = 1236;
+ props ["port"] = port;
props ["bindTo"] = IPAddress.Loopback.ToString ();
chn = new TcpChannel (props, null, null);
urls = chn.GetUrlsForUri (SERVICE_URI);
Assert.IsNotNull (urls, "#A2");
Assert.AreEqual (1, urls.Length, "#A3");
- Assert.AreEqual ("tcp://" + IPAddress.Loopback.ToString () + ":1236/" + SERVICE_URI, urls [0], "#A6");
+ Assert.AreEqual ($"tcp://{IPAddress.Loopback.ToString ()}:{port}/{SERVICE_URI}", urls [0], "#A6");
ds = chn.ChannelData as ChannelDataStore;
Assert.IsNotNull (ds, "#A4");
Assert.AreEqual (1, ds.ChannelUris.Length, "#A5");
- Assert.AreEqual ("tcp://" + IPAddress.Loopback.ToString () + ":1236", ds.ChannelUris [0], "#A6");
+ Assert.AreEqual ($"tcp://{IPAddress.Loopback.ToString ()}:{port}", ds.ChannelUris [0], "#A6");
ChannelServices.UnregisterChannel (chn);
using System.ServiceModel.Web;
using NUnit.Framework;
+using MonoTests.Helpers;
+
namespace MonoTests.System.ServiceModel.Activation
{
class MyHostFactory : WebScriptServiceHostFactory
[Test]
public void CreateServiceHost ()
{
+ var port = NetworkHelpers.FindFreePort ();
var f = new MyHostFactory ();
- var host = f.DoCreateServiceHost (typeof (TestService), new Uri [] {new Uri ("http://localhost:37564")});
+ var host = f.DoCreateServiceHost (typeof (TestService), new Uri [] {new Uri ($"http://localhost:{port}")});
Assert.IsFalse (host is WebServiceHost, "#1");
host.Open ();
host.Close ();
[ExpectedException (typeof (NotSupportedException))]
public void ResponseWrappedIsInvalid ()
{
+ var port = NetworkHelpers.FindFreePort ();
var f = new MyHostFactory ();
- var host = f.DoCreateServiceHost (typeof (TestService2), new Uri [] {new Uri ("http://localhost:37564")});
+ var host = f.DoCreateServiceHost (typeof (TestService2), new Uri [] {new Uri ($"http://localhost:{port}")});
host.Open (); // should raise an error here.
}
[ExpectedException (typeof (InvalidOperationException))]
public void MultipleContract ()
{
+ var port = NetworkHelpers.FindFreePort ();
var f = new MyHostFactory ();
- var host = f.DoCreateServiceHost (typeof (TestServiceMultiple), new Uri [] {new Uri ("http://localhost:37564")});
+ var host = f.DoCreateServiceHost (typeof (TestServiceMultiple), new Uri [] {new Uri ($"http://localhost:{port}")});
host.Open ();
}
public class CustomPeerResolverService : IPeerResolverContract
{
static ServiceHost localhost;
+ static int port;
static void SetupCustomPeerResolverServiceHost ()
{
+ string customPort = Environment.GetEnvironmentVariable ("MONO_CUSTOMPEERRESOLVERSERVICE_PORT");
+ if (customPort == null || !int.TryParse (customPort, out port))
+ port = 8931;
+
// launch peer resolver service locally only when it does not seem to be running ...
- var t = new TcpListener (8931);
+ var t = new TcpListener (port);
try {
t.Start ();
t.Stop ();
Console.WriteLine ("WARNING: it is running peer resolver service locally. This means, the node registration is valid only within this application domain...");
var host = new ServiceHost (new LocalPeerResolverService (TextWriter.Null));
host.Description.Behaviors.Find<ServiceBehaviorAttribute> ().InstanceContextMode = InstanceContextMode.Single;
- host.AddServiceEndpoint (typeof (ICustomPeerResolverContract), new BasicHttpBinding (), "http://localhost:8931");
+ host.AddServiceEndpoint (typeof (ICustomPeerResolverContract), new BasicHttpBinding (), $"http://localhost:{port}");
localhost = host;
host.Open ();
}
public CustomPeerResolverService ()
{
- client = ChannelFactory<ICustomPeerResolverClient>.CreateChannel (new BasicHttpBinding (), new EndpointAddress ("http://localhost:8931"));
+ client = ChannelFactory<ICustomPeerResolverClient>.CreateChannel (new BasicHttpBinding (), new EndpointAddress ($"http://localhost:{port}"));
refresh_interval = new TimeSpan (0, 10, 0);
cleanup_interval = new TimeSpan (0, 1, 0);
using System.ServiceModel.Dispatcher;
using System.Collections.ObjectModel;
+using MonoTests.Helpers;
+
namespace MonoTests.Features
{
public class Configuration
{
static Configuration() {
+ var port = NetworkHelpers.FindFreePort ();
onlyServers = Boolean.Parse (ConfigurationManager.AppSettings ["onlyServers"] ?? "false");
onlyClients = Boolean.Parse (ConfigurationManager.AppSettings ["onlyClients"] ?? "false");
- endpointBase = ConfigurationManager.AppSettings ["endpointBase"] ?? "http://localhost:9999/";
+ endpointBase = ConfigurationManager.AppSettings ["endpointBase"] ?? $"http://localhost:{port}/";
if (!endpointBase.EndsWith ("/"))
endpointBase = endpointBase + '/';
logMessages = Boolean.Parse (ConfigurationManager.AppSettings ["logMessages"] ?? "false");
using NUnit.Framework;
+using MonoTests.Helpers;
+
namespace MonoTests.System.ServiceModel.PeerResolvers
{
[TestFixture]
[SetUp]
protected void SetUp ()
{
+ var port = NetworkHelpers.FindFreePort ();
+ Environment.SetEnvironmentVariable ("MONO_CUSTOMPEERRESOLVERSERVICE_PORT", port.ToString ());
cprs = new CustomPeerResolverService ();
}
public override void Shutdown ()
{
- if (Interlocked.Exchange (ref pendingIO, 1) == 1)
- throw new InvalidOperationException ();
-
- Debug ("Shutdown");
-
- lastException = null;
-
- try {
- if (closed || disposed)
- return;
-
- var status = SSLClose (Handle);
- Debug ("Shutdown done: {0}", status);
- CheckStatusAndThrow (status);
- } finally {
- closed = true;
- pendingIO = 0;
- }
+ closed = true;
}
#endregion
get { return true; }
}
+ internal override bool SupportsCleanShutdown {
+ get { return false; }
+ }
+
public override SslProtocols SupportedProtocols {
get { return SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; }
}
public override void Shutdown ()
{
Debug ("Shutdown!");
-// ssl.SetQuietShutdown ();
+ if (Settings == null || !Settings.SendCloseNotify)
+ ssl.SetQuietShutdown ();
ssl.Shutdown ();
}
get { return true; }
}
+ internal override bool SupportsCleanShutdown {
+ get { return true; }
+ }
+
public override SslProtocols SupportedProtocols {
get { return SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; }
}
RunSynchronously = sync;
}
- [SD.Conditional ("MARTIN_DEBUG")]
+ [SD.Conditional ("MONO_TLS_DEBUG")]
protected void Debug (string message, params object[] args)
{
Parent.Debug ("{0}({1}:{2}): {3}", Name, Parent.ID, ID, string.Format (message, args));
if (Interlocked.Exchange (ref WriteRequested, 0) != 0) {
// Flush the write queue.
+ Debug ("ProcessOperation - flushing write queue");
await Parent.InnerWrite (RunSynchronously, cancellationToken);
}
get { return false; }
}
+ internal override bool SupportsCleanShutdown {
+ get { return false; }
+ }
+
public override SslProtocols SupportedProtocols {
get { return SslProtocols.Tls; }
}
static int nextId;
internal readonly int ID = ++nextId;
- [SD.Conditional ("MARTIN_DEBUG")]
+ [SD.Conditional ("MONO_TLS_DEBUG")]
protected internal void Debug (string message, params object[] args)
{
- Console.Error.WriteLine ("MobileAuthenticatedStream({0}): {1}", ID, string.Format (message, args));
+ MonoTlsProviderFactory.Debug ("MobileAuthenticatedStream({0}): {1}", ID, string.Format (message, args));
}
#region Called back from native code via SslConnection
get { return parent.Provider; }
}
- [SD.Conditional ("MARTIN_DEBUG")]
+ [SD.Conditional ("MONO_TLS_DEBUG")]
protected void Debug (string message, params object[] args)
{
- Console.Error.WriteLine ("{0}: {1}", GetType ().Name, string.Format (message, args));
+ parent.Debug ("{0}: {1}", GetType ().Name, string.Format (message, args));
}
public abstract bool HasContext {
using System;
using System.Net;
+using System.Diagnostics;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
}
}
+ static bool enableDebug;
+
+ [Conditional ("MONO_TLS_DEBUG")]
+ static void InitializeDebug ()
+ {
+ if (Environment.GetEnvironmentVariable ("MONO_TLS_DEBUG") != null)
+ enableDebug = true;
+ }
+
+ [Conditional ("MONO_TLS_DEBUG")]
+ internal static void Debug (string message, params object[] args)
+ {
+ if (enableDebug)
+ Console.Error.WriteLine (message, args);
+ }
+
#endregion
internal static readonly Guid AppleTlsId = new Guid ("981af8af-a3a3-419a-9f01-a518e3a17c1c");
lock (locker) {
if (providerRegistration != null)
return;
+
+ InitializeDebug ();
+
providerRegistration = new Dictionary<string,Tuple<Guid,string>> ();
providerCache = new Dictionary<Guid,MSI.MonoTlsProvider> ();
<Compile Include="Mono.Btls\MonoBtlsSsl.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsSslCtx.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsSslError.cs" />\r
+ <Compile Include="Mono.Btls\MonoBtlsSslRenegotiateMode.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsStream.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsUtils.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsX509.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsSsl.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsSslCtx.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsSslError.cs" />\r
+ <Compile Include="Mono.Btls\MonoBtlsSslRenegotiateMode.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsStream.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsUtils.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsX509.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsSsl.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsSslCtx.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsSslError.cs" />\r
+ <Compile Include="Mono.Btls\MonoBtlsSslRenegotiateMode.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsStream.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsUtils.cs" />\r
<Compile Include="Mono.Btls\MonoBtlsX509.cs" />\r
ThrowIfBufferOutOfRange (buffer, offset, size);
int nativeError;
- int ret = Receive_internal (m_Handle, buffer, offset, size, socketFlags, out nativeError, is_blocking);
+ int ret;
+ unsafe {
+ fixed (byte* pbuffer = buffer) {
+ ret = Receive_internal (m_Handle, &pbuffer[offset], size, socketFlags, out nativeError, is_blocking);
+ }
+ }
errorCode = (SocketError) nativeError;
if (errorCode != SocketError.Success && errorCode != SocketError.WouldBlock && errorCode != SocketError.InProgress) {
int nativeError;
int ret;
- /* Only example I can find of sending a byte array reference directly into an internal
- * call is in System.Runtime.Remoting/System.Runtime.Remoting.Channels.Ipc.Win32/NamedPipeSocket.cs,
- * so taking a lead from that... */
- WSABUF[] bufarray = new WSABUF[numsegments];
GCHandle[] gch = new GCHandle[numsegments];
+ try {
+ unsafe {
+ fixed (WSABUF* bufarray = new WSABUF[numsegments]) {
+ for (int i = 0; i < numsegments; i++) {
+ ArraySegment<byte> segment = buffers[i];
- for (int i = 0; i < numsegments; i++) {
- ArraySegment<byte> segment = buffers[i];
+ if (segment.Offset < 0 || segment.Count < 0 || segment.Count > segment.Array.Length - segment.Offset)
+ throw new ArgumentOutOfRangeException ("segment");
- if (segment.Offset < 0 || segment.Count < 0 || segment.Count > segment.Array.Length - segment.Offset)
- throw new ArgumentOutOfRangeException ("segment");
+ try {} finally {
+ gch[i] = GCHandle.Alloc (segment.Array, GCHandleType.Pinned);
+ }
- gch[i] = GCHandle.Alloc (segment.Array, GCHandleType.Pinned);
- bufarray[i].len = segment.Count;
- bufarray[i].buf = Marshal.UnsafeAddrOfPinnedArrayElement (segment.Array, segment.Offset);
- }
+ bufarray[i].len = segment.Count;
+ bufarray[i].buf = Marshal.UnsafeAddrOfPinnedArrayElement (segment.Array, segment.Offset);
+ }
- try {
- ret = Receive_internal (m_Handle, bufarray, socketFlags, out nativeError, is_blocking);
+ ret = Receive_internal (m_Handle, bufarray, numsegments, socketFlags, out nativeError, is_blocking);
+ }
+ }
} finally {
for (int i = 0; i < numsegments; i++) {
if (gch[i].IsAllocated)
int total = 0;
try {
- total = Receive_internal (sockares.socket.m_Handle, sockares.Buffer, sockares.Offset, sockares.Size, sockares.SockFlags, out sockares.error, sockares.socket.is_blocking);
+ unsafe {
+ fixed (byte* pbuffer = sockares.Buffer) {
+ total = Receive_internal (sockares.socket.m_Handle, &pbuffer[sockares.Offset], sockares.Size, sockares.SockFlags, out sockares.error, sockares.socket.is_blocking);
+ }
+ }
} catch (Exception e) {
sockares.Complete (e);
return;
return sockares.Total;
}
- static int Receive_internal (SafeSocketHandle safeHandle, WSABUF[] bufarray, SocketFlags flags, out int error, bool blocking)
+ static unsafe int Receive_internal (SafeSocketHandle safeHandle, WSABUF* bufarray, int count, SocketFlags flags, out int error, bool blocking)
{
try {
safeHandle.RegisterForBlockingSyscall ();
- return Receive_internal (safeHandle.DangerousGetHandle (), bufarray, flags, out error, blocking);
+ return Receive_internal (safeHandle.DangerousGetHandle (), bufarray, count, flags, out error, blocking);
} finally {
safeHandle.UnRegisterForBlockingSyscall ();
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
- extern static int Receive_internal (IntPtr sock, WSABUF[] bufarray, SocketFlags flags, out int error, bool blocking);
+ extern static unsafe int Receive_internal (IntPtr sock, WSABUF* bufarray, int count, SocketFlags flags, out int error, bool blocking);
- static int Receive_internal (SafeSocketHandle safeHandle, byte[] buffer, int offset, int count, SocketFlags flags, out int error, bool blocking)
+ static unsafe int Receive_internal (SafeSocketHandle safeHandle, byte* buffer, int count, SocketFlags flags, out int error, bool blocking)
{
try {
safeHandle.RegisterForBlockingSyscall ();
- return Receive_internal (safeHandle.DangerousGetHandle (), buffer, offset, count, flags, out error, blocking);
+ return Receive_internal (safeHandle.DangerousGetHandle (), buffer, count, flags, out error, blocking);
} finally {
safeHandle.UnRegisterForBlockingSyscall ();
}
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- extern static int Receive_internal(IntPtr sock, byte[] buffer, int offset, int count, SocketFlags flags, out int error, bool blocking);
+ extern static unsafe int Receive_internal(IntPtr sock, byte* buffer, int count, SocketFlags flags, out int error, bool blocking);
#endregion
SocketAddress sockaddr = remoteEP.Serialize();
int nativeError;
- int cnt = ReceiveFrom_internal (m_Handle, buffer, offset, size, socketFlags, ref sockaddr, out nativeError, is_blocking);
+ int cnt;
+ unsafe {
+ fixed (byte* pbuffer = buffer) {
+ cnt = ReceiveFrom_internal (m_Handle, &pbuffer[offset], size, socketFlags, ref sockaddr, out nativeError, is_blocking);
+ }
+ }
errorCode = (SocketError) nativeError;
if (errorCode != SocketError.Success) {
- static int ReceiveFrom_internal (SafeSocketHandle safeHandle, byte[] buffer, int offset, int count, SocketFlags flags, ref SocketAddress sockaddr, out int error, bool blocking)
+ static unsafe int ReceiveFrom_internal (SafeSocketHandle safeHandle, byte* buffer, int count, SocketFlags flags, ref SocketAddress sockaddr, out int error, bool blocking)
{
try {
safeHandle.RegisterForBlockingSyscall ();
- return ReceiveFrom_internal (safeHandle.DangerousGetHandle (), buffer, offset, count, flags, ref sockaddr, out error, blocking);
+ return ReceiveFrom_internal (safeHandle.DangerousGetHandle (), buffer, count, flags, ref sockaddr, out error, blocking);
} finally {
safeHandle.UnRegisterForBlockingSyscall ();
}
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- extern static int ReceiveFrom_internal(IntPtr sock, byte[] buffer, int offset, int count, SocketFlags flags, ref SocketAddress sockaddr, out int error, bool blocking);
+ extern static unsafe int ReceiveFrom_internal(IntPtr sock, byte* buffer, int count, SocketFlags flags, ref SocketAddress sockaddr, out int error, bool blocking);
#endregion
int nativeError;
int sent = 0;
do {
- sent += Send_internal (
-m_Handle, buffer, offset + sent, size - sent, socketFlags, out nativeError, is_blocking);
+ unsafe {
+ fixed (byte *pbuffer = buffer) {
+ sent += Send_internal (m_Handle, &pbuffer[offset + sent], size - sent, socketFlags, out nativeError, is_blocking);
+ }
+ }
+
errorCode = (SocketError)nativeError;
if (errorCode != SocketError.Success && errorCode != SocketError.WouldBlock && errorCode != SocketError.InProgress) {
is_connected = false;
int nativeError;
int ret;
- WSABUF[] bufarray = new WSABUF[numsegments];
GCHandle[] gch = new GCHandle[numsegments];
+ try {
+ unsafe {
+ fixed (WSABUF* bufarray = new WSABUF[numsegments]) {
+ for(int i = 0; i < numsegments; i++) {
+ ArraySegment<byte> segment = buffers[i];
- for(int i = 0; i < numsegments; i++) {
- ArraySegment<byte> segment = buffers[i];
+ if (segment.Offset < 0 || segment.Count < 0 || segment.Count > segment.Array.Length - segment.Offset)
+ throw new ArgumentOutOfRangeException ("segment");
- if (segment.Offset < 0 || segment.Count < 0 || segment.Count > segment.Array.Length - segment.Offset)
- throw new ArgumentOutOfRangeException ("segment");
+ try {} finally {
+ gch[i] = GCHandle.Alloc (segment.Array, GCHandleType.Pinned);
+ }
- gch[i] = GCHandle.Alloc (segment.Array, GCHandleType.Pinned);
- bufarray[i].len = segment.Count;
- bufarray[i].buf = Marshal.UnsafeAddrOfPinnedArrayElement (segment.Array, segment.Offset);
- }
+ bufarray[i].len = segment.Count;
+ bufarray[i].buf = Marshal.UnsafeAddrOfPinnedArrayElement (segment.Array, segment.Offset);
+ }
- try {
- ret = Send_internal (m_Handle, bufarray, socketFlags, out nativeError, is_blocking);
- } finally {
- for(int i = 0; i < numsegments; i++) {
- if (gch[i].IsAllocated) {
- gch[i].Free ();
+ ret = Send_internal (m_Handle, bufarray, numsegments, socketFlags, out nativeError, is_blocking);
}
}
+ } finally {
+ for (int i = 0; i < numsegments; i++) {
+ if (gch[i].IsAllocated)
+ gch[i].Free();
+ }
}
errorCode = (SocketError)nativeError;
int total = 0;
try {
- total = Socket.Send_internal (sockares.socket.m_Handle, sockares.Buffer, sockares.Offset, sockares.Size, sockares.SockFlags, out sockares.error, false);
+ unsafe {
+ fixed (byte *pbuffer = sockares.Buffer) {
+ total = Socket.Send_internal (sockares.socket.m_Handle, &pbuffer[sockares.Offset], sockares.Size, sockares.SockFlags, out sockares.error, false);
+ }
+ }
} catch (Exception e) {
sockares.Complete (e);
return;
return sockares.Total;
}
- static int Send_internal (SafeSocketHandle safeHandle, WSABUF[] bufarray, SocketFlags flags, out int error, bool blocking)
+ static unsafe int Send_internal (SafeSocketHandle safeHandle, WSABUF* bufarray, int count, SocketFlags flags, out int error, bool blocking)
{
try {
safeHandle.RegisterForBlockingSyscall ();
- return Send_internal (safeHandle.DangerousGetHandle (), bufarray, flags, out error, blocking);
+ return Send_internal (safeHandle.DangerousGetHandle (), bufarray, count, flags, out error, blocking);
} finally {
safeHandle.UnRegisterForBlockingSyscall ();
}
}
[MethodImplAttribute (MethodImplOptions.InternalCall)]
- extern static int Send_internal (IntPtr sock, WSABUF[] bufarray, SocketFlags flags, out int error, bool blocking);
+ extern static unsafe int Send_internal (IntPtr sock, WSABUF* bufarray, int count, SocketFlags flags, out int error, bool blocking);
- static int Send_internal (SafeSocketHandle safeHandle, byte[] buf, int offset, int count, SocketFlags flags, out int error, bool blocking)
+ static unsafe int Send_internal (SafeSocketHandle safeHandle, byte* buffer, int count, SocketFlags flags, out int error, bool blocking)
{
try {
safeHandle.RegisterForBlockingSyscall ();
- return Send_internal (safeHandle.DangerousGetHandle (), buf, offset, count, flags, out error, blocking);
+ return Send_internal (safeHandle.DangerousGetHandle (), buffer, count, flags, out error, blocking);
} finally {
safeHandle.UnRegisterForBlockingSyscall ();
}
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- extern static int Send_internal(IntPtr sock, byte[] buf, int offset, int count, SocketFlags flags, out int error, bool blocking);
+ extern static unsafe int Send_internal(IntPtr sock, byte* buffer, int count, SocketFlags flags, out int error, bool blocking);
#endregion
throw new ArgumentNullException("remoteEP");
int error;
- int ret = SendTo_internal (m_Handle, buffer, offset, size, socketFlags, remoteEP.Serialize (), out error, is_blocking);
+ int ret;
+ unsafe {
+ fixed (byte *pbuffer = buffer) {
+ ret = SendTo_internal (m_Handle, &pbuffer[offset], size, socketFlags, remoteEP.Serialize (), out error, is_blocking);
+ }
+ }
SocketError err = (SocketError) error;
if (err != 0) {
return sockares.Total;
}
- static int SendTo_internal (SafeSocketHandle safeHandle, byte[] buffer, int offset, int count, SocketFlags flags, SocketAddress sa, out int error, bool blocking)
+ static unsafe int SendTo_internal (SafeSocketHandle safeHandle, byte* buffer, int count, SocketFlags flags, SocketAddress sa, out int error, bool blocking)
{
try {
safeHandle.RegisterForBlockingSyscall ();
- return SendTo_internal (safeHandle.DangerousGetHandle (), buffer, offset, count, flags, sa, out error, blocking);
+ return SendTo_internal (safeHandle.DangerousGetHandle (), buffer, count, flags, sa, out error, blocking);
} finally {
safeHandle.UnRegisterForBlockingSyscall ();
}
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
- extern static int SendTo_internal (IntPtr sock, byte[] buffer, int offset, int count, SocketFlags flags, SocketAddress sa, out int error, bool blocking);
+ extern static unsafe int SendTo_internal (IntPtr sock, byte* buffer, int count, SocketFlags flags, SocketAddress sa, out int error, bool blocking);
#endregion
[TestFixture]
public class SocketTest
{
- // note: also used in SocketCas tests
public const string BogusAddress = "192.168.244.244";
- public const int BogusPort = 23483;
[Test]
#if FEATURE_NO_BSD_SOCKETS
public void BogusEndConnect ()
{
IPAddress ipOne = IPAddress.Parse (BogusAddress);
- IPEndPoint ipEP = new IPEndPoint (ipOne, BogusPort);
+ IPEndPoint ipEP = new IPEndPoint (ipOne, NetworkHelpers.FindFreePort ());
Socket sock = new Socket (ipEP.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
IAsyncResult ar = sock.BeginConnect (ipEP, null, null);
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
- IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
- BogusPort);
+ IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
SocketError_event.Reset ();
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
- IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
- BogusPort);
+ IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
Assert.AreEqual (false, sock.IsBound, "IsBoundTcp #1");
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Dgram,
ProtocolType.Udp);
- IPEndPoint ep = new IPEndPoint (IPAddress.Loopback,
- BogusPort);
+ IPEndPoint ep = NetworkHelpers.LocalEphemeralEndPoint ();
Assert.AreEqual (false, sock.IsBound, "IsBoundUdp #1");
[Test]
public void BeginConnectAddressPortNull ()
{
+ var port = NetworkHelpers.FindFreePort ();
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
IPAddress ip = null;
try {
- sock.BeginConnect (ip, 1244, BCCallback,
+ sock.BeginConnect (ip, port, BCCallback,
sock);
Assert.Fail ("BeginConnectAddressPortNull #1");
} catch (ArgumentNullException) {
[ExpectedException (typeof(ObjectDisposedException))]
public void BeginConnectAddressPortClosed ()
{
+ var port = NetworkHelpers.FindFreePort ();
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
sock.Close ();
- sock.BeginConnect (ip, 1244, BCCallback, sock);
+ sock.BeginConnect (ip, port, BCCallback, sock);
}
[Test]
[Test]
public void BeginConnectMultipleNull ()
{
+ var port = NetworkHelpers.FindFreePort ();
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
IPAddress[] ips = null;
try {
- sock.BeginConnect (ips, 1246, BCCallback,
+ sock.BeginConnect (ips, port, BCCallback,
sock);
Assert.Fail ("BeginConnectMultipleNull #1");
} catch (ArgumentNullException) {
[ExpectedException (typeof(ObjectDisposedException))]
public void BeginConnectMultipleClosed ()
{
+ var port = NetworkHelpers.FindFreePort ();
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
sock.Close ();
- sock.BeginConnect (ips, 1247, BCCallback, sock);
+ sock.BeginConnect (ips, port, BCCallback, sock);
}
[Test]
[Test]
public void ConnectAddressPortNull ()
{
+ var port = NetworkHelpers.FindFreePort ();
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
IPAddress ip = null;
try {
- sock.Connect (ip, 1249);
+ sock.Connect (ip, port);
Assert.Fail ("ConnectAddressPortNull #1");
} catch (ArgumentNullException) {
} finally {
[ExpectedException (typeof(ObjectDisposedException))]
public void ConnectAddressPortClosed ()
{
+ var port = NetworkHelpers.FindFreePort ();
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
sock.Close ();
- sock.Connect (ip, 1250);
+ sock.Connect (ip, port);
}
[Test]
[Test]
public void ConnectMultipleNull ()
{
+ var port = NetworkHelpers.FindFreePort ();
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
IPAddress[] ips = null;
try {
- sock.Connect (ips, 1251);
+ sock.Connect (ips, port);
Assert.Fail ("ConnectMultipleNull #1");
} catch (ArgumentNullException) {
} finally {
[ExpectedException (typeof(ObjectDisposedException))]
public void ConnectMultipleClosed ()
{
+ var port = NetworkHelpers.FindFreePort ();
Socket sock = new Socket (AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
sock.Close ();
- sock.Connect (ips, 1252);
+ sock.Connect (ips, port);
}
[Test]
IPv6MulticastOption option = new IPv6MulticastOption (
IPAddress.Parse ("ff02::1"));
- s.Bind (new IPEndPoint (IPAddress.IPv6Any, 1902));
+ s.Bind (new IPEndPoint (IPAddress.IPv6Any, 0));
s.SetSocketOption (SocketOptionLevel.IPv6, SocketOptionName.AddMembership,
option);
s.SetSocketOption (SocketOptionLevel.IPv6, SocketOptionName.DropMembership,
#if FEATURE_NO_BSD_SOCKETS
[ExpectedException (typeof (PlatformNotSupportedException))]
#endif
+ [Ignore ("https://bugzilla.xamarin.com/show_bug.cgi?id=43172")]
public void SendAsyncFile ()
{
Socket serverSocket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
TcpClient client = new TcpClient ();
IPAddress[] ipAddresses = null;
- client.Connect (ipAddresses, 1234);
+ client.Connect (ipAddresses, NetworkHelpers.FindFreePort ());
}
[Test]
ipAddresses[0] = IPAddress.Any;
try {
- client.Connect (ipAddresses, 1234);
+ client.Connect (ipAddresses, NetworkHelpers.FindFreePort ());
Assert.Fail ("ConnectMultiAny #1");
} catch (SocketException ex) {
Assert.AreEqual (10049, ex.ErrorCode, "ConnectMultiAny #2");
ipAddresses[0] = IPAddress.Loopback;
try {
- client.Connect (ipAddresses, 1234);
+ client.Connect (ipAddresses, NetworkHelpers.FindFreePort ());
Assert.Fail ("ConnectMultiRefused #1");
} catch (SocketException ex) {
Assert.AreEqual (10061, ex.ErrorCode, "ConnectMultiRefused #2");
using NUnit.Framework;
+using MonoTests.Helpers;
+
namespace MonoTests.System.Net.Sockets {
[TestFixture]
public class UdpClientTest {
IPEndPoint localEP;
IPEndPoint clientEP;
- clientEP = new IPEndPoint (IPAddress.Loopback, 8001);
+ clientEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ());
using (MyUdpClient client = new MyUdpClient (clientEP))
{
s = client.Client;
Socket s;
IPEndPoint localEP;
- // Bug #5503
- // UDP port 0 doesn't seem to be valid.
- using (MyUdpClient client = new MyUdpClient ("127.0.0.1", 53))
+ using (MyUdpClient client = new MyUdpClient ("127.0.0.1", NetworkHelpers.FindFreePort ()))
{
s = client.Client;
Assert.IsNotNull (s, "#A:Client");
byte[] bytes = new byte[] {10, 11, 12, 13};
try {
- client.Send (bytes, bytes.Length, new IPEndPoint (IPAddress.Broadcast, 1235));
+ client.Send (bytes, bytes.Length, new IPEndPoint (IPAddress.Broadcast, NetworkHelpers.FindFreePort ()));
} finally {
client.Close ();
}
{
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0))) {
client.JoinMulticastGroup (mcast_addr);
}
}
IPAddress mcast_addr = IPAddress.Parse ("ff02::1");
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 0))) {
client.JoinMulticastGroup (mcast_addr);
}
}
#endif
public void JoinMulticastGroup1_MulticastAddr_Null ()
{
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 0))) {
try {
client.JoinMulticastGroup ((IPAddress) null);
Assert.Fail ("#1");
{
IPAddress mcast_addr = null;
- UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234));
+ UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 0));
client.Close ();
try {
client.JoinMulticastGroup (mcast_addr);
{
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0))) {
try {
client.JoinMulticastGroup (0, mcast_addr);
Assert.Fail ("#1");
IPAddress mcast_addr = IPAddress.Parse ("ff02::1");
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 0))) {
client.JoinMulticastGroup (0, mcast_addr);
}
}
#endif
public void JoinMulticastGroup2_MulticastAddr_Null ()
{
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 0))) {
try {
client.JoinMulticastGroup (0, (IPAddress) null);
Assert.Fail ("#1");
IPAddress mcast_addr = null;
- UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 1234));
+ UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 0));
client.Close ();
try {
client.JoinMulticastGroup (0, mcast_addr);
{
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0))) {
client.JoinMulticastGroup (mcast_addr, 0);
}
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0))) {
client.JoinMulticastGroup (mcast_addr, 255);
}
}
IPAddress mcast_addr = IPAddress.Parse ("ff02::1");
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 0))) {
client.JoinMulticastGroup (mcast_addr, 0);
}
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 0))) {
client.JoinMulticastGroup (mcast_addr, 255);
}
}
#endif
public void JoinMulticastGroup3_MulticastAddr_Null ()
{
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 0))) {
try {
client.JoinMulticastGroup ((IPAddress) null, int.MaxValue);
Assert.Fail ("#1");
{
IPAddress mcast_addr = null;
- UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234));
+ UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0));
client.Close ();
try {
client.JoinMulticastGroup (mcast_addr, 0);
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
IPAddress local_addr = IPAddress.Any;
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0))) {
client.JoinMulticastGroup (mcast_addr, local_addr);
}
}
IPAddress mcast_addr = IPAddress.Parse ("ff02::1");
IPAddress local_addr = IPAddress.IPv6Any;
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.IPv6Any, 0))) {
try {
client.JoinMulticastGroup (mcast_addr, local_addr);
Assert.Fail ("#1");
{
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.23");
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 0))) {
try {
client.JoinMulticastGroup (mcast_addr, (IPAddress) null);
Assert.Fail ("#1");
#endif
public void JoinMulticastGroup4_MulticastAddr_Null ()
{
- using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 1234))) {
+ using (UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Loopback, 0))) {
try {
client.JoinMulticastGroup ((IPAddress) null, IPAddress.Loopback);
Assert.Fail ("#1");
IPAddress mcast_addr = null;
IPAddress local_addr = null;
- UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 1234));
+ UdpClient client = new UdpClient (new IPEndPoint (IPAddress.Any, 0));
client.Close ();
try {
client.JoinMulticastGroup (mcast_addr, local_addr);
#endif
public void CloseInReceive ()
{
- UdpClient client = null;
- var rnd = new Random ();
- for (int i = 0, max = 5; i < max; i++) {
- int port = rnd.Next (1025, 65534);
- try {
- client = new UdpClient (port);
- break;
- } catch (Exception) {
- if (i == max - 1)
- throw;
- }
- }
+ UdpClient client = new UdpClient (NetworkHelpers.FindFreePort ());
ManualResetEvent ready = new ManualResetEvent (false);
bool got_exc = false;
#endif
public void JoinMulticastGroupWithLocal ()
{
- UdpClient client = new UdpClient (9001);
+ UdpClient client = new UdpClient (0);
IPAddress mcast_addr = IPAddress.Parse ("224.0.0.24");
IPAddress local_addr = IPAddress.Any;
IPEndPoint ep = null;
foreach (IPAddress a in addresses) {
if (a.AddressFamily == AddressFamily.InterNetwork) {
- ep = new IPEndPoint (a, 1236);
+ ep = new IPEndPoint (a, NetworkHelpers.FindFreePort ());
break;
}
}
#endif
public void BeginReceive ()
{
- UdpClient client = new UdpClient (1237);
+ var port = NetworkHelpers.FindFreePort ();
+ UdpClient client = new UdpClient (port);
BRCalledBack.Reset ();
client.BeginReceive (BRCallback, client);
- IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 1237);
+ IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, port);
byte[] send_bytes = new byte[] {10, 11, 12, 13};
client.Send (send_bytes, send_bytes.Length, ep);
#endif
public void Available ()
{
- using (UdpClient client = new UdpClient (1238)) {
- IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 1238);
+ var port = NetworkHelpers.FindFreePort ();
+ using (UdpClient client = new UdpClient (port)) {
+ IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, port);
byte[] bytes = new byte[] {10, 11, 12, 13};
int res = client.Send (bytes, bytes.Length, ep);
[Category ("NotWorking")] // Not supported on Linux
public void ExclusiveAddressUseBound ()
{
- UdpClient client = new UdpClient (1239);
+ UdpClient client = new UdpClient (0);
client.ExclusiveAddressUse = true;
if (!Socket.OSSupportsIPv6)
Assert.Ignore ("IPv6 not enabled.");
- int PORT = 9997;
- using(var udpClient = new UdpClient (PORT, AddressFamily.InterNetworkV6))
- using(var udpClient2 = new UdpClient (PORT+1, AddressFamily.InterNetworkV6))
+ int port1 = NetworkHelpers.FindFreePort ();
+ int port2 = NetworkHelpers.FindFreePort ();
+ using(var udpClient = new UdpClient (port1, AddressFamily.InterNetworkV6))
+ using(var udpClient2 = new UdpClient (port2, AddressFamily.InterNetworkV6))
{
var dataSent = new byte [] {1,2,3};
- udpClient2.SendAsync (dataSent, dataSent.Length, "::1", PORT);
+ udpClient2.SendAsync (dataSent, dataSent.Length, "::1", port1);
IPEndPoint endPoint = new IPEndPoint (IPAddress.IPv6Any, 0);
var data = udpClient.Receive (ref endPoint);
using NUnit.Framework;
using HLPC=System.Net.HttpListenerPrefixCollection;
+using MonoTests.Helpers;
+
namespace MonoTests.System.Net {
[TestFixture]
public class HttpListenerPrefixCollectionTest {
#endif
public void AddOne ()
{
+ var port = NetworkHelpers.FindFreePort ();
HttpListener listener = new HttpListener ();
HLPC coll = listener.Prefixes;
listener.Start ();
- coll.Add ("http://127.0.0.1:8181/");
+ coll.Add ($"http://127.0.0.1:{port}/");
Assert.AreEqual (1, coll.Count, "Count");
Assert.IsFalse (coll.IsReadOnly, "IsReadOnly");
Assert.IsFalse (coll.IsSynchronized, "IsSynchronized");
#endif
public void Duplicate ()
{
+ var port = NetworkHelpers.FindFreePort ();
HttpListener listener = new HttpListener ();
HLPC coll = listener.Prefixes;
- coll.Add ("http://127.0.0.1:8181/");
- coll.Add ("http://127.0.0.1:8181/");
+ coll.Add ($"http://127.0.0.1:{port}/");
+ coll.Add ($"http://127.0.0.1:{port}/");
listener.Start ();
Assert.AreEqual (1, coll.Count, "Count");
Assert.IsFalse (coll.IsReadOnly, "IsReadOnly");
+++ /dev/null
-//
-// System.Runtime.Remoting.RemotingServices NUnit V2.0 test class
-//
-// Author Jean-Marc ANDRE (jean-marc.andre@polymtl.ca)
-//
-// ToDo: I didn't write test functions for the method not yep
-// implemented by Mono
-
-using System;
-using System.Collections;
-using NUnit.Framework;
-using System.Reflection;
-using System.Runtime.Remoting;
-using System.Threading;
-using System.Runtime.Remoting.Activation;
-using System.Runtime.Remoting.Messaging;
-using System.Runtime.Remoting.Proxies;
-using System.Runtime.Remoting.Channels;
-using System.Runtime.Remoting.Channels.Tcp;
-
-namespace MonoTests.System.Runtime.Remoting.RemotingServicesInternal
-{
- // We need our own proxy to intercept messages to remote object
- // and forward them using RemotingServices.ExecuteMessage
- public class MyProxy: RealProxy
- {
- MarshalByRefObject target;
- IMessageSink _sink;
- MethodBase _mthBase;
- bool methodOverloaded = false;
-
- public MethodBase MthBase
- {
- get{ return _mthBase;}
- }
-
- public bool IsMethodOverloaded
- {
- get{return methodOverloaded;}
- }
-
- public MyProxy(Type serverType, MarshalByRefObject target): base(serverType)
- {
- this.target = target;
-
- IChannel[] registeredChannels = ChannelServices.RegisteredChannels;
- string ObjectURI;
-
- // A new IMessageSink chain has to be created
- // since the RemotingServices.GetEnvoyChainForProxy() is not yet
- // implemented.
- foreach(IChannel channel in registeredChannels)
- {
- IChannelSender channelSender = channel as IChannelSender;
- if(channelSender != null)
- {
- _sink = (IMessageSink) channelSender.CreateMessageSink(RemotingServices.GetObjectUri(target), null, out ObjectURI);
- }
- }
-
- }
-
- // Messages will be intercepted here and redirected
- // to another object.
- public override IMessage Invoke(IMessage msg)
- {
- if(msg is IConstructionCallMessage)
- {
- IActivator remActivator = (IActivator) RemotingServices.Connect(typeof(IActivator), "tcp://localhost:1234/RemoteActivationService.rem");
- IConstructionReturnMessage crm = remActivator.Activate((IConstructionCallMessage)msg);
- return crm;
- }
- else
- {
- methodOverloaded = RemotingServices.IsMethodOverloaded((IMethodMessage)msg);
-
- _mthBase = RemotingServices.GetMethodBaseFromMethodMessage((IMethodMessage)msg);
- MethodCallMessageWrapper mcm = new MethodCallMessageWrapper((IMethodCallMessage) msg);
- mcm.Uri = RemotingServices.GetObjectUri((MarshalByRefObject)target);
- MarshalByRefObject objRem = (MarshalByRefObject)Activator.CreateInstance(GetProxiedType());
- RemotingServices.ExecuteMessage((MarshalByRefObject)objRem, (IMethodCallMessage)msg);
- IMessage rtnMsg = null;
-
- try
- {
- rtnMsg = _sink.SyncProcessMessage(msg);
- }
- catch(Exception e)
- {
- Console.WriteLine(e.Message);
- }
-
- return rtnMsg;
- }
- }
- } // end MyProxy
-
- // This class is used to create "CAO"
- public class MarshalObjectFactory: MarshalByRefObject
- {
- public MarshalObject GetNewMarshalObject()
- {
- return new MarshalObject();
- }
- }
-
- // A class used by the tests
- public class MarshalObject: ContextBoundObject
- {
- public MarshalObject()
- {
-
- }
-
- public MarshalObject(int id, string uri)
- {
- this.id = id;
- this.uri = uri;
- }
- public int Id
- {
- get{return id;}
- set{id = value;}
- }
- public string Uri
- {
- get{return uri;}
- }
-
- public void Method1()
- {
- _called++;
- methodOneWay = RemotingServices.IsOneWay(MethodBase.GetCurrentMethod());
- }
-
- public void Method2()
- {
- methodOneWay = RemotingServices.IsOneWay(MethodBase.GetCurrentMethod());
- }
-
- public void Method2(int i)
- {
- methodOneWay = RemotingServices.IsOneWay(MethodBase.GetCurrentMethod());
-
- }
-
- [OneWay()]
- public void Method3()
- {
- methodOneWay = RemotingServices.IsOneWay(MethodBase.GetCurrentMethod());
-
- }
-
- public static int Called
- {
- get{return _called;}
- }
-
- public static bool IsMethodOneWay
- {
- get{return methodOneWay;}
- }
-
-
- private static int _called;
- private int id = 0;
- private string uri;
- private static bool methodOneWay = false;
- }
-
- // Another class used by the tests
- public class DerivedMarshalObject: MarshalObject
- {
- public DerivedMarshalObject(){}
-
- public DerivedMarshalObject(int id, string uri): base(id, uri) {}
- }
-} // namespace MonoTests.System.Runtime.Remoting.RemotingServicesInternal
-
-namespace MonoTests.System.Runtime.Remoting
-{
- using MonoTests.System.Runtime.Remoting.RemotingServicesInternal;
-
- // The main test class
- [TestFixture]
- public class RemotingServicesTest
- {
- private static int MarshalObjectId = 0;
-
- public RemotingServicesTest()
- {
- MarshalObjectId = 0;
- }
-
- // Helper function that create a new
- // MarshalObject with an unique ID
- private static MarshalObject NewMarshalObject()
- {
- string uri = "MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject" + MarshalObjectId.ToString();
- MarshalObject objMarshal = new MarshalObject(MarshalObjectId, uri);
-
- MarshalObjectId++;
-
- return objMarshal;
- }
-
- // Another helper function
- private DerivedMarshalObject NewDerivedMarshalObject()
- {
- string uri = "MonoTests.System.Runtime.Remoting.RemotingServicesTest.DerivedMarshalObject" + MarshalObjectId.ToString();
- DerivedMarshalObject objMarshal = new DerivedMarshalObject(MarshalObjectId, uri);
-
- MarshalObjectId++;
-
- return objMarshal;
- }
-
- // The two folling method test RemotingServices.Marshal()
- [Test]
- public void Marshal1()
- {
-
- MarshalObject objMarshal = NewMarshalObject();
- ObjRef objRef = RemotingServices.Marshal(objMarshal);
-
- Assert.IsTrue(objRef.URI != null, "#A01");
-
- MarshalObject objRem = (MarshalObject) RemotingServices.Unmarshal(objRef);
- Assert.AreEqual(objMarshal.Id, objRem.Id, "#A02");
-
- objRem.Id = 2;
- Assert.AreEqual(objMarshal.Id, objRem.Id, "#A03");
-
- // TODO: uncomment when RemotingServices.Disconnect is implemented
- //RemotingServices.Disconnect(objMarshal);
-
- objMarshal = NewMarshalObject();
-
- objRef = RemotingServices.Marshal(objMarshal, objMarshal.Uri);
-
- Assert.IsTrue(objRef.URI.EndsWith(objMarshal.Uri), "#A04");
- // TODO: uncomment when RemotingServices.Disconnect is implemented
- //RemotingServices.Disconnect(objMarshal);
- }
-
- [Test]
- public void Marshal2()
- {
- DerivedMarshalObject derivedObjMarshal = NewDerivedMarshalObject();
-
- ObjRef objRef = RemotingServices.Marshal(derivedObjMarshal, derivedObjMarshal.Uri, typeof(MarshalObject));
-
- // Check that the type of the marshaled object is MarshalObject
- Assert.IsTrue(objRef.TypeInfo.TypeName.StartsWith((typeof(MarshalObject)).ToString()), "#A05");
-
- // TODO: uncomment when RemotingServices.Disconnect is implemented
- //RemotingServices.Disconnect(derivedObjMarshal);
- }
-
- // Tests RemotingServices.GetObjectUri()
- [Test]
- public void GetObjectUri()
- {
- MarshalObject objMarshal = NewMarshalObject();
-
- Assert.IsTrue(RemotingServices.GetObjectUri(objMarshal) == null, "#A06");
-
- ObjRef objRef = RemotingServices.Marshal(objMarshal);
-
- Assert.IsTrue(RemotingServices.GetObjectUri(objMarshal) != null, "#A07");
- // TODO: uncomment when RemotingServices.Disconnect is implemented
- //RemotingServices.Disconnect(objMarshal);
- }
-
- // Tests RemotingServices.Connect
- [Test]
- public void Connect()
- {
- MarshalObject objMarshal = NewMarshalObject();
-
- IDictionary props = new Hashtable();
- props["name"] = objMarshal.Uri;
- props["port"] = 1236;
- TcpChannel chn = new TcpChannel(props, null, null);
- ChannelServices.RegisterChannel(chn);
-
- RemotingServices.Marshal(objMarshal,objMarshal.Uri);
-
- MarshalObject objRem = (MarshalObject) RemotingServices.Connect(typeof(MarshalObject), "tcp://localhost:1236/" + objMarshal.Uri);
-
- Assert.IsTrue(RemotingServices.IsTransparentProxy(objRem), "#A08");
-
- ChannelServices.UnregisterChannel(chn);
-
- // TODO: uncomment when RemotingServices.Disconnect is implemented
- //RemotingServices.Disconnect(objMarshal);
- }
-
- // Tests RemotingServices.Marshal()
- [Test]
- [ExpectedException(typeof(RemotingException))]
- public void MarshalThrowException()
- {
- MarshalObject objMarshal = NewMarshalObject();
-
- IDictionary props = new Hashtable();
- props["name"] = objMarshal.Uri;
- props["port"] = 1237;
- TcpChannel chn = new TcpChannel(props, null, null);
- ChannelServices.RegisterChannel(chn);
-
- RemotingServices.Marshal(objMarshal,objMarshal.Uri);
-
- MarshalObject objRem = (MarshalObject) RemotingServices.Connect(typeof(MarshalObject), "tcp://localhost:1237/" + objMarshal.Uri);
- // This line sould throw a RemotingException
- // It is forbidden to export an object which is not
- // a real object
- try
- {
- RemotingServices.Marshal(objRem, objMarshal.Uri);
- }
- catch(Exception e)
- {
- ChannelServices.UnregisterChannel(chn);
-
- // TODO: uncomment when RemotingServices.Disconnect is implemented
- //RemotingServices.Disconnect(objMarshal);
-
- throw e;
- }
- }
-
- // Tests RemotingServices.ExecuteMessage()
- // also tests GetMethodBaseFromMessage()
- // IsMethodOverloaded()
- [Test]
- public void ExecuteMessage()
- {
- TcpChannel chn = null;
- try
- {
- chn = new TcpChannel(1235);
- ChannelServices.RegisterChannel(chn);
-
- MarshalObject objMarshal = NewMarshalObject();
- RemotingConfiguration.RegisterWellKnownServiceType(typeof(MarshalObject), objMarshal.Uri, WellKnownObjectMode.SingleCall);
-
- // use a proxy to catch the Message
- MyProxy proxy = new MyProxy(typeof(MarshalObject), (MarshalObject) Activator.GetObject(typeof(MarshalObject), "tcp://localhost:1235/" + objMarshal.Uri));
-
- MarshalObject objRem = (MarshalObject) proxy.GetTransparentProxy();
-
- objRem.Method1();
-
- // Tests RemotingServices.GetMethodBaseFromMethodMessage()
- AssertEquals("#A09","Method1",proxy.MthBase.Name);
- Assert.IsTrue(!proxy.IsMethodOverloaded, "#A09.1");
-
- objRem.Method2();
- Assert.IsTrue(proxy.IsMethodOverloaded, "#A09.2");
-
- // Tests RemotingServices.ExecuteMessage();
- // If ExecuteMessage does it job well, Method1 should be called 2 times
- Assert.AreEqual(2, MarshalObject.Called, "#A10");
- }
- finally
- {
- if(chn != null) ChannelServices.UnregisterChannel(chn);
- }
- }
-
- // Tests the IsOneWay method
- [Test]
- public void IsOneWay()
- {
- TcpChannel chn = null;
- try
- {
- chn = new TcpChannel(1238);
- ChannelServices.RegisterChannel(chn);
- RemotingConfiguration.RegisterWellKnownServiceType(typeof(MarshalObject), "MarshalObject.rem", WellKnownObjectMode.Singleton);
-
- MarshalObject objRem = (MarshalObject) Activator.GetObject(typeof(MarshalObject), "tcp://localhost:1238/MarshalObject.rem");
-
- Assert.IsTrue(RemotingServices.IsTransparentProxy(objRem), "#A10.1");
-
- objRem.Method1();
- Thread.Sleep(20);
- Assert.IsTrue(!MarshalObject.IsMethodOneWay, "#A10.2");
- objRem.Method3();
- Thread.Sleep(20);
- Assert.IsTrue(MarshalObject.IsMethodOneWay, "#A10.2");
- }
- finally
- {
- if(chn != null) ChannelServices.UnregisterChannel(chn);
- }
- }
-
- [Test]
- public void GetObjRefForProxy()
- {
- TcpChannel chn = null;
- try
- {
- chn = new TcpChannel(1239);
- ChannelServices.RegisterChannel(chn);
-
- // Register le factory as a SAO
- RemotingConfiguration.RegisterWellKnownServiceType(typeof(MarshalObjectFactory), "MonoTests.System.Runtime.Remoting.RemotingServicesTest.Factory.soap", WellKnownObjectMode.Singleton);
-
- MarshalObjectFactory objFactory = (MarshalObjectFactory) Activator.GetObject(typeof(MarshalObjectFactory), "tcp://localhost:1239/MonoTests.System.Runtime.Remoting.RemotingServicesTest.Factory.soap");
-
- // Get a new "CAO"
- MarshalObject objRem = objFactory.GetNewMarshalObject();
-
- ObjRef objRefRem = RemotingServices.GetObjRefForProxy((MarshalByRefObject)objRem);
-
- Assert.IsTrue(objRefRem != null, "#A11");
- }
- finally
- {
- if(chn != null) ChannelServices.UnregisterChannel(chn);
- }
- }
-
- // Tests GetRealProxy
- [Test]
- public void GetRealProxy()
- {
- TcpChannel chn = null;
- try
- {
- chn = new TcpChannel(1241);
- ChannelServices.RegisterChannel(chn);
-
- RemotingConfiguration.RegisterWellKnownServiceType(typeof(MarshalObject), "MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject.soap", WellKnownObjectMode.Singleton);
-
- MyProxy proxy = new MyProxy(typeof(MarshalObject), (MarshalByRefObject)Activator.GetObject(typeof(MarshalObject), "tcp://localhost:1241/MonoTests.System.Runtime.Remoting.RemotingServicesTest.MarshalObject.soap"));
- MarshalObject objRem = (MarshalObject) proxy.GetTransparentProxy();
-
- RealProxy rp = RemotingServices.GetRealProxy(objRem);
-
- Assert.IsTrue(rp != null, "#A12");
- Assert.AreEqual("MonoTests.System.Runtime.Remoting.RemotingServicesInternal.MyProxy", rp.GetType().ToString(), "#A13");
- }
- finally
- {
- if(chn != null) ChannelServices.UnregisterChannel(chn);
- }
- }
-
- // Tests SetObjectUriForMarshal()
- [Test]
- public void SetObjectUriForMarshal()
- {
- TcpChannel chn = null;
- try
- {
- chn = new TcpChannel(1242);
- ChannelServices.RegisterChannel(chn);
-
- MarshalObject objRem = NewMarshalObject();
- RemotingServices.SetObjectUriForMarshal(objRem, objRem.Uri);
- RemotingServices.Marshal(objRem);
-
- objRem = (MarshalObject) Activator.GetObject(typeof(MarshalObject), "tcp://localhost:1242/"+objRem.Uri);
- Assert.IsTrue(objRem != null, "#A14");
- }
- finally
- {
- if(chn != null) ChannelServices.UnregisterChannel(chn);
- }
-
- }
-
- // Tests GetServeurTypeForUri()
- [Test]
- public void GetServeurTypeForUri()
- {
- TcpChannel chn = null;
- Type type = typeof(MarshalObject);
- try
- {
- chn = new TcpChannel(1243);
- ChannelServices.RegisterChannel(chn);
-
- MarshalObject objRem = NewMarshalObject();
- RemotingServices.SetObjectUriForMarshal(objRem, objRem.Uri);
- RemotingServices.Marshal(objRem);
-
- Type typeRem = RemotingServices.GetServerTypeForUri(RemotingServices.GetObjectUri(objRem));
- Assert.AreEqual(type, typeRem, "#A15");
- }
- finally
- {
- if(chn != null) ChannelServices.UnregisterChannel(chn);
- }
- }
-
- // Tests IsObjectOutOfDomain
- // Tests IsObjectOutOfContext
- [Test]
- public void IsObjectOutOf()
- {
- TcpChannel chn = null;
- try
- {
- chn = new TcpChannel(1245);
- ChannelServices.RegisterChannel(chn);
-
- RemotingConfiguration.RegisterWellKnownServiceType(typeof(MarshalObject), "MarshalObject.rem", WellKnownObjectMode.Singleton);
-
- MarshalObject objRem = (MarshalObject) Activator.GetObject(typeof(MarshalObject), "tcp://localhost:1245/MarshalObject.rem");
-
- Assert.IsTrue(RemotingServices.IsObjectOutOfAppDomain(objRem), "#A16");
- Assert.IsTrue(RemotingServices.IsObjectOutOfContext(objRem), "#A17");
-
- MarshalObject objMarshal = new MarshalObject();
- Assert.IsTrue(!RemotingServices.IsObjectOutOfAppDomain(objMarshal), "#A18");
- Assert.IsTrue(!RemotingServices.IsObjectOutOfContext(objMarshal), "#A19");
- }
- finally
- {
- ChannelServices.UnregisterChannel(chn);
- }
- }
- } // end class RemotingServicesTest
-} // end of namespace MonoTests.System.Runtime.Remoting.RemotingServicesTest
System.Reflection.Emit/SaveTest.cs
System.Runtime.Remoting/ContextTest.cs
System.Runtime.Remoting/RemotingConfigurationTest.cs
-System.Runtime.Remoting/RemotingServicesTest.cs
System.Runtime.Remoting/SoapServicesTest.cs
System.Runtime.Remoting/SynchronizationAttributeTest.cs
System.Runtime.Remoting.Channels/ChannelServicesTest.cs
{
while (true) {
var ep = new IPEndPoint (IPAddress.Loopback, rndPort.Next (10000, 60000));
- var socket = new Socket (ep.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
try {
- socket.Bind (ep);
- socket.Close ();
+ using (var socket = new Socket (ep.AddressFamily, SocketType.Stream, ProtocolType.Tcp)) {
+ socket.Bind (ep);
+ socket.Close ();
+ }
return ep;
} catch (SocketException) { }
}
private bool keycontainer = false;
private string keyname;
private StrongName sn;
+ bool noautoinherit;
public DriverMain (string[] args)
{
if (output_file == null)
output_file = CreateOutputFilename ();
try {
- codegen = new CodeGen (output_file, target == Target.Dll, debugging_info);
+ codegen = new CodeGen (output_file, target == Target.Dll, debugging_info, noautoinherit);
foreach (string file_path in il_file_list) {
Report.FilePath = file_path;
ProcessFile (file_path);
else
keyname = command_arg;
break;
+ case "noautoinherit":
+ noautoinherit = true;
+ break;
case "scan_only":
scan_only = true;
break;
private void Usage ()
{
- Console.WriteLine ("Mono ILasm compiler\n" +
+ Console.WriteLine ("Mono IL assembler compiler\n" +
"ilasm [options] source-files\n" +
- " --about About the Mono ILasm compiler\n" +
- " --version Print the version number of the Mono ILasm compiler\n" +
+ " --about About the Mono IL assembler compiler\n" +
+ " --version Print the version number of the compiler\n" +
" /output:file_name Specifies output file.\n" +
" /exe Compile to executable.\n" +
" /dll Compile to library.\n" +
" /debug Include debug information.\n" +
" /key:keyfile Strongname using the specified key file\n" +
" /key:@container Strongname using the specified key container\n" +
+ " /noautoinherit Disable inheriting from System.Object by default\n" +
"Options can be of the form -option or /option\n");
Environment.Exit (1);
}
private void Version ()
{
string version = System.Reflection.Assembly.GetExecutingAssembly ().GetName ().Version.ToString ();
- Console.WriteLine ("Mono ILasm compiler version {0}", version);
+ Console.WriteLine ("Mono IL assembler compiler version {0}", version);
Environment.Exit (0);
}
private string output_file;\r
private bool is_dll;\r
private bool entry_point;\r
+ bool noautoinherit;\r
\r
private Module this_module;\r
\r
- public CodeGen (string output_file, bool is_dll, bool debugging_info)\r
+ public CodeGen (string output_file, bool is_dll, bool debugging_info, bool noautoinherit)\r
{\r
this.output_file = output_file;\r
this.is_dll = is_dll;\r
-\r
+ this.noautoinherit = noautoinherit;\r
+ \r
if (debugging_info)\r
symwriter = new SymbolWriter (output_file);\r
\r
\r
typedef = new TypeDef (attr, current_namespace,\r
name, parent, impl_list, location, gen_params, outer);\r
-\r
+ typedef.NoAutoInherit = noautoinherit && parent == null;\r
type_manager[cache_name] = typedef;\r
current_customattrtarget = current_typedef = typedef;\r
current_declsectarget = typedef;\r
this.attr |= PEAPI.TypeAttr.Abstract;
}
+ public bool NoAutoInherit { get; set; }
+
public string Name {
get { return name; }
}
name_space, name);
}
}
- if (FullName == "System.Object")
+ if (FullName == "System.Object" || NoAutoInherit)
classdef.SpecialNoSuper ();
}
<ItemGroup>
<Reference Include="System" />
<Reference Include="PEAPI">
- <HintPath>..\class\lib\net_4_5\PEAPI.dll</HintPath>
+ <HintPath>..\class\lib\net_4_x\PEAPI.dll</HintPath>
</Reference>
<Reference Include="Mono.CompilerServices.SymbolWriter" />
<Reference Include="Mono.Security" />
/* Keywords */\r
%token K_AT\r
%token K_AS\r
+%token K_AGGRESSIVEINLINING\r
%token K_IMPLICITCOM\r
%token K_IMPLICITRES\r
%token K_NOAPPDOMAIN\r
| impl_attr K_SYNCHRONIZED { $$ = (ImplAttr) $1 | ImplAttr.Synchronised; }\r
| impl_attr K_NOINLINING { $$ = (ImplAttr) $1 | ImplAttr.NoInLining; }\r
| impl_attr K_NOOPTIMIZATION { $$ = (ImplAttr) $1 | ImplAttr.NoOptimization; }\r
+ | impl_attr K_AGGRESSIVEINLINING{ $$ = (ImplAttr) $1 | ImplAttr.AggressiveInlining; }\r
;\r
\r
sig_args : /* EMPTY */\r
keywords ["legacy"] = new ILToken (Token.K_LEGACY, "legacy");\r
keywords ["library"] = new ILToken (Token.K_LIBRARY, "library");\r
keywords ["auto"] = new ILToken (Token.K_AUTO, "auto");\r
+ keywords ["aggressiveinlining"] = new ILToken (Token.K_AGGRESSIVEINLINING, "aggressiveinlining");\r
\r
return keywords;\r
}\r
return 1;
}
if (sdk_path != null || runtime != null)
- Error ("You can not specify one of --runtime, --sdk or --cross");
+ Error ("You can only specify one of --runtime, --sdk or --cross");
custom_mode = false;
autodeps = true;
cross_target = args [++i];
autodeps = true;
sdk_path = args [++i];
if (cross_target != null || runtime != null)
- Error ("You can not specify one of --runtime, --sdk or --cross");
+ Error ("You can only specify one of --runtime, --sdk or --cross");
break;
case "--runtime":
if (i+1 == top){
return false;
}
maker.Add (code, file);
+ // add a space after code (="systemconfig:" or "machineconfig:")
+ Console.WriteLine (code + " " + file);
return true;
}
Console.WriteLine (" Assembly: " + fname);
if (File.Exists (fname + ".config")){
maker.Add ("config:" + aname, fname + ".config");
- Console.WriteLine (" Config: " + runtime);
+ Console.WriteLine (" Config: " + fname + ".config");
}
}
if (!MaybeAddFile (maker, "systemconfig:", config_file) || !MaybeAddFile (maker, "machineconfig:", machine_config_file))
return false;
- if (config_dir != null)
+ if (config_dir != null){
maker.Add ("config_dir:", config_dir);
+ Console.WriteLine (" Config_dir: " + config_dir );
+ }
if (embedded_options != null)
maker.AddString ("options:", embedded_options);
if (environment.Count > 0){
../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/CommandStage.cs
../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/DelegatingTestCommand.cs
../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/ExpectedExceptionCommand.cs
+../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/FlakyTestRetriesCommand.cs
../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/ICommandDecorator.cs
../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/MaxTimeCommand.cs
../../../../external/nunit-lite/NUnitLite-1.0.0/src/framework/Internal/Commands/OneTimeSetUpCommand.cs
return mkdtemp (template_copy);
#else
- g_error("Function not supported");
+ g_error("Function mkdtemp not supported");
#endif
}
#include <errno.h>
-/*
- * Linux knows two different versions of strerror_r () that can only be distinguished
- * by using feature test macros. Please check the man pages for more details.
- */
-#if defined (_POSIX_C_SOURCE) && defined (_GNU_SOURCE)
-#if (_POSIX_C_SOURCE >= 200112L) && !_GNU_SOURCE
-#define USE_STRERROR_R_XSI
-#endif
-#endif
-
/*
* g_strndup and g_vasprintf need to allocate memory with g_malloc if
* ENABLE_OVERRIDABLE_ALLOCATORS is defined so that it can be safely freed with g_free
size_t buff_len = sizeof (tmp_buff);
buff [0] = 0;
-#ifdef USE_STRERROR_R_XSI
+#ifndef STRERROR_R_CHAR_P
int r;
while ((r = strerror_r (errnum, buff, buff_len - 1))) {
if (r != ERANGE) {
error_messages [errnum] = g_strdup (buff);
if (buff != tmp_buff)
g_free (buff);
-#else /* USE_STRERROR_R_XSI */
+#else /* STRERROR_R_CHAR_P */
buff = strerror_r (errnum, buff, buff_len);
if (!error_messages [errnum])
error_messages [errnum] = g_strdup (buff);
-#endif /* USE_STRERROR_R_XSI */
+#endif /* STRERROR_R_CHAR_P */
#else /* HAVE_STRERROR_R */
if (!error_messages [errnum])
#include <mono/utils/mono-os-mutex.h>
#include <mono/utils/mono-counters.h>
#include <mono/utils/mono-compiler.h>
+#include <mono/utils/unlocked.h>
#if HAVE_BOEHM_GC
mono_perfcounters->gc_gen0size = heap_size;
}
#endif
- InterlockedAdd64 (&gc_stats.major_gc_time, mono_100ns_ticks () - gc_start_time);
+ UnlockedAdd64 (&gc_stats.major_gc_time, mono_100ns_ticks () - gc_start_time);
mono_trace_message (MONO_TRACE_GC, "gc took %" G_GINT64_FORMAT " usecs", (mono_100ns_ticks () - gc_start_time) / 10);
break;
default:
}
void
-mono_mb_emit_cominterop_call (MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethod* method)
+mono_mb_emit_cominterop_get_function_pointer (MonoMethodBuilder *mb, MonoMethod *method)
{
#ifndef DISABLE_JIT
// get function pointer from 1st arg, the COM interface pointer
mono_mb_emit_ldarg (mb, 0);
mono_mb_emit_icon (mb, cominterop_get_com_slot_for_method (method));
mono_mb_emit_icall (mb, cominterop_get_function_pointer);
+ /* Leaves the function pointer on top of the stack */
+#endif
+}
+void
+mono_mb_emit_cominterop_call_function_pointer (MonoMethodBuilder *mb, MonoMethodSignature *sig)
+{
+#ifndef DISABLE_JIT
mono_mb_emit_byte (mb, MONO_CUSTOM_PREFIX);
mono_mb_emit_byte (mb, CEE_MONO_SAVE_LMF);
mono_mb_emit_calli (mb, sig);
#endif /* DISABLE_JIT */
}
+void
+mono_mb_emit_cominterop_call (MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethod* method)
+{
+#ifndef DISABLE_JIT
+ mono_mb_emit_cominterop_get_function_pointer (mb, method);
+
+ mono_mb_emit_cominterop_call_function_pointer (mb, sig);
+#endif /* DISABLE_JIT */
+}
+
void
mono_cominterop_emit_ptr_to_object_conv (MonoMethodBuilder *mb, MonoType *type, MonoMarshalConv conv, MonoMarshalSpec *mspec)
{
void
mono_cominterop_cleanup (void);
+void
+mono_mb_emit_cominterop_get_function_pointer (MonoMethodBuilder *mb, MonoMethod* method);
+
+void
+mono_mb_emit_cominterop_call_function_pointer (MonoMethodBuilder *mb, MonoMethodSignature *sig);
+
void
mono_mb_emit_cominterop_call (MonoMethodBuilder *mb, MonoMethodSignature *sig, MonoMethod* method);
HANDLES(ICALL(SOCK_9, "Listen_internal(intptr,int,int&)", ves_icall_System_Net_Sockets_Socket_Listen_internal))
HANDLES(ICALL(SOCK_10, "LocalEndPoint_internal(intptr,int,int&)", ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal))
HANDLES(ICALL(SOCK_11, "Poll_internal", ves_icall_System_Net_Sockets_Socket_Poll_internal))
-HANDLES(ICALL(SOCK_13, "ReceiveFrom_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress&,int&,bool)", ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal))
-HANDLES(ICALL(SOCK_11a, "Receive_internal(intptr,System.Net.Sockets.Socket/WSABUF[],System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Receive_array_internal))
-HANDLES(ICALL(SOCK_12, "Receive_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Receive_internal))
+HANDLES(ICALL(SOCK_13, "ReceiveFrom_internal(intptr,byte*,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress&,int&,bool)", ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal))
+HANDLES(ICALL(SOCK_11a, "Receive_internal(intptr,System.Net.Sockets.Socket/WSABUF*,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Receive_array_internal))
+HANDLES(ICALL(SOCK_12, "Receive_internal(intptr,byte*,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Receive_internal))
HANDLES(ICALL(SOCK_14, "RemoteEndPoint_internal(intptr,int,int&)", ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal))
HANDLES(ICALL(SOCK_15, "Select_internal(System.Net.Sockets.Socket[]&,int,int&)", ves_icall_System_Net_Sockets_Socket_Select_internal))
HANDLES(ICALL(SOCK_15a, "SendFile_internal(intptr,string,byte[],byte[],System.Net.Sockets.TransmitFileOptions,int&,bool)", ves_icall_System_Net_Sockets_Socket_SendFile_internal))
-HANDLES(ICALL(SOCK_16, "SendTo_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress,int&,bool)", ves_icall_System_Net_Sockets_Socket_SendTo_internal))
-HANDLES(ICALL(SOCK_16a, "Send_internal(intptr,System.Net.Sockets.Socket/WSABUF[],System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Send_array_internal))
-HANDLES(ICALL(SOCK_17, "Send_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Send_internal))
+HANDLES(ICALL(SOCK_16, "SendTo_internal(intptr,byte*,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress,int&,bool)", ves_icall_System_Net_Sockets_Socket_SendTo_internal))
+HANDLES(ICALL(SOCK_16a, "Send_internal(intptr,System.Net.Sockets.Socket/WSABUF*,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Send_array_internal))
+HANDLES(ICALL(SOCK_17, "Send_internal(intptr,byte*,int,System.Net.Sockets.SocketFlags,int&,bool)", ves_icall_System_Net_Sockets_Socket_Send_internal))
HANDLES(ICALL(SOCK_18, "SetSocketOption_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,object,byte[],int,int&)", ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal))
HANDLES(ICALL(SOCK_19, "Shutdown_internal(intptr,System.Net.Sockets.SocketShutdown,int&)", ves_icall_System_Net_Sockets_Socket_Shutdown_internal))
HANDLES(ICALL(SOCK_20, "Socket_internal(System.Net.Sockets.AddressFamily,System.Net.Sockets.SocketType,System.Net.Sockets.ProtocolType,int&)", ves_icall_System_Net_Sockets_Socket_Socket_internal))
register_icall (mono_marshal_free_asany, "mono_marshal_free_asany", "void object ptr int32 int32", FALSE);
register_icall (ves_icall_marshal_alloc, "ves_icall_marshal_alloc", "ptr ptr", FALSE);
register_icall (mono_marshal_free, "mono_marshal_free", "void ptr", FALSE);
- register_icall (mono_marshal_set_last_error, "mono_marshal_set_last_error", "void", FALSE);
- register_icall (mono_marshal_set_last_error_windows, "mono_marshal_set_last_error_windows", "void int32", FALSE);
+ register_icall (mono_marshal_set_last_error, "mono_marshal_set_last_error", "void", TRUE);
+ register_icall (mono_marshal_set_last_error_windows, "mono_marshal_set_last_error_windows", "void int32", TRUE);
register_icall (mono_string_utf8_to_builder, "mono_string_utf8_to_builder", "void ptr ptr", FALSE);
register_icall (mono_string_utf8_to_builder2, "mono_string_utf8_to_builder2", "object ptr", FALSE);
register_icall (mono_string_utf16_to_builder, "mono_string_utf16_to_builder", "void ptr ptr", FALSE);
int i, argnum, *tmp_locals;
int type, param_shift = 0;
int coop_gc_stack_dummy, coop_gc_var;
+#ifndef DISABLE_COM
+ int coop_cominterop_fnptr;
+#endif
memset (&m, 0, sizeof (m));
m.mb = mb;
coop_gc_stack_dummy = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
/* local 5, the local to be used when calling the suspend funcs */
coop_gc_var = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
+#ifndef DISABLE_COM
+ if (!func_param && MONO_CLASS_IS_IMPORT (mb->method->klass)) {
+ coop_cominterop_fnptr = mono_mb_add_local (mb, &mono_defaults.int_class->byval_arg);
+ }
+#endif
}
/*
mono_mb_emit_byte (mb, CEE_POP); // Result not needed yet
}
+#ifndef DISABLE_COM
+ if (!func_param && MONO_CLASS_IS_IMPORT (mb->method->klass)) {
+ mono_mb_emit_cominterop_get_function_pointer (mb, &piinfo->method);
+ mono_mb_emit_stloc (mb, coop_cominterop_fnptr);
+ }
+#endif
+
mono_mb_emit_ldloc_addr (mb, coop_gc_stack_dummy);
mono_mb_emit_icall (mb, mono_threads_enter_gc_safe_region_unbalanced);
mono_mb_emit_stloc (mb, coop_gc_var);
mono_mb_emit_calli (mb, csig);
} else if (MONO_CLASS_IS_IMPORT (mb->method->klass)) {
#ifndef DISABLE_COM
- mono_mb_emit_cominterop_call (mb, csig, &piinfo->method);
+ if (!mono_threads_is_blocking_transition_enabled ()) {
+ mono_mb_emit_cominterop_call (mb, csig, &piinfo->method);
+ } else {
+ mono_mb_emit_ldloc (mb, coop_cominterop_fnptr);
+ mono_mb_emit_cominterop_call_function_pointer (mb, csig);
+ }
#else
g_assert_not_reached ();
#endif
void
mono_marshal_set_last_error (void)
{
+ /* This icall is called just after a P/Invoke call before the P/Invoke
+ * wrapper transitions the runtime back to running mode. */
+ MONO_REQ_GC_SAFE_MODE;
#ifdef WIN32
mono_native_tls_set_value (last_error_tls_id, GINT_TO_POINTER (GetLastError ()));
#else
mono_marshal_set_last_error_windows (int error)
{
#ifdef WIN32
+ /* This icall is called just after a P/Invoke call before the P/Invoke
+ * wrapper transitions the runtime back to running mode. */
+ MONO_REQ_GC_SAFE_MODE;
mono_native_tls_set_value (last_error_tls_id, GINT_TO_POINTER (error));
#endif
}
return mono_object_domain (obj);
}
+/**
+ * mono_gchandle_new:
+ * \param obj managed object to get a handle for
+ * \param pinned whether the object should be pinned
+ * This returns a handle that wraps the object, this is used to keep a
+ * reference to a managed object from the unmanaged world and preventing the
+ * object from being disposed.
+ *
+ * If \p pinned is false the address of the object can not be obtained, if it is
+ * true the address of the object can be obtained. This will also pin the
+ * object so it will not be possible by a moving garbage collector to move the
+ * object.
+ *
+ * \returns a handle that can be used to access the object from unmanaged code.
+ */
+guint32
+mono_gchandle_new (MonoObject *obj, gboolean pinned)
+{
+ return sgen_gchandle_new (obj, pinned);
+}
+
+/**
+ * mono_gchandle_new_weakref:
+ * \param obj managed object to get a handle for
+ * \param track_resurrection Determines how long to track the object, if this is set to TRUE, the object is tracked after finalization, if FALSE, the object is only tracked up until the point of finalization.
+ *
+ * This returns a weak handle that wraps the object, this is used to
+ * keep a reference to a managed object from the unmanaged world.
+ * Unlike the \c mono_gchandle_new the object can be reclaimed by the
+ * garbage collector. In this case the value of the GCHandle will be
+ * set to zero.
+ *
+ * If \p track_resurrection is TRUE the object will be tracked through
+ * finalization and if the object is resurrected during the execution
+ * of the finalizer, then the returned weakref will continue to hold
+ * a reference to the object. If \p track_resurrection is FALSE, then
+ * the weak reference's target will become NULL as soon as the object
+ * is passed on to the finalizer.
+ *
+ * \returns a handle that can be used to access the object from
+ * unmanaged code.
+ */
+guint32
+mono_gchandle_new_weakref (GCObject *obj, gboolean track_resurrection)
+{
+ return sgen_gchandle_new_weakref (obj, track_resurrection);
+}
+
/**
* mono_gchandle_is_in_domain:
* \param gchandle a GCHandle's handle.
return domain->domain_id == gchandle_domain->domain_id;
}
+/**
+ * mono_gchandle_free:
+ * \param gchandle a GCHandle's handle.
+ *
+ * Frees the \p gchandle handle. If there are no outstanding
+ * references, the garbage collector can reclaim the memory of the
+ * object wrapped.
+ */
+void
+mono_gchandle_free (guint32 gchandle)
+{
+ sgen_gchandle_free (gchandle);
+}
+
/**
* mono_gchandle_free_domain:
* \param unloading domain that is unloading
{
}
+/**
+ * mono_gchandle_get_target:
+ * \param gchandle a GCHandle's handle.
+ *
+ * The handle was previously created by calling \c mono_gchandle_new or
+ * \c mono_gchandle_new_weakref.
+ *
+ * \returns a pointer to the \c MonoObject* represented by the handle or
+ * NULL for a collected object if using a weakref handle.
+ */
+MonoObject*
+mono_gchandle_get_target (guint32 gchandle)
+{
+ return sgen_gchandle_get_target (gchandle);
+}
+
static gpointer
null_link_if_in_domain (gpointer hidden, GCHandleType handle_type, int max_generation, gpointer user)
{
{ DRIVE_REMOTE, "ftp" },
{ DRIVE_FIXED, "hfs" },
{ DRIVE_FIXED, "apfs" },
+ { DRIVE_REMOTE, "kbfuse" },
{ DRIVE_FIXED, "msdos" },
{ DRIVE_REMOTE, "nfs" },
{ DRIVE_FIXED, "ntfs" },
#define TF_DISCONNECT 0x01
#define TF_REUSE_SOCKET 0x02
-typedef struct {
- guint32 len;
- gpointer buf;
-} WSABUF, *LPWSABUF;
-
typedef struct {
gpointer Head;
guint32 HeadLength;
}
gint32
-ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
+ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, gchar *buffer, gint32 count, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
{
int ret;
- gint32 alen;
int recvflags = 0;
gboolean interrupted;
- MonoInternalThread* curthread G_GNUC_UNUSED = mono_thread_internal_current ();
error_init (error);
*werror = 0;
- alen = mono_array_handle_length (buffer);
- if (offset > alen - count)
- return 0;
-
recvflags = convert_socketflags (flags);
if (recvflags == -1) {
*werror = WSAEOPNOTSUPP;
if (interrupted)
return 0;
- uint32_t gchandle;
- gchar *buf = MONO_ARRAY_HANDLE_PIN (buffer, gchar, offset, &gchandle);
-
- ret = mono_w32socket_recv (sock, buf, count, recvflags, blocking);
-
- mono_gchandle_free (gchandle);
+ ret = mono_w32socket_recv (sock, buffer, count, recvflags, blocking);
if (ret == SOCKET_ERROR)
*werror = mono_w32socket_get_last_error ();
}
gint32
-ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, MonoArrayHandle buffers, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
+ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, WSABUF *buffers, gint32 count, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
{
- int ret, count;
+ int ret;
gboolean interrupted;
guint32 recv;
guint32 recvflags = 0;
error_init (error);
*werror = 0;
- count = mono_array_handle_length (buffers);
-
recvflags = convert_socketflags (flags);
if (recvflags == -1) {
*werror = WSAEOPNOTSUPP;
return 0;
}
- uint32_t gchandle;
- WSABUF *wsabufs = MONO_ARRAY_HANDLE_PIN (buffers, WSABUF, 0, &gchandle);
-
- ret = mono_w32socket_recvbuffers (sock, wsabufs, count, &recv, &recvflags, NULL, NULL, blocking);
-
- mono_gchandle_free (gchandle);
+ ret = mono_w32socket_recvbuffers (sock, buffers, count, &recv, &recvflags, NULL, NULL, blocking);
if (ret == SOCKET_ERROR)
*werror = mono_w32socket_get_last_error ();
}
gint32
-ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count, gint32 flags, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error)
+ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, gchar *buffer, gint32 count, gint32 flags, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error)
{
int ret;
- gchar *buf;
- gint32 alen;
int recvflags = 0;
struct sockaddr *sa;
socklen_t sa_size;
error_init (error);
*werror = 0;
-
- alen = mono_array_handle_length (buffer);
- if (offset > alen - count)
- return 0;
sa = create_sockaddr_from_handle (sockaddr, &sa_size, werror, error);
if (*werror != 0)
return 0;
}
- uint32_t gchandle;
- buf = MONO_ARRAY_HANDLE_PIN (buffer, gchar, offset, &gchandle);
-
- ret = mono_w32socket_recvfrom (sock, buf, count, recvflags, sa, &sa_size, blocking);
-
- mono_gchandle_free (gchandle);
+ ret = mono_w32socket_recvfrom (sock, buffer, count, recvflags, sa, &sa_size, blocking);
if (ret == SOCKET_ERROR)
*werror = mono_w32socket_get_last_error ();
}
gint32
-ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
+ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, gchar *buffer, gint32 count, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
{
int ret;
- gint32 alen;
int sendflags = 0;
gboolean interrupted;
error_init (error);
*werror = 0;
- alen = mono_array_handle_length (buffer);
- if (offset > alen - count)
- return 0;
-
- LOGDEBUG (g_message("%s: alen: %d", __func__, alen));
-
LOGDEBUG (g_message("%s: Sending %d bytes", __func__, count));
sendflags = convert_socketflags (flags);
return 0;
}
- uint32_t gchandle;
- gchar *buf = MONO_ARRAY_HANDLE_PIN (buffer, gchar, offset, &gchandle);
-
- ret = mono_w32socket_send (sock, buf, count, sendflags, blocking);
-
- mono_gchandle_free (gchandle);
+ ret = mono_w32socket_send (sock, buffer, count, sendflags, blocking);
if (ret == SOCKET_ERROR)
*werror = mono_w32socket_get_last_error ();
}
gint32
-ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, MonoArrayHandle buffers, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
+ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, WSABUF *buffers, gint32 count, gint32 flags, gint32 *werror, gboolean blocking, MonoError *error)
{
- int ret, count;
+ int ret;
guint32 sent;
guint32 sendflags = 0;
gboolean interrupted;
error_init (error);
*werror = 0;
- count = mono_array_handle_length (buffers);
-
sendflags = convert_socketflags (flags);
if (sendflags == -1) {
*werror = WSAEOPNOTSUPP;
return 0;
}
- uint32_t gchandle;
- WSABUF *wsabufs = MONO_ARRAY_HANDLE_PIN (buffers, WSABUF, 0, &gchandle);
-
- ret = mono_w32socket_sendbuffers (sock, wsabufs, count, &sent, sendflags, NULL, NULL, blocking);
-
- mono_gchandle_free (gchandle);
+ ret = mono_w32socket_sendbuffers (sock, buffers, count, &sent, sendflags, NULL, NULL, blocking);
if (ret == SOCKET_ERROR)
*werror = mono_w32socket_get_last_error ();
}
gint32
-ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count, gint32 flags, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error)
+ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, gchar *buffer, gint32 count, gint32 flags, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error)
{
int ret;
- gint32 alen;
int sendflags = 0;
struct sockaddr *sa;
socklen_t sa_size;
gboolean interrupted;
*werror = 0;
-
- alen = mono_array_handle_length (buffer);
- if (offset > alen - count) {
- return 0;
- }
sa = create_sockaddr_from_handle (sockaddr, &sa_size, werror, error);
if (*werror != 0)
return 0;
return_val_if_nok (error, 0);
- LOGDEBUG (g_message ("%s: alen: %d", __func__, alen));
-
LOGDEBUG (g_message("%s: Sending %d bytes", __func__, count));
sendflags = convert_socketflags (flags);
return 0;
}
- uint32_t gchandle;
- gchar *buf = MONO_ARRAY_HANDLE_PIN (buffer, gchar, offset, &gchandle);
-
- ret = mono_w32socket_sendto (sock, buf, count, sendflags, sa, sa_size, blocking);
-
- mono_gchandle_free (gchandle);
+ ret = mono_w32socket_sendto (sock, buffer, count, sendflags, sa, sa_size, blocking);
if (ret == SOCKET_ERROR)
*werror = mono_w32socket_get_last_error ();
#ifndef HOST_WIN32
typedef gint SOCKET;
+
+typedef struct {
+ guint32 len;
+ gpointer buf;
+} WSABUF, *LPWSABUF;
#endif
/* This is a copy of System.Net.Sockets.SocketType */
ves_icall_System_Net_Sockets_Socket_Connect_internal (gsize sock, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error);
gint32
-ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count,
+ves_icall_System_Net_Sockets_Socket_Receive_internal (gsize sock, gchar *buffer, gint32 count,
gint32 flags, gint32 *werror, gboolean blocking, MonoError *error);
gint32
-ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, MonoArrayHandle buffers, gint32 flags,
+ves_icall_System_Net_Sockets_Socket_Receive_array_internal (gsize sock, WSABUF *buffers, gint32 count, gint32 flags,
gint32 *werror, gboolean blocking, MonoError *error);
-/* gint32 */
-/* ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArray *buffer, gint32 offset, gint32 count, */
-/* gint32 flags, MonoObject **sockaddr, gint32 *werror, gboolean blocking); */
-
gint32
-ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count,
+ves_icall_System_Net_Sockets_Socket_ReceiveFrom_internal (gsize sock, gchar *buffer, gint32 count,
gint32 flags, MonoObjectHandle sockaddr, gint32 *werror, gboolean blocking, MonoError *error);
gint32
-ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count,
+ves_icall_System_Net_Sockets_Socket_Send_internal (gsize sock, gchar *buffer, gint32 count,
gint32 flags, gint32 *werror, gboolean blocking, MonoError *error);
gint32
-ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, MonoArrayHandle buffers, gint32 flags,
+ves_icall_System_Net_Sockets_Socket_Send_array_internal (gsize sock, WSABUF *buffers, gint32 count, gint32 flags,
gint32 *werror, gboolean blocking, MonoError *error);
gint32
-ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, MonoArrayHandle buffer, gint32 offset, gint32 count,
+ves_icall_System_Net_Sockets_Socket_SendTo_internal (gsize sock, gchar *buffer, gint32 count,
gint32 flags, MonoObjectHandle sockaddr, gint32 *werror,
gboolean blocking, MonoError *error);
long_max: dest:i src1:i src2:i len:16 clob:1
long_max_un: dest:i src1:i src2:i len:16 clob:1
-throw: src1:i len:18
-rethrow: src1:i len:18
+throw: src1:i len:24
+rethrow: src1:i len:24
start_handler: len:16
endfinally: len:9
endfilter: src1:a len:9
return;
if (agent_config.defer) {
- /* Make sure the thread id is always set when doing deferred debugging */
if (is_debugger_thread ()) {
/* Don't suspend on events from the debugger thread */
suspend_policy = SUSPEND_POLICY_NONE;
- thread = mono_thread_get_main ();
}
- else thread = mono_thread_current ();
} else {
if (is_debugger_thread () && event != EVENT_KIND_VM_DEATH)
// FIXME: Send these with a NULL thread, don't suspend the current thread
thread = NULL;
} else {
if (!thread)
- thread = mono_thread_current ();
+ thread = is_debugger_thread () ? mono_thread_get_main () : mono_thread_current ();
if (event == EVENT_KIND_VM_START && arg != NULL)
thread = (MonoThread *)arg;
return bp->method && bp->method->klass->image->assembly == assembly;
}
-static MonoObject*
-get_this (StackFrame *frame)
+static gpointer
+get_this_addr (StackFrame *frame)
{
//Logic inspiered by "add_var" method and took out path that happens in async method for getting this
MonoDebugVarInfo *var = frame->jit->this_var;
if ((var->index & MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS) != MONO_DEBUG_VAR_ADDRESS_MODE_REGOFFSET)
return NULL;
- guint8 * addr = (guint8 *)mono_arch_context_get_int_reg (&frame->ctx, var->index & ~MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS);
+ guint8 *addr = (guint8 *)mono_arch_context_get_int_reg (&frame->ctx, var->index & ~MONO_DEBUG_VAR_ADDRESS_MODE_FLAGS);
addr += (gint32)var->offset;
- return *(MonoObject**)addr;
-}
-
-//This ID is used to figure out if breakpoint hit on resumeOffset belongs to us or not
-//since thread probably changed...
-static int
-get_this_async_id (StackFrame *frame)
-{
- return get_objid (get_this (frame));
+ return addr;
}
static MonoMethod*
return set_notification_method;
}
-static void
-set_set_notification_for_wait_completion_flag (StackFrame *frame)
+static MonoMethod*
+get_object_id_for_debugger_method (MonoClass* async_builder_class)
+{
+ MonoError error;
+ GPtrArray *array = mono_class_get_methods_by_name (async_builder_class, "get_ObjectIdForDebugger", 0x24, FALSE, FALSE, &error);
+ mono_error_assert_ok (&error);
+ g_assert (array->len == 1);
+ MonoMethod *method = (MonoMethod *)g_ptr_array_index (array, 0);
+ g_ptr_array_free (array, TRUE);
+ return method;
+}
+
+/* Return the address of the AsyncMethodBuilder struct belonging to the state machine method pointed to by FRAME */
+static gpointer
+get_async_method_builder (StackFrame *frame)
{
- MonoObject* obj = get_this (frame);
- g_assert (obj);
- MonoClassField *builder_field = mono_class_get_field_from_name (obj->vtable->klass, "<>t__builder");
+ MonoObject *this_obj;
+ MonoClassField *builder_field;
+ gpointer builder;
+ guint8 *this_addr;
+
+ builder_field = mono_class_get_field_from_name (frame->method->klass, "<>t__builder");
g_assert (builder_field);
- MonoObject* builder;
+
+ this_addr = get_this_addr (frame);
+ if (!this_addr)
+ return NULL;
+
+ if (frame->method->klass->valuetype) {
+ guint8 *vtaddr = *(guint8**)this_addr;
+ builder = (char*)vtaddr + builder_field->offset - sizeof (MonoObject);
+ } else {
+ this_obj = *(MonoObject**)this_addr;
+ builder = (char*)this_obj + builder_field->offset;
+ }
+
+ return builder;
+}
+
+//This ID is used to figure out if breakpoint hit on resumeOffset belongs to us or not
+//since thread probably changed...
+static int
+get_this_async_id (StackFrame *frame)
+{
+ MonoClassField *builder_field;
+ gpointer builder;
+ MonoMethod *method;
+ MonoObject *ex;
MonoError error;
- builder = mono_field_get_value_object_checked (frame->domain, builder_field, obj, &error);
+ MonoObject *obj;
+ gboolean old_disable_breakpoints = FALSE;
+ DebuggerTlsData *tls;
+
+ /*
+ * FRAME points to a method in a state machine class/struct.
+ * Call the ObjectIdForDebugger method of the associated method builder type.
+ */
+ builder = get_async_method_builder (frame);
+ if (!builder)
+ return 0;
+
+ builder_field = mono_class_get_field_from_name (frame->method->klass, "<>t__builder");
+ g_assert (builder_field);
+
+ tls = (DebuggerTlsData *)mono_native_tls_get_value (debugger_tls_id);
+ if (tls) {
+ old_disable_breakpoints = tls->disable_breakpoints;
+ tls->disable_breakpoints = TRUE;
+ }
+
+ method = get_object_id_for_debugger_method (mono_class_from_mono_type (builder_field->type));
+ obj = mono_runtime_try_invoke (method, builder, NULL, &ex, &error);
mono_error_assert_ok (&error);
+
+ if (tls)
+ tls->disable_breakpoints = old_disable_breakpoints;
+
+ return get_objid (obj);
+}
+
+static void
+set_set_notification_for_wait_completion_flag (StackFrame *frame)
+{
+ MonoClassField *builder_field = mono_class_get_field_from_name (frame->method->klass, "<>t__builder");
+ g_assert (builder_field);
+ gpointer builder = get_async_method_builder (frame);
g_assert (builder);
void* args [1];
gboolean arg = TRUE;
+ MonoError error;
args [0] = &arg;
- mono_runtime_invoke_checked (get_set_notification_method (builder->vtable->klass), mono_object_unbox (builder), args, &error);
+ mono_runtime_invoke_checked (get_set_notification_method (mono_class_from_mono_type (builder_field->type)), builder, args, &error);
mono_error_assert_ok (&error);
- mono_field_set_value (obj, builder_field, mono_object_unbox (builder));
}
static MonoMethod* notify_debugger_of_wait_completion_method_cache = NULL;
MonoMethodSignature *sig;
guint8 **arg_buf;
void **args;
- MonoObject *this_arg, *res, *exc;
+ MonoObject *this_arg, *res, *exc = NULL;
MonoDomain *domain;
guint8 *this_buf;
#ifdef MONO_ARCH_SOFT_DEBUG_SUPPORTED
mono_stopwatch_start (&watch);
res = mono_runtime_try_invoke (m, m->klass->valuetype ? (gpointer) this_buf : (gpointer) this_arg, args, &exc, &error);
- if (exc == NULL && !mono_error_ok (&error)) {
+ if (!mono_error_ok (&error) && exc == NULL) {
exc = (MonoObject*) mono_error_convert_to_exception (&error);
} else {
mono_error_cleanup (&error); /* FIXME report error */
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
+#if LLVM_API_VERSION >= 500
+#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
+#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
+#include "llvm/ExecutionEngine/JITSymbol.h"
+#else
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
+#endif
#include <cstdlib>
class MonoLLVMJIT {
public:
/* We use our own trampoline infrastructure instead of the Orc one */
+#if LLVM_API_VERSION >= 500
+ typedef RTDyldObjectLinkingLayer ObjLayerT;
+ typedef IRCompileLayer<ObjLayerT, SimpleCompiler> CompileLayerT;
+ typedef CompileLayerT::ModuleHandleT ModuleHandleT;
+#else
typedef ObjectLinkingLayer<> ObjLayerT;
typedef IRCompileLayer<ObjLayerT> CompileLayerT;
typedef CompileLayerT::ModuleSetHandleT ModuleHandleT;
+#endif
- MonoLLVMJIT (TargetMachine *TM)
+ MonoLLVMJIT (TargetMachine *TM, MonoJitMemoryManager *mm)
+#if LLVM_API_VERSION >= 500
+ : TM(TM), ObjectLayer([=] { return std::shared_ptr<RuntimeDyld::MemoryManager> (mm); }),
+#else
: TM(TM),
- CompileLayer (ObjectLayer, SimpleCompiler (*TM)) {
+#endif
+ CompileLayer (ObjectLayer, SimpleCompiler (*TM)),
+ modules() {
}
- ModuleHandleT addModule(Module *M) {
+#if LLVM_API_VERSION >= 500
+ ModuleHandleT addModule(Function *F, std::shared_ptr<Module> M) {
+#else
+ ModuleHandleT addModule(Function *F, Module *M) {
+#endif
auto Resolver = createLambdaResolver(
[&](const std::string &Name) {
const char *name = Name.c_str ();
- if (!strcmp (name, "___bzero"))
- return RuntimeDyld::SymbolInfo((uint64_t)(gssize)(void*)bzero, (JITSymbolFlags)0);
+#if LLVM_API_VERSION >= 500
+ JITSymbolFlags flags = JITSymbolFlags ();
+#else
+ JITSymbolFlags flags = (JITSymbolFlags)0;
+#endif
+ if (!strcmp (name, "___bzero")) {
+#if LLVM_API_VERSION >= 500
+ return JITSymbol((uint64_t)(gssize)(void*)bzero, flags);
+#else
+ return RuntimeDyld::SymbolInfo((uint64_t)(gssize)(void*)bzero, flags);
+#endif
+ }
MonoDl *current;
char *err;
if (!symbol)
outs () << "R: " << Name << "\n";
assert (symbol);
- return RuntimeDyld::SymbolInfo((uint64_t)(gssize)symbol, (JITSymbolFlags)0);
+#if LLVM_API_VERSION >= 500
+ return JITSymbol((uint64_t)(gssize)symbol, flags);
+#else
+ return RuntimeDyld::SymbolInfo((uint64_t)(gssize)symbol, flags);
+#endif
},
[](const std::string &S) {
outs () << "R2: " << S << "\n";
return nullptr;
} );
+#if LLVM_API_VERSION >= 500
+ ModuleHandleT m = CompileLayer.addModule(M,
+ std::move(Resolver));
+ return m;
+#else
return CompileLayer.addModuleSet(singletonSet(M),
make_unique<MonoJitMemoryManager>(),
std::move(Resolver));
+#endif
}
std::string mangle(const std::string &Name) {
gpointer compile (Function *F, int nvars, LLVMValueRef *callee_vars, gpointer *callee_addrs, gpointer *eh_frame) {
F->getParent ()->setDataLayout (TM->createDataLayout ());
- auto ModuleHandle = addModule (F->getParent ());
-
+#if LLVM_API_VERSION >= 500
+ // Orc uses a shared_ptr to refer to modules so we have to save them ourselves to keep a ref
+ std::shared_ptr<Module> m (F->getParent ());
+ modules.push_back (m);
+ auto ModuleHandle = addModule (F, m);
+#else
+ auto ModuleHandle = addModule (F, F->getParent ());
+#endif
auto BodySym = CompileLayer.findSymbolIn(ModuleHandle, mangle (F), false);
auto BodyAddr = BodySym.getAddress();
assert (BodyAddr);
TargetMachine *TM;
ObjLayerT ObjectLayer;
CompileLayerT CompileLayer;
+ std::vector<std::shared_ptr<Module>> modules;
};
static MonoLLVMJIT *jit;
+static MonoJitMemoryManager *mono_mm;
MonoEERef
mono_llvm_create_ee (LLVMModuleProviderRef MP, AllocCodeMemoryCb *alloc_cb, FunctionEmittedCb *emitted_cb, ExceptionTableCb *exception_cb, DlSymCb *dlsym_cb, LLVMExecutionEngineRef *ee)
auto TM = EB.selectTarget ();
assert (TM);
- jit = new MonoLLVMJIT (TM);
+ mono_mm = new MonoJitMemoryManager ();
+ jit = new MonoLLVMJIT (TM, mono_mm);
return NULL;
}
amd64_call_code (code, 0);
}
else {
+ if (!no_patch && ((guint32)(code + 2 - cfg->native_code) % 8) != 0) {
+ guint32 pad_size = 8 - ((guint32)(code + 2 - cfg->native_code) % 8);
+ amd64_padding (code, pad_size);
+ g_assert ((guint64)(code + 2 - cfg->native_code) % 8 == 0);
+ }
mono_add_patch_info (cfg, code - cfg->native_code, patch_type, data);
amd64_set_reg_template (code, GP_SCRATCH_REG);
amd64_call_reg (code, GP_SCRATCH_REG);
#define PARAM_REGS 6
#define FLOAT_PARAM_REGS 8
-static AMD64_Reg_No param_regs [] = { AMD64_RDI, AMD64_RSI, AMD64_RDX, AMD64_RCX, AMD64_R8, AMD64_R9 };
+static const AMD64_Reg_No param_regs [] = {AMD64_RDI, AMD64_RSI, AMD64_RDX,
+ AMD64_RCX, AMD64_R8, AMD64_R9};
-static AMD64_Reg_No return_regs [] = { AMD64_RAX, AMD64_RDX };
+static const AMD64_Reg_No return_regs [] = {AMD64_RAX, AMD64_RDX};
#endif
typedef struct {
#include <llvm/IR/IRBuilder.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/DIBuilder.h>
+#include <llvm/IR/CallSite.h>
#include "mini-llvm-cpp.h"
LLVMValueRef ArraySize,
int alignment, const char *Name)
{
+#if LLVM_API_VERSION >= 500
+ return wrap (unwrap (builder)->Insert (new AllocaInst (unwrap (Ty), 0, unwrap (ArraySize), alignment), Name));
+#else
return wrap (unwrap (builder)->Insert (new AllocaInst (unwrap (Ty), unwrap (ArraySize), alignment), Name));
+#endif
}
LLVMValueRef
#endif
}
+#if LLVM_API_VERSION > 500
+static Attribute::AttrKind
+convert_attr (AttrKind kind)
+{
+ switch (kind) {
+ case LLVM_ATTR_NO_UNWIND:
+ return Attribute::NoUnwind;
+ case LLVM_ATTR_NO_INLINE:
+ return Attribute::NoInline;
+ case LLVM_ATTR_OPTIMIZE_FOR_SIZE:
+ return Attribute::OptimizeForSize;
+ case LLVM_ATTR_IN_REG:
+ return Attribute::InReg;
+ case LLVM_ATTR_STRUCT_RET:
+ return Attribute::StructRet;
+ case LLVM_ATTR_NO_ALIAS:
+ return Attribute::NoAlias;
+ case LLVM_ATTR_BY_VAL:
+ return Attribute::ByVal;
+ case LLVM_ATTR_UW_TABLE:
+ return Attribute::UWTable;
+ default:
+ assert (0);
+ return Attribute::NoUnwind;
+ }
+}
+#else
+static LLVMAttribute
+convert_attr (AttrKind kind)
+{
+ switch (kind) {
+ case LLVM_ATTR_NO_UNWIND:
+ return LLVMNoUnwindAttribute;
+ case LLVM_ATTR_NO_INLINE:
+ return LLVMNoInlineAttribute;
+ case LLVM_ATTR_OPTIMIZE_FOR_SIZE:
+ return LLVMOptimizeForSizeAttribute;
+ case LLVM_ATTR_IN_REG:
+ return LLVMInRegAttribute;
+ case LLVM_ATTR_STRUCT_RET:
+ return LLVMStructRetAttribute;
+ case LLVM_ATTR_NO_ALIAS:
+ return LLVMNoAliasAttribute;
+ case LLVM_ATTR_BY_VAL:
+ return LLVMByValAttribute;
+ case LLVM_ATTR_UW_TABLE:
+ return LLVMUWTable;
+ default:
+ assert (0);
+ return LLVMNoUnwindAttribute;
+ }
+}
+#endif
+
+void
+mono_llvm_add_func_attr (LLVMValueRef func, AttrKind kind)
+{
+#if LLVM_API_VERSION > 100
+ unwrap<Function> (func)->addAttribute (AttributeList::FunctionIndex, convert_attr (kind));
+#else
+ Function *Func = unwrap<Function>(func);
+ const AttributeSet PAL = Func->getAttributes();
+ AttrBuilder B(convert_attr (kind));
+ const AttributeSet PALnew =
+ PAL.addAttributes(Func->getContext(), AttributeSet::FunctionIndex,
+ AttributeSet::get(Func->getContext(),
+ AttributeSet::FunctionIndex, B));
+ Func->setAttributes(PALnew);
+#endif
+}
+
+void
+mono_llvm_add_param_attr (LLVMValueRef param, AttrKind kind)
+{
+#if LLVM_API_VERSION > 100
+ Function *func = unwrap<Argument> (param)->getParent ();
+ int n = unwrap<Argument> (param)->getArgNo ();
+ func->addParamAttr (n, convert_attr (kind));
+#else
+ Argument *A = unwrap<Argument>(param);
+ AttrBuilder B(convert_attr (kind));
+ A->addAttr(AttributeSet::get(A->getContext(), A->getArgNo() + 1, B));
+#endif
+}
+
+void
+mono_llvm_add_instr_attr (LLVMValueRef val, int index, AttrKind kind)
+{
+#if LLVM_API_VERSION > 100
+ CallSite (unwrap<Instruction> (val)).addAttribute (index, convert_attr (kind));
+#else
+ CallSite Call = CallSite(unwrap<Instruction>(val));
+ AttrBuilder B(convert_attr (kind));
+ Call.setAttributes(
+ Call.getAttributes().addAttributes(Call->getContext(), index,
+ AttributeSet::get(Call->getContext(),
+ index, B)));
+#endif
+}
+
#if LLVM_API_VERSION > 100
void*
{
DIBuilder *builder = (DIBuilder*)di_builder;
+#if LLVM_API_VERSION >= 500
+ DIFile *di_file;
+
+ di_file = builder->createFile (cu_name, dir);
+ return builder->createCompileUnit (dwarf::DW_LANG_C99, di_file, producer, true, "", 0);
+#else
return builder->createCompileUnit (dwarf::DW_LANG_C99, cu_name, dir, producer, true, "", 0);
+#endif
}
void*
LLVM_ATOMICRMW_OP_ADD = 1,
} AtomicRMWOp;
+typedef enum {
+ LLVM_ATTR_NO_UNWIND,
+ LLVM_ATTR_NO_INLINE,
+ LLVM_ATTR_OPTIMIZE_FOR_SIZE,
+ LLVM_ATTR_IN_REG,
+ LLVM_ATTR_STRUCT_RET,
+ LLVM_ATTR_NO_ALIAS,
+ LLVM_ATTR_BY_VAL,
+ LLVM_ATTR_UW_TABLE
+} AttrKind;
+
void
mono_llvm_dump_value (LLVMValueRef value);
void
mono_llvm_set_call_notail (LLVMValueRef call);
+void
+mono_llvm_add_func_attr (LLVMValueRef func, AttrKind kind);
+
+void
+mono_llvm_add_param_attr (LLVMValueRef param, AttrKind kind);
+
+void
+mono_llvm_add_instr_attr (LLVMValueRef val, int index, AttrKind kind);
+
_Unwind_Reason_Code
mono_debug_personality (int a, _Unwind_Action b,
uint64_t c, struct _Unwind_Exception *d, struct _Unwind_Context *e);
func = LLVMAddFunction (lmodule, module->get_method_symbol, LLVMFunctionType1 (rtype, LLVMInt32Type (), FALSE));
LLVMSetLinkage (func, LLVMExternalLinkage);
LLVMSetVisibility (func, LLVMHiddenVisibility);
- LLVMAddFunctionAttr (func, LLVMNoUnwindAttribute);
+ mono_llvm_add_func_attr (func, LLVM_ATTR_NO_UNWIND);
module->get_method = func;
entry_bb = LLVMAppendBasicBlock (func, "ENTRY");
func = LLVMAddFunction (lmodule, module->get_unbox_tramp_symbol, LLVMFunctionType1 (rtype, LLVMInt32Type (), FALSE));
LLVMSetLinkage (func, LLVMExternalLinkage);
LLVMSetVisibility (func, LLVMHiddenVisibility);
- LLVMAddFunctionAttr (func, LLVMNoUnwindAttribute);
+ mono_llvm_add_func_attr (func, LLVM_ATTR_NO_UNWIND);
module->get_unbox_tramp = func;
entry_bb = LLVMAppendBasicBlock (func, "ENTRY");
func = LLVMAddFunction (lmodule, "llvm_code_start", LLVMFunctionType (LLVMVoidType (), NULL, 0, FALSE));
LLVMSetLinkage (func, LLVMInternalLinkage);
- LLVMAddFunctionAttr (func, LLVMNoUnwindAttribute);
+ mono_llvm_add_func_attr (func, LLVM_ATTR_NO_UNWIND);
module->code_start = func;
entry_bb = LLVMAppendBasicBlock (func, "ENTRY");
builder = LLVMCreateBuilder ();
g_assert_not_reached ();
}
LLVMSetLinkage (func, LLVMInternalLinkage);
- LLVMAddFunctionAttr (func, LLVMNoInlineAttribute);
+ mono_llvm_add_func_attr (func, LLVM_ATTR_NO_INLINE);
mono_llvm_set_preserveall_cc (func);
entry_bb = LLVMAppendBasicBlock (func, "ENTRY");
builder = LLVMCreateBuilder ();
func = LLVMAddFunction (lmodule, "llvm_code_end", LLVMFunctionType (LLVMVoidType (), NULL, 0, FALSE));
LLVMSetLinkage (func, LLVMInternalLinkage);
- LLVMAddFunctionAttr (func, LLVMNoUnwindAttribute);
+ mono_llvm_add_func_attr (func, LLVM_ATTR_NO_UNWIND);
module->code_end = func;
entry_bb = LLVMAppendBasicBlock (func, "ENTRY");
builder = LLVMCreateBuilder ();
tramp_name = g_strdup_printf ("ut_%s", method_name);
tramp = LLVMAddFunction (ctx->module->lmodule, tramp_name, method_type);
LLVMSetLinkage (tramp, LLVMInternalLinkage);
- LLVMAddFunctionAttr (tramp, LLVMOptimizeForSizeAttribute);
- //LLVMAddFunctionAttr (tramp, LLVMNoUnwindAttribute);
+ mono_llvm_add_func_attr (tramp, LLVM_ATTR_OPTIMIZE_FOR_SIZE);
+ //mono_llvm_add_func_attr (tramp, LLVM_ATTR_NO_UNWIND);
linfo = ctx->linfo;
// FIXME: Reduce code duplication with mono_llvm_compile_method () etc.
if (!ctx->llvm_only && ctx->rgctx_arg_pindex != -1)
- LLVMAddAttribute (LLVMGetParam (tramp, ctx->rgctx_arg_pindex), LLVMInRegAttribute);
+ mono_llvm_add_param_attr (LLVMGetParam (tramp, ctx->rgctx_arg_pindex), LLVM_ATTR_IN_REG);
if (ctx->cfg->vret_addr) {
LLVMSetValueName (LLVMGetParam (tramp, linfo->vret_arg_pindex), "vret");
if (linfo->ret.storage == LLVMArgVtypeByRef) {
- LLVMAddAttribute (LLVMGetParam (tramp, linfo->vret_arg_pindex), LLVMStructRetAttribute);
- LLVMAddAttribute (LLVMGetParam (tramp, linfo->vret_arg_pindex), LLVMNoAliasAttribute);
+ mono_llvm_add_param_attr (LLVMGetParam (tramp, linfo->vret_arg_pindex), LLVM_ATTR_STRUCT_RET);
+ mono_llvm_add_param_attr (LLVMGetParam (tramp, linfo->vret_arg_pindex), LLVM_ATTR_NO_ALIAS);
}
}
}
call = LLVMBuildCall (builder, method, args, nargs, "");
if (!ctx->llvm_only && ctx->rgctx_arg_pindex != -1)
- LLVMAddInstrAttribute (call, 1 + ctx->rgctx_arg_pindex, LLVMInRegAttribute);
+ mono_llvm_add_instr_attr (call, 1 + ctx->rgctx_arg_pindex, LLVM_ATTR_IN_REG);
if (linfo->ret.storage == LLVMArgVtypeByRef)
- LLVMAddInstrAttribute (call, 1 + linfo->vret_arg_pindex, LLVMStructRetAttribute);
+ mono_llvm_add_instr_attr (call, 1 + linfo->vret_arg_pindex, LLVM_ATTR_STRUCT_RET);
// FIXME: This causes assertions in clang
//mono_llvm_set_must_tail (call);
mono_llvm_set_call_preserveall_cc (lcall);
if (cinfo->ret.storage == LLVMArgVtypeByRef)
- LLVMAddInstrAttribute (lcall, 1 + cinfo->vret_arg_pindex, LLVMStructRetAttribute);
+ mono_llvm_add_instr_attr (lcall, 1 + cinfo->vret_arg_pindex, LLVM_ATTR_STRUCT_RET);
if (!ctx->llvm_only && call->rgctx_arg_reg)
- LLVMAddInstrAttribute (lcall, 1 + cinfo->rgctx_arg_pindex, LLVMInRegAttribute);
+ mono_llvm_add_instr_attr (lcall, 1 + cinfo->rgctx_arg_pindex, LLVM_ATTR_IN_REG);
if (call->imt_arg_reg)
- LLVMAddInstrAttribute (lcall, 1 + cinfo->imt_arg_pindex, LLVMInRegAttribute);
+ mono_llvm_add_instr_attr (lcall, 1 + cinfo->imt_arg_pindex, LLVM_ATTR_IN_REG);
/* Add byval attributes if needed */
for (i = 0; i < sig->param_count; ++i) {
LLVMArgInfo *ainfo = &call->cinfo->args [i + sig->hasthis];
if (ainfo && ainfo->storage == LLVMArgVtypeByVal)
- LLVMAddInstrAttribute (lcall, 1 + ainfo->pindex, LLVMByValAttribute);
+ mono_llvm_add_instr_attr (lcall, 1 + ainfo->pindex, LLVM_ATTR_BY_VAL);
}
/*
g_assert (personality);
} else {
#if LLVM_API_VERSION > 100
- personality = ctx->module->personality;
- if (!personality) {
- LLVMTypeRef personality_type = LLVMFunctionType (LLVMInt32Type (), NULL, 0, TRUE);
- personality = LLVMAddFunction (ctx->lmodule, "mono_personality", personality_type);
- LLVMAddFunctionAttr (personality, LLVMNoUnwindAttribute);
- LLVMBasicBlockRef entry_bb = LLVMAppendBasicBlock (personality, "ENTRY");
- LLVMBuilderRef builder2 = LLVMCreateBuilder ();
- LLVMPositionBuilderAtEnd (builder2, entry_bb);
- LLVMBuildRet (builder2, LLVMConstInt (LLVMInt32Type (), 0, FALSE));
- ctx->module->personality = personality;
- LLVMDisposeBuilder (builder2);
- }
+ /* Can't cache this as each method is in its own llvm module */
+ LLVMTypeRef personality_type = LLVMFunctionType (LLVMInt32Type (), NULL, 0, TRUE);
+ personality = LLVMAddFunction (ctx->lmodule, "mono_personality", personality_type);
+ mono_llvm_add_func_attr (personality, LLVM_ATTR_NO_UNWIND);
+ LLVMBasicBlockRef entry_bb = LLVMAppendBasicBlock (personality, "ENTRY");
+ LLVMBuilderRef builder2 = LLVMCreateBuilder ();
+ LLVMPositionBuilderAtEnd (builder2, entry_bb);
+ LLVMBuildRet (builder2, LLVMConstInt (LLVMInt32Type (), 0, FALSE));
+ LLVMDisposeBuilder (builder2);
#else
static gint32 mapping_inited;
args [0] = lhs;
args [1] = rhs;
/* 0xf1 == multiply all 4 elements, add them together, and store the result to the lowest element */
+#if LLVM_API_VERSION >= 500
+ args [2] = LLVMConstInt (LLVMInt8Type (), 0xf1, FALSE);
+#else
args [2] = LLVMConstInt (LLVMInt32Type (), 0xf1, FALSE);
+#endif
values [ins->dreg] = LLVMBuildCall (builder, get_intrinsic (ctx, simd_op_to_intrins (ins->opcode)), args, 3, dname);
break;
if (cfg->compile_aot)
ctx->lmodule = ctx->module->lmodule;
else
- ctx->lmodule = LLVMModuleCreateWithName ("jit-module");
+ ctx->lmodule = LLVMModuleCreateWithName (g_strdup_printf ("jit-module-%s", cfg->method->name));
#else
ctx->lmodule = ctx->module->lmodule;
#endif
LLVMSetFunctionCallConv (method, LLVMMono1CallConv);
LLVMSetLinkage (method, LLVMPrivateLinkage);
- LLVMAddFunctionAttr (method, LLVMUWTable);
+ mono_llvm_add_func_attr (method, LLVM_ATTR_UW_TABLE);
if (cfg->compile_aot) {
LLVMSetLinkage (method, LLVMInternalLinkage);
}
if (header->num_clauses || (cfg->method->iflags & METHOD_IMPL_ATTRIBUTE_NOINLINING) || cfg->no_inline)
/* We can't handle inlined methods with clauses */
- LLVMAddFunctionAttr (method, LLVMNoInlineAttribute);
+ mono_llvm_add_func_attr (method, LLVM_ATTR_NO_INLINE);
if (linfo->rgctx_arg) {
ctx->rgctx_arg = LLVMGetParam (method, linfo->rgctx_arg_pindex);
* CC_X86_64_Mono in X86CallingConv.td.
*/
if (!ctx->llvm_only)
- LLVMAddAttribute (ctx->rgctx_arg, LLVMInRegAttribute);
+ mono_llvm_add_param_attr (ctx->rgctx_arg, LLVM_ATTR_IN_REG);
LLVMSetValueName (ctx->rgctx_arg, "rgctx");
} else {
ctx->rgctx_arg_pindex = -1;
values [cfg->vret_addr->dreg] = LLVMGetParam (method, linfo->vret_arg_pindex);
LLVMSetValueName (values [cfg->vret_addr->dreg], "vret");
if (linfo->ret.storage == LLVMArgVtypeByRef) {
- LLVMAddAttribute (LLVMGetParam (method, linfo->vret_arg_pindex), LLVMStructRetAttribute);
- LLVMAddAttribute (LLVMGetParam (method, linfo->vret_arg_pindex), LLVMNoAliasAttribute);
+ mono_llvm_add_param_attr (LLVMGetParam (method, linfo->vret_arg_pindex), LLVM_ATTR_STRUCT_RET);
+ mono_llvm_add_param_attr (LLVMGetParam (method, linfo->vret_arg_pindex), LLVM_ATTR_NO_ALIAS);
}
}
LLVMSetValueName (values [cfg->args [i + sig->hasthis]->dreg], name);
g_free (name);
if (ainfo->storage == LLVMArgVtypeByVal)
- LLVMAddAttribute (LLVMGetParam (method, pindex), LLVMByValAttribute);
+ mono_llvm_add_param_attr (LLVMGetParam (method, pindex), LLVM_ATTR_BY_VAL);
if (ainfo->storage == LLVMArgVtypeByRef) {
/* For OP_LDADDR */
ret_type = type_to_simd_type (MONO_TYPE_R4);
arg_types [0] = type_to_simd_type (MONO_TYPE_R4);
arg_types [1] = type_to_simd_type (MONO_TYPE_R4);
+#if LLVM_API_VERSION >= 500
+ arg_types [2] = LLVMInt8Type ();
+#else
arg_types [2] = LLVMInt32Type ();
+#endif
AddFunc (module, name, ret_type, arg_types, 3);
break;
#endif
#endif
error_init (error);
+ if (exc)
+ *exc = NULL;
if (obj == NULL && !(method->flags & METHOD_ATTRIBUTE_STATIC) && !method->string_ctor && (method->wrapper_type == 0)) {
g_warning ("Ignoring invocation of an instance method on a NULL instance.\n");
mono_magic_trampoline (mgreg_t *regs, guint8 *code, gpointer arg, guint8* tramp)
{
gpointer res;
+ MonoError error;
- MONO_ENTER_GC_UNSAFE_UNBALANCED;
+ MONO_REQ_GC_UNSAFE_MODE;
- MonoError error;
+ g_assert (mono_thread_is_gc_unsafe_mode ());
trampoline_calls ++;
res = common_call_trampoline (regs, code, (MonoMethod *)arg, NULL, NULL, &error);
- mono_error_set_pending_exception (&error);
-
- mono_interruption_checkpoint_from_trampoline ();
-
- MONO_EXIT_GC_UNSAFE_UNBALANCED;
+ if (!is_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ return NULL;
+ }
return res;
}
if (((code [-13] == 0x49) && (code [-12] == 0xbb)) || (code [-5] == 0xe8)) {
if (code [-5] != 0xe8) {
if (can_write) {
+ g_assert ((guint64)(orig_code - 11) % 8 == 0);
InterlockedExchangePointer ((gpointer*)(orig_code - 11), addr);
VALGRIND_DISCARD_TRANSLATIONS (orig_code - 11, sizeof (gpointer));
}
mono_profiler_printf ("\t %s", event_list [i].event_name);
mono_profiler_printf ("\t[no]alloc enable/disable recording allocation info");
- mono_profiler_printf ("\t[no]legacy enable/disable pre mono 5.4 default profiler events");
+ mono_profiler_printf ("\t[no]legacy enable/disable pre Mono 5.6 default profiler events");
mono_profiler_printf ("\tsample[-real][=FREQ] enable/disable statistical sampling of threads");
mono_profiler_printf ("\t FREQ in Hz, 100 by default");
mono_profiler_printf ("\t the -real variant uses wall clock time instead of process time");
#include <mono/utils/memcheck.h>
#include <mono/utils/mono-mmap-internals.h>
+#include <mono/utils/unlocked.h>
#undef pthread_create
#undef pthread_join
major_collector.finish_nursery_collection ();
TV_GETTIME (last_minor_collection_end_tv);
- InterlockedAdd64 (&gc_stats.minor_gc_time, TV_ELAPSED (last_minor_collection_start_tv, last_minor_collection_end_tv));
+ UnlockedAdd64 (&gc_stats.minor_gc_time, TV_ELAPSED (last_minor_collection_start_tv, last_minor_collection_end_tv));
sgen_debug_dump_heap ("minor", InterlockedRead (&gc_stats.minor_gc_count) - 1, NULL);
sgen_gray_object_queue_dispose (&gc_thread_gray_queue);
TV_GETTIME (time_end);
- InterlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (time_start, time_end));
+ UnlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (time_start, time_end));
/* FIXME: also report this to the user, preferably in gc-end. */
if (major_collector.get_and_reset_num_major_objects_marked)
num_objects_marked = major_collector.get_and_reset_num_major_objects_marked ();
TV_GETTIME (time_end);
- InterlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (time_start, time_end));
+ UnlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (time_start, time_end));
current_collection_generation = -1;
}
sgen_los_update_cardtable_mod_union ();
TV_GETTIME (total_end);
- InterlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (total_start, total_end));
+ UnlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (total_start, total_end));
}
static void
sgen_workers_stop_all_workers (GENERATION_OLD);
SGEN_TV_GETTIME (time_major_conc_collection_end);
- InterlockedAdd64 (&gc_stats.major_gc_time_concurrent, SGEN_TV_ELAPSED (time_major_conc_collection_start, time_major_conc_collection_end));
+ UnlockedAdd64 (&gc_stats.major_gc_time_concurrent, SGEN_TV_ELAPSED (time_major_conc_collection_start, time_major_conc_collection_end));
major_collector.update_cardtable_mod_union ();
sgen_los_update_cardtable_mod_union ();
sgen_gray_object_queue_dispose (&gc_thread_gray_queue);
TV_GETTIME (total_end);
- InterlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (total_start, total_end));
+ UnlockedAdd64 (&gc_stats.major_gc_time, TV_ELAPSED (total_start, total_end));
current_collection_generation = -1;
}
typedef gpointer (*SgenGCHandleIterateCallback) (gpointer hidden, GCHandleType handle_type, int max_generation, gpointer user);
+guint32 sgen_gchandle_new (GCObject *obj, gboolean pinned);
+guint32 sgen_gchandle_new_weakref (GCObject *obj, gboolean track_resurrection);
void sgen_gchandle_iterate (GCHandleType handle_type, int max_generation, SgenGCHandleIterateCallback callback, gpointer user);
void sgen_gchandle_set_target (guint32 gchandle, GCObject *obj);
void sgen_mark_normal_gc_handles (void *addr, SgenUserMarkFunc mark_func, void *gc_data);
gpointer sgen_gchandle_get_metadata (guint32 gchandle);
+GCObject *sgen_gchandle_get_target (guint32 gchandle);
+void sgen_gchandle_free (guint32 gchandle);
/* Other globals */
} SGEN_ARRAY_LIST_END_FOREACH_SLOT;
}
-/**
- * mono_gchandle_new:
- * \param obj managed object to get a handle for
- * \param pinned whether the object should be pinned
- * This returns a handle that wraps the object, this is used to keep a
- * reference to a managed object from the unmanaged world and preventing the
- * object from being disposed.
- *
- * If \p pinned is false the address of the object can not be obtained, if it is
- * true the address of the object can be obtained. This will also pin the
- * object so it will not be possible by a moving garbage collector to move the
- * object.
- *
- * \returns a handle that can be used to access the object from unmanaged code.
- */
guint32
-mono_gchandle_new (GCObject *obj, gboolean pinned)
+sgen_gchandle_new (GCObject *obj, gboolean pinned)
{
return alloc_handle (gc_handles_for_type (pinned ? HANDLE_PINNED : HANDLE_NORMAL), obj, FALSE);
}
-/**
- * mono_gchandle_new_weakref:
- * \param obj managed object to get a handle for
- * \param track_resurrection Determines how long to track the object, if this is set to TRUE, the object is tracked after finalization, if FALSE, the object is only tracked up until the point of finalization.
- *
- * This returns a weak handle that wraps the object, this is used to
- * keep a reference to a managed object from the unmanaged world.
- * Unlike the \c mono_gchandle_new the object can be reclaimed by the
- * garbage collector. In this case the value of the GCHandle will be
- * set to zero.
- *
- * If \p track_resurrection is TRUE the object will be tracked through
- * finalization and if the object is resurrected during the execution
- * of the finalizer, then the returned weakref will continue to hold
- * a reference to the object. If \p track_resurrection is FALSE, then
- * the weak reference's target will become NULL as soon as the object
- * is passed on to the finalizer.
- *
- * \returns a handle that can be used to access the object from
- * unmanaged code.
- */
guint32
-mono_gchandle_new_weakref (GCObject *obj, gboolean track_resurrection)
+sgen_gchandle_new_weakref (GCObject *obj, gboolean track_resurrection)
{
return alloc_handle (gc_handles_for_type (track_resurrection ? HANDLE_WEAK_TRACK : HANDLE_WEAK), obj, track_resurrection);
}
return obj;
}
-/**
- * mono_gchandle_get_target:
- * \param gchandle a GCHandle's handle.
- *
- * The handle was previously created by calling \c mono_gchandle_new or
- * \c mono_gchandle_new_weakref.
- *
- * \returns a pointer to the \c MonoObject* represented by the handle or
- * NULL for a collected object if using a weakref handle.
- */
GCObject*
-mono_gchandle_get_target (guint32 gchandle)
+sgen_gchandle_get_target (guint32 gchandle)
{
guint index = MONO_GC_HANDLE_SLOT (gchandle);
GCHandleType type = MONO_GC_HANDLE_TYPE (gchandle);
return mono_gchandle_slot_metadata (slot, MONO_GC_HANDLE_TYPE_IS_WEAK (type));
}
-/**
- * mono_gchandle_free:
- * \param gchandle a GCHandle's handle.
- *
- * Frees the \p gchandle handle. If there are no outstanding
- * references, the garbage collector can reclaim the memory of the
- * object wrapped.
- */
void
-mono_gchandle_free (guint32 gchandle)
+sgen_gchandle_free (guint32 gchandle)
{
guint32 index = MONO_GC_HANDLE_SLOT (gchandle);
GCHandleType type = MONO_GC_HANDLE_TYPE (gchandle);
{
return state_name (state);
}
+
+gboolean
+mono_thread_is_gc_unsafe_mode (void)
+{
+ MonoThreadInfo *cur = mono_thread_info_current ();
+
+ if (!cur)
+ return FALSE;
+
+ switch (mono_thread_info_current_state (cur)) {
+ case STATE_RUNNING:
+ case STATE_ASYNC_SUSPEND_REQUESTED:
+ case STATE_SELF_SUSPEND_REQUESTED:
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
int mono_thread_info_suspend_count (THREAD_INFO_TYPE *info);
int mono_thread_info_current_state (THREAD_INFO_TYPE *info);
const char* mono_thread_state_name (int state);
+gboolean mono_thread_is_gc_unsafe_mode (void);
gboolean mono_thread_info_in_critical_location (THREAD_INFO_TYPE *info);
gboolean mono_thread_info_begin_suspend (THREAD_INFO_TYPE *info);
g_strfreev (encodings);
if(g_utf8_validate (in, -1, NULL)) {
- gunichar2 *unires=g_utf8_to_utf16 (in, -1, NULL, (glong *)bytes, NULL);
- *bytes *= 2;
+ glong items_written;
+ gunichar2 *unires=g_utf8_to_utf16 (in, -1, NULL, &items_written, NULL);
+ items_written *= 2;
+ *bytes = items_written;
return(unires);
}
-# ------------------------------------------------------------ #
-# mono/eglib
-# ------------------------------------------------------------ #
+# --------------------------------------------------------------------------- #
+# mono/eglib #
+# --------------------------------------------------------------------------- #
+
+# ghashtable.c #
fun:monoeg_g_hash_table_iter_next
+fun:monoeg_g_hash_table_lookup_extended
+
+# sort.frag.h #
+
+fun:init_sort_info
+fun:insert_list
+fun:merge_lists
+
+# --------------------------------------------------------------------------- #
+# mono/metadata #
+# --------------------------------------------------------------------------- #
+
+# class-accessors.c #
+
+fun:mono_class_get_first_method_idx
+fun:mono_class_get_flags
+fun:mono_class_get_generic_class
+fun:mono_class_get_method_count
+fun:mono_class_get_field_count
+fun:mono_class_set_first_method_idx
+fun:mono_class_set_method_count
+
+# class-inlines.h #
+
+fun:mono_class_is_ginst
+fun:mono_class_is_gtd
-# ------------------------------------------------------------ #
-# mono/metadata
-# ------------------------------------------------------------ #
+# class-internals.h #
+
+fun:mono_class_has_parent
+fun:mono_class_has_parent_fast
# class.c #
+fun:can_access_type
+fun:inflate_generic_context
fun:inflate_generic_type
fun:init_sizes_with_info
fun:make_generic_param_class
+fun:mono_bounded_array_class_get
fun:mono_class_create_from_typedef
fun:mono_class_from_generic_parameter_internal
-fun:mono_class_get_field_count
+fun:mono_class_from_mono_type
+fun:mono_class_get_cctor
+fun:mono_class_get_inflated_method
fun:mono_class_get_method_from_name_flags
fun:mono_class_get_methods
+fun:mono_class_get_vtable_entry
fun:mono_class_has_failure
fun:mono_class_has_finalizer
fun:mono_class_inflate_generic_method_full_checked
-fun:mono_class_inflate_generic_type_no_copy
-fun:mono_class_inflate_generic_type_with_mempool
fun:mono_class_init
+fun:mono_class_instance_size
+fun:mono_class_is_assignable_from
fun:mono_class_layout_fields
fun:mono_class_setup_basic_field_info
fun:mono_class_setup_fields
+fun:mono_class_setup_interfaces
fun:mono_class_setup_methods
+fun:mono_class_setup_supertypes
fun:mono_class_setup_vtable_full
fun:mono_class_setup_vtable_general
+fun:mono_field_resolve_type
fun:mono_generic_class_get_class
fun:mono_method_get_context_general
+fun:mono_method_get_method_definition
+fun:mono_ptr_class_get
fun:mono_type_get_basic_type_from_generic
fun:mono_type_get_underlying_type
-
-# class-accessors.c #
-
-fun:mono_class_get_flags
-fun:mono_class_get_method_count
-fun:mono_class_set_method_count
-
-# class-inlines.h #
-
-fun:mono_class_is_ginst
-fun:mono_class_is_gtd
+fun:mono_type_has_exceptions
# domain.c #
fun:finalizer_thread
fun:mono_domain_finalize
fun:mono_gc_cleanup
-
-# handle.h #
-
-fun:mono_stack_mark_pop
+fun:object_register_finalizer
# handle.c #
fun:mono_handle_new
fun:mono_handle_stack_scan
+# handle.h #
+
+fun:mono_stack_mark_init
+fun:mono_stack_mark_pop
+
# icall.c #
+fun:vell_icall_get_method_attributes
+fun:ves_icall_InternalInvoke
+fun:ves_icall_RuntimeTypeHandle_IsArray
+fun:ves_icall_RuntimeType_GetConstructors_native
fun:ves_icall_System_Array_FastCopy
fun:ves_icall_System_Reflection_MonoMethodInfo_get_parameter_info
-fun:ves_icall_RuntimeType_GetConstructors_native
# image.c #
fun:jit_info_table_add
fun:jit_info_table_chunk_index
+fun:jit_info_table_copy_and_split_chunk
fun:jit_info_table_find
fun:jit_info_table_index
-fun:mono_jit_compile_method_with_opt
+fun:jit_info_table_split_chunk
fun:mono_jit_info_init
-fun:mono_jit_info_table_find_internal
# loader.c #
fun:cache_memberref_sig
-fun:mon_new
+fun:inflate_generic_signature_checked
fun:mono_get_method_from_token
fun:mono_method_get_signature_checked
fun:mono_method_signature_checked
# marshal.c #
+fun:mono_icall_start
fun:mono_marshal_get_native_wrapper
fun:mono_marshal_isinst_with_cache
# metadata.c #
-fun:img_set_cache_get
fun:_mono_metadata_generic_class_equal
+fun:collect_method_images
+fun:do_mono_metadata_parse_type
+fun:img_set_cache_get
+fun:mono_metadata_decode_row
+fun:mono_metadata_get_canonical_generic_inst
fun:mono_metadata_lookup_generic_class
+fun:mono_metadata_parse_type_internal
+fun:mono_type_get_class
fun:mono_type_get_type
fun:mono_type_is_struct
# monitor.c #
+fun:mon_new
fun:mono_monitor_ensure_owned
+fun:mono_monitor_enter_v4_fast
fun:mono_monitor_exit_inflated
+fun:mono_monitor_inflate
fun:mono_monitor_try_enter_inflated
fun:mono_monitor_try_enter_internal
fun:mono_object_hash
fun:ves_icall_System_Threading_Monitor_Monitor_pulse_all
fun:ves_icall_System_Threading_Monitor_Monitor_test_synchronised
+fun:ves_icall_System_Threading_Monitor_Monitor_try_enter_with_atomic_var
fun:ves_icall_System_Threading_Monitor_Monitor_wait
# mono-conc-hash.c #
+fun:expand_table
fun:mono_conc_g_hash_table_lookup_extended
fun:set_key
# mono-hash.c #
fun:mono_g_hash_table_find_slot
-fun:mono_g_hash_table_max_chain_length
# object.c #
fun:mono_class_compute_gc_descriptor
fun:mono_class_create_runtime_vtable
fun:mono_class_vtable_full
-fun:mono_delegate_ctor_with_method
+fun:mono_object_handle_get_virtual_method
fun:mono_object_handle_isinst
+fun:mono_object_isinst_checked
+fun:mono_object_new_alloc_specific_checked
+fun:mono_object_new_specific_checked
fun:mono_runtime_class_init_full
+fun:mono_runtime_invoke_array_checked
+fun:mono_runtime_try_invoke_array
+fun:mono_string_new_size_checked
+
+# reflection-cache.h #
+
+fun:cache_object_handle
# reflection.c #
fun:method_object_construct
fun:reflected_equal
-# reflection-cache.h #
-
-fun:cache_object_handle
-
# runtime.c #
fun:mono_runtime_is_shutting_down
fun:mono_runtime_try_shutdown
+# sgen-client-mono.h #
+
+fun:SGEN_LOAD_VTABLE_UNCHECKED
+
# sgen-mono.c #
+fun:mono_gchandle_free
fun:mono_gc_alloc_string
fun:mono_gc_alloc_vector
fun:mono_gc_thread_in_critical_region
fun:sgen_client_gchandle_created
fun:sgen_client_gchandle_destroyed
-# threadpool.c #
-
-fun:worker_callback
-
# threadpool-worker-default.c #
fun:heuristic_adjust
fun:heuristic_notify_work_completed
fun:heuristic_should_adjust
+fun:hill_climbing_change_thread_count
+fun:hill_climbing_force_change
fun:hill_climbing_update
fun:monitor_should_keep_running
fun:monitor_thread
+fun:monitor_sufficient_delay_since_last_dequeue
+
+# threadpool.c #
+
+fun:try_invoke_perform_wait_callback
+fun:worker_callback
# threads.c #
fun:create_thread
fun:mono_thread_clr_state
fun:mono_thread_detach_internal
+fun:mono_thread_set_name_internal
fun:mono_threads_add_joinable_thread
fun:mono_threads_join_threads
fun:remove_and_abort_threads
+fun:request_thread_abort
# w32handle.c #
-fun:mono_w32handle_init_handle
+fun:mono_w32handle_lookup
fun:mono_w32handle_lookup_data
+fun:mono_w32handle_new_internal
+fun:mono_w32handle_ref_core
fun:mono_w32handle_unref_core
-# ------------------------------------------------------------ #
-# mono/mini
-# ------------------------------------------------------------ #
+# --------------------------------------------------------------------------- #
+# mono/mini #
+# --------------------------------------------------------------------------- #
# alias-analysis.c #
fun:recompute_aliased_variables
-# method-to-ir.c #
+# aot-runtime.c #
-fun:mono_method_to_ir
+fun:mono_aot_get_cached_class_info
+fun:mono_aot_get_method_from_vt_slot
-# mini.c #
+# decompose.c #
-fun:mini_method_compile
-fun:mono_allocate_stack_slots
-fun:mono_jit_compile_method_inner
-fun:mono_save_seq_point_info
-fun:mono_time_track_end
-fun:mono_type_to_load_membase
+fun:mono_decompose_vtype_opts
+
+# linear-scan.c #
+
+fun:mono_linear_scan
+
+# liveness.c #
+
+fun:mono_analyze_liveness
+fun:mono_liveness_handle_exception_clauses
+
+# method-to-ir.c #
+
+fun:check_call_signature
+fun:emit_init_rvar
+fun:inline_method
+fun:mono_method_check_inlining
+fun:mono_method_to_ir
+fun:mono_spill_global_vars
# mini-amd64.c #
+fun:get_call_info
+fun:mono_arch_allocate_vars
+fun:mono_arch_emit_epilog
+fun:mono_arch_emit_prolog
fun:mono_arch_get_delegate_invoke_impl
+fun:mono_arch_lowering_pass
+fun:mono_arch_peephole_pass_2
+
+# mini-codegen.c #
+
+fun:mono_local_regalloc
+fun:mono_peephole_ins
# mini-exceptions.c #
# mini-generic-sharing.c #
+fun:alloc_template
+fun:class_get_rgctx_template_oti
+fun:get_info_templates
+fun:inflate_info
+fun:inst_check_context_used
fun:mini_get_basic_type_from_generic
fun:mini_is_gsharedvt_type
fun:mini_type_get_underlying_type
fun:mono_class_fill_runtime_generic_context
fun:mono_generic_context_check_used
fun:mono_method_check_context_used
+fun:mono_method_fill_runtime_generic_context
+fun:mono_method_get_declaring_generic_method
+fun:mono_method_is_generic_impl
+fun:mono_method_needs_static_rgctx_invoke
+fun:rgctx_template_set_slot
+fun:set_info_templates
# mini-native-types.c #
# mini-runtime.c #
+fun:create_runtime_invoke_info
+fun:mini_imt_entry_inited
+fun:mono_jit_compile_method_with_opt
fun:mono_jit_find_compiled_method_with_jit_info
+fun:mono_jit_runtime_invoke
# mini-trampolines.c #
fun:common_call_trampoline
+fun:mini_add_method_trampoline
fun:mini_resolve_imt_method
+fun:mono_create_delegate_trampoline_info
fun:mono_create_jit_trampoline
+fun:mono_create_jump_trampoline
fun:mono_delegate_trampoline
fun:mono_magic_trampoline
fun:mono_rgctx_lazy_fetch_trampoline
fun:mono_vcall_trampoline
-# ------------------------------------------------------------ #
-# mono/sgen
-# ------------------------------------------------------------ #
+# mini.c #
+
+fun:mini_method_compile
+fun:mono_allocate_stack_slots
+fun:mono_codegen
+fun:mono_compile_create_vars
+fun:mono_insert_branches_between_bblocks
+fun:mono_jit_compile_method_inner
+fun:mono_time_track_end
+fun:mono_type_to_load_membase
+fun:mono_type_to_store_membase
+
+# seq-points.c #
+
+fun:mono_save_seq_point_info
+
+# tramp-amd64.c #
+
+fun:mono_arch_patch_callsite
+
+# unwind.c #
+
+fun:mono_unwind_ops_encode_full
+
+# --------------------------------------------------------------------------- #
+# mono/sgen #
+# --------------------------------------------------------------------------- #
# sgen-alloc.c #
fun:sgen_clear_tlabs
fun:sgen_try_alloc_obj_nolock
+# sgen-array-list.c #
+
+fun:sgen_array_list_add
+fun:sgen_array_list_find_unset
+
# sgen-array-list.h #
fun:sgen_array_list_bucketize
-# sgen-array-list.c #
+# sgen-cardtable.c #
-fun:sgen_array_list_add
-fun:sgen_array_list_find_unset
+fun:sgen_card_table_wbarrier_range_copy
# sgen-cardtable.h #
fun:add_stage_entry
-# sgen-gc.h #
-
-fun:sgen_set_nursery_scan_start
-
# sgen-gc.c #
fun:mono_gc_wbarrier_generic_store
-fun:sgen_conservatively_pin_objects_from
+
+# sgen-gc.h #
+
+fun:sgen_set_nursery_scan_start
# sgen-gchandles.c #
fun:is_slot_set
fun:link_get
-fun:mono_gchandle_free
fun:sgen_gchandle_iterate
# sgen-marksweep.c #
fun:ensure_block_is_checked_for_sweeping
+fun:ensure_can_access_block_free_list
fun:major_finish_sweep_checking
fun:set_block_state
fun:sweep_block
fun:sgen_fragment_allocator_par_range_alloc
fun:sgen_fragment_allocator_release
-# ------------------------------------------------------------ #
-# mono/utils
-# ------------------------------------------------------------ #
+# --------------------------------------------------------------------------- #
+# mono/utils #
+# --------------------------------------------------------------------------- #
# hazard-pointer.c #
fun:is_pointer_hazardous
fun:mono_get_hazardous_pointer
+fun:mono_thread_small_id_alloc
+
+# lock-free-array-queue.c #
+
+fun:mono_lock_free_array_queue_pop
+fun:mono_lock_free_array_queue_push
# memfuncs.c #
# mono-conc-hashtable.c #
+fun:expand_table
+fun:mono_conc_hashtable_insert
fun:mono_conc_hashtable_lookup
# mono-context.c #
fun:mono_sigctx_to_monoctx
+# mono-error.c #
+
+fun:mono_error_cleanup
+
# mono-lazy-init.h #
fun:mono_lazy_initialize
+# mono-linked-list-set.c #
+
+fun:mono_lls_find
+fun:mono_lls_get_hazardous_pointer_with_mask
+
# mono-threads-posix-signals.c #
fun:restart_signal_handler
fun:check_thread_state
fun:mono_threads_transition_finish_async_suspend
+# mono-threads.c #
+
+fun:mono_thread_info_uninstall_interrupt
+
# os-event-unix.c #
fun:mono_os_event_set
compare_names);
if (ptr == NULL) {
- g_warning ("Function '%s' not not found.", name);
+ g_warning ("Function '%s' not found.", name);
return NULL;
}