From: Vlad Brezae Date: Mon, 15 Feb 2016 19:04:55 +0000 (+0700) Subject: Merge pull request #2562 from BrzVlad/fix-drainstack-stats X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=0e4acb2215d2bec1de92ef7871b2e9038d1ef037;hp=10130afaf59b652837e7bc7e923a2bd6aae22a9a;p=mono.git Merge pull request #2562 from BrzVlad/fix-drainstack-stats [sgen] Drain the gray stack only in finish gray stack --- diff --git a/eglib/src/giconv.c b/eglib/src/giconv.c index 61db988909b..a6f222dfe87 100644 --- a/eglib/src/giconv.c +++ b/eglib/src/giconv.c @@ -777,42 +777,9 @@ g_convert (const gchar *str, gssize len, const gchar *to_charset, const gchar *f */ /** - * from http://home.tiscali.nl/t876506/utf8tbl.html + * An explanation of the conversion can be found at: + * http://home.tiscali.nl/t876506/utf8tbl.html * - * From Unicode UCS-4 to UTF-8: - * Start with the Unicode number expressed as a decimal number and call this ud. - * - * If ud <128 (7F hex) then UTF-8 is 1 byte long, the value of ud. - * - * If ud >=128 and <=2047 (7FF hex) then UTF-8 is 2 bytes long. - * byte 1 = 192 + (ud div 64) - * byte 2 = 128 + (ud mod 64) - * - * If ud >=2048 and <=65535 (FFFF hex) then UTF-8 is 3 bytes long. - * byte 1 = 224 + (ud div 4096) - * byte 2 = 128 + ((ud div 64) mod 64) - * byte 3 = 128 + (ud mod 64) - * - * If ud >=65536 and <=2097151 (1FFFFF hex) then UTF-8 is 4 bytes long. - * byte 1 = 240 + (ud div 262144) - * byte 2 = 128 + ((ud div 4096) mod 64) - * byte 3 = 128 + ((ud div 64) mod 64) - * byte 4 = 128 + (ud mod 64) - * - * If ud >=2097152 and <=67108863 (3FFFFFF hex) then UTF-8 is 5 bytes long. - * byte 1 = 248 + (ud div 16777216) - * byte 2 = 128 + ((ud div 262144) mod 64) - * byte 3 = 128 + ((ud div 4096) mod 64) - * byte 4 = 128 + ((ud div 64) mod 64) - * byte 5 = 128 + (ud mod 64) - * - * If ud >=67108864 and <=2147483647 (7FFFFFFF hex) then UTF-8 is 6 bytes long. - * byte 1 = 252 + (ud div 1073741824) - * byte 2 = 128 + ((ud div 16777216) mod 64) - * byte 3 = 128 + ((ud div 262144) mod 64) - * byte 4 = 128 + ((ud div 4096) mod 64) - * byte 5 = 128 + ((ud div 64) mod 64) - * byte 6 = 128 + (ud mod 64) **/ gint g_unichar_to_utf8 (gunichar c, gchar *outbuf) diff --git a/external/referencesource b/external/referencesource index 78dccece97d..7d42294ca69 160000 --- a/external/referencesource +++ b/external/referencesource @@ -1 +1 @@ -Subproject commit 78dccece97d38f6e771ce039001c84fa8435349a +Subproject commit 7d42294ca69063974d15e729ed73854734ef95c6 diff --git a/mcs/build/library.make b/mcs/build/library.make index 5954ba2e316..65f11f600f9 100644 --- a/mcs/build/library.make +++ b/mcs/build/library.make @@ -141,7 +141,7 @@ csproj-local: csproj-library csproj-test intermediate_clean=$(subst /,-,$(intermediate)) csproj-library: config_file=`basename $(LIBRARY) .dll`-$(intermediate_clean)$(PROFILE).input; \ - [[ $(thisdir) == *"Facades"* ]] && config_file=Facades_$$config_file; \ + case "$(thisdir)" in *"Facades"*) config_file=Facades_$$config_file;; esac; \ echo $(thisdir):$$config_file >> $(topdir)/../msvc/scripts/order; \ (echo $(is_boot); \ echo $(USE_MCS_FLAGS) $(LIBRARY_FLAGS) $(LIB_MCS_FLAGS); \ diff --git a/mcs/class/Facades/System.Diagnostics.Tracing/TypeForwarders.cs b/mcs/class/Facades/System.Diagnostics.Tracing/TypeForwarders.cs index 45d99c94ea7..ca09028ce16 100644 --- a/mcs/class/Facades/System.Diagnostics.Tracing/TypeForwarders.cs +++ b/mcs/class/Facades/System.Diagnostics.Tracing/TypeForwarders.cs @@ -26,10 +26,10 @@ [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.Tracing.EventKeywords))] [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.Tracing.EventLevel))] //[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.Tracing.EventListener))] -//[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.Tracing.EventOpcode))] +[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.Tracing.EventOpcode))] [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.Tracing.EventSource))] [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.Tracing.EventSourceAttribute))] //[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.Tracing.EventSourceException))] -//[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.Tracing.EventTask))] +[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.Tracing.EventTask))] //[assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.Tracing.EventWrittenEventArgs))] [assembly: System.Runtime.CompilerServices.TypeForwardedToAttribute(typeof(System.Diagnostics.Tracing.NonEventAttribute))] diff --git a/mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsProviderFactory.cs b/mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsProviderFactory.cs index 770680cbb8c..557d024da21 100644 --- a/mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsProviderFactory.cs +++ b/mcs/class/Mono.Security/Mono.Security.Interface/MonoTlsProviderFactory.cs @@ -82,6 +82,11 @@ namespace Mono.Security.Interface NoReflectionHelper.SetDefaultProvider (name); } + public static MonoTlsProvider GetProvider (string name) + { + return (MonoTlsProvider)NoReflectionHelper.GetProvider (name); + } + /* * Create @HttpWebRequest with the specified @provider (may be null to use the default one). * diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/ChallengeResponse.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/ChallengeResponse.cs index 5b5e74e48c1..eb60c6bd086 100644 --- a/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/ChallengeResponse.cs +++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/ChallengeResponse.cs @@ -46,12 +46,7 @@ using Mono.Security.Cryptography; namespace Mono.Security.Protocol.Ntlm { [Obsolete (Type3Message.LegacyAPIWarning)] -#if INSIDE_SYSTEM - internal -#else - public -#endif - class ChallengeResponse : IDisposable { + public class ChallengeResponse : IDisposable { static private byte[] magic = { 0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25 }; diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/ChallengeResponse2.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/ChallengeResponse2.cs index 747ab89c15b..abaef0e259b 100644 --- a/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/ChallengeResponse2.cs +++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/ChallengeResponse2.cs @@ -49,12 +49,7 @@ using Mono.Security.Cryptography; namespace Mono.Security.Protocol.Ntlm { -#if INSIDE_SYSTEM - internal -#else - public -#endif - static class ChallengeResponse2 { + public static class ChallengeResponse2 { static private byte[] magic = { 0x4B, 0x47, 0x53, 0x21, 0x40, 0x23, 0x24, 0x25 }; diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/MessageBase.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/MessageBase.cs index 0e6e571bb4e..d62ed40c973 100644 --- a/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/MessageBase.cs +++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/MessageBase.cs @@ -39,12 +39,7 @@ using System.Globalization; namespace Mono.Security.Protocol.Ntlm { -#if INSIDE_SYSTEM - internal -#else - public -#endif - abstract class MessageBase { + public abstract class MessageBase { static private byte[] header = { 0x4e, 0x54, 0x4c, 0x4d, 0x53, 0x53, 0x50, 0x00 }; diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/NtlmAuthLevel.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/NtlmAuthLevel.cs index 2dc12129b5d..e66d5901b5b 100644 --- a/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/NtlmAuthLevel.cs +++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/NtlmAuthLevel.cs @@ -36,12 +36,7 @@ namespace Mono.Security.Protocol.Ntlm { * is LM_and_NTLM_and_try_NTLMv2_Session. */ -#if INSIDE_SYSTEM - internal -#else - public -#endif - enum NtlmAuthLevel { + public enum NtlmAuthLevel { /* Use LM and NTLM, never use NTLMv2 session security. */ LM_and_NTLM, diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/NtlmFlags.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/NtlmFlags.cs index f835bd8b145..5b5db641a4a 100644 --- a/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/NtlmFlags.cs +++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/NtlmFlags.cs @@ -40,12 +40,7 @@ using System; namespace Mono.Security.Protocol.Ntlm { [Flags] -#if INSIDE_SYSTEM - internal -#else - public -#endif - enum NtlmFlags : int { + public enum NtlmFlags : int { // The client sets this flag to indicate that it supports Unicode strings. NegotiateUnicode = 0x00000001, // This is set to indicate that the client supports OEM strings. diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/NtlmSettings.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/NtlmSettings.cs index 7cd5c7f8327..02778af48e1 100644 --- a/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/NtlmSettings.cs +++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/NtlmSettings.cs @@ -38,48 +38,13 @@ namespace Mono.Security.Protocol.Ntlm { * is LM_and_NTLM_and_try_NTLMv2_Session. */ - #if INSIDE_SYSTEM - internal - #else - public - #endif - static class NtlmSettings { + public static class NtlmSettings { static NtlmAuthLevel defaultAuthLevel = NtlmAuthLevel.LM_and_NTLM_and_try_NTLMv2_Session; - static FieldInfo GetDefaultAuthLevelField () - { - #if INSIDE_SYSTEM - return null; - #else - var type = typeof (HttpWebRequest).Assembly.GetType ("Mono.Security.Protocol.Ntlm.NtlmSettings", false); - if (type == null) - return null; - return type.GetField ("defaultAuthLevel", BindingFlags.Static | BindingFlags.NonPublic); - #endif - } - - #if INSIDE_SYSTEM - internal - #else - public - #endif - static NtlmAuthLevel DefaultAuthLevel { - get { - var field = GetDefaultAuthLevelField (); - if (field != null) - return (NtlmAuthLevel)field.GetValue (null); - else - return defaultAuthLevel; - } - - set { - var field = GetDefaultAuthLevelField (); - if (field != null) - field.SetValue (null, value); - else - defaultAuthLevel = value; - } + public static NtlmAuthLevel DefaultAuthLevel { + get { return defaultAuthLevel; } + set { defaultAuthLevel = value; } } } } diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type1Message.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type1Message.cs index b9ef8559360..531fce02622 100644 --- a/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type1Message.cs +++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type1Message.cs @@ -39,12 +39,7 @@ using System.Text; namespace Mono.Security.Protocol.Ntlm { -#if INSIDE_SYSTEM - internal -#else - public -#endif - class Type1Message : MessageBase { + public class Type1Message : MessageBase { private string _host; private string _domain; diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type2Message.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type2Message.cs index e6a89936a90..a2f65e3e584 100644 --- a/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type2Message.cs +++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type2Message.cs @@ -39,12 +39,7 @@ using System.Security.Cryptography; namespace Mono.Security.Protocol.Ntlm { -#if INSIDE_SYSTEM - internal -#else - public -#endif - class Type2Message : MessageBase { + public class Type2Message : MessageBase { private byte[] _nonce; private string _targetName; diff --git a/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type3Message.cs b/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type3Message.cs index 7472e719400..ddb44b2dfde 100644 --- a/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type3Message.cs +++ b/mcs/class/Mono.Security/Mono.Security.Protocol.Ntlm/Type3Message.cs @@ -39,12 +39,7 @@ using System.Text; namespace Mono.Security.Protocol.Ntlm { -#if INSIDE_SYSTEM - internal -#else - public -#endif - class Type3Message : MessageBase { + public class Type3Message : MessageBase { private NtlmAuthLevel _level; private byte[] _challenge; diff --git a/mcs/class/Mono.Security/mobile_Mono.Security.dll.sources b/mcs/class/Mono.Security/mobile_Mono.Security.dll.sources index 05cc4faad16..2e938683b3a 100644 --- a/mcs/class/Mono.Security/mobile_Mono.Security.dll.sources +++ b/mcs/class/Mono.Security/mobile_Mono.Security.dll.sources @@ -61,15 +61,6 @@ ./Mono.Security.X509.Extensions/SubjectKeyIdentifierExtension.cs ./Mono.Security.Cryptography/TlsHMAC.cs ./Mono.Security.Cryptography/MD5SHA1.cs -./Mono.Security.Protocol.Ntlm/ChallengeResponse.cs -./Mono.Security.Protocol.Ntlm/ChallengeResponse2.cs -./Mono.Security.Protocol.Ntlm/MessageBase.cs -./Mono.Security.Protocol.Ntlm/NtlmAuthLevel.cs -./Mono.Security.Protocol.Ntlm/NtlmFlags.cs -./Mono.Security.Protocol.Ntlm/NtlmSettings.cs -./Mono.Security.Protocol.Ntlm/Type1Message.cs -./Mono.Security.Protocol.Ntlm/Type2Message.cs -./Mono.Security.Protocol.Ntlm/Type3Message.cs ./Mono.Security.Protocol.Tls/Alert.cs ./Mono.Security.Protocol.Tls/CipherAlgorithmType.cs ./Mono.Security.Protocol.Tls/CipherSuite.cs diff --git a/mcs/class/System.Configuration/System.Configuration/Configuration.cs b/mcs/class/System.Configuration/System.Configuration/Configuration.cs index 76037176690..fb48cc9664f 100644 --- a/mcs/class/System.Configuration/System.Configuration/Configuration.cs +++ b/mcs/class/System.Configuration/System.Configuration/Configuration.cs @@ -133,8 +133,12 @@ namespace System.Configuration { rootGroup.StreamName = streamName; } - if (streamName != null) - Load (); + try { + if (streamName != null) + Load (); + } catch (XmlException ex) { + throw new ConfigurationErrorsException (ex.Message, ex, streamName, 0); + } } internal Configuration Parent { diff --git a/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs b/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs index d2e1a240f6d..7efff1dddff 100644 --- a/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs +++ b/mcs/class/System.Configuration/Test/System.Configuration/ConfigurationManagerTest.cs @@ -627,5 +627,23 @@ namespace MonoTests.System.Configuration { Assert.AreEqual ("Server=(local);Initial Catalog=someDb;User Id=someUser;Password=somePassword;Application Name=someAppName;Min Pool Size=5;Max Pool Size=500;Connect Timeout=10;Connection Lifetime=29;", connString); } + + [Test] + public void BadConfig () + { + string xml = @" badXml"; + + var file = Path.Combine (tempFolder, "badConfig.config"); + File.WriteAllText (file, xml); + + try { + var fileMap = new ConfigurationFileMap (file); + var configuration = ConfigurationManager.OpenMappedMachineConfiguration (fileMap); + Assert.Fail ("Exception ConfigurationErrorsException was expected."); + } catch (ConfigurationErrorsException e) { + Assert.AreEqual (file, e.Filename); + } + + } } } diff --git a/mcs/class/System.Core/System.Core-net_4_x.csproj b/mcs/class/System.Core/System.Core-net_4_x.csproj index f789945f01b..1ff7e4d05f9 100644 --- a/mcs/class/System.Core/System.Core-net_4_x.csproj +++ b/mcs/class/System.Core/System.Core-net_4_x.csproj @@ -208,6 +208,7 @@ + diff --git a/mcs/class/System.Core/System.Core-plaincore-net_4_x.csproj b/mcs/class/System.Core/System.Core-plaincore-net_4_x.csproj index ef334979b34..85e07de17a5 100644 --- a/mcs/class/System.Core/System.Core-plaincore-net_4_x.csproj +++ b/mcs/class/System.Core/System.Core-plaincore-net_4_x.csproj @@ -208,6 +208,7 @@ + diff --git a/mcs/class/System.Core/System.Security.Cryptography/CngKeyBlobFormat.cs b/mcs/class/System.Core/System.Security.Cryptography/CngKeyBlobFormat.cs deleted file mode 100644 index e8f184ce3d7..00000000000 --- a/mcs/class/System.Core/System.Security.Cryptography/CngKeyBlobFormat.cs +++ /dev/null @@ -1,148 +0,0 @@ -// -// System.Security.Cryptography.CngKeyBlobFormat -// -// Authors: -// Sebastien Pouliot -// -// Copyright (C) 2008 Novell, Inc (http://www.novell.com) -// Copyright (C) 2011 Juho Vähä-Herttua -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; - -namespace System.Security.Cryptography { - - // note: CNG stands for "Cryptography API: Next Generation" - - [Serializable] - public sealed class CngKeyBlobFormat : IEquatable { - - private string m_format; - - public CngKeyBlobFormat (string format) - { - if (format == null) - throw new ArgumentNullException ("format"); - if (format.Length == 0) - throw new ArgumentException ("format"); - - m_format = format; - } - - public string Format { - get { return m_format; } - } - - public bool Equals (CngKeyBlobFormat other) - { - if (other == null) - return false; - return m_format == other.m_format; - } - - public override bool Equals (object obj) - { - return Equals (obj as CngKeyBlobFormat); - } - - public override int GetHashCode () - { - return m_format.GetHashCode (); - } - - public override string ToString () - { - return m_format; - } - - // static - - private static CngKeyBlobFormat opaqueTransportBlob; - private static CngKeyBlobFormat genericPrivateBlob; - private static CngKeyBlobFormat genericPublicBlob; - private static CngKeyBlobFormat eccPrivateBlob; - private static CngKeyBlobFormat eccPublicBlob; - private static CngKeyBlobFormat pkcs8PrivateBlob; - - public static CngKeyBlobFormat OpaqueTransportBlob { - get { - if (opaqueTransportBlob == null) - opaqueTransportBlob = new CngKeyBlobFormat ("OpaqueTransport"); - return opaqueTransportBlob; - } - } - - public static CngKeyBlobFormat GenericPrivateBlob { - get { - if (genericPrivateBlob == null) - genericPrivateBlob = new CngKeyBlobFormat ("PRIVATEBLOB"); - return genericPrivateBlob; - } - } - - public static CngKeyBlobFormat GenericPublicBlob { - get { - if (genericPublicBlob == null) - genericPublicBlob = new CngKeyBlobFormat ("PUBLICBLOB"); - return genericPublicBlob; - } - } - - public static CngKeyBlobFormat EccPrivateBlob { - get { - if (eccPrivateBlob == null) - eccPrivateBlob = new CngKeyBlobFormat ("ECCPRIVATEBLOB"); - return eccPrivateBlob; - } - } - - public static CngKeyBlobFormat EccPublicBlob { - get { - if (eccPublicBlob == null) - eccPublicBlob = new CngKeyBlobFormat ("ECCPUBLICBLOB"); - return eccPublicBlob; - } - } - - public static CngKeyBlobFormat Pkcs8PrivateBlob { - get { - if (pkcs8PrivateBlob == null) - pkcs8PrivateBlob = new CngKeyBlobFormat ("PKCS8_PRIVATEKEY"); - return pkcs8PrivateBlob; - } - } - - public static bool operator == (CngKeyBlobFormat left, CngKeyBlobFormat right) - { - if ((object)left == null) - return ((object)right == null); - return left.Equals (right); - } - - public static bool operator != (CngKeyBlobFormat left, CngKeyBlobFormat right) - { - if ((object)left == null) - return ((object)right != null); - return !left.Equals (right); - } - } -} diff --git a/mcs/class/System.Core/common_System.Core.dll.sources b/mcs/class/System.Core/common_System.Core.dll.sources index 455930f26f8..634c075073a 100644 --- a/mcs/class/System.Core/common_System.Core.dll.sources +++ b/mcs/class/System.Core/common_System.Core.dll.sources @@ -184,6 +184,7 @@ ReferenceSources/Strings.cs ../../../external/referencesource/System.Core/System/Runtime/CompilerServices/ExecutionScope.cs ../../../external/referencesource/System.Core/System/Security/Cryptography/Aes.cs +../../../external/referencesource/System.Core/System/Security/Cryptography/CngKeyBlobFormat.cs ../../../external/referencesource/System.Core/System/Security/Cryptography/ECDiffieHellmanPublicKey.cs ../../../external/referencesource/System.Core/System/Security/Cryptography/ECDsa.cs diff --git a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XmlMessagesFormatter.cs b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XmlMessagesFormatter.cs index 9c1df61310a..0f881358df5 100644 --- a/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XmlMessagesFormatter.cs +++ b/mcs/class/System.ServiceModel/System.ServiceModel.Dispatcher/XmlMessagesFormatter.cs @@ -38,6 +38,7 @@ using System.ServiceModel.Channels; using System.ServiceModel.Description; using System.Text; using System.Xml; +using System.Xml.Schema; using System.Xml.Serialization; namespace System.ServiceModel.Dispatcher @@ -135,6 +136,11 @@ namespace System.ServiceModel.Dispatcher protected override void OnWriteBodyContents (XmlDictionaryWriter writer) { + if (writer.WriteState == WriteState.Element) { + writer.WriteXmlnsAttribute ("xsi", XmlSchema.InstanceNamespace); + writer.WriteXmlnsAttribute ("xsd", XmlSchema.Namespace); + } + serializer.Serialize (writer, body); } } diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/ChannelFactory_1Test.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/ChannelFactory_1Test.cs index 0a169ec364f..5282f954c05 100644 --- a/mcs/class/System.ServiceModel/Test/System.ServiceModel/ChannelFactory_1Test.cs +++ b/mcs/class/System.ServiceModel/Test/System.ServiceModel/ChannelFactory_1Test.cs @@ -480,15 +480,16 @@ namespace MonoTests.System.ServiceModel [Test] public void OneWayOperationWithRequestReplyChannel () { + var port = NetworkHelpers.FindFreePort (); var host = new ServiceHost (typeof (OneWayService)); host.AddServiceEndpoint (typeof (IOneWayService), new BasicHttpBinding (), - new Uri ("http://localhost:30158")); + new Uri ("http://localhost:" + port)); host.Open (); try { var cf = new ChannelFactory ( new BasicHttpBinding (), - new EndpointAddress ("http://localhost:30158")); + new EndpointAddress ("http://localhost:" + port)); var ch = cf.CreateChannel (); ch.GiveMessage ("test"); diff --git a/mcs/class/System.ServiceModel/Test/System.ServiceModel/ClientBaseTest.cs b/mcs/class/System.ServiceModel/Test/System.ServiceModel/ClientBaseTest.cs index 3c12a464686..4d15e9138a5 100644 --- a/mcs/class/System.ServiceModel/Test/System.ServiceModel/ClientBaseTest.cs +++ b/mcs/class/System.ServiceModel/Test/System.ServiceModel/ClientBaseTest.cs @@ -28,12 +28,16 @@ using System; using System.Collections.ObjectModel; using System.IO; +using System.Net; using System.Net.Sockets; using System.Reflection; using System.ServiceModel; using System.ServiceModel.Channels; using System.ServiceModel.Description; +using System.Text; +using System.Threading.Tasks; using System.Xml; +using System.Xml.Serialization; using NUnit.Framework; using MonoTests.Helpers; @@ -503,5 +507,82 @@ namespace MonoTests.System.ServiceModel { } } + + [SerializableAttribute ()] + [XmlTypeAttribute (Namespace = "http://mono.com/")] + public class ValueWithXmlAttributes + { + [XmlElementAttribute (ElementName = "Name")] + public string FakeName; + } + + [ServiceContractAttribute (Namespace = "http://mono.com/")] + public interface IXmlSerializerFormatService + { + [OperationContractAttribute (Action = "http://mono.com/Send", ReplyAction = "*")] + [XmlSerializerFormatAttribute ()] + void SendValueWithXmlAttributes (ValueWithXmlAttributes v); + } + + class XmlSerializerFormatClient : ClientBase + { + public XmlSerializerFormatClient (Binding binding, EndpointAddress address) + : base (binding, address) + { + } + + public void SendValue () + { + var v = new ValueWithXmlAttributes () { FakeName = "name" }; + base.Channel.SendValueWithXmlAttributes (v); + } + } + + [Test] + public void TestXmlAttributes () + { + int port = NetworkHelpers.FindFreePort(); + var endpoint = new EndpointAddress ("http://localhost:" + port); + var binding = new BasicHttpBinding (); + var client = new XmlSerializerFormatClient (binding, endpoint); + + var server = new TcpListener (IPAddress.Any, port); + server.Start (); + + var acceptTask = server.AcceptTcpClientAsync (); + + var t1 = new Task( () => client.SendValue ()); + t1.Start(); + + if (!acceptTask.Wait (2000)) + Assert.Fail ("No request from client."); + + var netStream = acceptTask.Result.GetStream (); + + byte[] buffer = new byte [1024]; + int numBytesRead = 0; + var message = new StringBuilder (); + + do { + numBytesRead = netStream.Read (buffer, 0, buffer.Length); + var str = Encoding.UTF8.GetString (buffer, 0, numBytesRead); + message.AppendFormat ("{0}", str); + if (str.EndsWith ("", StringComparison.InvariantCulture)) + break; + } while (numBytesRead > 0); + + var messageStr = message.ToString (); + var envelopeIndex = messageStr.IndexOf ("name"; + + Assert.AreEqual (expected, envelope); + + server.Stop (); + } } } diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/AsyncMethodData.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/AsyncMethodData.cs index cbfeea4c763..934823502df 100644 --- a/mcs/class/System.Windows.Forms/System.Windows.Forms/AsyncMethodData.cs +++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/AsyncMethodData.cs @@ -35,6 +35,7 @@ namespace System.Windows.Forms { public object [] Args; public AsyncMethodResult Result; public ExecutionContext Context; + public SynchronizationContext SyncContext; } } diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs index ff2427e0690..eb0fecfdb87 100644 --- a/mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs +++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs @@ -468,11 +468,10 @@ namespace System.Windows.Forms { #endregion // XplatUI Driver Methods } - internal class XplatUIDriverSupport { + static class XplatUIDriverSupport { #region XplatUI Driver Support Methods - internal static void ExecutionCallback (object state) + internal static void ExecutionCallback (AsyncMethodData data) { - AsyncMethodData data = (AsyncMethodData) state; AsyncMethodResult result = data.Result; object ret; @@ -492,6 +491,25 @@ namespace System.Windows.Forms { } } + static void ExecutionCallbackInContext (object state) + { + AsyncMethodData data = (AsyncMethodData) state; + + if (data.SyncContext == null) { + ExecutionCallback (data); + return; + } + + var oldContext = SynchronizationContext.Current; + SynchronizationContext.SetSynchronizationContext (data.SyncContext); + + try { + ExecutionCallback (data); + } finally { + SynchronizationContext.SetSynchronizationContext (oldContext); + } + } + internal static void ExecuteClientMessage (GCHandle gchandle) { AsyncMethodData data = (AsyncMethodData) gchandle.Target; @@ -499,7 +517,8 @@ namespace System.Windows.Forms { if (data.Context == null) { ExecutionCallback (data); } else { - ExecutionContext.Run (data.Context, new ContextCallback (ExecutionCallback), data); + data.SyncContext = SynchronizationContext.Current; + ExecutionContext.Run (data.Context, new ContextCallback (ExecutionCallbackInContext), data); } } finally { diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs index e541b1fdb97..2bb60f5ff2b 100644 --- a/mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs +++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs @@ -44,7 +44,7 @@ namespace System.Windows.Forms { #region Local Variables private static XplatUIWin32 instance; private static int ref_count; - private static IntPtr FosterParent; + private static IntPtr FosterParentLast; internal static MouseButtons mouse_state; internal static Point mouse_position; @@ -847,11 +847,7 @@ namespace System.Windows.Forms { wnd_proc = new WndProc(InternalWndProc); - FosterParent=Win32CreateWindow(WindowExStyles.WS_EX_TOOLWINDOW, "static", "Foster Parent Window", WindowStyles.WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); - - if (FosterParent==IntPtr.Zero) { - Win32MessageBox(IntPtr.Zero, "Could not create foster window, win32 error " + Win32GetLastError().ToString(), "Oops", 0); - } + FosterParentLast = IntPtr.Zero; scroll_height = Win32GetSystemMetrics(SystemMetrics.SM_CYHSCROLL); scroll_width = Win32GetSystemMetrics(SystemMetrics.SM_CXVSCROLL); @@ -863,6 +859,19 @@ namespace System.Windows.Forms { #region Private Support Methods + private IntPtr GetFosterParent() + { + if (!IsWindow(FosterParentLast)) + { + FosterParentLast=Win32CreateWindow(WindowExStyles.WS_EX_TOOLWINDOW, "static", "Foster Parent Window", WindowStyles.WS_OVERLAPPEDWINDOW, 0, 0, 0, 0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero); + + if (FosterParentLast==IntPtr.Zero) { + Win32MessageBox(IntPtr.Zero, "Could not create foster window, win32 error " + Win32GetLastError().ToString(), "Oops", 0); + } + } + return FosterParentLast; + } + private string RegisterWindowClass (int classStyle) { string class_name; @@ -1616,13 +1625,13 @@ namespace System.Windows.Forms { if ((ParentHandle==IntPtr.Zero) && (cp.Style & (int)(WindowStyles.WS_CHILD))!=0) { // We need to use our foster parent window until this poor child gets it's parent assigned - ParentHandle = FosterParent; + ParentHandle = GetFosterParent(); } if ( ((cp.Style & (int)(WindowStyles.WS_CHILD | WindowStyles.WS_POPUP))==0) && ((cp.ExStyle & (int)WindowExStyles.WS_EX_APPWINDOW) == 0)) { // If we want to be hidden from the taskbar we need to be 'owned' by // something not on the taskbar. FosterParent is just that - ParentHandle = FosterParent; + ParentHandle = GetFosterParent(); } Point location; @@ -2265,7 +2274,7 @@ namespace System.Windows.Forms { if (parent == IntPtr.Zero) { new_style = style & ~WindowStyles.WS_CHILD; - result = Win32SetParent (handle, FosterParent); + result = Win32SetParent (handle, GetFosterParent()); } else { new_style = style | WindowStyles.WS_CHILD; result = Win32SetParent (handle, parent); @@ -2562,11 +2571,12 @@ namespace System.Windows.Forms { internal override void SendAsyncMethod (AsyncMethodData method) { - Win32PostMessage(FosterParent, Msg.WM_ASYNC_MESSAGE, IntPtr.Zero, (IntPtr)GCHandle.Alloc (method)); + Win32PostMessage(GetFosterParent(), Msg.WM_ASYNC_MESSAGE, IntPtr.Zero, (IntPtr)GCHandle.Alloc (method)); } internal override void SetTimer (Timer timer) { + IntPtr FosterParent=GetFosterParent(); int index; index = timer.GetHashCode(); @@ -2824,7 +2834,7 @@ namespace System.Windows.Forms { internal override IntPtr ClipboardOpen(bool primary_selection) { // Win32 does not have primary selection - Win32OpenClipboard(FosterParent); + Win32OpenClipboard(GetFosterParent()); return clip_magic; } @@ -3220,7 +3230,7 @@ namespace System.Windows.Forms { string magic_string = "The quick brown fox jumped over the lazy dog."; double magic_number = 44.549996948242189; - g = Graphics.FromHwnd(FosterParent); + g = Graphics.FromHwnd(GetFosterParent()); width = (float) (g.MeasureString (magic_string, font).Width / magic_number); return new SizeF(width, font.Height); @@ -3595,6 +3605,9 @@ namespace System.Windows.Forms { [DllImport ("user32.dll", EntryPoint="IsWindowVisible", CallingConvention=CallingConvention.StdCall)] private extern static bool IsWindowVisible(IntPtr hwnd); + [DllImport ("user32.dll", EntryPoint="IsWindow", CallingConvention=CallingConvention.StdCall)] + private extern static bool IsWindow(IntPtr hwnd); + //[DllImport ("user32.dll", EntryPoint="SetClassLong", CallingConvention=CallingConvention.StdCall)] //private extern static bool Win32SetClassLong(IntPtr hwnd, ClassLong nIndex, IntPtr dwNewLong); diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms_test.dll.sources b/mcs/class/System.Windows.Forms/System.Windows.Forms_test.dll.sources index e9a833018a6..f336b1537be 100644 --- a/mcs/class/System.Windows.Forms/System.Windows.Forms_test.dll.sources +++ b/mcs/class/System.Windows.Forms/System.Windows.Forms_test.dll.sources @@ -78,6 +78,7 @@ System.Windows.Forms/FocusTest.cs System.Windows.Forms/FolderBrowserDialogTest.cs System.Windows.Forms/FormEventTest.cs System.Windows.Forms/FormHandleTest.cs +System.Windows.Forms/FormThreadTest.cs System.Windows.Forms/FormTest.cs System.Windows.Forms/EventArgsTest.cs System.Windows.Forms/EventLogger.cs diff --git a/mcs/class/System.Windows.Forms/Test/System.Windows.Forms/FormThreadTest.cs b/mcs/class/System.Windows.Forms/Test/System.Windows.Forms/FormThreadTest.cs new file mode 100644 index 00000000000..e9858bb7fcb --- /dev/null +++ b/mcs/class/System.Windows.Forms/Test/System.Windows.Forms/FormThreadTest.cs @@ -0,0 +1,43 @@ +using System; +using System.Windows.Forms; +using System.Threading; +using Sys_Threading=System.Threading; + +using NUnit.Framework; + +using CategoryAttribute = NUnit.Framework.CategoryAttribute; + +namespace MonoTests.System.Windows.Forms +{ + [TestFixture] + public class FormThreadTest : TestHelper + { + private static void GuiThread() + { + Form form1; + + form1 = new Form(); + form1.Show(); + form1.Dispose(); + } + + [Test] + public void TestThreadFormsInit () + { + Sys_Threading.Thread thread; + + thread = new Sys_Threading.Thread(new ThreadStart(GuiThread)); + thread.Start(); + thread.Join(); + + try + { + GuiThread(); + } + catch (Exception e) + { + Assert.Fail ("#1"); + } + } + } +} diff --git a/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs b/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs index f2cf321677d..1a0c2bc5842 100644 --- a/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs +++ b/mcs/class/System/Mono.Net.Security/MonoTlsProviderFactory.cs @@ -230,6 +230,11 @@ namespace Mono.Net.Security return provider.Provider; } + internal static MSI.MonoTlsProvider GetProvider (string name) + { + return LookupProvider (name, false); + } + internal static bool HasProvider { get { lock (locker) { diff --git a/mcs/class/System/Mono.Net.Security/NoReflectionHelper.cs b/mcs/class/System/Mono.Net.Security/NoReflectionHelper.cs index a11fcec2c19..6de1cd25993 100644 --- a/mcs/class/System/Mono.Net.Security/NoReflectionHelper.cs +++ b/mcs/class/System/Mono.Net.Security/NoReflectionHelper.cs @@ -120,5 +120,13 @@ namespace Mono.Net.Security #endif } + internal static object GetProvider (string name) + { + #if SECURITY_DEP + return MonoTlsProviderFactory.GetProvider (name); + #else + throw new NotSupportedException (); + #endif + } } } diff --git a/mcs/class/System/System.Configuration/CustomizableFileSettingsProvider.cs b/mcs/class/System/System.Configuration/CustomizableFileSettingsProvider.cs index 4b69010b975..31d56ce09eb 100644 --- a/mcs/class/System/System.Configuration/CustomizableFileSettingsProvider.cs +++ b/mcs/class/System/System.Configuration/CustomizableFileSettingsProvider.cs @@ -578,6 +578,34 @@ namespace System.Configuration private ExeConfigurationFileMap exeMapPrev = null; private SettingsPropertyValueCollection values = null; + /// + /// Hack to remove the XmlDeclaration that the XmlSerializer adds. + ///
+ /// see Issue 2273 for details + ///
+ private string StripXmlHeader (string serializedValue) + { + if (serializedValue == null) + { + return string.Empty; + } + + XmlDocument doc = new XmlDocument (); + XmlElement valueXml = doc.CreateElement ("value"); + valueXml.InnerXml = serializedValue; + + foreach (XmlNode child in valueXml.ChildNodes) { + if (child.NodeType == XmlNodeType.XmlDeclaration) { + valueXml.RemoveChild (child); + break; + } + } + + // InnerXml will give you well-formed XML that you could save as a separate document, and + // InnerText will immediately give you a pure-text representation of this inner XML. + return valueXml.InnerXml; + } + private void SaveProperties (ExeConfigurationFileMap exeMap, SettingsPropertyValueCollection collection, ConfigurationUserLevel level, SettingsContext context, bool checkUserLevel) { Configuration config = ConfigurationManager.OpenMappedExeConfiguration (exeMap, level); @@ -585,8 +613,6 @@ namespace System.Configuration UserSettingsGroup userGroup = config.GetSectionGroup ("userSettings") as UserSettingsGroup; bool isRoaming = (level == ConfigurationUserLevel.PerUserRoaming); -#if true // my reimplementation - if (userGroup == null) { userGroup = new UserSettingsGroup (); config.SectionGroups.Add ("userSettings", userGroup); @@ -623,7 +649,7 @@ namespace System.Configuration element.Value.ValueXml = new XmlDocument ().CreateElement ("value"); switch (value.Property.SerializeAs) { case SettingsSerializeAs.Xml: - element.Value.ValueXml.InnerXml = (value.SerializedValue as string) ?? string.Empty; + element.Value.ValueXml.InnerXml = StripXmlHeader (value.SerializedValue as string); break; case SettingsSerializeAs.String: element.Value.ValueXml.InnerText = value.SerializedValue as string; @@ -637,43 +663,6 @@ namespace System.Configuration } if (hasChanges) config.Save (ConfigurationSaveMode.Minimal, true); - -#else // original impl. - likely buggy to miss some properties to save - - foreach (ConfigurationSection configSection in userGroup.Sections) - { - ClientSettingsSection userSection = configSection as ClientSettingsSection; - if (userSection != null) - { -/* - userSection.Settings.Clear(); - - foreach (SettingsPropertyValue propertyValue in collection) - { - if (propertyValue.IsDirty) - { - SettingElement element = new SettingElement(propertyValue.Name, SettingsSerializeAs.String); - element.Value.ValueXml = new XmlDocument(); - element.Value.ValueXml.InnerXml = (string)propertyValue.SerializedValue; - userSection.Settings.Add(element); - } - } -*/ - foreach (SettingElement element in userSection.Settings) - { - if (collection [element.Name] != null) { - if (collection [element.Name].Property.Attributes.Contains (typeof (SettingsManageabilityAttribute)) != isRoaming) - continue; - - element.SerializeAs = SettingsSerializeAs.String; - element.Value.ValueXml.InnerXml = (string) collection [element.Name].SerializedValue; ///Value = XmlElement - } - } - - } - } - config.Save (ConfigurationSaveMode.Minimal, true); -#endif } // NOTE: We should add here all the chars that are valid in a name of a class (Ecma-wise), diff --git a/mcs/class/System/System.Net.Security/NegotiateStream.cs b/mcs/class/System/System.Net.Security/NegotiateStream.cs index cedb3651c88..ad9e3526ff7 100644 --- a/mcs/class/System/System.Net.Security/NegotiateStream.cs +++ b/mcs/class/System/System.Net.Security/NegotiateStream.cs @@ -33,6 +33,10 @@ using System; using System.IO; using System.Net; using System.Security.Principal; +using System.Security.Permissions; +using System.Security.Authentication.ExtendedProtection; +using System.Threading; +using System.Threading.Tasks; namespace System.Net.Security { @@ -272,6 +276,60 @@ namespace System.Net.Security throw new NotImplementedException (); } + public virtual Task AuthenticateAsClientAsync() + { + return Task.Factory.FromAsync(BeginAuthenticateAsClient, EndAuthenticateAsClient, null); + } + + public virtual Task AuthenticateAsClientAsync(NetworkCredential credential, string targetName) + { + return Task.Factory.FromAsync(BeginAuthenticateAsClient, EndAuthenticateAsClient, credential, targetName, null); + } + + public virtual Task AuthenticateAsClientAsync( + NetworkCredential credential, string targetName, + ProtectionLevel requiredProtectionLevel, + TokenImpersonationLevel allowedImpersonationLevel) + { + return Task.Factory.FromAsync((callback, state) => BeginAuthenticateAsClient(credential, targetName, requiredProtectionLevel, allowedImpersonationLevel, callback, state), EndAuthenticateAsClient, null); + } + + public virtual Task AuthenticateAsClientAsync(NetworkCredential credential, ChannelBinding binding, string targetName) + { + throw new NotImplementedException (); + } + + public virtual Task AuthenticateAsClientAsync( + NetworkCredential credential, ChannelBinding binding, + string targetName, ProtectionLevel requiredProtectionLevel, + TokenImpersonationLevel allowedImpersonationLevel) + { + throw new NotImplementedException (); + } + + public virtual Task AuthenticateAsServerAsync() + { + return Task.Factory.FromAsync(BeginAuthenticateAsServer, EndAuthenticateAsServer, null); + } + + public virtual Task AuthenticateAsServerAsync(ExtendedProtectionPolicy policy) + { + throw new NotImplementedException (); + } + + public virtual Task AuthenticateAsServerAsync(NetworkCredential credential, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel requiredImpersonationLevel) + { + throw new NotImplementedException (); + } + + public virtual Task AuthenticateAsServerAsync( + NetworkCredential credential, ExtendedProtectionPolicy policy, + ProtectionLevel requiredProtectionLevel, + TokenImpersonationLevel requiredImpersonationLevel) + { + throw new NotImplementedException (); + } + #endregion // Methods } } diff --git a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Store.cs b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Store.cs index 42b6c6e3d44..904142e3595 100644 --- a/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Store.cs +++ b/mcs/class/System/System.Security.Cryptography.X509Certificates/X509Store.cs @@ -40,7 +40,7 @@ using System.Security.Permissions; namespace System.Security.Cryptography.X509Certificates { - public sealed class X509Store { + public sealed class X509Store : IDisposable { private string _name; private StoreLocation _location; @@ -107,6 +107,10 @@ namespace System.Security.Cryptography.X509Certificates { _location = storeLocation; } + public void Dispose () + { + } + // properties public X509Certificate2Collection Certificates { diff --git a/mcs/class/System/Test/System.Configuration/ApplicationSettingsBaseTest.cs b/mcs/class/System/Test/System.Configuration/ApplicationSettingsBaseTest.cs index 7b0b3ac8152..e12f53291d2 100644 --- a/mcs/class/System/Test/System.Configuration/ApplicationSettingsBaseTest.cs +++ b/mcs/class/System/Test/System.Configuration/ApplicationSettingsBaseTest.cs @@ -29,8 +29,11 @@ //#define SPEW - using System; +using System.IO; +using System.Xml; +using System.Xml.Serialization; +using System.Xml.Schema; using System.Text; using System.Configuration; using System.ComponentModel; @@ -461,6 +464,60 @@ namespace MonoTests.System.Configuration { Assert.AreEqual ("eclair", holder1.TestKey, "#4"); Assert.AreEqual ("", holder2.TestKey, "#5"); } + + class Settings : ApplicationSettingsBase + { + [UserScopedSetting] + public WindowPositionList WindowPositions { + get { + return ((WindowPositionList)(this ["WindowPositions"])); + } + set { + this ["WindowPositions"] = value; + } + } + } + + [Serializable] + public class WindowPositionList : IXmlSerializable + { + public XmlSchema GetSchema () + { + return null; + } + + public void ReadXml (XmlReader reader) + { + reader.ReadStartElement ("sampleNode"); + reader.ReadEndElement (); + } + + public void WriteXml (XmlWriter writer) + { + writer.WriteStartElement ("sampleNode"); + writer.WriteEndElement (); + } + } + + [Test] //Covers 36388 + public void XmlHeader () + { + try { + var settings = new Settings (); + settings.Reset (); + settings.Save (); + + settings.WindowPositions = new WindowPositionList (); + + settings.Save (); + // If Reloads fails then saved data is corrupted + settings.Reload (); + } catch (ConfigurationErrorsException e) { + // Delete corrupted config file so other test won't fail. + File.Delete (e.Filename); + Assert.Fail ("Invalid data was saved to config file."); + } + } } } diff --git a/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs b/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs index 2dd0d067463..cea6bb18c14 100644 --- a/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs +++ b/mcs/class/System/Test/System.Net.Security/SslStreamTest.cs @@ -39,6 +39,8 @@ using System.Net.Security; using System.Security.Cryptography.X509Certificates; using System.Threading; +using MonoTests.Helpers; + namespace MonoTests.System.Net.Security { @@ -64,7 +66,7 @@ public class SslStreamTest { void AuthenticateClientAndServer (bool server, bool client) { - IPEndPoint endPoint = new IPEndPoint (IPAddress.Parse ("127.0.0.1"), 10000); + IPEndPoint endPoint = new IPEndPoint (IPAddress.Parse ("127.0.0.1"), NetworkHelpers.FindFreePort ()); ClientServerState state = new ClientServerState (); state.Client = new TcpClient (); state.Listener = new TcpListener (endPoint); diff --git a/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs b/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs index a0e19d4f2d1..a53a5d5624a 100755 --- a/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs +++ b/mcs/class/System/Test/System.Net.Sockets/SocketTest.cs @@ -22,6 +22,8 @@ using System.IO; using System.Collections.Generic; +using MonoTests.Helpers; + namespace MonoTests.System.Net.Sockets { [TestFixture] @@ -34,7 +36,7 @@ namespace MonoTests.System.Net.Sockets [Test] public void ConnectIPAddressAny () { - IPEndPoint ep = new IPEndPoint (IPAddress.Any, 0); + IPEndPoint ep = new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ()); /* UDP sockets use Any to disconnect try { @@ -64,7 +66,7 @@ namespace MonoTests.System.Net.Sockets public void IncompatibleAddress () { IPEndPoint epIPv6 = new IPEndPoint (IPAddress.IPv6Any, - 0); + NetworkHelpers.FindFreePort ()); try { using (Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP)) { @@ -111,9 +113,9 @@ namespace MonoTests.System.Net.Sockets Socket.Select (list, list, list, 1000); } - private bool BlockingConnect (bool block) + private bool BlockingConnect (bool block, int port) { - IPEndPoint ep = new IPEndPoint(IPAddress.Loopback, 1234); + IPEndPoint ep = new IPEndPoint(IPAddress.Loopback, port); Socket server = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); @@ -155,11 +157,12 @@ namespace MonoTests.System.Net.Sockets public void AcceptBlockingStatus() { bool block; - - block = BlockingConnect(true); + var port = NetworkHelpers.FindFreePort (); + + block = BlockingConnect(true, port); Assert.AreEqual (block, true, "BlockingStatus01"); - block = BlockingConnect(false); + block = BlockingConnect(false, port); Assert.AreEqual (block, false, "BlockingStatus02"); } @@ -208,7 +211,7 @@ namespace MonoTests.System.Net.Sockets * anything... */ sock.BeginConnect (new IPEndPoint (IPAddress.Loopback, - 114), + NetworkHelpers.FindFreePort ()), new AsyncCallback (CFACallback), sock); CFACalledBack.WaitOne (); @@ -219,7 +222,7 @@ namespace MonoTests.System.Net.Sockets [Test] public void SetSocketOptionBoolean () { - IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 1); + IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ()); Socket sock = new Socket (ep.Address.AddressFamily, SocketType.Stream, ProtocolType.Tcp); try { sock.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true); @@ -230,7 +233,7 @@ namespace MonoTests.System.Net.Sockets [Test] public void TestSelect1 () { - Socket srv = CreateServer (); + Socket srv = CreateServer (NetworkHelpers.FindFreePort ()); ClientSocket clnt = new ClientSocket (srv.LocalEndPoint); Thread th = new Thread (new ThreadStart (clnt.ConnectSleepClose)); Socket acc = null; @@ -260,10 +263,10 @@ namespace MonoTests.System.Net.Sockets } } - static Socket CreateServer () + static Socket CreateServer (int port) { Socket sock = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - sock.Bind (new IPEndPoint (IPAddress.Loopback, 0)); + sock.Bind (new IPEndPoint (IPAddress.Loopback, port)); sock.Listen (1); return sock; } @@ -369,7 +372,7 @@ namespace MonoTests.System.Net.Sockets public void Disposed19 () { Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); - EndPoint ep = new IPEndPoint (IPAddress.Any, 31337); + EndPoint ep = new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ()); s.Close(); s.SendTo (buf, 0, ep); @@ -380,7 +383,7 @@ namespace MonoTests.System.Net.Sockets public void Disposed20 () { Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); - EndPoint ep = new IPEndPoint (IPAddress.Any, 31337); + EndPoint ep = new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ()); s.Close(); s.SendTo (buf, 10, 0, ep); @@ -391,7 +394,7 @@ namespace MonoTests.System.Net.Sockets public void Disposed21 () { Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); - EndPoint ep = new IPEndPoint (IPAddress.Any, 31337); + EndPoint ep = new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ()); s.Close(); s.SendTo (buf, 0, 10, 0, ep); @@ -402,7 +405,7 @@ namespace MonoTests.System.Net.Sockets public void Disposed22 () { Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); - EndPoint ep = new IPEndPoint (IPAddress.Any, 31337); + EndPoint ep = new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ()); s.Close(); s.SendTo (buf, ep); @@ -424,7 +427,7 @@ namespace MonoTests.System.Net.Sockets Socket server = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, - 9010); + NetworkHelpers.FindFreePort ()); server.Bind (ep); server.Listen (1); @@ -682,7 +685,7 @@ namespace MonoTests.System.Net.Sockets SocketType.Stream, ProtocolType.Tcp); - sock.Bind (new IPEndPoint (IPAddress.Any, 1235)); + sock.Bind (new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ())); sock.ExclusiveAddressUse = true; sock.Close (); } @@ -1329,7 +1332,7 @@ namespace MonoTests.System.Net.Sockets SocketType.Stream, ProtocolType.Tcp); - sock.Bind (new IPEndPoint (IPAddress.Any, 1236)); + sock.Bind (new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ())); sock.BeginAccept (BACallback, sock); @@ -1343,7 +1346,7 @@ namespace MonoTests.System.Net.Sockets SocketType.Stream, ProtocolType.Tcp); IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, - 1237); + NetworkHelpers.FindFreePort ()); sock.Bind (ep); sock.Listen (1); @@ -1410,7 +1413,7 @@ namespace MonoTests.System.Net.Sockets SocketType.Stream, ProtocolType.Tcp); IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, - 1238); + NetworkHelpers.FindFreePort ()); sock.Bind (ep); sock.Listen (1); @@ -1478,7 +1481,7 @@ namespace MonoTests.System.Net.Sockets ProtocolType.Udp); IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, - 1239); + NetworkHelpers.FindFreePort ()); sock.Bind (ep); sock.Listen (1); @@ -1507,10 +1510,10 @@ namespace MonoTests.System.Net.Sockets ProtocolType.Tcp); IPEndPoint ep1 = new IPEndPoint (IPAddress.Loopback, - 1240); + NetworkHelpers.FindFreePort ()); IPEndPoint ep2 = new IPEndPoint (IPAddress.Loopback, - 1241); + NetworkHelpers.FindFreePort ()); sock.Bind (ep1); sock.Listen (1); @@ -1540,7 +1543,7 @@ namespace MonoTests.System.Net.Sockets ProtocolType.Tcp); IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, - 1242); + NetworkHelpers.FindFreePort ()); sock.Bind (ep); sock.Listen (1); @@ -1622,7 +1625,7 @@ namespace MonoTests.System.Net.Sockets SocketType.Stream, ProtocolType.Tcp); IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, - 1243); + NetworkHelpers.FindFreePort ()); sock.Bind (ep); sock.Listen (1); @@ -1673,7 +1676,7 @@ namespace MonoTests.System.Net.Sockets SocketType.Stream, ProtocolType.Tcp); IPAddress ip = IPAddress.Loopback; - IPEndPoint ep = new IPEndPoint (ip, 1244); + IPEndPoint ep = new IPEndPoint (ip, NetworkHelpers.FindFreePort ()); listen.Bind (ep); listen.Listen (1); @@ -1682,7 +1685,7 @@ namespace MonoTests.System.Net.Sockets BCConnected = false; - sock.BeginConnect (ip, 1244, BCCallback, sock); + sock.BeginConnect (ip, ep.Port, BCCallback, sock); if (BCCalledBack.WaitOne (2000, false) == false) { Assert.Fail ("BeginConnectAddressPort wait timed out"); @@ -1721,13 +1724,13 @@ namespace MonoTests.System.Net.Sockets SocketType.Stream, ProtocolType.Tcp); IPAddress ip = IPAddress.Loopback; - IPEndPoint ep = new IPEndPoint (ip, 1245); + IPEndPoint ep = new IPEndPoint (ip, NetworkHelpers.FindFreePort ()); sock.Bind (ep); sock.Listen (1); try { - sock.BeginConnect (ip, 1245, BCCallback, sock); + sock.BeginConnect (ip, ep.Port, BCCallback, sock); Assert.Fail ("BeginConnectAddressPortListen #1"); } catch (InvalidOperationException) { } catch { @@ -1772,7 +1775,7 @@ namespace MonoTests.System.Net.Sockets SocketType.Stream, ProtocolType.Tcp); IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, - 1246); + NetworkHelpers.FindFreePort ()); IPAddress[] ips = new IPAddress[4]; ips[0] = IPAddress.Parse ("127.0.0.4"); @@ -1787,7 +1790,7 @@ namespace MonoTests.System.Net.Sockets BCConnected = false; - sock.BeginConnect (ips, 1246, BCCallback, sock); + sock.BeginConnect (ips, ep.Port, BCCallback, sock); /* Longer wait here, because the ms runtime * takes a lot longer to not connect @@ -1835,7 +1838,7 @@ namespace MonoTests.System.Net.Sockets * succeed it it can connect to at least one of the requested * addresses. */ - IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, 1246); + IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ()); listen.Bind (ep); listen.Listen (1); @@ -1844,7 +1847,7 @@ namespace MonoTests.System.Net.Sockets BCConnected = false; - sock.BeginConnect (allIps, 1246, BCCallback, sock); + sock.BeginConnect (allIps, ep.Port, BCCallback, sock); /* Longer wait here, because the ms runtime * takes a lot longer to not connect @@ -1892,7 +1895,7 @@ namespace MonoTests.System.Net.Sockets ProtocolType.Tcp); IPAddress[] ips = new IPAddress[4]; IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, - 1247); + NetworkHelpers.FindFreePort ()); ips[0] = IPAddress.Parse ("127.0.0.4"); ips[1] = IPAddress.Parse ("127.0.0.3"); @@ -1903,7 +1906,7 @@ namespace MonoTests.System.Net.Sockets sock.Listen (1); try { - sock.BeginConnect (ips, 1247, BCCallback, + sock.BeginConnect (ips, ep.Port, BCCallback, sock); Assert.Fail ("BeginConnectMultipleListen #1"); } catch (InvalidOperationException) { @@ -1959,13 +1962,13 @@ namespace MonoTests.System.Net.Sockets SocketType.Stream, ProtocolType.Tcp); IPAddress ip = IPAddress.Loopback; - IPEndPoint ep = new IPEndPoint (ip, 1248); + IPEndPoint ep = new IPEndPoint (ip, NetworkHelpers.FindFreePort ()); sock.Bind (ep); sock.Listen (1); try { - sock.BeginConnect ("localhost", 1248, + sock.BeginConnect ("localhost", ep.Port, BCCallback, sock); Assert.Fail ("BeginConnectHostPortListen #1"); } catch (InvalidOperationException) { @@ -2033,12 +2036,12 @@ namespace MonoTests.System.Net.Sockets SocketType.Stream, ProtocolType.Tcp); IPAddress ip = IPAddress.Loopback; - IPEndPoint ep = new IPEndPoint (ip, 1254); + IPEndPoint ep = new IPEndPoint (ip, NetworkHelpers.FindFreePort ()); listen.Bind (ep); listen.Listen (1); - sock.Connect (ip, 1254); + sock.Connect (ip, ep.Port); Assert.AreEqual (true, sock.Connected, "BeginDisconnect #1"); @@ -2128,9 +2131,9 @@ namespace MonoTests.System.Net.Sockets SocketType.Stream, ProtocolType.Tcp); IPEndPoint ep1 = new IPEndPoint (IPAddress.Loopback, - 1256); + NetworkHelpers.FindFreePort ()); IPEndPoint ep2 = new IPEndPoint (IPAddress.Loopback, - 1257); + NetworkHelpers.FindFreePort ()); sock.Bind (ep1); @@ -2156,7 +2159,7 @@ namespace MonoTests.System.Net.Sockets SocketType.Stream, ProtocolType.Tcp); IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, - 1258); + NetworkHelpers.FindFreePort ()); listen.Bind (ep); listen.Listen (1); @@ -2184,12 +2187,12 @@ namespace MonoTests.System.Net.Sockets SocketType.Stream, ProtocolType.Tcp); IPAddress ip = IPAddress.Loopback; - IPEndPoint ep = new IPEndPoint (ip, 1249); + IPEndPoint ep = new IPEndPoint (ip, NetworkHelpers.FindFreePort ()); listen.Bind (ep); listen.Listen (1); - sock.Connect (ip, 1249); + sock.Connect (ip, ep.Port); Assert.AreEqual (true, sock.Connected, "ConnectAddressPort #1"); @@ -2223,13 +2226,13 @@ namespace MonoTests.System.Net.Sockets SocketType.Stream, ProtocolType.Tcp); IPAddress ip = IPAddress.Loopback; - IPEndPoint ep = new IPEndPoint (ip, 1250); + IPEndPoint ep = new IPEndPoint (ip, NetworkHelpers.FindFreePort ()); sock.Bind (ep); sock.Listen (1); try { - sock.Connect (ip, 1250); + sock.Connect (ip, ep.Port); Assert.Fail ("ConnectAddressPortListen #1"); } catch (InvalidOperationException) { } catch { @@ -2281,7 +2284,7 @@ namespace MonoTests.System.Net.Sockets SocketType.Stream, ProtocolType.Tcp); IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, - 1251); + NetworkHelpers.FindFreePort ()); IPAddress[] ips = new IPAddress[4]; ips[0] = IPAddress.Parse ("127.0.0.4"); @@ -2292,7 +2295,7 @@ namespace MonoTests.System.Net.Sockets listen.Bind (ep); listen.Listen (1); - sock.Connect (ips, 1251); + sock.Connect (ips, ep.Port); Assert.AreEqual (true, sock.Connected, "ConnectMultiple #1"); Assert.AreEqual (AddressFamily.InterNetwork, sock.RemoteEndPoint.AddressFamily, "ConnectMultiple #2"); @@ -2327,12 +2330,12 @@ namespace MonoTests.System.Net.Sockets * Bind to IPAddress.Any; Connect() will fail unless it can * connect to all the addresses in allIps. */ - IPEndPoint ep = new IPEndPoint (IPAddress.Any, 1251); + IPEndPoint ep = new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ()); listen.Bind (ep); listen.Listen (1); - sock.Connect (allIps, 1251); + sock.Connect (allIps, ep.Port); Assert.AreEqual (true, sock.Connected, "ConnectMultiple2 #1"); Assert.AreEqual (AddressFamily.InterNetwork, sock.RemoteEndPoint.AddressFamily, "ConnectMultiple2 #2"); @@ -2371,7 +2374,7 @@ namespace MonoTests.System.Net.Sockets ProtocolType.Tcp); IPAddress[] ips = new IPAddress[4]; IPEndPoint ep = new IPEndPoint (IPAddress.Loopback, - 1252); + NetworkHelpers.FindFreePort ()); ips[0] = IPAddress.Parse ("127.0.0.4"); ips[1] = IPAddress.Parse ("127.0.0.3"); @@ -2382,7 +2385,7 @@ namespace MonoTests.System.Net.Sockets sock.Listen (1); try { - sock.Connect (ips, 1252); + sock.Connect (ips, ep.Port); Assert.Fail ("ConnectMultipleListen #1"); } catch (InvalidOperationException) { } catch { @@ -2436,13 +2439,13 @@ namespace MonoTests.System.Net.Sockets SocketType.Stream, ProtocolType.Tcp); IPAddress ip = IPAddress.Loopback; - IPEndPoint ep = new IPEndPoint (ip, 1253); + IPEndPoint ep = new IPEndPoint (ip, NetworkHelpers.FindFreePort ()); sock.Bind (ep); sock.Listen (1); try { - sock.Connect ("localhost", 1253); + sock.Connect ("localhost", ep.Port); Assert.Fail ("ConnectHostPortListen #1"); } catch (InvalidOperationException) { } catch { @@ -2495,12 +2498,12 @@ namespace MonoTests.System.Net.Sockets SocketType.Stream, ProtocolType.Tcp); IPAddress ip = IPAddress.Loopback; - IPEndPoint ep = new IPEndPoint (ip, 1255); + IPEndPoint ep = new IPEndPoint (ip, NetworkHelpers.FindFreePort ()); listen.Bind (ep); listen.Listen (1); - sock.Connect (ip, 1255); + sock.Connect (ip, ep.Port); Assert.AreEqual (true, sock.Connected, "Disconnect #1"); @@ -2547,7 +2550,7 @@ namespace MonoTests.System.Net.Sockets { int i; - IPEndPoint endpoint = new IPEndPoint(IPAddress.Loopback, 1258); + IPEndPoint endpoint = new IPEndPoint(IPAddress.Loopback, NetworkHelpers.FindFreePort ()); Socket listensock = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); listensock.Bind (endpoint); @@ -2604,7 +2607,7 @@ namespace MonoTests.System.Net.Sockets { int i; - IPEndPoint endpoint = new IPEndPoint(IPAddress.Loopback, 1259); + IPEndPoint endpoint = new IPEndPoint(IPAddress.Loopback, NetworkHelpers.FindFreePort ()); Socket listensock = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); listensock.Bind (endpoint); @@ -2700,7 +2703,7 @@ namespace MonoTests.System.Net.Sockets SocketType.Dgram, ProtocolType.Udp); CWRSocket.Bind (new IPEndPoint (IPAddress.Loopback, - 1256)); + NetworkHelpers.FindFreePort ())); Thread recv_thread = new Thread (new ThreadStart (CWRReceiveThread)); CWRReady.Reset (); @@ -2718,7 +2721,7 @@ namespace MonoTests.System.Net.Sockets static bool RRCLastRead = false; static ManualResetEvent RRCReady = new ManualResetEvent (false); - private static void RRCClientThread () + private static void RRCClientThread (int port) { byte[] bytes = new byte[8]; int readbyte; @@ -2727,7 +2730,7 @@ namespace MonoTests.System.Net.Sockets SocketType.Stream, ProtocolType.Tcp); sock.Connect (new IPEndPoint (IPAddress.Loopback, - 1257)); + port)); NetworkStream stream = new NetworkStream (sock); @@ -3068,7 +3071,7 @@ namespace MonoTests.System.Net.Sockets Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001); + EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ()); try { s.ReceiveFrom ((Byte []) null, ref remoteEP); Assert.Fail ("#1"); @@ -3110,7 +3113,7 @@ namespace MonoTests.System.Net.Sockets ProtocolType.Tcp); s.Close (); - EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001); + EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ()); try { s.ReceiveFrom ((Byte []) null, ref remoteEP); Assert.Fail ("#1"); @@ -3129,7 +3132,7 @@ namespace MonoTests.System.Net.Sockets Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001); + EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ()); try { s.ReceiveFrom ((Byte []) null, (SocketFlags) 666, ref remoteEP); Assert.Fail ("#1"); @@ -3171,7 +3174,7 @@ namespace MonoTests.System.Net.Sockets ProtocolType.Tcp); s.Close (); - EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001); + EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ()); try { s.ReceiveFrom ((Byte []) null, (SocketFlags) 666, ref remoteEP); Assert.Fail ("#1"); @@ -3190,7 +3193,7 @@ namespace MonoTests.System.Net.Sockets Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001); + EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ()); try { s.ReceiveFrom ((Byte []) null, 0, (SocketFlags) 666, ref remoteEP); @@ -3231,7 +3234,7 @@ namespace MonoTests.System.Net.Sockets { Socket s; byte [] buffer = new byte [5]; - EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001); + EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ()); // size negative s = new Socket (AddressFamily.InterNetwork, SocketType.Stream, @@ -3274,7 +3277,7 @@ namespace MonoTests.System.Net.Sockets ProtocolType.Tcp); s.Close (); - EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001); + EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ()); try { s.ReceiveFrom ((Byte []) null, -1, (SocketFlags) 666, ref remoteEP); @@ -3293,7 +3296,7 @@ namespace MonoTests.System.Net.Sockets { Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001); + EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ()); try { s.ReceiveFrom ((Byte []) null, -1, -1, (SocketFlags) 666, @@ -3312,7 +3315,7 @@ namespace MonoTests.System.Net.Sockets { Socket s; byte [] buffer = new byte [5]; - EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001); + EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ()); // offset negative s = new Socket (AddressFamily.InterNetwork, SocketType.Stream, @@ -3375,7 +3378,7 @@ namespace MonoTests.System.Net.Sockets { Socket s; byte [] buffer = new byte [5]; - EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001); + EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ()); // size negative s = new Socket (AddressFamily.InterNetwork, SocketType.Stream, @@ -3436,7 +3439,7 @@ namespace MonoTests.System.Net.Sockets s.Close (); byte [] buffer = new byte [5]; - EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, 8001); + EndPoint remoteEP = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ()); try { s.ReceiveFrom (buffer, -1, -1, (SocketFlags) 666, ref remoteEP); @@ -3453,14 +3456,15 @@ namespace MonoTests.System.Net.Sockets [Test] public void ReceiveRemoteClosed () { + var port = NetworkHelpers.FindFreePort (); Socket sock = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - sock.Bind (new IPEndPoint (IPAddress.Loopback, 1257)); + sock.Bind (new IPEndPoint (IPAddress.Loopback, port)); sock.Listen (1); RRCReady.Reset (); - Thread client_thread = new Thread (new ThreadStart (RRCClientThread)); + Thread client_thread = new Thread (() => RRCClientThread (port)); client_thread.Start (); Socket client = sock.Accept (); @@ -3482,12 +3486,13 @@ namespace MonoTests.System.Net.Sockets Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); s.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1); - s.Bind (new IPEndPoint (IPAddress.Any, 12345)); + var ep = new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ()); + s.Bind (ep); Socket ss = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); ss.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1); - ss.Bind (new IPEndPoint (IPAddress.Any, 12345)); + ss.Bind (new IPEndPoint (IPAddress.Any, ep.Port)); // If we make it this far, we succeeded. @@ -3525,15 +3530,15 @@ namespace MonoTests.System.Net.Sockets using (Socket ss = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) { s.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); - - s.Bind (new IPEndPoint (IPAddress.Any, 12345)); + var ep = new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ()); + s.Bind (ep); s.Listen(1); ss.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); Exception ex = null; try { - ss.Bind (new IPEndPoint (IPAddress.Any, 12345)); + ss.Bind (new IPEndPoint (IPAddress.Any, ep.Port)); ss.Listen(1); } catch (SocketException e) { ex = e; @@ -3547,11 +3552,11 @@ namespace MonoTests.System.Net.Sockets [Category ("NotOnMac")] public void ConnectedProperty () { - TcpListener listener = new TcpListener (IPAddress.Loopback, 23456); + TcpListener listener = new TcpListener (IPAddress.Loopback, NetworkHelpers.FindFreePort ()); listener.Start(); Socket client = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - client.Connect (IPAddress.Loopback, 23456); + client.Connect (IPAddress.Loopback, ((IPEndPoint)listener.LocalEndpoint).Port); Socket server = listener.AcceptSocket (); try { @@ -3753,7 +3758,7 @@ namespace MonoTests.System.Net.Sockets IPAddress mcast_addr = IPAddress.Parse ("239.255.255.250"); using (Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)) { - s.Bind (new IPEndPoint (IPAddress.Any, 1901)); + s.Bind (new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ())); try { s.SetSocketOption (SocketOptionLevel.IP, SocketOptionName.AddMembership, new IPv6MulticastOption (mcast_addr)); @@ -3775,7 +3780,7 @@ namespace MonoTests.System.Net.Sockets IPAddress mcast_addr = IPAddress.Parse ("239.255.255.250"); using (Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)) { - s.Bind (new IPEndPoint (IPAddress.Any, 1901)); + s.Bind (new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ())); s.SetSocketOption (SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption (mcast_addr)); } @@ -3814,7 +3819,7 @@ namespace MonoTests.System.Net.Sockets IPAddress mcast_addr = IPAddress.Parse ("ff02::1"); using (Socket s = new Socket (AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp)) { - s.Bind (new IPEndPoint (IPAddress.IPv6Any, 1902)); + s.Bind (new IPEndPoint (IPAddress.IPv6Any, NetworkHelpers.FindFreePort ())); s.SetSocketOption (SocketOptionLevel.IPv6, SocketOptionName.AddMembership, new IPv6MulticastOption (mcast_addr)); } @@ -3829,7 +3834,7 @@ namespace MonoTests.System.Net.Sockets IPAddress mcast_addr = IPAddress.Parse ("ff02::1"); using (Socket s = new Socket (AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp)) { - s.Bind (new IPEndPoint (IPAddress.IPv6Any, 1902)); + s.Bind (new IPEndPoint (IPAddress.IPv6Any, NetworkHelpers.FindFreePort ())); try { s.SetSocketOption (SocketOptionLevel.IPv6, SocketOptionName.AddMembership, new MulticastOption (mcast_addr)); @@ -3980,7 +3985,7 @@ namespace MonoTests.System.Net.Sockets IPAddress mcast_addr = IPAddress.Parse ("239.255.255.250"); using (Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)) { - s.Bind (new IPEndPoint (IPAddress.Any, 1901)); + s.Bind (new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ())); s.SetSocketOption (SocketOptionLevel.IP, SocketOptionName.AddMembership, new MulticastOption (mcast_addr)); try { @@ -4006,7 +4011,7 @@ namespace MonoTests.System.Net.Sockets using (Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)) { MulticastOption option = new MulticastOption (mcast_addr); - s.Bind (new IPEndPoint (IPAddress.Any, 1901)); + s.Bind (new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ())); s.SetSocketOption (SocketOptionLevel.IP, SocketOptionName.AddMembership, option); s.SetSocketOption (SocketOptionLevel.IP, SocketOptionName.DropMembership, @@ -4065,7 +4070,7 @@ namespace MonoTests.System.Net.Sockets IPAddress mcast_addr = IPAddress.Parse ("ff02::1"); using (Socket s = new Socket (AddressFamily.InterNetworkV6, SocketType.Dgram, ProtocolType.Udp)) { - s.Bind (new IPEndPoint (IPAddress.IPv6Any, 1902)); + s.Bind (new IPEndPoint (IPAddress.IPv6Any, NetworkHelpers.FindFreePort ())); s.SetSocketOption (SocketOptionLevel.IPv6, SocketOptionName.AddMembership, new IPv6MulticastOption (mcast_addr)); try { @@ -4194,7 +4199,7 @@ namespace MonoTests.System.Net.Sockets public void Shutdown_NoConnect () { Socket s = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - s.Bind (new IPEndPoint (IPAddress.Loopback, 0)); + s.Bind (new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ())); s.Listen (1); try { s.Shutdown (SocketShutdown.Both); @@ -4332,7 +4337,7 @@ namespace MonoTests.System.Net.Sockets public void ConnectToIPV4EndPointUsingDualModelSocket () { using (var server = new Socket (SocketType.Stream, ProtocolType.Tcp)) using (var client = new Socket (SocketType.Stream, ProtocolType.Tcp)) { - var host = new IPEndPoint (IPAddress.Loopback, 0); + var host = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ()); server.Bind (host); server.Listen (0); @@ -4354,7 +4359,7 @@ namespace MonoTests.System.Net.Sockets public void BeginConnectToIPV4EndPointUsingDualModelSocket () { using (var server = new Socket (SocketType.Stream, ProtocolType.Tcp)) using (var client = new Socket (SocketType.Stream, ProtocolType.Tcp)) { - var host = new IPEndPoint (IPAddress.Loopback, 0); + var host = new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ()); server.Bind (host); server.Listen (0); @@ -4383,7 +4388,7 @@ namespace MonoTests.System.Net.Sockets Socket listenSocket = new Socket (AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); - listenSocket.Bind (new IPEndPoint (IPAddress.Loopback, 0)); + listenSocket.Bind (new IPEndPoint (IPAddress.Loopback, NetworkHelpers.FindFreePort ())); listenSocket.Listen (1); listenSocket.BeginAccept (new AsyncCallback (ReceiveCallback), listenSocket); @@ -4408,7 +4413,7 @@ namespace MonoTests.System.Net.Sockets /* see https://bugzilla.xamarin.com/show_bug.cgi?id=36941 */ using (Socket socket = new Socket (AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)) { - IPEndPoint end_point = new IPEndPoint (IPAddress.Any, 11000); + IPEndPoint end_point = new IPEndPoint (IPAddress.Any, NetworkHelpers.FindFreePort ()); socket.SetSocketOption (SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1); socket.Bind (end_point); socket.SetSocketOption (SocketOptionLevel.IP, SocketOptionName.MulticastTimeToLive, 19); diff --git a/mcs/class/corlib/Makefile b/mcs/class/corlib/Makefile index 9fc807acc27..2540e236031 100644 --- a/mcs/class/corlib/Makefile +++ b/mcs/class/corlib/Makefile @@ -67,7 +67,7 @@ CORLIB_MONO_POSIX_REF = -r:Mono.Posix.dll endif # System.IO/DirectoryInfoTest.cs needs Mono.Posix -TEST_MCS_FLAGS += -debug -nowarn:168,219,618,672 -unsafe $(CORLIB_MONO_POSIX_REF) -r:System.Core.dll \ +TEST_MCS_FLAGS += -debug -nowarn:168,219,618,672 -unsafe $(CORLIB_MONO_POSIX_REF) -r:System.Core.dll -r:System.dll \ -define:MONO_DATACONVERTER_STATIC_METHODS $(TEST_RESX_RESOURCES:%=-resource:%) EXTRA_DISTFILES = \ @@ -95,39 +95,6 @@ CLEAN_FILES += $(TEST_RESX_RESOURCES) include $(topdir)/build/library.make -ifdef FIXME_CORLIB_CMP -# corlib_cmp -corlib_flags = -unsafe -nostdlib -cmplib = $(topdir)/class/lib/$(PROFILE)/corlib_cmp.dll -cmppdb = $(cmplib:.dll=.pdb) -cmp_response = $(depsdir)/$(PROFILE)_corlib_cmp.dll.response -cmp_makefrag = $(depsdir)/$(PROFILE)_corlib_cmp.dll.makefrag -cmp_flags = -r:$(PLATFORM_CORLIB) $(corlib_flags) - -EXTRA_DISTFILES += corlib_cmp.dll.excludes -CLEAN_FILES += $(cmplib) $(cmp_response) $(cmp_makefrag) $(cmppdb) - -$(cmplib): $(cmp_makefrag) $(cmp_response) - $(BOOT_COMPILE) $(LIBRARY_FLAGS) $(cmp_flags) -target:library -out:$@ @$(cmp_response) - -$(cmp_response): $(sourcefile) corlib_cmp.dll.excludes - @echo Creating $@ ... - @sort $(sourcefile) corlib_cmp.dll.excludes | uniq -u | $(PLATFORM_CHANGE_SEPARATOR_CMD) >$@ - -$(cmp_makefrag): $(cmp_response) - @echo Creating $@ ... - @sed 's,^,$(cmplib): ,' $< >$@ - -# Since we make corlib_cmp on demand, there isn't a real need -# to have full dep tracking for it. Also, the generation of this -# file is busted on Win32 ('sort' seems to mess up line endings), -# leading to a broken build. -# -# -include $(cmp_makefrag) - -$(cmp_response) $(cmp_makefrag): Makefile $(depsdir)/.stamp -endif - $(TEST_RESX_RESOURCES) $(TEST_RESX_RESOURCES_SATELITE): %.resources: %.resx $(RESGEN) $< || cp $@.prebuilt $@ diff --git a/mcs/class/corlib/Mono/DataConverter.cs b/mcs/class/corlib/Mono/DataConverter.cs index daf8eb72322..b442da4d2fb 100644 --- a/mcs/class/corlib/Mono/DataConverter.cs +++ b/mcs/class/corlib/Mono/DataConverter.cs @@ -683,7 +683,11 @@ namespace Mono { n = 2; break; case '7': +#if PCL + e = Encoding.GetEncoding ("utf-7"); +#else e = Encoding.UTF7; +#endif n = 1; break; case 'b': @@ -691,11 +695,19 @@ namespace Mono { n = 2; break; case '3': +#if PCL + e = Encoding.GetEncoding ("utf-32"); +#else e = Encoding.GetEncoding (12000); +#endif n = 4; break; case '4': +#if PCL + e = Encoding.GetEncoding ("utf-32BE"); +#else e = Encoding.GetEncoding (12001); +#endif n = 4; break; diff --git a/mcs/class/corlib/System.Diagnostics.Tracing/EventAttribute.cs b/mcs/class/corlib/System.Diagnostics.Tracing/EventAttribute.cs index 33ff04a566a..a0d0fd05b21 100644 --- a/mcs/class/corlib/System.Diagnostics.Tracing/EventAttribute.cs +++ b/mcs/class/corlib/System.Diagnostics.Tracing/EventAttribute.cs @@ -43,7 +43,10 @@ namespace System.Diagnostics.Tracing public EventLevel Level { get; set; } public EventKeywords Keywords { get; set; } - + public EventOpcode Opcode { get; set; } + public EventChannel Channel { get; set; } + public string Message { get; set; } + public EventTask Task { get; set; } } } diff --git a/mcs/class/corlib/System.Reflection.Emit/MethodOnTypeBuilderInst.cs b/mcs/class/corlib/System.Reflection.Emit/MethodOnTypeBuilderInst.cs index 41a79eb6d7e..9bc0b8a5994 100644 --- a/mcs/class/corlib/System.Reflection.Emit/MethodOnTypeBuilderInst.cs +++ b/mcs/class/corlib/System.Reflection.Emit/MethodOnTypeBuilderInst.cs @@ -283,6 +283,12 @@ namespace System.Reflection.Emit throw new NotSupportedException (); } + public override ParameterInfo ReturnParameter { + get { + throw new NotSupportedException(); + } + } + public override ICustomAttributeProvider ReturnTypeCustomAttributes { get { throw new NotSupportedException (); diff --git a/mcs/class/corlib/System.Reflection/MethodInfo.cs b/mcs/class/corlib/System.Reflection/MethodInfo.cs deleted file mode 100644 index 83fc9a72ac9..00000000000 --- a/mcs/class/corlib/System.Reflection/MethodInfo.cs +++ /dev/null @@ -1,155 +0,0 @@ -// -// System.Reflection/MethodInfo.cs -// -// Author: -// Paolo Molaro (lupus@ximian.com) -// -// (C) 2001 Ximian, Inc. http://www.ximian.com -// Copyright (C) 2004-2005 Novell, Inc (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System.Diagnostics; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace System.Reflection { - - [ComVisible (true)] - [ComDefaultInterfaceAttribute (typeof (_MethodInfo))] - [Serializable] - [ClassInterface(ClassInterfaceType.None)] -#if MOBILE - public abstract class MethodInfo: MethodBase { -#else - public abstract class MethodInfo: MethodBase, _MethodInfo { -#endif - public abstract MethodInfo GetBaseDefinition(); - - internal virtual MethodInfo GetBaseMethod () - { - return this; - } - - protected MethodInfo() { - } - - - public override MemberTypes MemberType { get {return MemberTypes.Method;} } - - public virtual Type ReturnType { - get { return null; } - } - - public abstract ICustomAttributeProvider ReturnTypeCustomAttributes { get; } - -#if !MOBILE - void _MethodInfo.GetIDsOfNames ([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId) - { - throw new NotImplementedException (); - } - - Type _MethodInfo.GetType () - { - // Required or object::GetType becomes virtual final - return base.GetType (); - } - - void _MethodInfo.GetTypeInfo (uint iTInfo, uint lcid, IntPtr ppTInfo) - { - throw new NotImplementedException (); - } - - void _MethodInfo.GetTypeInfoCount (out uint pcTInfo) - { - throw new NotImplementedException (); - } - - void _MethodInfo.Invoke (uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr) - { - throw new NotImplementedException (); - } -#endif - - [ComVisible (true)] - public virtual MethodInfo GetGenericMethodDefinition () - { - throw new NotSupportedException (); - } - - public virtual MethodInfo MakeGenericMethod (params Type [] typeArguments) - { - throw new NotSupportedException (this.GetType().ToString ()); - } - - // GetGenericArguments, IsGenericMethod, IsGenericMethodDefinition - // and ContainsGenericParameters are implemented in the derived classes. - [ComVisible (true)] - public override Type [] GetGenericArguments () { - return Type.EmptyTypes; - } - - - public virtual ParameterInfo ReturnParameter { - get { - throw new NotSupportedException (); - } - } - - public override bool Equals (object obj) - { - return obj == (object) this; - } - - public override int GetHashCode () - { - return base.GetHashCode (); - } - - public static bool operator == (MethodInfo left, MethodInfo right) - { - if ((object)left == (object)right) - return true; - if ((object)left == null ^ (object)right == null) - return false; - return left.Equals (right); - } - - public static bool operator != (MethodInfo left, MethodInfo right) - { - if ((object)left == (object)right) - return false; - if ((object)left == null ^ (object)right == null) - return true; - return !left.Equals (right); - } - - public virtual Delegate CreateDelegate (Type delegateType) - { - return Delegate.CreateDelegate (delegateType, this); - } - - public virtual Delegate CreateDelegate (Type delegateType, object target) - { - return Delegate.CreateDelegate (delegateType, target, this); - } - } -} diff --git a/mcs/class/corlib/System.Reflection/MonoMethod.cs b/mcs/class/corlib/System.Reflection/MonoMethod.cs index f9a931f1135..544774d1786 100644 --- a/mcs/class/corlib/System.Reflection/MonoMethod.cs +++ b/mcs/class/corlib/System.Reflection/MonoMethod.cs @@ -149,6 +149,16 @@ namespace System.Reflection { return sbName.ToString(); } + public override Delegate CreateDelegate (Type delegateType) + { + return Delegate.CreateDelegate (delegateType, this); + } + + public override Delegate CreateDelegate (Type delegateType, object target) + { + return Delegate.CreateDelegate (delegateType, target, this); + } + public override String ToString() { return ReturnType.FormatTypeName() + " " + FormatNameAndSig(false); diff --git a/mcs/class/corlib/System.Security.Principal/WindowsIdentity.cs b/mcs/class/corlib/System.Security.Principal/WindowsIdentity.cs index 0ce7736f574..c86156e8ca1 100644 --- a/mcs/class/corlib/System.Security.Principal/WindowsIdentity.cs +++ b/mcs/class/corlib/System.Security.Principal/WindowsIdentity.cs @@ -34,6 +34,7 @@ using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Security.Permissions; using System.Security.Claims; +using Microsoft.Win32.SafeHandles; namespace System.Security.Principal { @@ -312,6 +313,10 @@ namespace System.Security.Principal { } } + public SafeAccessTokenHandle AccessToken { + get { throw new NotImplementedException (); } + } + // see mono/mono/metadata/security.c for implementation // Many people use reflection to get a user's roles - so many diff --git a/mcs/class/corlib/System.Security/SafeAccessTokenHandle.cs b/mcs/class/corlib/System.Security/SafeAccessTokenHandle.cs new file mode 100644 index 00000000000..d7682bfd2ff --- /dev/null +++ b/mcs/class/corlib/System.Security/SafeAccessTokenHandle.cs @@ -0,0 +1,25 @@ +using System; +using System.Runtime.InteropServices; + +namespace Microsoft.Win32.SafeHandles +{ + public sealed class SafeAccessTokenHandle : SafeHandle + { + public override bool IsInvalid { + get { + return handle == IntPtr.Zero; + } + } + + public SafeAccessTokenHandle () + : base (IntPtr.Zero, true) + { + + } + + protected override bool ReleaseHandle() + { + return true; + } + } +} diff --git a/mcs/class/corlib/Test/System.IO/FileStreamTest.cs b/mcs/class/corlib/Test/System.IO/FileStreamTest.cs index be6236d6a07..2eae58e3e44 100644 --- a/mcs/class/corlib/Test/System.IO/FileStreamTest.cs +++ b/mcs/class/corlib/Test/System.IO/FileStreamTest.cs @@ -1660,6 +1660,25 @@ namespace MonoTests.System.IO } + [Test] + public void OpenCharDeviceRepeatedly () + { + // https://bugzilla.xamarin.com/show_bug.cgi?id=38408 + try { + using (var f = new FileStream ("/dev/zero", FileMode.Open)) + { + } + } catch (FileNotFoundException) { + // Only run this test on platforms where /dev/zero exists + Assert.Ignore(); + } + + // this shouldn't throw + using (var g = new FileStream ("/dev/zero", FileMode.Open)) + { + } + } + #if !MOBILE [Test] public void WriteWithExposedHandle () diff --git a/mcs/class/corlib/Test/System.Text/UTF8EncodingTest.cs b/mcs/class/corlib/Test/System.Text/UTF8EncodingTest.cs index 82aab2be061..474abcd2208 100644 --- a/mcs/class/corlib/Test/System.Text/UTF8EncodingTest.cs +++ b/mcs/class/corlib/Test/System.Text/UTF8EncodingTest.cs @@ -175,7 +175,14 @@ namespace MonoTests.System.Text Assert.AreEqual (0x32, (int) s [5], "#B7"); } - // UTF8 decoding tests from http://www.cl.cam.ac.uk/~mgk25/ + // + // UTF8 decoding tests are based on the test file from http://www.cl.cam.ac.uk/~mgk25/ + // The test file is: https://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt + // which is licensed under CC-by-4.0: https://creativecommons.org/licenses/by/4.0/ + // + // The file is not copied verbatim, instead individual + // tests are based on individual portions of that file + // [Test] public void T1_Correct_GreekWord_kosme () diff --git a/mcs/class/corlib/Test/System/StringTest.cs b/mcs/class/corlib/Test/System/StringTest.cs index 7119236c8aa..a45c7ec198c 100644 --- a/mcs/class/corlib/Test/System/StringTest.cs +++ b/mcs/class/corlib/Test/System/StringTest.cs @@ -16,6 +16,10 @@ using System.Globalization; using System.Reflection; using System.Threading; +#if !MOBILE +using System.Diagnostics; +#endif + using NUnit.Framework; namespace MonoTests.System @@ -92,19 +96,36 @@ public class StringTest } } + // Several tests in this file, to run properly, allocate 4GB objects. + // Obviously this creates problems on several kinds of systems, so we + // conservatively skip these tests unless we find a high-RAM environment. + // Checking RAM requires PerformanceCounter which is absent on mobile, + // so any test that calls this must be category MobileNotWorking. + static void RequireHighMemoryTestEnvironment () + { +#if MOBILE + Assert.Ignore("PerformanceCounter not available."); +#else + if (!Environment.Is64BitProcess) + Assert.Ignore("This test cannot run on a 32-bit system."); + + // Require 6 GB physical RAM, for the 4GB string plus 2GB headroom + var pc = new PerformanceCounter ("Mono Memory", "Total Physical Memory"); + + if (pc.RawValue < 6L*1024L*1024L*1024L) + Assert.Ignore("This machine may not have enough RAM to run this test."); +#endif + } + [Test] // ctor (Char, Int32) + [Category ("MobileNotWorking")] public void Constructor4_LargeString () { - try { - var x = new String ('A', int.MaxValue); - if (Environment.Is64BitProcess) { - Assert.AreEqual ('A', x[0]); - Assert.AreEqual ('A', x[int.MaxValue - 1]); - } - else - Assert.Fail ("Expected OutOfMemoryException."); - } catch (OutOfMemoryException) { - } + RequireHighMemoryTestEnvironment(); + + var x = new String ('A', int.MaxValue); + Assert.AreEqual ('A', x[0]); + Assert.AreEqual ('A', x[int.MaxValue - 1]); } [Test] // ctor (Char [], Int32, Int32) @@ -3008,18 +3029,14 @@ public class StringTest } [Test] + [Category ("MobileNotWorking")] public void PadLeft_LargeString () { - try { - var x = "x".PadLeft (int.MaxValue, '-'); - if (Environment.Is64BitProcess) { - Assert.AreEqual ('-', x[0]); - Assert.AreEqual ('x', x[int.MaxValue - 1]); - } - else - Assert.Fail ("Expected OutOfMemoryException."); - } catch (OutOfMemoryException) { - } + RequireHighMemoryTestEnvironment(); + + var x = "x".PadLeft (int.MaxValue, '-'); + Assert.AreEqual ('-', x[0]); + Assert.AreEqual ('x', x[int.MaxValue - 1]); } [Test] // PadRight (Int32) @@ -3064,18 +3081,14 @@ public class StringTest } [Test] + [Category ("MobileNotWorking")] public void PadRight_LargeString () { - try { - var x = "x".PadRight (int.MaxValue, '-'); - if (Environment.Is64BitProcess) { - Assert.AreEqual ('x', x[0]); - Assert.AreEqual ('-', x[int.MaxValue - 1]); - } - else - Assert.Fail ("Expected OutOfMemoryException."); - } catch (OutOfMemoryException) { - } + RequireHighMemoryTestEnvironment(); + + var x = "x".PadRight (int.MaxValue, '-'); + Assert.AreEqual ('x', x[0]); + Assert.AreEqual ('-', x[int.MaxValue - 1]); } [Test] // Remove (Int32, Int32) diff --git a/mcs/class/corlib/corlib-net_4_x.csproj b/mcs/class/corlib/corlib-net_4_x.csproj index 223880c0297..b4b398166e8 100644 --- a/mcs/class/corlib/corlib-net_4_x.csproj +++ b/mcs/class/corlib/corlib-net_4_x.csproj @@ -60,6 +60,7 @@ + @@ -1501,6 +1502,7 @@ + @@ -1537,7 +1539,6 @@ - diff --git a/mcs/class/corlib/corlib.dll.sources b/mcs/class/corlib/corlib.dll.sources index aa0f448ce34..55755abad47 100644 --- a/mcs/class/corlib/corlib.dll.sources +++ b/mcs/class/corlib/corlib.dll.sources @@ -239,7 +239,6 @@ System.Reflection/FieldInfo.cs System.Reflection/ImageFileMachine.cs System.Reflection/LocalVariableInfo.cs System.Reflection/MethodBody.cs -System.Reflection/MethodInfo.cs System.Reflection/Module.cs System.Reflection/ModuleResolveEventHandler.cs System.Reflection/MonoAssembly.cs @@ -637,6 +636,7 @@ System.Security/NamedPermissionSet.cs System.Security/PermissionBuilder.cs System.Security/PermissionSet.cs System.Security/PolicyLevelType.cs +System.Security/SafeAccessTokenHandle.cs System.Security/SecureString.cs System.Security/SecurityElement.cs System.Security/SecurityFrame.cs @@ -1137,6 +1137,7 @@ ReferenceSources/SecurityContext.cs ../../../external/referencesource/mscorlib/system/diagnostics/contracts/contracts.cs ../../../external/referencesource/mscorlib/system/diagnostics/contracts/contractsbcl.cs +../../../external/referencesource/mscorlib/system/diagnostics/eventing/winmeta.cs ../../../external/referencesource/mscorlib/system/globalization/bidicategory.cs ../../../external/referencesource/mscorlib/system/globalization/calendar.cs @@ -1236,6 +1237,7 @@ ReferenceSources/SecurityContext.cs ../../../external/referencesource/mscorlib/system/reflection/methodbase.cs ../../../external/referencesource/mscorlib/system/reflection/methodbody.cs ../../../external/referencesource/mscorlib/system/reflection/methodimplattributes.cs +../../../external/referencesource/mscorlib/system/reflection/methodinfo.cs ../../../external/referencesource/mscorlib/system/reflection/missing.cs ../../../external/referencesource/mscorlib/system/reflection/obfuscateassemblyattribute.cs ../../../external/referencesource/mscorlib/system/reflection/obfuscationattribute.cs diff --git a/mcs/mcs/assembly.cs b/mcs/mcs/assembly.cs index 69097d49639..d69feb3de5b 100644 --- a/mcs/mcs/assembly.cs +++ b/mcs/mcs/assembly.cs @@ -77,6 +77,7 @@ namespace Mono.CSharp // Win32 version info values string vi_product, vi_product_version, vi_company, vi_copyright, vi_trademark; + string pa_file_version, pa_assembly_version; protected AssemblyDefinition (ModuleContainer module, string name) { @@ -240,6 +241,7 @@ namespace Mono.CSharp SetCustomAttribute (ctor, cdata); } else { builder_extra.SetVersion (vinfo, a.Location); + pa_assembly_version = vinfo.ToString (); } return; @@ -357,15 +359,15 @@ namespace Mono.CSharp } else if (a.Type == pa.RuntimeCompatibility) { wrap_non_exception_throws_custom = true; } else if (a.Type == pa.AssemblyFileVersion) { - vi_product_version = a.GetString (); - if (string.IsNullOrEmpty (vi_product_version) || IsValidAssemblyVersion (vi_product_version, false) == null) { + pa_file_version = a.GetString (); + if (string.IsNullOrEmpty (pa_file_version) || IsValidAssemblyVersion (pa_file_version, false) == null) { Report.Warning (7035, 1, a.Location, "The specified version string `{0}' does not conform to the recommended format major.minor.build.revision", - vi_product_version, a.Name); + pa_file_version, a.Name); return; } // File version info decoding from blob is not supported - var cab = new CustomAttributeBuilder ((ConstructorInfo) ctor.GetMetaInfo (), new object[] { vi_product_version }); + var cab = new CustomAttributeBuilder ((ConstructorInfo)ctor.GetMetaInfo (), new object [] { pa_file_version }); Builder.SetCustomAttribute (cab); return; } else if (a.Type == pa.AssemblyProduct) { @@ -378,6 +380,8 @@ namespace Mono.CSharp vi_trademark = a.GetString (); } else if (a.Type == pa.Debuggable) { has_user_debuggable = true; + } else if (a.Type == pa.AssemblyInformationalVersion) { + vi_product_version = a.GetString (); } // @@ -817,7 +821,11 @@ namespace Mono.CSharp if (Compiler.Settings.Win32ResourceFile != null) { Builder.DefineUnmanagedResource (Compiler.Settings.Win32ResourceFile); } else { - Builder.DefineVersionInfoResource (vi_product, vi_product_version, vi_company, vi_copyright, vi_trademark); + Builder.DefineVersionInfoResource (vi_product, + vi_product_version ?? pa_file_version ?? pa_assembly_version, + vi_company, + vi_copyright, + vi_trademark); } if (Compiler.Settings.Win32IconFile != null) { diff --git a/mcs/mcs/attribute.cs b/mcs/mcs/attribute.cs index a145c37211f..8edce969a44 100644 --- a/mcs/mcs/attribute.cs +++ b/mcs/mcs/attribute.cs @@ -1700,6 +1700,7 @@ namespace Mono.CSharp { public readonly PredefinedAttribute AssemblyAlgorithmId; public readonly PredefinedAttribute AssemblyFlags; public readonly PredefinedAttribute AssemblyFileVersion; + public readonly PredefinedAttribute AssemblyInformationalVersion; public readonly PredefinedAttribute ComImport; public readonly PredefinedAttribute CoClass; public readonly PredefinedAttribute AttributeUsage; @@ -1800,6 +1801,7 @@ namespace Mono.CSharp { AssemblyCompany = new PredefinedAttribute (module, "System.Reflection", "AssemblyCompanyAttribute"); AssemblyCopyright = new PredefinedAttribute (module, "System.Reflection", "AssemblyCopyrightAttribute"); AssemblyTrademark = new PredefinedAttribute (module, "System.Reflection", "AssemblyTrademarkAttribute"); + AssemblyInformationalVersion = new PredefinedAttribute (module, "System.Reflection", "AssemblyInformationalVersionAttribute"); AsyncStateMachine = new PredefinedStateMachineAttribute (module, "System.Runtime.CompilerServices", "AsyncStateMachineAttribute"); diff --git a/mcs/mcs/delegate.cs b/mcs/mcs/delegate.cs index 9ec4d99766c..8553856ac58 100644 --- a/mcs/mcs/delegate.cs +++ b/mcs/mcs/delegate.cs @@ -499,9 +499,7 @@ namespace Mono.CSharp { public override Expression CreateExpressionTree (ResolveContext ec) { - MemberAccess ma = new MemberAccess (new MemberAccess (new QualifiedAliasMember ("global", "System", loc), "Delegate", loc), "CreateDelegate", loc); - - Arguments args = new Arguments (3); + Arguments args = new Arguments (2); args.Add (new Argument (new TypeOf (type, loc))); if (method_group.InstanceExpression == null) @@ -509,7 +507,21 @@ namespace Mono.CSharp { else args.Add (new Argument (method_group.InstanceExpression)); - args.Add (new Argument (method_group.CreateExpressionTree (ec))); + Expression ma; + var create_v45 = ec.Module.PredefinedMembers.MethodInfoCreateDelegate.Get (); + if (create_v45 != null) { + // + // .NET 4.5 has better API but it produces different instance than Delegate::CreateDelegate + // and because csc uses this enhancement we have to as well to be fully compatible + // + var mg = MethodGroupExpr.CreatePredefined (create_v45, create_v45.DeclaringType, loc); + mg.InstanceExpression = method_group.CreateExpressionTree (ec); + ma = mg; + } else { + ma = new MemberAccess (new MemberAccess (new QualifiedAliasMember ("global", "System", loc), "Delegate", loc), "CreateDelegate", loc); + args.Add (new Argument (method_group.CreateExpressionTree (ec))); + } + Expression e = new Invocation (ma, args).Resolve (ec); if (e == null) return null; diff --git a/mcs/mcs/typemanager.cs b/mcs/mcs/typemanager.cs index b16e2f38b9f..a5a9ad15607 100644 --- a/mcs/mcs/typemanager.cs +++ b/mcs/mcs/typemanager.cs @@ -384,6 +384,7 @@ namespace Mono.CSharp public readonly PredefinedMember FixedBufferAttributeCtor; public readonly PredefinedMember MethodInfoGetMethodFromHandle; public readonly PredefinedMember MethodInfoGetMethodFromHandle2; + public readonly PredefinedMember MethodInfoCreateDelegate; public readonly PredefinedMember MonitorEnter; public readonly PredefinedMember MonitorEnter_v4; public readonly PredefinedMember MonitorExit; @@ -659,6 +660,10 @@ namespace Mono.CSharp MethodInfoGetMethodFromHandle2 = new PredefinedMember (module, types.MethodBase, "GetMethodFromHandle", MemberKind.Method, types.RuntimeMethodHandle, new PredefinedType (btypes.RuntimeTypeHandle)); + MethodInfoCreateDelegate = new PredefinedMember (module, types.MethodInfo, + "CreateDelegate", MemberKind.Method, + new PredefinedType (btypes.Type), new PredefinedType (btypes.Object)); + MonitorEnter = new PredefinedMember (module, types.Monitor, "Enter", btypes.Object); MonitorEnter_v4 = new PredefinedMember (module, types.Monitor, diff --git a/mcs/tests/gtest-etree-07.cs b/mcs/tests/gtest-etree-07.cs index 74a4d1ad1f4..6e46735c818 100644 --- a/mcs/tests/gtest-etree-07.cs +++ b/mcs/tests/gtest-etree-07.cs @@ -27,13 +27,13 @@ class C int TestInstance () { Expression> e = () => M; - if (e.Body.ToString () != "Convert(CreateDelegate(EmptyDelegate, value(C), Void M()))") + if (e.Body.ToString () != "Convert(Void M().CreateDelegate(EmptyDelegate, value(C)))") return 1; e.Compile () (); Expression> e2 = (l) => l.M; - if (e2.Body.ToString () != "Convert(CreateDelegate(EmptyDelegate, l, Void M()))") + if (e2.Body.ToString () != "Convert(Void M().CreateDelegate(EmptyDelegate, l))") return 2; e2.Compile () (this); @@ -43,8 +43,7 @@ class C public static int Main () { Expression> e = () => new EmptyDelegate (Test); - - if (e.Body.ToString () != "Convert(CreateDelegate(EmptyDelegate, null, Void Test()))") + if (e.Body.ToString () != "Convert(Void Test().CreateDelegate(EmptyDelegate, null))") return 1; var v = e.Compile (); @@ -54,7 +53,7 @@ class C return 2; Expression> e2 = () => Test; - if (e2.Body.ToString () != "Convert(CreateDelegate(EmptyDelegate, null, Void Test()))") + if (e2.Body.ToString () != "Convert(Void Test().CreateDelegate(EmptyDelegate, null))") return 3; var v2 = e2.Compile (); @@ -65,7 +64,7 @@ class C unsafe { Expression> e3 = () => new UnsafeDelegate (Foo); - if (e3.Body.ToString () != "Convert(CreateDelegate(UnsafeDelegate, null, Int32* Foo()))") + if (e3.Body.ToString () != "Convert(Int32* Foo().CreateDelegate(UnsafeDelegate, null))") return 5; var v3 = e3.Compile (); diff --git a/mcs/tests/gtest-etree-31.cs b/mcs/tests/gtest-etree-31.cs new file mode 100644 index 00000000000..350a64aa37e --- /dev/null +++ b/mcs/tests/gtest-etree-31.cs @@ -0,0 +1,31 @@ +using System; +using System.Linq.Expressions; + +class X +{ + class HasAction + { + public void Start () + { + } + } + + public static int Main () + { + var expectedObject = typeof (HasAction).GetMethod("Start"); + + Expression> methodToUse = r => r.Start; + + UnaryExpression unary = methodToUse.Body as UnaryExpression; + MethodCallExpression methodCall = unary.Operand as MethodCallExpression; + ConstantExpression constantExpression = methodCall.Object as ConstantExpression; + + if (expectedObject != constantExpression.Value) + return 1; + + if (methodCall.Object == null) + return 2; + + return 0; + } +} \ No newline at end of file diff --git a/mcs/tests/test-892.cs b/mcs/tests/test-892.cs index b6492798125..e57c81cfd74 100644 --- a/mcs/tests/test-892.cs +++ b/mcs/tests/test-892.cs @@ -14,6 +14,9 @@ class X if (fvi.FileVersion != "2011.02.0.0") return 1; + if (fvi.ProductVersion != "2011.02.0.0") + return 2; + return 0; } } \ No newline at end of file diff --git a/mcs/tests/ver-il-net_4_x.xml b/mcs/tests/ver-il-net_4_x.xml index 76a4c4217b6..47486e7f971 100644 --- a/mcs/tests/ver-il-net_4_x.xml +++ b/mcs/tests/ver-il-net_4_x.xml @@ -21361,7 +21361,7 @@ 102 - 142 + 141 87 @@ -21460,7 +21460,7 @@ 313 - 230 + 229 116 @@ -22310,10 +22310,10 @@ 2 - 339 + 337 - 583 + 580 7 @@ -22740,7 +22740,7 @@ 9 - 222 + 221 7 @@ -22869,6 +22869,24 @@ + + + + 241 + + + 7 + + + + + 2 + + + 7 + + + @@ -51198,7 +51216,7 @@ - 66 + 94 7 diff --git a/mcs/tools/misc/.gitattributes b/mcs/tools/misc/.gitattributes deleted file mode 100644 index 3ca3e2b5874..00000000000 --- a/mcs/tools/misc/.gitattributes +++ /dev/null @@ -1,5 +0,0 @@ -/EnumCheck.cs -crlf -/EnumCheckAssemblyCollection.cs -crlf -/GenerateDelegate.cs -crlf -/IFaceDisco.cs -crlf -/XMLUtil.cs -crlf diff --git a/mcs/tools/misc/EnumCheck.cs b/mcs/tools/misc/EnumCheck.cs deleted file mode 100644 index 8c564cc7956..00000000000 --- a/mcs/tools/misc/EnumCheck.cs +++ /dev/null @@ -1,132 +0,0 @@ -/** - * Namespace: System.Web - * Class: EnumCheck - * - * Author: Gaurav Vaish - * Contact: - * Status: 100% - * - * (C) Gaurav Vaish (2002) - */ - -using System; -using System.Xml; -using System.Collections; -using System.Reflection; - -namespace Mono.Enumerations -{ - public class EnumCheck - { - private string className; - private Type type; - private EnumCheckAssemblyCollection ecac = new EnumCheckAssemblyCollection(); - - public static string confFile = "assemblies.xml"; - - public EnumCheck(string className) - { - this.className = className; - ecac.Parse(); - } - - public void Display() - { - ecac.ConfigFile = confFile; - LoadType(); - if(type == null || !type.IsEnum) - { - System.Console.Write("-->Failed to load the enumeration: " + className); - return; - } - Array ar = Enum.GetValues(type); - System.Console.WriteLine("-->Enumeration: {0}", type.ToString()); - for(int i=0; i < ar.Length; i++) - { - Enum b = (Enum)ar.GetValue(i); - System.Console.Write(" {0}", Enum.Format(type, b, "G")); - System.Console.WriteLine(" ({0}) ", Enum.Format(type, b, "D")); - } - } - - private void LoadType() - { - type = null; - foreach(string url in ecac) - { - try - { - Assembly assembly = Assembly.LoadFrom(url); - foreach(Type t in assembly.GetTypes()) - { - if(!t.IsEnum) - continue; - if(className == t.ToString()) - { - type = t; - break; - } - } - } catch(BadImageFormatException) - { - } catch(ReflectionTypeLoadException) - { - } catch(ArgumentException) - { - } - if(type != null) - return; - } - } - - public static void PrintUsage() - { - System.Console.WriteLine("Usage:"); - System.Console.WriteLine("EnumCheck [ [ [... ] ] ]"); - System.Console.WriteLine(""); - System.Console.WriteLine("enum := [.[...]].enum_name"); - System.Console.WriteLine(""); - } - - public static void Main(string[] args) - { - if(args.Length > 0 && (args[0] == "--help" || args[0] == "-h")) - { - PrintUsage(); - return; - } - EnumCheck check = null; - string bdir; - System.Console.Write("Enter assembly configuration file [{0}]:", confFile); - //System.Console.Write("[{0}]: ", confFile); - bdir = System.Console.ReadLine(); - while(bdir.EndsWith("/") || bdir.EndsWith("\\")) - { - bdir = bdir.Substring(0, bdir.Length - 1); - } - if(bdir != "") - { - confFile = bdir; - } - if(args.Length != 0) - { - foreach(string clName in args) - { - check = new EnumCheck(clName); - check.Display(); - System.Console.WriteLine("\n"); - } - } - while(true) - { - System.Console.Write("Enter the name of the Enumeration (end to stop): "); - string clName = System.Console.ReadLine(); - if(clName == "stop" || clName == "end" || clName.Length == 0) - break; - check = new EnumCheck(clName); - check.Display(); - System.Console.WriteLine("\n"); - } - } - } -} diff --git a/mcs/tools/misc/EnumCheckAssemblyCollection.cs b/mcs/tools/misc/EnumCheckAssemblyCollection.cs deleted file mode 100644 index 470492c25b5..00000000000 --- a/mcs/tools/misc/EnumCheckAssemblyCollection.cs +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Namespace: System.Web - * Class: EnumCheckAssembly - * - * Author: Gaurav Vaish - * Contact: - * Status: 100% - * - * (C) Gaurav Vaish (2002) - */ - -using System; -using System.IO; -using System.Xml; -using System.Collections; -using System.Reflection; - -namespace Mono.Enumerations -{ - public class EnumCheckAssemblyCollection: IEnumerable - { - public string ConfigFile = "assemblies.xml"; - - private ArrayList assemblyList = new ArrayList(); - - public EnumCheckAssemblyCollection() - { - } - - public void Parse() - { - Stream fStream; - XmlReader reader; - XmlDocument document; - string url; - - fStream = new FileStream(ConfigFile, FileMode.Open, FileAccess.Read, FileShare.Read); - reader = new XmlTextReader(fStream); - document = new XmlDocument(); - document.Load(reader); - if(document.DocumentElement != null) - { - if(document.DocumentElement.LocalName == "assemblies") - { - foreach(XmlNode pathNode in document.DocumentElement) - { - if(pathNode.NodeType == XmlNodeType.Element && pathNode.LocalName=="path") - { - url = pathNode.Attributes["url"].Value; - while(url.EndsWith("\\") || url.EndsWith("/")) - { - url = url.Substring(0, url.Length - 1); - } - if(url == null || url.Length == 0) - { - continue; - } - foreach(XmlNode assemblyNode in pathNode.ChildNodes) - { - if(assemblyNode.LocalName == "assembly") - { - assemblyList.Add(url + "\\" + assemblyNode.Attributes["file"].Value); - } - } - } - } - } - } - fStream.Close(); - } - - public IEnumerator GetEnumerator() - { - return assemblyList.GetEnumerator(); - } - } -} diff --git a/mcs/tools/misc/GenerateDelegate.cs b/mcs/tools/misc/GenerateDelegate.cs deleted file mode 100644 index 0ba8e78c0a0..00000000000 --- a/mcs/tools/misc/GenerateDelegate.cs +++ /dev/null @@ -1,190 +0,0 @@ -/** - * Namespace: com.mastergaurav.utils - * Class: GenerateDelegate - * - * Author: Gaurav Vaish - * Maintainer: gvaish@iitk.ac.in - * Contact: , - * Implementation: yes - * Status: 100% - * - * (C) Gaurav Vaish (2001) - */ - -using System; -using System.IO; - -namespace com.mastergaurav.Utils -{ - public class GenerateDelegate - { - public static string TargetDirectory = String.Empty; - public static string NamespaceName = String.Empty; - - public static readonly string PROLOGUE = "/**\n * Namespace: "; - public static readonly string DETAILS = " *\n * Author: Gaurav Vaish\n" + - " * Maintainer: gvaish@iitk.ac.in\n" + - " * Contact: , \n" + - " * Implementation: yes\n" + - " * Status: 100%\n" + - " *\n" + - " * (C) Gaurav Vaish (2002)\n" + - " */\n\n"; - public static readonly string USING = "using System;\n" + - "using System.Web;\n" + - "using System.Web.UI;\n\n"; - - public static readonly string NAMESPACE = "namespace "; - - public static string AskForNamespace() - { - string nm = String.Empty; - System.Console.Write("Enter the name of the namespace: "); - nm = System.Console.ReadLine(); - return nm; - } - - public static string AskForMore() - { - string del = String.Empty; - System.Console.Write("Enter the name of the delegate (end to stop): "); - del = System.Console.ReadLine(); - if(del == String.Empty || del == "end") - return String.Empty; - return del; - } - - public static void Generate(string delName) - { - string fileName = TargetDirectory + "\\" + delName + "EventHandler.cs"; - System.Console.Write("File: ");//, fileName); - System.Console.Write(fileName); - System.Console.Write("\tGenerating"); - - StreamWriter writer; - try - { - Stream stream = new FileStream(fileName, FileMode.Truncate, FileAccess.Write); - writer = new StreamWriter(stream); - } catch(FileNotFoundException) - { - writer = File.CreateText(fileName); - } - if(writer == null) - { - System.Console.WriteLine("Null writer...\n"); - return; - } - writer.Write(PROLOGUE); - writer.Write(NamespaceName + "\n"); - writer.Write(DETAILS); - writer.Write(NAMESPACE); - writer.Write(NamespaceName + "\n"); - writer.Write("{\n"); - writer.Write("\tpublic delegate void "); - writer.Write(delName); - writer.Write("EventHandler(object sender, "); - writer.Write(delName); - writer.Write("EventArgs e);\n"); - writer.Write("}"); - - writer.Flush(); - writer.Close(); - - System.Console.WriteLine("\tGenerated\n"); - } - - public static string GetTargetDir() - { - System.Console.Write("Enter target directory: "); - return System.Console.ReadLine(); - } - - public static void Usage(bool wrong) - { - if(wrong) - { - System.Console.WriteLine("Wrong # arguments."); - } - System.Console.WriteLine("Usage: GenerateDelegate [target-dir] [namespace] [delegate1 [delegate2 [...]]]"); - } - - public static bool IsHelp(string arg) - { - return (arg == "-h" || arg == "--help"); - } - - public static bool IsDirectory(string dirName) - { - FileAttributes attrs; - try - { - attrs = File.GetAttributes(dirName); - if( (attrs & FileAttributes.Directory) != FileAttributes.Directory) - { - Usage(true); - return false; - } - }catch(Exception e) - { - System.Console.WriteLine("Exception: {0}", e.ToString()); - return false; - } - return true; - } - - public static void Main(string[] args) - { - if(args.Length == 1 && IsHelp(args[0])) - { - Usage(false); - return; - } - - if(args.Length == 0) - { - TargetDirectory = GetTargetDir(); - while(TargetDirectory.EndsWith("\\")) - { - TargetDirectory = TargetDirectory.Substring(0, TargetDirectory.Length - 1); - } - } else - { - while(args[0].EndsWith("\\")) - { - args[0] = args[0].Substring(0, args[0].Length - 1); - } - TargetDirectory = args[0]; - } - - if(!IsDirectory(TargetDirectory)) - return; - - if(args.Length > 1) - { - NamespaceName = args[1]; - } else - { - NamespaceName = AskForNamespace(); - } - - if(args.Length > 2) - { - int i=0; - foreach(string currArg in args) - { - if(i != 0) - { - Generate(currArg); - } - i++; - } - } - string delegateName = String.Empty; - while((delegateName = AskForMore()) != String.Empty) - { - Generate(delegateName); - } - } - } -} diff --git a/mcs/tools/misc/IFaceDisco.cs b/mcs/tools/misc/IFaceDisco.cs deleted file mode 100644 index 0f8a06225e9..00000000000 --- a/mcs/tools/misc/IFaceDisco.cs +++ /dev/null @@ -1,105 +0,0 @@ -// IFaceDisco.cs -// -// Nick Drochak (ndrochak@gol.com) -// -// (C) 2001 Nick Drochak - -using System; -using System.Reflection; -using System.Collections; -using System.IO; - -namespace Mono.Util -{ - class IFaceDisco { - public static void Main(string[] args) { - Assembly asm; - Type[] asmTypes; - InterfaceMapping map; - Type[] interfaces; - ArrayList TypesList = new ArrayList(); - ArrayList implementingTypes = new ArrayList(); - string asmFullPath = null; - string ifaceToDiscover = null; - - if (args.Length < 1 || args.Length > 3) { - Usage(); - return; - } - - for (int i = 0; i < args.Length; i++) { - string arg = args[i]; - - if (arg.StartsWith("-") && ((i + 1) < args.Length)) { - if (arg == "--asm") { - asmFullPath = args[++i]; - } else { - Usage(); - return; - } - } else { - // allow only one interface to discover - if (ifaceToDiscover != null){ - Usage(); - return; - } - ifaceToDiscover = arg; - } - } - - // find the assembly - if (null == asmFullPath){ - asm = Assembly.GetAssembly(typeof (System.Object)); - } - else { - try{ - asm = Assembly.LoadFrom(asmFullPath); - } - catch(Exception e){ - Console.WriteLine("Could not open assembly '{0}' for discovery. Error is: "+e.Message, asmFullPath); - return; - } - } - asmTypes = asm.GetTypes(); - - // examine all the public types - foreach(Type t in asmTypes) { - if (t.IsPublic) { - // find out which, if any, interfaces are "in" the type - interfaces= t.GetInterfaces(); - if (null != interfaces){ - // look for the interface we want to discover - foreach (Type iface in interfaces) { - // this area seems to throw an exception sometimes, just ignore it - try{ - if (iface.FullName.ToLower() == args[0].ToLower()) { - // find out if this type is the one which "declares" the interface - map = t.GetInterfaceMap(iface); - if (map.TargetMethods[0].DeclaringType.FullName == t.FullName){ - // if so, then we found a class to report - implementingTypes.Add(t.FullName); - } // if - } // if - }catch{} - } // foreach - } // if - } // if - } // foreach - - // sort the list to make it easier to find what you are looking for - implementingTypes.Sort(); - Console.WriteLine(XMLUtil.ToXML(implementingTypes, "Type", "ImplementingTypes")); - } // Main() - - private static void Usage() { - Console.WriteLine ( - "Mono Interface Discovery Tool\n" + - "usage: ifacedisco [--asm assembly] interface\n\n" + - " The full path to 'assembly' should be specified when using --asm.\n" + - " If 'assembly' is not specified, the assembly that contains System.Object will be used.\n" + - " Use the fully qualified form for 'interface', e.g. System.Runtime.Serialization.ISerializable\n" - ); - } // Usage() - - } // class IFaceDisco -} // namespace Mono.Util diff --git a/mcs/tools/misc/XMLUtil.cs b/mcs/tools/misc/XMLUtil.cs deleted file mode 100644 index 0643472ad28..00000000000 --- a/mcs/tools/misc/XMLUtil.cs +++ /dev/null @@ -1,36 +0,0 @@ -// IFaceDisco.cs -// -// Nick Drochak (ndrochak@gol.com) -// -// (C) 2001 Nick Drochak - -using System; -using System.Text; -using System.Collections; - -namespace Mono.Util -{ - class XMLUtil{ - public static string ToXML( - ArrayList list, - string itemWrap, - string listWrap) - { - if (null == itemWrap){ - throw new ArgumentNullException("itemWrap"); - } - if (null == listWrap){ - throw new ArgumentNullException("listWrap"); - } - StringBuilder output = new StringBuilder(); - output.Append("<"+listWrap+">"); - foreach(object o in list){ - output.Append("\n<"+itemWrap+">"); - output.Append(o.ToString()); - output.Append(""); - } - output.Append("\n"); - return output.ToString(); - } - } -} \ No newline at end of file diff --git a/mcs/tools/misc/monostyle.cs b/mcs/tools/misc/monostyle.cs deleted file mode 100644 index 845ab93fa82..00000000000 --- a/mcs/tools/misc/monostyle.cs +++ /dev/null @@ -1,368 +0,0 @@ -// monostyle.cs -// -// Adam Treat (manyoso@yahoo.com) -// Ben Maurer (bmaurer@users.sf.net) -// (C) 2002 Adam Treat -// (C) 2003 Ben Maurer -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2 of the License, or -// (at your option) any later version. - -using System; -using System.IO; -using System.Text.RegularExpressions; -using System.Collections.Specialized; - -namespace Mono.Util { - - class MonoStyle { - - string file; - StringCollection filebuffer; - bool linespace = true; - - void Usage() - { - Console.Write ( - "monostyle -f file.cs -l > output.cs\n\n" + - " -f || /-f || --file file.cs The csharp source file to parse.\n\n" + - " -l || /-l || --line Specifies wether to use line spacing.\n\n"); - } - - public static void Main (string[] args) - { - MonoStyle style = new MonoStyle(args); - } - - public MonoStyle (string[] args) - { - int argc = args.Length; - for(int i = 0; i < argc; i++) { - string arg = args[i]; - // The "/" switch is there for wine users, like me ;-) - if(arg.StartsWith("-") || arg.StartsWith("/")) { - switch(arg) { - case "-l": case "/-l": case "--line": - if((i + 1) >= argc) { - Usage(); - return; - } - if (args[i++] == "false") { - linespace = false; - } - continue; - case "-f": case "/-f": case "--file": - if((i + 1) >= argc) { - Usage(); - return; - } - file = args[++i]; - continue; - default: - Usage(); - return; - } - } - } - if(file == null) { - Usage(); - return; - } - filebuffer = new StringCollection(); - StreamReader sr = new StreamReader(file); - FillBuffer(sr); - FixMonoStyle(); - PrintToConsole(); - } - - public void FillBuffer(StreamReader sr) - { - sr.BaseStream.Seek(0, SeekOrigin.Begin); - while (sr.Peek() > -1) { - filebuffer.Add(sr.ReadLine()); - } - sr.Close(); - } - - public void FixMonoStyle() - { - for (int i=0; i < filebuffer.Count; i++) { - IsBadMonoStyle(filebuffer[i]); - } - } - - public void PrintToConsole() - { - for (int i=0; i < filebuffer.Count; i++) { - Console.WriteLine(filebuffer[i]); - } - } - - public void IsBadMonoStyle(String str) - { - if (IsBadMonoType(str)) { - FixHangingBrace(str); - } else if(IsBadMonoFlow(str)) { - FixHangingBrace(str); - } else if(IsBadMonoFunction(str)) { - FixEndBrace(str); - } else if(IsBadMonoProperty(str)) { - FixHangingBrace(str); - } else { - } - } - - public void FixHangingBrace(String str) - { - int strloc = filebuffer.IndexOf(str); - int brcloc = FindHangingBrace(strloc); - int diff = brcloc - strloc; - if (brcloc > 0) { - for (int i = 0; i < diff+1; i++) { - filebuffer.RemoveAt(strloc); - } - filebuffer.Insert(strloc, str + " {"); - if (linespace) { - filebuffer.Insert(strloc+1, ""); - } - } else {} - } - - public int FindHangingBrace(int strloc) - { - strloc++; - bool found = false; - while (!found) { - try { - string str = filebuffer[strloc++]; - found = IsHangingBrace(str); - if (!found && !IsBlankLine(str)) { - return -1; - } - } catch (Exception) { - return -1; - } - } - return strloc -1; - } - - public void FixEndBrace(String str) - { - int strloc = filebuffer.IndexOf(str); - filebuffer.RemoveAt(strloc); - filebuffer.Insert(strloc, RemoveEndBrace(str)); - filebuffer.Insert(strloc+1, AddHangingBrace(str)); - } - - public static bool IsBadMonoType(String str) - { - if ( IsType(str) && !EndWithBrace(str)) { - return true; - } else { - return false; - } - } - - public static bool IsBadMonoFlow(String str) - { - if (IsFlow(str) && !EndWithBrace(str)) { - return true; - } else { - return false; - } - } - - public static bool IsBadMonoFunction(String str) - { - if (IsFunction(str) && EndWithBrace(str)) { - return true; - } else { - return false; - } - } - - public static bool IsBadMonoProperty(String str) - { - if (IsProperty(str) && !EndWithBrace(str)) { - return true; - } else { - return false; - } - } - - public static bool IsType(String str) - { - if ( !IsComment(str) && ( - IsNameSpace(str) || - IsClass(str) || - IsStruct(str) || - IsEnum(str) )) { - return true; - } else { - return false; - } - } - - public static bool IsFlow(String str) - { - if ( !IsComment(str) && ( - IsIf(str) || - IsElse(str) || - IsElseIf(str) || - IsTry(str) || - IsCatch(str) || - IsFinally(str) || - IsFor(str) || - IsForEach(str) || - IsWhile(str) || - IsSwitch(str) - )) { - return true; - } else { - return false; - } - } - - public static bool IsFunction(String str) - { - if ( Regex.IsMatch(str, @"^\s*(\w+)\s+(\w+).*\(+") && - !IsDeclaration(str) && - !IsComment(str) && - !IsType(str) && - !IsFlow(str) ) { - return true; - } else { - return false; - } - } - - public static bool IsProperty(String str) - { - if ( Regex.IsMatch(str, @"^\s*(\w+)\s+(\w+).*") && - !IsDeclaration(str) && - !IsComment(str) && - !IsType(str) && - !IsFlow(str) && - !IsFunction(str) ) { - return true; - } else { - return false; - } - } - - public static string RemoveEndBrace(String str) - { - Regex rg = new Regex(@"\{\s*$"); - return rg.Replace(str, ""); - } - - public static string AddHangingBrace(String str) - { - Regex rg = new Regex(@"\S+\s*"); - string blank = rg.Replace(str,""); - return blank + "{"; - } - - public static bool IsDeclaration(String str) - { - return Regex.IsMatch(str, @"\;\s*$"); - } - - public static bool IsComment(String str) - { - return Regex.IsMatch(str, @"^(\s*\/+|\s*\*+|\s*\#+)"); - } - - public static bool EndWithBrace(String str) - { - return Regex.IsMatch(str, @"\{\s*$"); - } - - public static bool IsHangingBrace(String str) - { - return Regex.IsMatch(str, @"^\s*\{"); - } - - public static bool IsBlankLine(String str) - { - return Regex.IsMatch(str, @"^\s*$"); - } - - public static bool IsNameSpace(String str) - { - return Regex.IsMatch(str, @"(^|\s+)namespace\s+"); - } - - public static bool IsClass(String str) - { - return Regex.IsMatch(str, @"\s+class\s+"); - } - - public static bool IsStruct(String str) - { - return Regex.IsMatch(str, @"\s+struct\s+"); - } - - public static bool IsEnum(String str) - { - return Regex.IsMatch(str, @"\s+enum\s+"); - } - - public static bool IsIf(String str) - { - return Regex.IsMatch(str, @"(^|\s+|\}+)if(\s+|\(+|$)"); - } - - public static bool IsElse(String str) - { - return Regex.IsMatch(str, @"(^|\s+|\}+)else(\s+|\{+|$)"); - } - - public static bool IsElseIf(String str) - { - return Regex.IsMatch(str, @"(^|\s+|\}+)else if(\s+|\(+|$)"); - } - - public static bool IsTry(String str) - { - return Regex.IsMatch(str, @"(^|\s+|\}+)try(\s+|\(+|$)"); - } - - public static bool IsCatch(String str) - { - return Regex.IsMatch(str, @"(^|\s+|\}+)catch(\s+|\(+|$)"); - } - - public static bool IsFinally(String str) - { - return Regex.IsMatch(str, @"(^|\s+|\}+)finally(\s+|\{+|$)"); - } - - public static bool IsFor(String str) - { - return Regex.IsMatch(str, @"(^|\s+|\}+)for(\s+|\(+|$)"); - } - - public static bool IsForEach(String str) - { - return Regex.IsMatch(str, @"(^|\s+|\}+)foreach(\s+|\(+|$)"); - } - - public static bool IsWhile(String str) - { - return Regex.IsMatch(str, @"(^|\s+|\}+)while(\s+|\(+|$)"); - } - - public static bool IsSwitch(String str) - { - return Regex.IsMatch(str, @"(^|\s+|\}+)switch(\s+|\(+|$)"); - } - - public static bool IsCase(String str) - { - return Regex.IsMatch(str, @"(^|\s+|\}+)case(\s+|\(+|$)"); - } - } -} diff --git a/mcs/tools/misc/sample_cast_const.cs b/mcs/tools/misc/sample_cast_const.cs deleted file mode 100644 index 04969312cde..00000000000 --- a/mcs/tools/misc/sample_cast_const.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; - -class X { - static void w (string s) - { - Console.WriteLine ("\t" + s); - } - - static void Main () - { - object [,] names = - { { "Byte", "byte" }, - { "SByte", "sbyte" }, - { "Short", "short" }, - { "UShort", "ushort" }, - { "Int", "int32" }, - { "UInt", "uint32" }, - { "Long", "int64" }, - { "ULong", "uint64" }, - { "Float", "float" }, - { "Double", "double" }, - { null, null } - }; - - for (int i = 0; names [i,0] != null; i++){ - string big = names [i, 0] + "Constant"; - string small = "TypeManager." + names [i, 1] + "_type"; - string nat = ((string) names [i,0]).ToLower (); - - w ("\t\tif (expr is " + big + "){"); - w ("\t\t\t" + nat + " v = ((" + big + ") expr).Value;"); - w (""); - - for (int j = 0; names [j,0] != null; j++){ - string b = names [j, 0] + "Constant"; - string s = "TypeManager." + names [j, 1] + "_type"; - string n = ((string) names [j,0]).ToLower (); - - if (i == j) - continue; - - w ("\t\t\tif (target_type == " + s + ")"); - w ("\t\t\t\treturn new " + b + " ((" + n + ") v);"); - } - w ("\t\t}"); - } - } -} - diff --git a/mcs/tools/misc/serialize.cs b/mcs/tools/misc/serialize.cs deleted file mode 100644 index 01b83f83b87..00000000000 --- a/mcs/tools/misc/serialize.cs +++ /dev/null @@ -1,138 +0,0 @@ -// -// Serialize.cs -// -// This program creates a SerializationInfo and requests an object -// to serialize itself. -// -// We serialize because we need to know the *exact* names that are -// used for the values being serialized. -// -// Author: Miguel de Icaza -// Duncan Mak -// -// (C) Ximian, Inc. -// - -using System; -using System.Collections; -using System.Globalization; -using System.Runtime.Serialization; -using System.Runtime.Serialization.Formatters.Soap; -using System.IO; - -namespace Mono.Serialize { - class Driver { - static object StaticCreateObject () - { - // - // Change the object type here. - // - return null; - } - - static object LiveCreateObject (Type obj, Type[] types, string[] values) - { - if (types.Length != values.Length) - throw new ArgumentException (); - - object[] a = new object [types.Length]; - - for (int i = 0; i < a.Length; i++) - a [i] = Convert.ChangeType (values [i], types [i]); - - return Activator.CreateInstance (obj, a); - } - - static void Main (string[] args) - { - object x = null; - string strTypes = null; - string argValues = null; - - if (args.Length == 1) { - Type t = Type.GetType (args[0]); - Console.WriteLine ("\nPlease enter the arguments to the constructor for type {0}", t.ToString()); - strTypes = Console.ReadLine (); - Console.WriteLine ("\nPlease enter the values"); - argValues = Console.ReadLine (); - Type[] types = ToTypeArray (strTypes.Split (',')); - string[] param = argValues.Split (','); - - x = LiveCreateObject (t, types, param); - } else { - x = StaticCreateObject (); - } - - string fileName = x.GetType().FullName + ".xml"; - Stream output = new FileStream (fileName, FileMode.Create, - FileAccess.Write, FileShare.None); - IFormatter formatter = new SoapFormatter (); - - formatter.Serialize ((Stream) output, x); - output.Close (); - } - - public static Type[] ToTypeArray (string[] strTypes) - { - Type[] t = new Type [strTypes.Length]; - - for (int i = 0; i < strTypes.Length; i++) - t [i] = StringToType (strTypes [i]); - return t; - } - - public static Type StringToType (string s) - { - switch (s) { - case "bool": - return typeof (System.Boolean); - break; - case "byte": - return typeof (System.Byte); - break; - case "sbyte": - return typeof (System.SByte); - break; - case "char": - return typeof (System.Char); - break; - case "decimal": - return typeof (System.Decimal); - break; - case "double": - return typeof (System.Double); - break; - case "float": - return typeof (System.Single); - break; - case "int": - return typeof (System.Int32); - break; - case "uint": - return typeof (System.UInt32); - break; - case "long": - return typeof (System.Int64); - break; - case "ulong": - return typeof (System.UInt64); - break; - case "object": - return typeof (System.Object); - break; - case "short": - return typeof (System.Int16); - break; - case "ushort": - return typeof (System.UInt16); - break; - case "string": - return typeof (System.String); - break; - default: - return Type.GetType (s); - break; - } - } - } -} diff --git a/mcs/tools/misc/verifier.cs b/mcs/tools/misc/verifier.cs deleted file mode 100644 index 25268147b26..00000000000 --- a/mcs/tools/misc/verifier.cs +++ /dev/null @@ -1,1587 +0,0 @@ -// -// verifier.cs: compares two assemblies and reports differences. -// -// Author: -// Sergey Chaban (serge@wildwestsoftware.com) -// -// (C) Sergey Chaban (serge@wildwestsoftware.com) -// - -using System; -using System.IO; -using System.Collections; -using System.Reflection; - -namespace Mono.Verifier { - - - - //////////////////////////////// - // Collections - //////////////////////////////// - - public abstract class MemberCollection : IEnumerable { - - public delegate MemberInfo [] InfoQuery (Type type, BindingFlags bindings); - public delegate bool MemberComparer (MemberInfo mi1, MemberInfo mi2); - - protected SortedList list; - protected MemberComparer comparer; - - protected BindingFlags bindings; - - protected MemberCollection (Type type, InfoQuery query, MemberComparer comparer, BindingFlags bindings) - { - if (query == null) - throw new NullReferenceException ("Invalid query delegate."); - - if (comparer == null) - throw new NullReferenceException ("Invalid comparer."); - - this.comparer = comparer; - this.bindings = bindings; - - this.list = new SortedList (); - - MemberInfo [] data = query (type, bindings); - foreach (MemberInfo info in data) { - this.list [info.Name] = info; - } - } - - - - public MemberInfo this [string name] { - get { - return list [name] as MemberInfo; - } - } - - - public override int GetHashCode () - { - return list.GetHashCode (); - } - - - public override bool Equals (object o) - { - bool res = (o is MemberCollection); - if (res) { - MemberCollection another = o as MemberCollection; - IEnumerator it = GetEnumerator (); - while (it.MoveNext () && res) { - MemberInfo inf1 = it.Current as MemberInfo; - MemberInfo inf2 = another [inf1.Name]; - res &= comparer (inf1, inf2); - } - } - return res; - } - - - - public static bool operator == (MemberCollection c1, MemberCollection c2) - { - return c1.Equals (c2); - } - - public static bool operator != (MemberCollection c1, MemberCollection c2) - { - return !(c1 == c2); - } - - - - public IEnumerator GetEnumerator() - { - return new Iterator (this); - } - - - internal class Iterator : IEnumerator { - private MemberCollection host; - private int pos; - - internal Iterator (MemberCollection host) - { - this.host=host; - this.Reset (); - } - - /// - public object Current - { - get { - if (host != null && pos >=0 && pos < host.list.Count) { - return host.list.GetByIndex (pos); - } else { - return null; - } - } - } - - /// - public bool MoveNext () - { - if (host!=null) { - return (++pos) < host.list.Count; - } else { - return false; - } - } - - /// - public void Reset () - { - this.pos = -1; - } - } - - } - - - - - //--- Method collections - - /// - /// Abstract collection of class' methods. - /// - public abstract class MethodCollectionBase : MemberCollection { - - - protected MethodCollectionBase (Type type, BindingFlags bindings) - : base (type, new InfoQuery (Query), new MemberComparer (Comparer), bindings) - { - } - - - private static MemberInfo [] Query (Type type, BindingFlags bindings) - { - // returns MethodInfo [] - return type.GetMethods (bindings); - } - - private static bool Comparer (MemberInfo mi1, MemberInfo mi2) - { - bool res = false; - if (mi1 is MethodInfo && (mi2 == null || mi2 is MethodInfo)) { - MethodInfo inf1 = mi1 as MethodInfo; - MethodInfo inf2 = mi2 as MethodInfo; - res = Compare.Methods (inf1, inf2); - } else { - Verifier.log.Write ("internal-error", "Wrong comparer arguments.", ImportanceLevel.HIGH); - } - return res; - } - } - - - - /// - /// Collection of public instance methods of a class. - /// - public class PublicMethods : MethodCollectionBase { - - public PublicMethods (Type type) - : base (type, BindingFlags.Public | BindingFlags.Instance) - { - } - } - - /// - /// Collection of public static methods of a class. - /// - public class PublicStaticMethods : MethodCollectionBase { - - public PublicStaticMethods (Type type) - : base (type, BindingFlags.Public | BindingFlags.Static) - { - } - } - - /// - /// Collection of non-public instance methods of a class. - /// - public class NonPublicMethods : MethodCollectionBase { - - public NonPublicMethods (Type type) - : base (type, BindingFlags.NonPublic | BindingFlags.Instance) - { - } - } - - /// - /// Collection of non-public static methods of a class. - /// - public class NonPublicStaticMethods : MethodCollectionBase { - - public NonPublicStaticMethods (Type type) - : base (type, BindingFlags.NonPublic | BindingFlags.Static) - { - } - } - - - - - - //--- Field collections - - public abstract class FieldCollectionBase : MemberCollection { - - - protected FieldCollectionBase (Type type, BindingFlags bindings) - : base (type, new InfoQuery (Query), new MemberComparer (Comparer), bindings) - { - } - - - private static MemberInfo [] Query (Type type, BindingFlags bindings) - { - // returns FieldInfo [] - return type.GetFields (bindings); - } - - private static bool Comparer (MemberInfo mi1, MemberInfo mi2) - { - bool res = false; - if (mi1 is FieldInfo && (mi2 == null || mi2 is FieldInfo)) { - FieldInfo inf1 = mi1 as FieldInfo; - FieldInfo inf2 = mi2 as FieldInfo; - res = Compare.Fields (inf1, inf2); - } else { - Verifier.log.Write ("internal-error", "Wrong comparer arguments.", ImportanceLevel.HIGH); - } - return res; - } - } - - - public class PublicFields : FieldCollectionBase { - - public PublicFields (Type type) - : base (type, BindingFlags.Public | BindingFlags.Instance) - { - } - } - - public class PublicStaticFields : FieldCollectionBase { - - public PublicStaticFields (Type type) - : base (type, BindingFlags.Public | BindingFlags.Static) - { - } - } - - public class NonPublicFields : FieldCollectionBase { - - public NonPublicFields (Type type) - : base (type, BindingFlags.NonPublic | BindingFlags.Instance) - { - } - } - - public class NonPublicStaticFields : FieldCollectionBase { - - public NonPublicStaticFields (Type type) - : base (type, BindingFlags.NonPublic | BindingFlags.Static) - { - } - } - - - - - - public abstract class AbstractTypeStuff { - public readonly Type type; - - public AbstractTypeStuff (Type type) - { - if (type == null) - throw new NullReferenceException ("Invalid type."); - - this.type = type; - } - - public override int GetHashCode () - { - return type.GetHashCode (); - } - - public static bool operator == (AbstractTypeStuff t1, AbstractTypeStuff t2) - { - if ((t1 as object) == null) { - if ((t2 as object) == null) return true; - return false; - } - return t1.Equals (t2); - } - - public static bool operator != (AbstractTypeStuff t1, AbstractTypeStuff t2) - { - return !(t1 == t2); - } - - public override bool Equals (object o) - { - return (o is AbstractTypeStuff && CompareTypes (o as AbstractTypeStuff)); - } - - protected virtual bool CompareTypes (AbstractTypeStuff that) - { - Verifier.Log.Write ("info", "Comparing types.", ImportanceLevel.LOW); - bool res; - - res = Compare.Types (this.type, that.type); - - return res; - } - - } - - - - - /// - /// Represents a class. - /// - public class ClassStuff : AbstractTypeStuff { - - public PublicMethods publicMethods; - public PublicStaticMethods publicStaticMethods; - public NonPublicMethods nonpublicMethods; - public NonPublicStaticMethods nonpublicStaticMethods; - - public PublicFields publicFields; - public PublicStaticFields publicStaticFields; - public NonPublicFields nonpublicFields; - public NonPublicStaticFields nonpublicStaticFields; - - public ClassStuff (Type type) : base (type) - { - publicMethods = new PublicMethods (type); - publicStaticMethods = new PublicStaticMethods (type); - nonpublicMethods = new NonPublicMethods (type); - nonpublicStaticMethods = new NonPublicStaticMethods (type); - - publicFields = new PublicFields (type); - publicStaticFields = new PublicStaticFields (type); - nonpublicFields = new NonPublicFields (type); - nonpublicStaticFields = new NonPublicStaticFields (type); - } - - - public override int GetHashCode () - { - return base.GetHashCode (); - } - - private bool CompareMethods (ClassStuff that) - { - bool res = true; - bool ok; - - Verifier.Log.Write ("info", "Comparing public instance methods.", ImportanceLevel.LOW); - ok = (this.publicMethods == that.publicMethods); - res &= ok; - if (!ok && Verifier.stopOnError) return res; - - Verifier.Log.Write ("info", "Comparing public static methods.", ImportanceLevel.LOW); - ok = (this.publicStaticMethods == that.publicStaticMethods); - res &= ok; - if (!ok && Verifier.stopOnError) return res; - - Verifier.Log.Write ("info", "Comparing non-public instance methods.", ImportanceLevel.LOW); - ok = (this.nonpublicMethods == that.nonpublicMethods); - res &= ok; - if (!ok && Verifier.stopOnError) return res; - - Verifier.Log.Write ("info", "Comparing non-public static methods.", ImportanceLevel.LOW); - ok = (this.nonpublicStaticMethods == that.nonpublicStaticMethods); - res &= ok; - if (!ok && Verifier.stopOnError) return res; - - return res; - } - - - private bool CompareFields (ClassStuff that) - { - bool res = true; - bool ok; - - Verifier.Log.Write ("info", "Comparing public instance fields.", ImportanceLevel.LOW); - ok = (this.publicFields == that.publicFields); - res &= ok; - if (!ok && Verifier.stopOnError) return res; - - Verifier.Log.Write ("info", "Comparing public static fields.", ImportanceLevel.LOW); - ok = (this.publicStaticFields == that.publicStaticFields); - res &= ok; - if (!ok && Verifier.stopOnError) return res; - - Verifier.Log.Write ("info", "Comparing non-public instance fields.", ImportanceLevel.LOW); - ok = (this.nonpublicFields == that.nonpublicFields); - res &= ok; - if (!ok && Verifier.stopOnError) return res; - - Verifier.Log.Write ("info", "Comparing non-public static fields.", ImportanceLevel.LOW); - ok = (this.nonpublicStaticFields == that.nonpublicStaticFields); - res &= ok; - if (!ok && Verifier.stopOnError) return res; - - return res; - } - - - public override bool Equals (object o) - { - bool res = (o is ClassStuff); - if (res) { - ClassStuff that = o as ClassStuff; - - res &= this.CompareTypes (that); - if (!res && Verifier.stopOnError) return res; - - res &= this.CompareMethods (that); - if (!res && Verifier.stopOnError) return res; - - res &= this.CompareFields (that); - if (!res && Verifier.stopOnError) return res; - - } - return res; - } - - } - - - - /// - /// Represents an interface. - /// - public class InterfaceStuff : AbstractTypeStuff { - - public PublicMethods publicMethods; - - public InterfaceStuff (Type type) : base (type) - { - publicMethods = new PublicMethods (type); - } - - public override int GetHashCode () - { - return base.GetHashCode (); - } - - public override bool Equals (object o) - { - bool res = (o is InterfaceStuff); - if (res) { - bool ok; - InterfaceStuff that = o as InterfaceStuff; - - res = this.CompareTypes (that); - if (!res && Verifier.stopOnError) return res; - - Verifier.Log.Write ("info", "Comparing interface methods.", ImportanceLevel.LOW); - ok = (this.publicMethods == that.publicMethods); - res &= ok; - if (!ok && Verifier.stopOnError) return res; - } - return res; - } - - } - - - - /// - /// Represents an enumeration. - /// - public class EnumStuff : AbstractTypeStuff { - - //public FieldInfo [] members; - - public string baseType; - public Hashtable enumTable; - public bool isFlags; - - public EnumStuff (Type type) : base (type) - { - //members = type.GetFields (BindingFlags.Public | BindingFlags.Static); - - Array values = Enum.GetValues (type); - Array names = Enum.GetNames (type); - - baseType = Enum.GetUnderlyingType (type).Name; - - enumTable = new Hashtable (); - - object [] attrs = type.GetCustomAttributes (false); - isFlags = (attrs != null && attrs.Length > 0); - if (isFlags) { - foreach (object attr in attrs) { - isFlags |= (attr is FlagsAttribute); - } - } - - int indx = 0; - foreach (string id in names) { - enumTable [id] = Convert.ToInt64(values.GetValue(indx) as Enum); - ++indx; - } - } - - public override int GetHashCode () - { - return base.GetHashCode (); - } - - public override bool Equals (object o) - { - bool res = (o is EnumStuff); - bool ok; - - if (res) { - EnumStuff that = o as EnumStuff; - ok = this.CompareTypes (that); - res &= ok; - if (!ok && Verifier.stopOnError) return res; - - ok = (this.baseType == that.baseType); - res &= ok; - if (!ok) { - Verifier.log.Write ("error", - String.Format ("Underlying types mismatch [{0}, {1}].", this.baseType, that.baseType), - ImportanceLevel.MEDIUM); - if (Verifier.stopOnError) return res; - } - - Verifier.Log.Write ("info", "Comparing [Flags] attribute."); - ok = !(this.isFlags ^ that.isFlags); - res &= ok; - if (!ok) { - Verifier.log.Write ("error", - String.Format ("[Flags] attribute mismatch ({0} : {1}).", this.isFlags ? "Yes" : "No", that.isFlags ? "Yes" : "No"), - ImportanceLevel.MEDIUM); - if (Verifier.stopOnError) return res; - } - - Verifier.Log.Write ("info", "Comparing enum values."); - - ICollection names = enumTable.Keys; - foreach (string id in names) { - ok = that.enumTable.ContainsKey (id); - res &= ok; - if (!ok) { - Verifier.log.Write ("error", String.Format("{0} absent in enumeration.", id), - ImportanceLevel.MEDIUM); - if (Verifier.stopOnError) return res; - } - - if (ok) { - long val1 = (long) this.enumTable [id]; - long val2 = (long) that.enumTable [id]; - ok = (val1 == val2); - res &= ok; - if (!ok) { - Verifier.log.Write ("error", - String.Format ("Enum values mismatch [{0}: {1} != {2}].", id, val1, val2), - ImportanceLevel.MEDIUM); - if (Verifier.stopOnError) return res; - } - } - } - } - return res; - } - } - - - - public sealed class TypeArray { - public static readonly TypeArray empty = new TypeArray (Type.EmptyTypes); - - public Type [] types; - - public TypeArray (Type [] types) - { - this.types = new Type [types.Length]; - for (int i = 0; i < types.Length; i++) { - this.types.SetValue (types.GetValue (i), i); - } - } - } - - - - public class AssemblyLoader { - public delegate void Hook (TypeArray assemblyTypes); - - private static Hashtable cache; - - private Hook hook; - - static AssemblyLoader () - { - cache = new Hashtable (11); - } - - public AssemblyLoader (Hook hook) - { - if (hook == null) - throw new NullReferenceException ("Invalid loader hook."); - - this.hook = hook; - } - - - public bool LoadFrom (string assemblyName) - { - bool res = false; - try { - TypeArray types = TypeArray.empty; - - lock (cache) { - if (cache.Contains (assemblyName)) { - types = (cache [assemblyName] as TypeArray); - if (types == null) types = TypeArray.empty; - } else { - Assembly asm = Assembly.LoadFrom (assemblyName); - Type [] allTypes = asm.GetTypes (); - if (allTypes == null) allTypes = Type.EmptyTypes; - types = new TypeArray (allTypes); - cache [assemblyName] = types; - } - } - hook (types); - res = true; - } catch (ReflectionTypeLoadException rtle) { - // FIXME: Should we try to recover? Use loaded portion of types. - Type [] loaded = rtle.Types; - for (int i = 0, xCnt = 0; i < loaded.Length; i++) { - if (loaded [i] == null) { - Verifier.log.Write ("fatal error", - String.Format ("Unable to load {0}, reason - {1}", loaded [i], rtle.LoaderExceptions [xCnt++]), - ImportanceLevel.LOW); - } - } - } catch (FileNotFoundException fnfe) { - Verifier.log.Write ("fatal error", fnfe.ToString (), ImportanceLevel.LOW); - } catch (Exception x) { - Verifier.log.Write ("fatal error", x.ToString (), ImportanceLevel.LOW); - } - - return res; - } - - } - - - - - public abstract class AbstractTypeCollection : SortedList { - - private AssemblyLoader loader; - - public AbstractTypeCollection () - { - loader = new AssemblyLoader (new AssemblyLoader.Hook (LoaderHook)); - } - - public AbstractTypeCollection (string assemblyName) : this () - { - LoadFrom (assemblyName); - } - - public abstract void LoaderHook (TypeArray types); - - - public bool LoadFrom (string assemblyName) - { - return loader.LoadFrom (assemblyName); - } - - } - - - - public class ClassCollection : AbstractTypeCollection { - - public ClassCollection () : base () - { - } - - public ClassCollection (string assemblyName) - : base (assemblyName) - { - } - - - public override void LoaderHook (TypeArray types) - { - foreach (Type type in types.types) { - if (type.IsClass) { - this [type.FullName] = new ClassStuff (type); - } - } - } - - } - - - public class InterfaceCollection : AbstractTypeCollection { - - public InterfaceCollection () : base () - { - } - - public InterfaceCollection (string assemblyName) - : base (assemblyName) - { - } - - - public override void LoaderHook (TypeArray types) - { - foreach (Type type in types.types) { - if (type.IsInterface) { - this [type.FullName] = new InterfaceStuff (type); - } - } - } - - } - - - - public class EnumCollection : AbstractTypeCollection { - - public EnumCollection () : base () - { - } - - public EnumCollection (string assemblyName) - : base (assemblyName) - { - } - - public override void LoaderHook (TypeArray types) - { - foreach (Type type in types.types) { - if (type.IsEnum) { - this [type.FullName] = new EnumStuff (type); - } - } - } - } - - - - public class AssemblyStuff { - - public string name; - public bool valid; - - public ClassCollection classes; - public InterfaceCollection interfaces; - public EnumCollection enums; - - - protected delegate bool Comparer (AssemblyStuff asm1, AssemblyStuff asm2); - private static ArrayList comparers; - - static AssemblyStuff () - { - comparers = new ArrayList (); - comparers.Add (new Comparer (CompareNumClasses)); - comparers.Add (new Comparer (CompareNumInterfaces)); - comparers.Add (new Comparer (CompareClasses)); - comparers.Add (new Comparer (CompareInterfaces)); - comparers.Add (new Comparer (CompareEnums)); - } - - protected static bool CompareNumClasses (AssemblyStuff asm1, AssemblyStuff asm2) - { - bool res = (asm1.classes.Count == asm2.classes.Count); - if (!res) Verifier.Log.Write ("error", "Number of classes mismatch.", ImportanceLevel.MEDIUM); - return res; - } - - protected static bool CompareNumInterfaces (AssemblyStuff asm1, AssemblyStuff asm2) - { - bool res = (asm1.interfaces.Count == asm2.interfaces.Count); - if (!res) Verifier.Log.Write ("error", "Number of interfaces mismatch.", ImportanceLevel.MEDIUM); - return res; - } - - - protected static bool CompareClasses (AssemblyStuff asm1, AssemblyStuff asm2) - { - bool res = true; - Verifier.Log.Write ("info", "Comparing classes."); - - foreach (DictionaryEntry c in asm1.classes) { - string className = c.Key as string; - - if (Verifier.Excluded.Contains (className)) { - Verifier.Log.Write ("info", String.Format ("Ignoring class {0}.", className), ImportanceLevel.MEDIUM); - continue; - } - - Verifier.Log.Write ("class", className); - - ClassStuff class1 = c.Value as ClassStuff; - ClassStuff class2 = asm2.classes [className] as ClassStuff; - - if (class2 == null) { - Verifier.Log.Write ("error", String.Format ("There is no such class in {0}", asm2.name)); - res = false; - if (Verifier.stopOnError || !Verifier.ignoreMissingTypes) return res; - continue; - } - - res &= (class1 == class2); - if (!res && Verifier.stopOnError) return res; - } - - return res; - } - - - protected static bool CompareInterfaces (AssemblyStuff asm1, AssemblyStuff asm2) - { - bool res = true; - Verifier.Log.Write ("info", "Comparing interfaces."); - - foreach (DictionaryEntry ifc in asm1.interfaces) { - string ifcName = ifc.Key as string; - Verifier.Log.Write ("interface", ifcName); - - InterfaceStuff ifc1 = ifc.Value as InterfaceStuff; - InterfaceStuff ifc2 = asm2.interfaces [ifcName] as InterfaceStuff; - - if (ifc2 == null) { - Verifier.Log.Write ("error", String.Format ("There is no such interface in {0}", asm2.name)); - res = false; - if (Verifier.stopOnError || !Verifier.ignoreMissingTypes) return res; - continue; - } - - res &= (ifc1 == ifc2); - if (!res && Verifier.stopOnError) return res; - - } - - return res; - } - - - protected static bool CompareEnums (AssemblyStuff asm1, AssemblyStuff asm2) - { - bool res = true; - Verifier.Log.Write ("info", "Comparing enums."); - - foreach (DictionaryEntry e in asm1.enums) { - string enumName = e.Key as string; - Verifier.Log.Write ("enum", enumName); - - EnumStuff e1 = e.Value as EnumStuff; - EnumStuff e2 = asm2.enums [enumName] as EnumStuff; - - if (e2 == null) { - Verifier.Log.Write ("error", String.Format ("There is no such enum in {0}", asm2.name)); - res = false; - if (Verifier.stopOnError || !Verifier.ignoreMissingTypes) return res; - continue; - } - res &= (e1 == e2); - if (!res && Verifier.stopOnError) return res; - } - - return res; - } - - - - public AssemblyStuff (string assemblyName) - { - this.name = assemblyName; - valid = false; - } - - public bool Load () - { - bool res = true; - bool ok; - - classes = new ClassCollection (); - ok = classes.LoadFrom (name); - res &= ok; - if (!ok) Verifier.log.Write ("error", String.Format ("Unable to load classes from {0}.", name), ImportanceLevel.HIGH); - - interfaces = new InterfaceCollection (); - ok = interfaces.LoadFrom (name); - res &= ok; - if (!ok) Verifier.log.Write ("error", String.Format ("Unable to load interfaces from {0}.", name), ImportanceLevel.HIGH); - - enums = new EnumCollection (); - ok = enums.LoadFrom (name); - res &= ok; - if (!ok) Verifier.log.Write ("error", String.Format ("Unable to load enums from {0}.", name), ImportanceLevel.HIGH); - - valid = res; - return res; - } - - - public override bool Equals (object o) - { - bool res = (o is AssemblyStuff); - if (res) { - AssemblyStuff that = o as AssemblyStuff; - IEnumerator it = comparers.GetEnumerator (); - while ((res || !Verifier.stopOnError) && it.MoveNext ()) { - Comparer compare = it.Current as Comparer; - res &= compare (this, that); - } - } - return res; - } - - - public static bool operator == (AssemblyStuff asm1, AssemblyStuff asm2) - { - return asm1.Equals (asm2); - } - - public static bool operator != (AssemblyStuff asm1, AssemblyStuff asm2) - { - return !(asm1 == asm2); - } - - public override int GetHashCode () - { - return classes.GetHashCode () ^ interfaces.GetHashCode (); - } - - - public override string ToString () - { - string res; - if (valid) { - res = String.Format ("Asssembly {0}, valid, {1} classes, {2} interfaces, {3} enums.", - name, classes.Count, interfaces.Count, enums.Count); - } else { - res = String.Format ("Asssembly {0}, invalid.", name); - } - return res; - } - - } - - - - - //////////////////////////////// - // Compare - //////////////////////////////// - - public sealed class Compare { - - private Compare () - { - } - - - public static bool Parameters (ParameterInfo[] params1, ParameterInfo[] params2) - { - bool res = true; - if (params1.Length != params2.Length) { - Verifier.Log.Write ("Parameter count mismatch."); - return false; - } - - int count = params1.Length; - - for (int i = 0; i < count && res; i++) { - if (params1 [i].Name != params2 [i].Name) { - Verifier.Log.Write ("error", String.Format ("Parameters names mismatch {0}, {1}.", params1 [i].Name, params2 [i].Name)); - res = false; - if (Verifier.stopOnError) break; - } - - Verifier.Log.Write ("parameter", params1 [i].Name); - - if (!Compare.Types (params1 [i].ParameterType, params2 [i].ParameterType)) { - Verifier.Log.Write ("error", String.Format ("Parameters types mismatch {0}, {1}.", params1 [i].ParameterType, params2 [i].ParameterType)); - res = false; - if (Verifier.stopOnError) break; - } - - - if (Verifier.checkOptionalFlags) { - if (params1 [i].IsIn != params2 [i].IsIn) { - Verifier.Log.Write ("error", "[in] mismatch."); - res = false; - if (Verifier.stopOnError) break; - } - - if (params1 [i].IsOut != params2 [i].IsOut) { - Verifier.Log.Write ("error", "[out] mismatch."); - res = false; - if (Verifier.stopOnError) break; - } - - if (params1 [i].IsRetval != params2 [i].IsRetval) { - Verifier.Log.Write ("error", "[ref] mismatch."); - res = false; - if (Verifier.stopOnError) break; - } - - if (params1 [i].IsOptional != params2 [i].IsOptional) { - Verifier.Log.Write ("error", "Optional flag mismatch."); - res = false; - if (Verifier.stopOnError) break; - } - - } // checkOptionalFlags - - - } - - return res; - } - - - - public static bool Methods (MethodInfo mi1, MethodInfo mi2) - { - - if (mi2 == null) { - Verifier.Log.Write ("error", String.Format ("There is no such method {0}.", mi1.Name), ImportanceLevel.MEDIUM); - return false; - } - - - Verifier.Log.Flush (); - Verifier.Log.Write ("method", String.Format ("{0}.", mi1.Name)); - bool res = true; - bool ok; - string expected; - - ok = Compare.Types (mi1.ReturnType, mi2.ReturnType); - res &= ok; - if (!ok) { - Verifier.Log.Write ("error", "Return types mismatch.", ImportanceLevel.MEDIUM); - if (Verifier.stopOnError) return res; - } - - - - - ok = (mi1.IsAbstract == mi2.IsAbstract); - res &= ok; - if (!ok) { - expected = (mi1.IsAbstract) ? "abstract" : "non-abstract"; - Verifier.Log.Write ("error", String.Format ("Expected to be {0}.", expected), ImportanceLevel.MEDIUM); - if (Verifier.stopOnError) return res; - } - - ok = (mi1.IsVirtual == mi2.IsVirtual); - res &= ok; - if (!ok) { - expected = (mi1.IsVirtual) ? "virtual" : "non-virtual"; - Verifier.Log.Write ("error", String.Format ("Expected to be {0}.", expected), ImportanceLevel.MEDIUM); - if (Verifier.stopOnError) return res; - } - - ok = (mi1.IsFinal == mi2.IsFinal); - res &= ok; - if (!ok) { - expected = (mi1.IsFinal) ? "final" : "overridable"; - Verifier.Log.Write ("error", String.Format ("Expected to be {0}.", expected), ImportanceLevel.MEDIUM); - if (Verifier.stopOnError) return res; - } - - - - // compare access modifiers - - ok = (mi1.IsPrivate == mi2.IsPrivate); - res &= ok; - if (!ok) { - expected = (mi1.IsPublic) ? "public" : "private"; - Verifier.Log.Write ("error", String.Format ("Accessibility levels mismatch (expected [{0}]).", expected), ImportanceLevel.MEDIUM); - if (Verifier.stopOnError) return res; - } - - - ok = (mi1.IsFamily == mi2.IsFamily); - res &= ok; - if (!ok) { - expected = (mi1.IsFamily) ? "protected" : "!protected"; - Verifier.Log.Write ("error", String.Format ("Accessibility levels mismatch (expected [{0}]).", expected), ImportanceLevel.MEDIUM); - if (Verifier.stopOnError) return res; - } - - ok = (mi1.IsAssembly == mi2.IsAssembly); - res &= ok; - if (!ok) { - expected = (mi1.IsAssembly) ? "internal" : "!internal"; - Verifier.Log.Write ("error", String.Format ("Accessibility levels mismatch (expected [{0}]).", expected), ImportanceLevel.MEDIUM); - if (Verifier.stopOnError) return res; - } - - - ok = (mi1.IsStatic == mi2.IsStatic); - res &= ok; - if (!ok) { - expected = (mi1.IsStatic) ? "static" : "instance"; - Verifier.Log.Write ("error", String.Format ("Accessibility levels mismatch (expected [{0}]).", expected), ImportanceLevel.MEDIUM); - if (Verifier.stopOnError) return res; - } - - - - // parameters - - ok = Compare.Parameters (mi1.GetParameters (), mi2.GetParameters ()); - res &= ok; - if (!ok && Verifier.stopOnError) return res; - - - ok = (mi1.CallingConvention == mi2.CallingConvention); - res &= ok; - if (!ok) { - Verifier.Log.Write ("error", "Calling conventions mismatch.", ImportanceLevel.MEDIUM); - if (Verifier.stopOnError) return res; - } - - - - - return res; - } - - - public static bool Fields (FieldInfo fi1, FieldInfo fi2) - { - if (fi2 == null) { - Verifier.Log.Write ("error", String.Format ("There is no such field {0}.", fi1.Name), ImportanceLevel.MEDIUM); - return false; - } - - bool res = true; - bool ok; - string expected; - - Verifier.Log.Write ("field", String.Format ("{0}.", fi1.Name)); - - ok = (fi1.IsPrivate == fi2.IsPrivate); - res &= ok; - if (!ok) { - expected = (fi1.IsPublic) ? "public" : "private"; - Verifier.Log.Write ("error", String.Format ("Accessibility levels mismatch (expected [{0}]).", expected), ImportanceLevel.MEDIUM); - if (Verifier.stopOnError) return res; - } - - ok = (fi1.IsFamily == fi2.IsFamily); - res &= ok; - if (!ok) { - expected = (fi1.IsFamily) ? "protected" : "!protected"; - Verifier.Log.Write ("error", String.Format ("Accessibility levels mismatch (expected [{0}]).", expected), ImportanceLevel.MEDIUM); - if (Verifier.stopOnError) return res; - } - - ok = (fi1.IsAssembly == fi2.IsAssembly); - res &= ok; - if (!ok) { - expected = (fi1.IsAssembly) ? "internal" : "!internal"; - Verifier.Log.Write ("error", String.Format ("Accessibility levels mismatch (expected [{0}]).", expected), ImportanceLevel.MEDIUM); - if (Verifier.stopOnError) return res; - } - - ok = (fi1.IsInitOnly == fi2.IsInitOnly); - res &= ok; - if (!ok) { - expected = (fi1.IsInitOnly) ? "readonly" : "!readonly"; - Verifier.Log.Write ("error", String.Format ("Accessibility levels mismatch (expected [{0}]).", expected), ImportanceLevel.MEDIUM); - if (Verifier.stopOnError) return res; - } - - ok = (fi1.IsStatic == fi2.IsStatic); - res &= ok; - if (!ok) { - expected = (fi1.IsStatic) ? "static" : "instance"; - Verifier.Log.Write ("error", String.Format ("Accessibility levels mismatch (expected [{0}]).", expected), ImportanceLevel.MEDIUM); - if (Verifier.stopOnError) return res; - } - - return res; - } - - - - public static bool Types (Type type1, Type type2) - { - // NOTE: - // simply calling type1.Equals (type2) won't work, - // types are in different assemblies hence they have - // different (fully-qualified) names. - int eqFlags = 0; - eqFlags |= (type1.IsAbstract == type2.IsAbstract) ? 0 : 0x001; - eqFlags |= (type1.IsClass == type2.IsClass) ? 0 : 0x002; - eqFlags |= (type1.IsValueType == type2.IsValueType) ? 0 : 0x004; - eqFlags |= (type1.IsPublic == type2.IsPublic) ? 0 : 0x008; - eqFlags |= (type1.IsSealed == type2.IsSealed) ? 0 : 0x010; - eqFlags |= (type1.IsEnum == type2.IsEnum) ? 0 : 0x020; - eqFlags |= (type1.IsPointer == type2.IsPointer) ? 0 : 0x040; - eqFlags |= (type1.IsPrimitive == type2.IsPrimitive) ? 0 : 0x080; - bool res = (eqFlags == 0); - - if (!res) { - // TODO: convert flags into descriptive message. - Verifier.Log.Write ("error", "Types mismatch (0x" + eqFlags.ToString("X") + ").", ImportanceLevel.HIGH); - } - - - bool ok; - - ok = (type1.Attributes & TypeAttributes.BeforeFieldInit) == - (type2.Attributes & TypeAttributes.BeforeFieldInit); - if (!ok) { - Verifier.Log.Write ("error", "Types attributes mismatch: BeforeFieldInit.", ImportanceLevel.HIGH); - } - res &= ok; - - ok = (type1.Attributes & TypeAttributes.ExplicitLayout) == - (type2.Attributes & TypeAttributes.ExplicitLayout); - if (!ok) { - Verifier.Log.Write ("error", "Types attributes mismatch: ExplicitLayout.", ImportanceLevel.HIGH); - } - res &= ok; - - ok = (type1.Attributes & TypeAttributes.SequentialLayout) == - (type2.Attributes & TypeAttributes.SequentialLayout); - if (!ok) { - Verifier.Log.Write ("error", "Types attributes mismatch: SequentialLayout.", ImportanceLevel.HIGH); - } - res &= ok; - - ok = (type1.Attributes & TypeAttributes.Serializable) == - (type2.Attributes & TypeAttributes.Serializable); - if (!ok) { - Verifier.Log.Write ("error", "Types attributes mismatch: Serializable.", ImportanceLevel.HIGH); - } - res &= ok; - - return res; - } - - } - - - - - //////////////////////////////// - // Log - //////////////////////////////// - - public enum ImportanceLevel : int { - LOW = 0, MEDIUM, HIGH - } - - - public interface ILogger { - - void Write (string tag, string msg, ImportanceLevel importance); - void Write (string msg, ImportanceLevel level); - void Write (string tag, string msg); - void Write (string msg); - ImportanceLevel DefaultImportance {get; set;} - void Flush (); - void Close (); - } - - - public abstract class AbstractLogger : ILogger { - private ImportanceLevel defImportance = ImportanceLevel.MEDIUM; - - public abstract void Write (string tag, string msg, ImportanceLevel importance); - public abstract void Write (string msg, ImportanceLevel level); - - public virtual void Write (string tag, string msg) - { - Write (tag, msg, DefaultImportance); - } - - public virtual void Write (string msg) - { - Write (msg, DefaultImportance); - } - - public virtual ImportanceLevel DefaultImportance { - get { - return defImportance; - } - set { - defImportance = value < ImportanceLevel.LOW - ? ImportanceLevel.LOW - : value > ImportanceLevel.HIGH - ? ImportanceLevel.HIGH - : value; - } - } - - public abstract void Flush (); - public abstract void Close (); - - } - - - - public class TextLogger : AbstractLogger { - - private TextWriter writer; - - public TextLogger (TextWriter writer) - { - if (writer == null) - throw new NullReferenceException (); - - this.writer = writer; - } - - private void DoWrite (string tag, string msg) - { - if (tag != null && tag.Length > 0) { - writer.WriteLine ("[{0}]\t{1}", tag, msg); - } else { - writer.WriteLine ("\t\t" + msg); - } - } - - public override void Write (string tag, string msg, ImportanceLevel importance) - { - int v = Log.VerboseLevel; - switch (v) { - case 0 : - break; - case 1 : - if (importance >= ImportanceLevel.HIGH) { - DoWrite (tag, msg); - } - break; - case 2 : - if (importance >= ImportanceLevel.MEDIUM) { - DoWrite (tag, msg); - } - break; - case 3 : - DoWrite (tag, msg); - break; - default: - break; - } - } - - public override void Write (string msg, ImportanceLevel importance) - { - Write (null, msg, importance); - } - - public override void Flush () - { - Console.Out.Flush (); - } - - public override void Close () - { - if (writer != Console.Out && writer != Console.Error) { - writer.Close (); - } - } - } - - - - public sealed class Log { - - private static int verbose = 3; - - private ArrayList consumers; - - public Log (bool useDefault) - { - consumers = new ArrayList (); - if (useDefault) AddConsumer (new TextLogger (Console.Out)); - } - - public Log () : this (true) - { - } - - - public static int VerboseLevel { - get { - return verbose; - } - set { - verbose = (value < 0) - ? 0 - : (value > 3) - ? 3 : value; - } - } - - public void AddConsumer (ILogger consumer) - { - consumers.Add (consumer); - } - - - public void Write (string tag, string msg, ImportanceLevel importance) - { - foreach (ILogger logger in consumers) { - if (tag == null || tag == "") { - logger.Write (msg, importance); - } else { - logger.Write (tag, msg, importance); - } - } - } - - public void Write (string msg, ImportanceLevel importance) - { - Write (null, msg, importance); - } - - - public void Write (string tag, string msg) - { - foreach (ILogger logger in consumers) { - if (tag == null || tag == "") { - logger.Write (msg); - } else { - logger.Write (tag, msg); - } - } - } - - public void Write (string msg) - { - Write (null, msg); - } - - - public void Flush () - { - foreach (ILogger logger in consumers) { - logger.Flush (); - } - } - - - public void Close () - { - foreach (ILogger logger in consumers) { - logger.Flush (); - logger.Close (); - } - } - - } - - - - - - - //////////////////////////////// - // Main - //////////////////////////////// - - public class Verifier { - - public static readonly Log log = new Log (); - public static bool stopOnError = false; - public static bool ignoreMissingTypes = true; - public static bool checkOptionalFlags = true; - - private static readonly IList excluded; - - static Verifier () - { - excluded = new ArrayList (); - excluded.Add (""); - } - - - private Verifier () - { - } - - public static Log Log { - get { - return log; - } - } - - public static IList Excluded { - get { - return excluded; - } - } - - - - public static void Main (String [] args) - { - if (args.Length < 2) { - Console.WriteLine ("Usage: verifier assembly1 assembly2"); - } else { - string name1 = args [0]; - string name2 = args [1]; - - bool ok = false; - - AssemblyStuff asm1 = new AssemblyStuff (name1); - AssemblyStuff asm2 = new AssemblyStuff (name2); - ok = asm1.Load (); - if (!ok) { - Console.WriteLine ("Unable to load assembly {0}.", name1); - Environment.Exit (-1); - } - - ok = asm2.Load (); - if (!ok) { - Console.WriteLine ("Unable to load assembly {0}.", name2); - Environment.Exit (-1); - } - - - try { - ok = (asm1 == asm2); - } catch { - ok = false; - } finally { - Log.Close (); - } - - if (!ok) { - Console.WriteLine ("--- not equal"); - Environment.Exit (-1); - } - } - } - - } - - -} - diff --git a/mcs/tools/xbuild/data/12.0/Microsoft.Common.tasks b/mcs/tools/xbuild/data/12.0/Microsoft.Common.tasks index 2155da3f277..9bcd6450ffa 100644 --- a/mcs/tools/xbuild/data/12.0/Microsoft.Common.tasks +++ b/mcs/tools/xbuild/data/12.0/Microsoft.Common.tasks @@ -36,4 +36,5 @@ + diff --git a/mcs/tools/xbuild/data/14.0/Microsoft.Common.tasks b/mcs/tools/xbuild/data/14.0/Microsoft.Common.tasks index 01964063c0f..192b8dabad3 100644 --- a/mcs/tools/xbuild/data/14.0/Microsoft.Common.tasks +++ b/mcs/tools/xbuild/data/14.0/Microsoft.Common.tasks @@ -35,4 +35,5 @@ + diff --git a/mcs/tools/xbuild/data/4.0/Microsoft.Common.tasks b/mcs/tools/xbuild/data/4.0/Microsoft.Common.tasks index b183750f9e2..caf108e39ce 100644 --- a/mcs/tools/xbuild/data/4.0/Microsoft.Common.tasks +++ b/mcs/tools/xbuild/data/4.0/Microsoft.Common.tasks @@ -36,4 +36,5 @@ + diff --git a/mono/io-layer/io.c b/mono/io-layer/io.c index 4fe2e248be7..bac7e874998 100644 --- a/mono/io-layer/io.c +++ b/mono/io-layer/io.c @@ -1037,8 +1037,11 @@ static void console_close (gpointer handle, gpointer data) g_free (console_handle->filename); - if (fd > 2) + if (fd > 2) { + if (console_handle->share_info) + _wapi_handle_share_release (console_handle->share_info); close (fd); + } } static WapiFileType console_getfiletype(void) @@ -1159,6 +1162,9 @@ static void pipe_close (gpointer handle, gpointer data) /* No filename with pipe handles */ + if (pipe_handle->share_info) + _wapi_handle_share_release (pipe_handle->share_info); + close (fd); } @@ -1630,6 +1636,10 @@ gpointer CreateFile(const gunichar2 *name, guint32 fileaccess, #endif if (S_ISFIFO (statbuf.st_mode)) { handle_type = WAPI_HANDLE_PIPE; + /* maintain invariant that pipes have no filename */ + file_handle.filename = NULL; + g_free (filename); + filename = NULL; } else if (S_ISCHR (statbuf.st_mode)) { handle_type = WAPI_HANDLE_CONSOLE; } else { diff --git a/mono/io-layer/wapi-remap.h b/mono/io-layer/wapi-remap.h index 211c92bba17..10118183618 100644 --- a/mono/io-layer/wapi-remap.h +++ b/mono/io-layer/wapi-remap.h @@ -102,5 +102,7 @@ #define WaitForMultipleObjects wapi_WaitForMultipleObjects #define WaitForMultipleObjectsEx wapi_WaitForMultipleObjectsEx #define WaitForInputIdle wapi_WaitForInputIdle +#define GetThreadPriority wapi_GetThreadPriority +#define SetThreadPriority wapi_SetThreadPriority #endif /* __WAPI_REMAP_H__ */ diff --git a/mono/metadata/appdomain.c b/mono/metadata/appdomain.c index 20d55eb878f..d618bef4803 100644 --- a/mono/metadata/appdomain.c +++ b/mono/metadata/appdomain.c @@ -2528,7 +2528,7 @@ mono_domain_try_unload (MonoDomain *domain, MonoObject **exc) if (*exc) mono_error_cleanup (&error); else - *exc = mono_error_convert_to_exception (&error); + *exc = (MonoObject*)mono_error_convert_to_exception (&error); } if (*exc) { diff --git a/mono/metadata/assembly.c b/mono/metadata/assembly.c index be250d67bd9..381d102b39b 100644 --- a/mono/metadata/assembly.c +++ b/mono/metadata/assembly.c @@ -105,7 +105,6 @@ static const AssemblyVersionMap framework_assemblies [] = { {"Mono.Security.Win32", 0}, {"Mono.Xml.Ext", 0}, {"Novell.Directory.Ldap", 0}, - {"Npgsql", 0}, {"PEAPI", 0}, {"System", 0}, {"System.ComponentModel.Composition", 2}, @@ -3050,13 +3049,13 @@ mono_assembly_load_corlib (const MonoRuntimeInfo *runtime, MonoImageOpenStatus * mono_assembly_name_free (aname); g_free (aname); if (corlib != NULL) - return corlib; + goto return_corlib_and_facades; // This unusual directory layout can occur if mono is being built and run out of its own source repo if (assemblies_path) { // Custom assemblies path set via MONO_PATH or mono_set_assemblies_path corlib = load_in_path ("mscorlib.dll", (const char**)assemblies_path, status, FALSE); if (corlib) - return corlib; + goto return_corlib_and_facades; } /* Normal case: Load corlib from mono/ */ @@ -3065,14 +3064,15 @@ mono_assembly_load_corlib (const MonoRuntimeInfo *runtime, MonoImageOpenStatus * corlib = load_in_path (corlib_file, (const char**)assemblies_path, status, FALSE); if (corlib) { g_free (corlib_file); - return corlib; + goto return_corlib_and_facades; } } corlib = load_in_path (corlib_file, default_path, status, FALSE); g_free (corlib_file); - + +return_corlib_and_facades: if (corlib && !strcmp (runtime->framework_version, "4.5")) // FIXME: stop hardcoding 4.5 here - default_path [1] = g_strdup_printf ("%s/mono/4.5/Facades", default_path [0]); + default_path [1] = g_strdup_printf ("%s/Facades", corlib->basedir); return corlib; } diff --git a/mono/metadata/icall-def.h b/mono/metadata/icall-def.h index 538371bf50c..9a4aafe0597 100644 --- a/mono/metadata/icall-def.h +++ b/mono/metadata/icall-def.h @@ -399,7 +399,7 @@ ICALL(MATH_17, "Tan", ves_icall_System_Math_Tan) ICALL(MATH_18, "Tanh", ves_icall_System_Math_Tanh) ICALL_TYPE(MCATTR, "System.MonoCustomAttrs", MCATTR_1) -ICALL(MCATTR_1, "GetCustomAttributesDataInternal", mono_reflection_get_custom_attrs_data) +ICALL(MCATTR_1, "GetCustomAttributesDataInternal", ves_icall_MonoCustomAttrs_GetCustomAttributesDataInternal) ICALL(MCATTR_2, "GetCustomAttributesInternal", custom_attrs_get_by_type) ICALL(MCATTR_3, "IsDefinedInternal", custom_attrs_defined_internal) diff --git a/mono/metadata/icall.c b/mono/metadata/icall.c index 4c456dfaedd..ba18aac5ac1 100644 --- a/mono/metadata/icall.c +++ b/mono/metadata/icall.c @@ -1273,16 +1273,16 @@ get_caller_no_reflection (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed } static MonoReflectionType * -type_from_parsed_name (MonoTypeNameParse *info, MonoBoolean ignoreCase) +type_from_parsed_name (MonoTypeNameParse *info, MonoBoolean ignoreCase, MonoError *error) { - MonoError error; - MonoReflectionType *ret; MonoMethod *m, *dest; MonoType *type = NULL; MonoAssembly *assembly = NULL; gboolean type_resolve = FALSE; + mono_error_init (error); + /* * We must compute the calling assembly as type loading must happen under a metadata context. * For example. The main assembly is a.exe and Type.GetType is called from dir/b.dll. Without @@ -1330,42 +1330,15 @@ type_from_parsed_name (MonoTypeNameParse *info, MonoBoolean ignoreCase) if (!type) return NULL; - ret = mono_type_get_object_checked (mono_domain_get (), type, &error); - mono_error_raise_exception (&error); /* FIXME don't raise here */ - - return ret; + return mono_type_get_object_checked (mono_domain_get (), type, error); } -#ifdef UNUSED -MonoReflectionType * -mono_type_get (const char *str) -{ - char *copy = g_strdup (str); - MonoTypeNameParse info; - MonoReflectionType *type; - gboolean parsedOk; - - parsedOk = mono_reflection_parse_type(copy, &info); - if (!parsedOk) { - mono_reflection_free_type_info (&info); - g_free(copy); - return NULL; - } - - type = type_from_parsed_name (&info, FALSE); - - mono_reflection_free_type_info (&info); - g_free(copy); - - return type; -} -#endif - ICALL_EXPORT MonoReflectionType* ves_icall_type_from_name (MonoString *name, MonoBoolean throwOnError, MonoBoolean ignoreCase) { + MonoError error; char *str = mono_string_to_utf8 (name); MonoTypeNameParse info; MonoReflectionType *type; @@ -1383,11 +1356,19 @@ ves_icall_type_from_name (MonoString *name, return NULL; } - type = type_from_parsed_name (&info, ignoreCase); + type = type_from_parsed_name (&info, ignoreCase, &error); mono_reflection_free_type_info (&info); g_free (str); + if (!mono_error_ok (&error)) { + if (throwOnError) + mono_error_set_pending_exception (&error); + else + mono_error_cleanup (&error); + return NULL; + } + if (type == NULL){ MonoException *e = NULL; @@ -4595,13 +4576,14 @@ ves_icall_System_Reflection_Assembly_GetManifestResourceNames (MonoReflectionAss } static MonoObject* -create_version (MonoDomain *domain, guint32 major, guint32 minor, guint32 build, guint32 revision) +create_version (MonoDomain *domain, guint32 major, guint32 minor, guint32 build, guint32 revision, MonoError *error) { static MonoClass *System_Version = NULL; static MonoMethod *create_version = NULL; - MonoError error; MonoObject *result; gpointer args [4]; + + mono_error_init (error); if (!System_Version) { System_Version = mono_class_from_name (mono_defaults.corlib, "System", "Version"); @@ -4619,11 +4601,11 @@ create_version (MonoDomain *domain, guint32 major, guint32 minor, guint32 build, args [1] = &minor; args [2] = &build; args [3] = &revision; - result = mono_object_new_checked (domain, System_Version, &error); - mono_error_raise_exception (&error); /* FIXME don't raise here */ + result = mono_object_new_checked (domain, System_Version, error); + return_val_if_nok (error, NULL); - mono_runtime_invoke_checked (create_version, result, args, &error); - mono_error_raise_exception (&error); /* FIXME don't raise here */ + mono_runtime_invoke_checked (create_version, result, args, error); + return_val_if_nok (error, NULL); return result; } @@ -4659,6 +4641,7 @@ ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAsse } for (i = 0; i < count; i++) { + MonoObject *version; MonoReflectionAssemblyName *aname; guint32 cols [MONO_ASSEMBLYREF_SIZE]; @@ -4677,7 +4660,11 @@ ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAsse aname->flags = cols [MONO_ASSEMBLYREF_FLAGS]; aname->versioncompat = 1; /* SameMachine (default) */ aname->hashalg = ASSEMBLY_HASH_SHA1; /* SHA1 (default) */ - MONO_OBJECT_SETREF (aname, version, create_version (domain, aname->major, aname->minor, aname->build, aname->revision)); + + version = create_version (domain, aname->major, aname->minor, aname->build, aname->revision, &error); + mono_error_raise_exception (&error); + + MONO_OBJECT_SETREF (aname, version, version); if (create_culture) { gpointer args [2]; @@ -5161,10 +5148,9 @@ ves_icall_MonoMethod_get_core_clr_security_level (MonoReflectionMethod *rfield) } static void -fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *aname, MonoAssemblyName *name, const char *absolute, gboolean by_default_version, gboolean default_publickey, gboolean default_token) +fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *aname, MonoAssemblyName *name, const char *absolute, gboolean by_default_version, gboolean default_publickey, gboolean default_token, MonoError *error) { static MonoMethod *create_culture = NULL; - MonoError error; MonoObject *obj; gpointer args [2]; guint32 pkey_len; @@ -5172,6 +5158,8 @@ fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *a gchar *codebase; MonoBoolean assembly_ref = 0; + mono_error_init (error); + MONO_OBJECT_SETREF (aname, name, mono_string_new (domain, name->name)); aname->major = name->major; aname->minor = name->minor; @@ -5182,8 +5170,14 @@ fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *a aname->versioncompat = 1; /* SameMachine (default) */ aname->processor_architecture = name->arch; - if (by_default_version) - MONO_OBJECT_SETREF (aname, version, create_version (domain, name->major, name->minor, name->build, name->revision)); + if (by_default_version) { + MonoObject *version; + + version = create_version (domain, name->major, name->minor, name->build, name->revision, error); + return_if_nok (error); + + MONO_OBJECT_SETREF (aname, version, version); + } codebase = NULL; if (absolute != NULL && *absolute != '\0') { @@ -5227,8 +5221,8 @@ fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *a args [0] = mono_string_new (domain, name->culture); args [1] = &assembly_ref; - obj = mono_runtime_invoke_checked (create_culture, NULL, args, &error); - mono_error_raise_exception (&error); /* FIXME don't raise here */ + obj = mono_runtime_invoke_checked (create_culture, NULL, args, error); + return_if_nok (error); MONO_OBJECT_SETREF (aname, cultureInfo, obj); } @@ -5281,20 +5275,19 @@ ves_icall_System_Reflection_Assembly_get_fullName (MonoReflectionAssembly *assem ICALL_EXPORT void ves_icall_System_Reflection_Assembly_FillName (MonoReflectionAssembly *assembly, MonoReflectionAssemblyName *aname) { + MonoError error; gchar *absolute; MonoAssembly *mass = assembly->assembly; if (g_path_is_absolute (mass->image->name)) { - fill_reflection_assembly_name (mono_object_domain (assembly), - aname, &mass->aname, mass->image->name, TRUE, - TRUE, TRUE); + fill_reflection_assembly_name (mono_object_domain (assembly), aname, &mass->aname, mass->image->name, TRUE, TRUE, TRUE, &error); + mono_error_set_pending_exception (&error); return; } absolute = g_build_filename (mass->basedir, mass->image->name, NULL); - fill_reflection_assembly_name (mono_object_domain (assembly), - aname, &mass->aname, absolute, TRUE, TRUE, - TRUE); + fill_reflection_assembly_name (mono_object_domain (assembly), aname, &mass->aname, absolute, TRUE, TRUE, TRUE, &error); + mono_error_set_pending_exception (&error); g_free (absolute); } @@ -5302,6 +5295,7 @@ ves_icall_System_Reflection_Assembly_FillName (MonoReflectionAssembly *assembly, ICALL_EXPORT void ves_icall_System_Reflection_Assembly_InternalGetAssemblyName (MonoString *fname, MonoReflectionAssemblyName *aname) { + MonoError error; char *filename; MonoImageOpenStatus status = MONO_IMAGE_OK; gboolean res; @@ -5337,11 +5331,11 @@ ves_icall_System_Reflection_Assembly_InternalGetAssemblyName (MonoString *fname, return; } - fill_reflection_assembly_name (mono_domain_get (), aname, &name, filename, - TRUE, FALSE, TRUE); + fill_reflection_assembly_name (mono_domain_get (), aname, &name, filename, TRUE, FALSE, TRUE, &error); + mono_error_set_pending_exception (&error); - g_free (filename); mono_image_close (image); + g_free (filename); } ICALL_EXPORT MonoBoolean @@ -5389,15 +5383,16 @@ mono_module_type_is_visible (MonoTableInfo *tdef, MonoImage *image, int type) } static MonoArray* -mono_module_get_types (MonoDomain *domain, MonoImage *image, MonoArray **exceptions, MonoBoolean exportedOnly) +mono_module_get_types (MonoDomain *domain, MonoImage *image, MonoArray **exceptions, MonoBoolean exportedOnly, MonoError *error) { - MonoError error; MonoReflectionType *rt; MonoArray *res; MonoClass *klass; MonoTableInfo *tdef = &image->tables [MONO_TABLE_TYPEDEF]; int i, count; + mono_error_init (error); + /* we start the count from 1 because we skip the special type */ if (exportedOnly) { count = 0; @@ -5413,17 +5408,17 @@ mono_module_get_types (MonoDomain *domain, MonoImage *image, MonoArray **excepti count = 0; for (i = 1; i < tdef->rows; ++i) { if (!exportedOnly || mono_module_type_is_visible (tdef, image, i + 1)) { - klass = mono_class_get_checked (image, (i + 1) | MONO_TOKEN_TYPE_DEF, &error); + klass = mono_class_get_checked (image, (i + 1) | MONO_TOKEN_TYPE_DEF, error); mono_loader_assert_no_error (); /* Plug any leaks */ - g_assert (mono_error_ok (&error)); + mono_error_assert_ok (error); if (klass) { - rt = mono_type_get_object_checked (domain, &klass->byval_arg, &error); - mono_error_raise_exception (&error); /* FIXME don't raise here */ + rt = mono_type_get_object_checked (domain, &klass->byval_arg, error); + return_val_if_nok (error, NULL); mono_array_setref (res, count, rt); } else { - MonoException *ex = mono_error_convert_to_exception (&error); + MonoException *ex = mono_error_convert_to_exception (error); mono_array_setref (*exceptions, count, ex); } count++; @@ -5436,6 +5431,7 @@ mono_module_get_types (MonoDomain *domain, MonoImage *image, MonoArray **excepti ICALL_EXPORT MonoArray* ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly, MonoBoolean exportedOnly) { + MonoError error; MonoArray *res = NULL; MonoArray *exceptions = NULL; MonoImage *image = NULL; @@ -5449,7 +5445,8 @@ ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly, g_assert (!assembly_is_dynamic (assembly->assembly)); image = assembly->assembly->image; table = &image->tables [MONO_TABLE_FILE]; - res = mono_module_get_types (domain, image, &exceptions, exportedOnly); + res = mono_module_get_types (domain, image, &exceptions, exportedOnly, &error); + mono_error_raise_exception (&error); /* Append data from all modules in the assembly */ for (i = 0; i < table->rows; ++i) { @@ -5457,7 +5454,11 @@ ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly, MonoImage *loaded_image = mono_assembly_load_module (image->assembly, i + 1); if (loaded_image) { MonoArray *ex2; - MonoArray *res2 = mono_module_get_types (domain, loaded_image, &ex2, exportedOnly); + MonoArray *res2; + + res2 = mono_module_get_types (domain, loaded_image, &ex2, exportedOnly, &error); + mono_error_raise_exception (&error); + /* Append the new types to the end of the array */ if (mono_array_length (res2) > 0) { guint32 len1, len2; @@ -5543,6 +5544,7 @@ ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly, ICALL_EXPORT gboolean ves_icall_System_Reflection_AssemblyName_ParseName (MonoReflectionAssemblyName *name, MonoString *assname) { + MonoError error; MonoAssemblyName aname; MonoDomain *domain = mono_object_domain (name); char *val; @@ -5557,8 +5559,8 @@ ves_icall_System_Reflection_AssemblyName_ParseName (MonoReflectionAssemblyName * return FALSE; } - fill_reflection_assembly_name (domain, name, &aname, "", is_version_defined, - FALSE, is_token_defined); + fill_reflection_assembly_name (domain, name, &aname, "", is_version_defined, FALSE, is_token_defined, &error); + mono_error_set_pending_exception (&error); mono_assembly_name_free (&aname); g_free ((guint8*) aname.public_key); @@ -5646,13 +5648,18 @@ ves_icall_System_Reflection_Module_GetMDStreamVersion (MonoImage *image) ICALL_EXPORT MonoArray* ves_icall_System_Reflection_Module_InternalGetTypes (MonoReflectionModule *module) { + MonoError error; MonoArray *exceptions; int i; if (!module->image) return mono_array_new (mono_object_domain (module), mono_defaults.monotype_class, 0); else { - MonoArray *res = mono_module_get_types (mono_object_domain (module), module->image, &exceptions, FALSE); + MonoArray *res; + + res = mono_module_get_types (mono_object_domain (module), module->image, &exceptions, FALSE, &error); + mono_error_raise_exception (&error); + for (i = 0; i < mono_array_length (exceptions); ++i) { MonoException *ex = mono_array_get (exceptions, MonoException *, i); if (ex) { @@ -7741,6 +7748,17 @@ custom_attrs_get_by_type (MonoObject *obj, MonoReflectionType *attr_type) } } +ICALL_EXPORT MonoArray* +ves_icall_MonoCustomAttrs_GetCustomAttributesDataInternal (MonoObject *obj) +{ + MonoError error; + MonoArray *result; + result = mono_reflection_get_custom_attrs_data_checked (obj, &error); + mono_error_set_pending_exception (&error); + return result; +} + + ICALL_EXPORT MonoString* ves_icall_Mono_Runtime_GetDisplayName (void) { diff --git a/mono/metadata/monitor.c b/mono/metadata/monitor.c index 0c1d28130af..b05a8416aac 100644 --- a/mono/metadata/monitor.c +++ b/mono/metadata/monitor.c @@ -1009,6 +1009,12 @@ mono_monitor_enter (MonoObject *obj) } gboolean +mono_monitor_enter_fast (MonoObject *obj) +{ + return mono_monitor_try_enter_internal (obj, 0, FALSE) == 1; +} + +gboolean mono_monitor_try_enter (MonoObject *obj, guint32 ms) { return mono_monitor_try_enter_internal (obj, ms, FALSE) == 1; @@ -1100,7 +1106,6 @@ ves_icall_System_Threading_Monitor_Monitor_try_enter_with_atomic_var (MonoObject void mono_monitor_enter_v4 (MonoObject *obj, char *lock_taken) { - if (*lock_taken == 1) { mono_set_pending_exception (mono_get_exception_argument ("lockTaken", "lockTaken is already true")); return; @@ -1109,6 +1114,23 @@ mono_monitor_enter_v4 (MonoObject *obj, char *lock_taken) ves_icall_System_Threading_Monitor_Monitor_try_enter_with_atomic_var (obj, INFINITE, lock_taken); } +/* + * mono_monitor_enter_v4_fast: + * + * Same as mono_monitor_enter_v4, but return immediately if the + * monitor cannot be acquired. + * Returns TRUE if the lock was acquired, FALSE otherwise. + */ +gboolean +mono_monitor_enter_v4_fast (MonoObject *obj, char *lock_taken) +{ + if (*lock_taken == 1) + return FALSE; + gint32 res = mono_monitor_try_enter_internal (obj, 0, TRUE); + *lock_taken = res == 1; + return res == 1; +} + gboolean ves_icall_System_Threading_Monitor_Monitor_test_owner (MonoObject *obj) { diff --git a/mono/metadata/monitor.h b/mono/metadata/monitor.h index bd796254034..f8e89936ba9 100644 --- a/mono/metadata/monitor.h +++ b/mono/metadata/monitor.h @@ -106,6 +106,9 @@ MONO_API void mono_locks_dump (gboolean include_untaken); void mono_monitor_init (void); void mono_monitor_cleanup (void); +gboolean mono_monitor_enter_fast (MonoObject *obj); +gboolean mono_monitor_enter_v4_fast (MonoObject *obj, char *lock_taken); + guint32 mono_monitor_get_object_monitor_gchandle (MonoObject *object); void mono_monitor_threads_sync_members_offset (int *status_offset, int *nest_offset); diff --git a/mono/metadata/reflection-internals.h b/mono/metadata/reflection-internals.h index 9ff3b451281..f445b436172 100644 --- a/mono/metadata/reflection-internals.h +++ b/mono/metadata/reflection-internals.h @@ -11,6 +11,9 @@ MonoObject* mono_custom_attrs_get_attr_checked (MonoCustomAttrInfo *ainfo, MonoClass *attr_klass, MonoError *error); +MonoArray* +mono_reflection_get_custom_attrs_data_checked (MonoObject *obj, MonoError *error); + char* mono_identifier_unescape_type_name_chars (char* identifier); diff --git a/mono/metadata/reflection.c b/mono/metadata/reflection.c index 77865984052..49cac40c7ad 100644 --- a/mono/metadata/reflection.c +++ b/mono/metadata/reflection.c @@ -6661,12 +6661,11 @@ mono_assembly_get_object (MonoDomain *domain, MonoAssembly *assembly) MonoError error; MonoReflectionAssembly *result; result = mono_assembly_get_object_checked (domain, assembly, &error); - if (!result) - mono_error_set_pending_exception (&error); + mono_error_cleanup (&error); /* FIXME new API that doesn't swallow the error */ return result; } /* - * mono_assembly_get_object: + * mono_assembly_get_object_checked: * @domain: an app domain * @assembly: an assembly * @@ -6764,7 +6763,7 @@ mono_module_file_get_object (MonoDomain *domain, MonoImage *image, int table_ind MonoError error; MonoReflectionModule *result; result = mono_module_file_get_object_checked (domain, image, table_index, &error); - mono_error_raise_exception (&error); + mono_error_cleanup (&error); /* FIXME new API that doesn't swallow the error */ return result; } @@ -10019,10 +10018,31 @@ mono_reflection_get_custom_attrs (MonoObject *obj) */ MonoArray* mono_reflection_get_custom_attrs_data (MonoObject *obj) +{ + MonoError error; + MonoArray* result; + result = mono_reflection_get_custom_attrs_data_checked (obj, &error); + mono_error_cleanup (&error); /* FIXME new API that doesn't swallow the error */ + return result; +} + +/* + * mono_reflection_get_custom_attrs_data_checked: + * @obj: a reflection obj handle + * @error: set on error + * + * Returns an array of System.Reflection.CustomAttributeData, + * which include information about attributes reflected on + * types loaded using the Reflection Only methods + */ +MonoArray* +mono_reflection_get_custom_attrs_data_checked (MonoObject *obj, MonoError *error) { MonoArray *result; MonoCustomAttrInfo *cinfo; + mono_error_init (error); + cinfo = mono_reflection_get_custom_attrs_info (obj); if (cinfo) { result = mono_custom_attrs_data_construct (cinfo); @@ -10031,6 +10051,9 @@ mono_reflection_get_custom_attrs_data (MonoObject *obj) } else result = mono_array_new (mono_domain_get (), mono_defaults.customattribute_data_class, 0); + if (mono_loader_get_last_error ()) + mono_error_set_from_loader_error (error); + return result; } diff --git a/mono/metadata/reflection.h b/mono/metadata/reflection.h index e3e84f11e73..a8bdff969b0 100644 --- a/mono/metadata/reflection.h +++ b/mono/metadata/reflection.h @@ -70,6 +70,7 @@ MONO_API MonoObject *mono_get_dbnull_object (MonoDomain *domain); MONO_API MonoArray* mono_reflection_get_custom_attrs_by_type (MonoObject *obj, MonoClass *attr_klass, MonoError *error); MONO_API MonoArray* mono_reflection_get_custom_attrs (MonoObject *obj); +MONO_RT_EXTERNAL_ONLY MONO_API MonoArray* mono_reflection_get_custom_attrs_data (MonoObject *obj); MONO_API MonoArray* mono_reflection_get_custom_attrs_blob (MonoReflectionAssembly *assembly, MonoObject *ctor, MonoArray *ctorArgs, MonoArray *properties, MonoArray *porpValues, MonoArray *fields, MonoArray* fieldValues); diff --git a/mono/metadata/sgen-mono.c b/mono/metadata/sgen-mono.c index 74ee377c49a..8f86228dce1 100644 --- a/mono/metadata/sgen-mono.c +++ b/mono/metadata/sgen-mono.c @@ -2738,7 +2738,7 @@ sgen_client_degraded_allocation (size_t size) static int last_major_gc_warned = -1; static int num_degraded = 0; - if (last_major_gc_warned < gc_stats.major_gc_count) { + if (last_major_gc_warned < (int)gc_stats.major_gc_count) { ++num_degraded; if (num_degraded == 1 || num_degraded == 3) mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC, "Warning: Degraded allocation. Consider increasing nursery-size if the warning persists."); diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c index 9bd451ee71c..6867741e3ce 100644 --- a/mono/metadata/threads.c +++ b/mono/metadata/threads.c @@ -202,9 +202,10 @@ static void mono_free_static_data (gpointer* static_data); static void mono_init_static_data_info (StaticDataInfo *static_data); static guint32 mono_alloc_static_data_slot (StaticDataInfo *static_data, guint32 size, guint32 align); static gboolean mono_thread_resume (MonoInternalThread* thread); -static void abort_thread_internal (MonoInternalThread *thread, gboolean can_raise_exception, gboolean install_async_abort); -static void suspend_thread_internal (MonoInternalThread *thread, gboolean interrupt); -static void self_suspend_internal (MonoInternalThread *thread); +static void async_abort_internal (MonoInternalThread *thread, gboolean install_async_abort); +static void self_abort_internal (void); +static void async_suspend_internal (MonoInternalThread *thread, gboolean interrupt); +static void self_suspend_internal (void); static MonoException* mono_thread_execute_interruption (void); static void ref_stack_destroy (gpointer rs); @@ -2145,9 +2146,9 @@ void ves_icall_System_Threading_Thread_Interrupt_internal (MonoThread *this_obj) throw_ = current != thread && (thread->state & ThreadState_WaitSleepJoin); UNLOCK_THREAD (thread); - + if (throw_) { - abort_thread_internal (thread, TRUE, FALSE); + async_abort_internal (thread, FALSE); } } @@ -2209,7 +2210,10 @@ ves_icall_System_Threading_Thread_Abort (MonoInternalThread *thread, MonoObject UNLOCK_THREAD (thread); - abort_thread_internal (thread, TRUE, TRUE); + if (thread == mono_thread_internal_current ()) + self_abort_internal (); + else + async_abort_internal (thread, TRUE); } void @@ -2309,7 +2313,15 @@ mono_thread_suspend (MonoInternalThread *thread) } thread->state |= ThreadState_SuspendRequested; - suspend_thread_internal (thread, FALSE); + + if (thread == mono_thread_internal_current ()) { + /* calls UNLOCK_THREAD (thread) */ + self_suspend_internal (); + } else { + /* calls UNLOCK_THREAD (thread) */ + async_suspend_internal (thread, FALSE); + } + return TRUE; } @@ -2417,7 +2429,10 @@ void mono_thread_internal_stop (MonoInternalThread *thread) UNLOCK_THREAD (thread); - abort_thread_internal (thread, TRUE, TRUE); + if (thread == mono_thread_internal_current ()) + self_abort_internal (); + else + async_abort_internal (thread, TRUE); } void mono_thread_stop (MonoThread *thread) @@ -3285,8 +3300,9 @@ void mono_thread_suspend_all_other_threads (void) thread->state &= ~ThreadState_AbortRequested; thread->state |= ThreadState_SuspendRequested; - /* Signal the thread to suspend */ - suspend_thread_internal (thread, TRUE); + + /* Signal the thread to suspend + calls UNLOCK_THREAD (thread) */ + async_suspend_internal (thread, TRUE); } if (eventidx <= 0) { /* @@ -4336,7 +4352,8 @@ mono_thread_execute_interruption (void) return thread->abort_exc; } else if ((thread->state & ThreadState_SuspendRequested) != 0) { - self_suspend_internal (thread); + /* calls UNLOCK_THREAD (thread) */ + self_suspend_internal (); return NULL; } else if ((thread->state & ThreadState_StopRequested) != 0) { @@ -4676,7 +4693,7 @@ typedef struct { } AbortThreadData; static SuspendThreadResult -abort_thread_critical (MonoThreadInfo *info, gpointer ud) +async_abort_critical (MonoThreadInfo *info, gpointer ud) { AbortThreadData *data = (AbortThreadData *)ud; MonoInternalThread *thread = data->thread; @@ -4718,41 +4735,45 @@ abort_thread_critical (MonoThreadInfo *info, gpointer ud) } static void -abort_thread_internal (MonoInternalThread *thread, gboolean can_raise_exception, gboolean install_async_abort) +async_abort_internal (MonoInternalThread *thread, gboolean install_async_abort) { - AbortThreadData data = { 0 }; - data.thread = thread; - data.install_async_abort = install_async_abort; + AbortThreadData data; - /* - FIXME this is insanely broken, it doesn't cause interruption to happen - synchronously since passing FALSE to mono_thread_request_interruption makes sure it returns NULL - */ - if (thread == mono_thread_internal_current ()) { - /* Do it synchronously */ - MonoException *exc = mono_thread_request_interruption (can_raise_exception); - if (exc) - mono_raise_exception (exc); + g_assert (thread != mono_thread_internal_current ()); - mono_thread_info_self_interrupt (); - - return; - } + data.thread = thread; + data.install_async_abort = install_async_abort; + data.interrupt_token = NULL; - mono_thread_info_safe_suspend_and_run (thread_get_tid (thread), TRUE, abort_thread_critical, &data); + mono_thread_info_safe_suspend_and_run (thread_get_tid (thread), TRUE, async_abort_critical, &data); if (data.interrupt_token) mono_thread_info_finish_interrupt (data.interrupt_token); /*FIXME we need to wait for interruption to complete -- figure out how much into interruption we should wait for here*/ } -typedef struct{ +static void +self_abort_internal (void) +{ + MonoException *exc; + + /* FIXME this is insanely broken, it doesn't cause interruption to happen synchronously + * since passing FALSE to mono_thread_request_interruption makes sure it returns NULL */ + + exc = mono_thread_request_interruption (TRUE); + if (exc) + mono_raise_exception (exc); + + mono_thread_info_self_interrupt (); +} + +typedef struct { MonoInternalThread *thread; gboolean interrupt; MonoThreadInfoInterruptToken *interrupt_token; } SuspendThreadData; static SuspendThreadResult -suspend_thread_critical (MonoThreadInfo *info, gpointer ud) +async_suspend_critical (MonoThreadInfo *info, gpointer ud) { SuspendThreadData *data = (SuspendThreadData *)ud; MonoInternalThread *thread = data->thread; @@ -4777,41 +4798,43 @@ suspend_thread_critical (MonoThreadInfo *info, gpointer ud) return MonoResumeThread; } } - + +/* LOCKING: called with @thread synch_cs held, and releases it */ static void -suspend_thread_internal (MonoInternalThread *thread, gboolean interrupt) +async_suspend_internal (MonoInternalThread *thread, gboolean interrupt) { - if (thread == mono_thread_internal_current ()) { - mono_thread_info_begin_self_suspend (); - //XXX replace this with better named functions - thread->state &= ~ThreadState_SuspendRequested; - thread->state |= ThreadState_Suspended; - UNLOCK_THREAD (thread); - mono_thread_info_end_self_suspend (); - } else { - SuspendThreadData data = { 0 }; - data.thread = thread; - data.interrupt = interrupt; + SuspendThreadData data; - mono_thread_info_safe_suspend_and_run (thread_get_tid (thread), interrupt, suspend_thread_critical, &data); - if (data.interrupt_token) - mono_thread_info_finish_interrupt (data.interrupt_token); - UNLOCK_THREAD (thread); - } + g_assert (thread != mono_thread_internal_current ()); + + data.thread = thread; + data.interrupt = interrupt; + data.interrupt_token = NULL; + + mono_thread_info_safe_suspend_and_run (thread_get_tid (thread), interrupt, async_suspend_critical, &data); + if (data.interrupt_token) + mono_thread_info_finish_interrupt (data.interrupt_token); + + UNLOCK_THREAD (thread); } -/*This is called with @thread synch_cs held and it must release it*/ +/* LOCKING: called with @thread synch_cs held, and releases it */ static void -self_suspend_internal (MonoInternalThread *thread) +self_suspend_internal (void) { + MonoInternalThread *thread; + + thread = mono_thread_internal_current (); + mono_thread_info_begin_self_suspend (); thread->state &= ~ThreadState_SuspendRequested; thread->state |= ThreadState_Suspended; + UNLOCK_THREAD (thread); + mono_thread_info_end_self_suspend (); } - /* * mono_thread_is_foreign: * @thread: the thread to query diff --git a/mono/mini/aot-compiler.c b/mono/mini/aot-compiler.c index f980ec9d35e..772105fd258 100644 --- a/mono/mini/aot-compiler.c +++ b/mono/mini/aot-compiler.c @@ -7356,9 +7356,6 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method) if (acfg->aot_opts.llvm_only) { GSList *l; - if (cfg->method->wrapper_type == MONO_WRAPPER_DELEGATE_INVOKE && strstr (mono_method_full_name (cfg->method, 1), "ParallelLoopState")) - printf ("HIT!\n"); - if (!cfg->method->wrapper_type || cfg->method->wrapper_type == MONO_WRAPPER_DELEGATE_INVOKE) /* These only need out wrappers */ add_gsharedvt_wrappers (acfg, mono_method_signature (cfg->method), FALSE, TRUE); @@ -7947,10 +7944,7 @@ emit_llvm_file (MonoAotCompile *acfg) if (acfg->aot_opts.llvm_only) { /* Use the stock clang from xcode */ // FIXME: arch - // FIXME: -O2 - // FIXME: llc/opt flags - command = g_strdup_printf ("clang -march=x86-64 -fpic -msse -msse2 -msse3 -msse4 -O0 -fno-optimize-sibling-calls -Wno-override-module -c -o \"%s\" \"%s.opt.bc\"", acfg->llvm_ofile, acfg->tmpbasename); - //command = g_strdup_printf ("/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.3.sdk -Qunused-arguments -miphoneos-version-min=8.2 -arch arm64 -fpic -O0 -c -o \"%s\" \"%s.bc\"", acfg->llvm_ofile, acfg->tmpbasename); + command = g_strdup_printf ("clang -march=x86-64 -fpic -msse -msse2 -msse3 -msse4 -O2 -fno-optimize-sibling-calls -Wno-override-module -c -o \"%s\" \"%s.opt.bc\"", acfg->llvm_ofile, acfg->tmpbasename); aot_printf (acfg, "Executing clang: %s\n", command); if (execute_system (command) != 0) diff --git a/mono/mini/aot-runtime.c b/mono/mini/aot-runtime.c index 0b6c4a6ecf6..b082a6e3b0f 100644 --- a/mono/mini/aot-runtime.c +++ b/mono/mini/aot-runtime.c @@ -4599,7 +4599,7 @@ mono_aot_patch_plt_entry (guint8 *code, guint8 *plt_entry, gpointer *got, mgreg_ * Returns NULL if the something cannot be loaded. */ gpointer -mono_aot_plt_resolve (gpointer aot_module, guint32 plt_info_offset, guint8 *code) +mono_aot_plt_resolve (gpointer aot_module, guint32 plt_info_offset, guint8 *code, MonoError *error) { #ifdef MONO_ARCH_AOT_SUPPORTED guint8 *p, *target, *plt_entry; @@ -4607,9 +4607,10 @@ mono_aot_plt_resolve (gpointer aot_module, guint32 plt_info_offset, guint8 *code MonoAotModule *module = (MonoAotModule*)aot_module; gboolean res, no_ftnptr = FALSE; MonoMemPool *mp; - MonoError error; gboolean using_gsharedvt = FALSE; + mono_error_init (error); + //printf ("DYN: %p %d\n", aot_module, plt_info_offset); p = &module->blob [plt_info_offset]; @@ -4636,12 +4637,14 @@ mono_aot_plt_resolve (gpointer aot_module, guint32 plt_info_offset, guint8 *code */ if (mono_aot_only && ji.type == MONO_PATCH_INFO_METHOD && !ji.data.method->is_generic && !mono_method_check_context_used (ji.data.method) && !(ji.data.method->iflags & METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED) && !mono_method_needs_static_rgctx_invoke (ji.data.method, FALSE) && !using_gsharedvt) { - target = (guint8 *)mono_jit_compile_method (ji.data.method, &error); - if (!mono_error_ok (&error)) - mono_error_raise_exception (&error); + target = (guint8 *)mono_jit_compile_method (ji.data.method, error); + if (!mono_error_ok (error)) + return NULL; no_ftnptr = TRUE; } else { - target = (guint8 *)mono_resolve_patch_target (NULL, mono_domain_get (), NULL, &ji, TRUE); + target = (guint8 *)mono_resolve_patch_target_checked (NULL, mono_domain_get (), NULL, &ji, TRUE, error); + if (!mono_error_ok (error)) + return NULL; } /* @@ -4729,7 +4732,7 @@ mono_aot_get_plt_entry (guint8 *code) return NULL; #ifdef TARGET_ARM - if (is_thumb_code (amodule, code)) + if (is_thumb_code (amodule, code - 4)) return mono_arm_get_thumb_plt_entry (code); #endif @@ -5728,7 +5731,7 @@ mono_aot_get_plt_entry (guint8 *code) } gpointer -mono_aot_plt_resolve (gpointer aot_module, guint32 plt_info_offset, guint8 *code) +mono_aot_plt_resolve (gpointer aot_module, guint32 plt_info_offset, guint8 *code, MonoError *error) { return NULL; } diff --git a/mono/mini/cfold.c b/mono/mini/cfold.c index 258e930d201..a4910feb180 100644 --- a/mono/mini/cfold.c +++ b/mono/mini/cfold.c @@ -336,13 +336,16 @@ mono_constant_fold_ins (MonoCompile *cfg, MonoInst *ins, MonoInst *arg1, MonoIns } break; case OP_COND_EXC_EQ: - if (overwrite) { - NULLIFY_INS (ins); - NULLIFY_INS (next); - } else { - ALLOC_DEST (cfg, dest, ins); - dest->opcode = OP_ICONST; - dest->inst_c0 = res; + res = arg1->inst_c0 == arg2->inst_c0; + if (!res) { + if (overwrite) { + NULLIFY_INS (ins); + NULLIFY_INS (next); + } else { + ALLOC_DEST (cfg, dest, ins); + dest->opcode = OP_ICONST; + dest->inst_c0 = res; + } } break; case OP_NOP: diff --git a/mono/mini/method-to-ir.c b/mono/mini/method-to-ir.c index edece583b1c..cc25ae065d6 100644 --- a/mono/mini/method-to-ir.c +++ b/mono/mini/method-to-ir.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -5981,7 +5982,6 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign } else return NULL; } else if (cmethod->klass == mono_defaults.object_class) { - if (strcmp (cmethod->name, "GetType") == 0 && fsig->param_count + fsig->hasthis == 1) { int dreg = alloc_ireg_ref (cfg); int vt_reg = alloc_preg (cfg); @@ -6079,12 +6079,38 @@ mini_emit_inst_for_method (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSign } else return NULL; } else if (cmethod->klass == runtime_helpers_class) { - if (strcmp (cmethod->name, "get_OffsetToStringData") == 0 && fsig->param_count == 0) { EMIT_NEW_ICONST (cfg, ins, MONO_STRUCT_OFFSET (MonoString, chars)); return ins; } else return NULL; + } else if (cmethod->klass == mono_defaults.monitor_class) { + gboolean is_enter = FALSE; + gboolean is_v4 = FALSE; + + if (!strcmp (cmethod->name, "enter_with_atomic_var") && mono_method_signature (cmethod)->param_count == 2) { + is_enter = TRUE; + is_v4 = TRUE; + } + if (!strcmp (cmethod->name, "Enter") && mono_method_signature (cmethod)->param_count == 1) + is_enter = TRUE; + + if (is_enter) { + /* + * To make async stack traces work, icalls which can block should have a wrapper. + * For Monitor.Enter, emit two calls: a fastpath which doesn't have a wrapper, and a slowpath, which does. + */ + MonoBasicBlock *end_bb; + + NEW_BBLOCK (cfg, end_bb); + + ins = mono_emit_jit_icall (cfg, is_v4 ? (gpointer)mono_monitor_enter_v4_fast : (gpointer)mono_monitor_enter_fast, args); + MONO_EMIT_NEW_BIALU_IMM (cfg, OP_ICOMPARE_IMM, -1, ins->dreg, 0); + MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_IBNE_UN, end_bb); + ins = mono_emit_jit_icall (cfg, is_v4 ? (gpointer)mono_monitor_enter_v4 : (gpointer)mono_monitor_enter, args); + MONO_START_BB (cfg, end_bb); + return ins; + } } else if (cmethod->klass == mono_defaults.thread_class) { if (strcmp (cmethod->name, "SpinWait_nop") == 0 && fsig->param_count == 0) { MONO_INST_NEW (cfg, ins, OP_RELAXED_NOP); diff --git a/mono/mini/mini-llvm-cpp.cpp b/mono/mini/mini-llvm-cpp.cpp index cb5ddd33e79..6fab934f479 100644 --- a/mono/mini/mini-llvm-cpp.cpp +++ b/mono/mini/mini-llvm-cpp.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include "mini-llvm-cpp.h" @@ -216,3 +217,11 @@ mono_llvm_set_call_preserveall_cc (LLVMValueRef func) { unwrap(func)->setCallingConv (CallingConv::PreserveAll); } + +void +mono_llvm_create_di_compile_unit (LLVMModuleRef module) +{ + DIBuilder d(*unwrap(module)); + + d.createCompileUnit (0, "X", "Y", "Z", false, "", 0, "", DIBuilder::DebugEmissionKind::FullDebug, true); +} diff --git a/mono/mini/mini-llvm-cpp.h b/mono/mini/mini-llvm-cpp.h index 78bccd07ff9..9e551e2557d 100644 --- a/mono/mini/mini-llvm-cpp.h +++ b/mono/mini/mini-llvm-cpp.h @@ -111,6 +111,9 @@ mono_llvm_set_unhandled_exception_handler (void); void default_mono_llvm_unhandled_exception (void); +void +mono_llvm_create_di_compile_unit (LLVMModuleRef module); + G_END_DECLS #endif /* __MONO_MINI_LLVM_CPP_H__ */ diff --git a/mono/mini/mini-llvm.c b/mono/mini/mini-llvm.c index 3484ed3faec..ae0767d1769 100644 --- a/mono/mini/mini-llvm.c +++ b/mono/mini/mini-llvm.c @@ -7999,6 +7999,8 @@ mono_llvm_emit_aot_module (const char *filename, const char *cu_name) emit_dbg_info (&aot_module, filename, cu_name); emit_aot_file_info (&aot_module); + mono_llvm_create_di_compile_unit (aot_module.lmodule); + /* * Replace GOT entries for directly callable methods with the methods themselves. * It would be easier to implement this by predefining all methods before compiling diff --git a/mono/mini/mini-runtime.c b/mono/mini/mini-runtime.c index 997f198c80b..170cc65e7bd 100644 --- a/mono/mini/mini-runtime.c +++ b/mono/mini/mini-runtime.c @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -711,6 +712,19 @@ register_icall_no_wrapper (gpointer func, const char *name, const char *sigstr) mono_register_jit_icall_full (func, name, sig, TRUE, FALSE, name); } +static void +register_icall_with_wrapper (gpointer func, const char *name, const char *sigstr) +{ + MonoMethodSignature *sig; + + if (sigstr) + sig = mono_create_icall_signature (sigstr); + else + sig = NULL; + + mono_register_jit_icall_full (func, name, sig, FALSE, FALSE, NULL); +} + static void register_dyn_icall (gpointer func, const char *name, const char *sigstr, gboolean save) { @@ -1341,11 +1355,13 @@ mono_patch_info_equal (gconstpointer ka, gconstpointer kb) } gpointer -mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *patch_info, gboolean run_cctors) +mono_resolve_patch_target_checked (MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *patch_info, gboolean run_cctors, MonoError *error) { unsigned char *ip = patch_info->ip.i + code; gconstpointer target = NULL; + mono_error_init (error); + switch (patch_info->type) { case MONO_PATCH_INFO_BB: /* @@ -1558,29 +1574,27 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code, case MONO_PATCH_INFO_TYPE_FROM_HANDLE: { gpointer handle; MonoClass *handle_class; - MonoError error; handle = mono_ldtoken_checked (patch_info->data.token->image, - patch_info->data.token->token, &handle_class, patch_info->data.token->has_context ? &patch_info->data.token->context : NULL, &error); - if (!mono_error_ok (&error)) - g_error ("Could not patch ldtoken due to %s", mono_error_get_message (&error)); + patch_info->data.token->token, &handle_class, patch_info->data.token->has_context ? &patch_info->data.token->context : NULL, error); + if (!mono_error_ok (error)) + g_error ("Could not patch ldtoken due to %s", mono_error_get_message (error)); mono_class_init (handle_class); mono_class_init (mono_class_from_mono_type ((MonoType *)handle)); - target = mono_type_get_object_checked (domain, (MonoType *)handle, &error); - mono_error_raise_exception (&error); - + target = mono_type_get_object_checked (domain, (MonoType *)handle, error); + if (!mono_error_ok (error)) + return NULL; break; } case MONO_PATCH_INFO_LDTOKEN: { gpointer handle; MonoClass *handle_class; - MonoError error; handle = mono_ldtoken_checked (patch_info->data.token->image, - patch_info->data.token->token, &handle_class, patch_info->data.token->has_context ? &patch_info->data.token->context : NULL, &error); - if (!mono_error_ok (&error)) - g_error ("Could not patch ldtoken due to %s", mono_error_get_message (&error)); + patch_info->data.token->token, &handle_class, patch_info->data.token->has_context ? &patch_info->data.token->context : NULL, error); + if (!mono_error_ok (error)) + g_error ("Could not patch ldtoken due to %s", mono_error_get_message (error)); mono_class_init (handle_class); target = handle; @@ -1598,8 +1612,10 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code, if (run_cctors) { target = mono_lookup_pinvoke_call (patch_info->data.method, &exc_class, &exc_arg); if (!target) { - if (mono_aot_only) - mono_raise_exception (mono_exception_from_name_msg (mono_defaults.corlib, "System", exc_class, exc_arg)); + if (mono_aot_only) { + mono_error_set_exception_instance (error, mono_exception_from_name_msg (mono_defaults.corlib, "System", exc_class, exc_arg)); + return NULL; + } g_error ("Unable to resolve pinvoke method '%s' Re-run with MONO_LOG_LEVEL=debug for more information.\n", mono_method_full_name (patch_info->data.method, TRUE)); } } else { @@ -1714,6 +1730,17 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code, return (gpointer)target; } +gpointer +mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *patch_info, gboolean run_cctors) +{ + MonoError error; + gpointer res; + + res = mono_resolve_patch_target_checked (method, domain, code, patch_info, run_cctors, &error); + mono_error_raise_exception (&error); /* FIXME don't raise here */ + return res; +} + void mini_init_gsctx (MonoDomain *domain, MonoMemPool *mp, MonoGenericContext *context, MonoGenericSharingContext *gsctx) { @@ -3948,6 +3975,11 @@ register_icalls (void) register_icall (mono_get_assembly_object, "mono_get_assembly_object", "object ptr", TRUE); register_icall (mono_get_method_object, "mono_get_method_object", "object ptr", TRUE); + register_icall_with_wrapper (mono_monitor_enter, "mono_monitor_enter", "void obj"); + register_icall_with_wrapper (mono_monitor_enter_v4, "mono_monitor_enter_v4", "void obj ptr"); + register_icall_no_wrapper (mono_monitor_enter_fast, "mono_monitor_enter_fast", "int obj"); + register_icall_no_wrapper (mono_monitor_enter_v4_fast, "mono_monitor_enter_v4_fast", "int obj ptr"); + #ifdef TARGET_IOS register_icall (pthread_getspecific, "pthread_getspecific", "ptr ptr", TRUE); #endif diff --git a/mono/mini/mini-trampolines.c b/mono/mini/mini-trampolines.c index a28fd9168d3..a624f37d37e 100644 --- a/mono/mini/mini-trampolines.c +++ b/mono/mini/mini-trampolines.c @@ -1006,11 +1006,16 @@ mono_aot_plt_trampoline (mgreg_t *regs, guint8 *code, guint8 *aot_module, { guint32 plt_info_offset = mono_aot_get_plt_info_offset (regs, code); gpointer res; + MonoError error; trampoline_calls ++; - res = mono_aot_plt_resolve (aot_module, plt_info_offset, code); + res = mono_aot_plt_resolve (aot_module, plt_info_offset, code, &error); if (!res) { + if (!mono_error_ok (&error)) { + mono_error_set_pending_exception (&error); + return NULL; + } if (mono_loader_get_last_error ()) { MonoError error; diff --git a/mono/mini/mini.h b/mono/mini/mini.h index 81ef032a467..1b1c728f248 100644 --- a/mono/mini/mini.h +++ b/mono/mini/mini.h @@ -2324,6 +2324,7 @@ guint mono_patch_info_hash (gconstpointer data); gint mono_patch_info_equal (gconstpointer ka, gconstpointer kb); MonoJumpInfo *mono_patch_info_list_prepend (MonoJumpInfo *list, int ip, MonoJumpInfoType type, gconstpointer target); gpointer mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *patch_info, gboolean run_cctors) MONO_LLVM_INTERNAL; +gpointer mono_resolve_patch_target_checked (MonoMethod *method, MonoDomain *domain, guint8 *code, MonoJumpInfo *patch_info, gboolean run_cctors, MonoError *error) MONO_LLVM_INTERNAL; gpointer mono_jit_find_compiled_method_with_jit_info (MonoDomain *domain, MonoMethod *method, MonoJitInfo **ji); gpointer mono_jit_find_compiled_method (MonoDomain *domain, MonoMethod *method); gpointer mono_jit_compile_method (MonoMethod *method, MonoError *error); @@ -2438,7 +2439,7 @@ guint32 mono_aot_get_plt_info_offset (mgreg_t *regs, guint8 *code); gboolean mono_aot_get_cached_class_info (MonoClass *klass, MonoCachedClassInfo *res); gboolean mono_aot_get_class_from_name (MonoImage *image, const char *name_space, const char *name, MonoClass **klass); MonoJitInfo* mono_aot_find_jit_info (MonoDomain *domain, MonoImage *image, gpointer addr); -gpointer mono_aot_plt_resolve (gpointer aot_module, guint32 plt_info_offset, guint8 *code); +gpointer mono_aot_plt_resolve (gpointer aot_module, guint32 plt_info_offset, guint8 *code, MonoError *error); void mono_aot_patch_plt_entry (guint8 *code, guint8 *plt_entry, gpointer *got, mgreg_t *regs, guint8 *addr); gpointer mono_aot_get_method_from_vt_slot (MonoDomain *domain, MonoVTable *vtable, int slot); gpointer mono_aot_create_specific_trampoline (MonoImage *image, gpointer arg1, MonoTrampolineType tramp_type, MonoDomain *domain, guint32 *code_len); diff --git a/mono/profiler/Makefile.am b/mono/profiler/Makefile.am index 1dc7a5e64cd..39cf237bf87 100644 --- a/mono/profiler/Makefile.am +++ b/mono/profiler/Makefile.am @@ -115,6 +115,6 @@ endif suppressiondir = $(datadir)/mono-$(API_VER)/mono/profiler suppression_DATA = mono-profiler-log.suppression -EXTRA_DIST=utils.c utils.h proflog.h perf_event.h \ +EXTRA_DIST=utils.c utils.h proflog.h \ $(PLOG_TESTS_SRC) ptestrunner.pl \ $(suppression_DATA) diff --git a/mono/profiler/perf_event.h b/mono/profiler/perf_event.h deleted file mode 100644 index 3137aea7980..00000000000 --- a/mono/profiler/perf_event.h +++ /dev/null @@ -1,1147 +0,0 @@ -/* - * Performance events: - * - * Copyright (C) 2008-2009, Thomas Gleixner - * Copyright (C) 2008-2009, Red Hat, Inc., Ingo Molnar - * Copyright (C) 2008-2009, Red Hat, Inc., Peter Zijlstra - * - * Data type definitions, declarations, prototypes. - * - * Started by: Thomas Gleixner and Ingo Molnar - * - * For licencing details see kernel-base/COPYING - */ -#ifndef _LINUX_PERF_EVENT_H -#define _LINUX_PERF_EVENT_H - -#include -#include -#include - -#include "mono/utils/mono-compiler.h" - -/* - * User-space ABI bits: - */ - -/* - * attr.type - */ -enum perf_type_id { - PERF_TYPE_HARDWARE = 0, - PERF_TYPE_SOFTWARE = 1, - PERF_TYPE_TRACEPOINT = 2, - PERF_TYPE_HW_CACHE = 3, - PERF_TYPE_RAW = 4, - PERF_TYPE_BREAKPOINT = 5, - - PERF_TYPE_MAX, /* non-ABI */ -}; - -/* - * Generalized performance event event_id types, used by the - * attr.event_id parameter of the sys_perf_event_open() - * syscall: - */ -enum perf_hw_id { - /* - * Common hardware events, generalized by the kernel: - */ - PERF_COUNT_HW_CPU_CYCLES = 0, - PERF_COUNT_HW_INSTRUCTIONS = 1, - PERF_COUNT_HW_CACHE_REFERENCES = 2, - PERF_COUNT_HW_CACHE_MISSES = 3, - PERF_COUNT_HW_BRANCH_INSTRUCTIONS = 4, - PERF_COUNT_HW_BRANCH_MISSES = 5, - PERF_COUNT_HW_BUS_CYCLES = 6, - - PERF_COUNT_HW_MAX, /* non-ABI */ -}; - -/* - * Generalized hardware cache events: - * - * { L1-D, L1-I, LLC, ITLB, DTLB, BPU } x - * { read, write, prefetch } x - * { accesses, misses } - */ -enum perf_hw_cache_id { - PERF_COUNT_HW_CACHE_L1D = 0, - PERF_COUNT_HW_CACHE_L1I = 1, - PERF_COUNT_HW_CACHE_LL = 2, - PERF_COUNT_HW_CACHE_DTLB = 3, - PERF_COUNT_HW_CACHE_ITLB = 4, - PERF_COUNT_HW_CACHE_BPU = 5, - - PERF_COUNT_HW_CACHE_MAX, /* non-ABI */ -}; - -enum perf_hw_cache_op_id { - PERF_COUNT_HW_CACHE_OP_READ = 0, - PERF_COUNT_HW_CACHE_OP_WRITE = 1, - PERF_COUNT_HW_CACHE_OP_PREFETCH = 2, - - PERF_COUNT_HW_CACHE_OP_MAX, /* non-ABI */ -}; - -enum perf_hw_cache_op_result_id { - PERF_COUNT_HW_CACHE_RESULT_ACCESS = 0, - PERF_COUNT_HW_CACHE_RESULT_MISS = 1, - - PERF_COUNT_HW_CACHE_RESULT_MAX, /* non-ABI */ -}; - -/* - * Special "software" events provided by the kernel, even if the hardware - * does not support performance events. These events measure various - * physical and sw events of the kernel (and allow the profiling of them as - * well): - */ -enum perf_sw_ids { - PERF_COUNT_SW_CPU_CLOCK = 0, - PERF_COUNT_SW_TASK_CLOCK = 1, - PERF_COUNT_SW_PAGE_FAULTS = 2, - PERF_COUNT_SW_CONTEXT_SWITCHES = 3, - PERF_COUNT_SW_CPU_MIGRATIONS = 4, - PERF_COUNT_SW_PAGE_FAULTS_MIN = 5, - PERF_COUNT_SW_PAGE_FAULTS_MAJ = 6, - PERF_COUNT_SW_ALIGNMENT_FAULTS = 7, - PERF_COUNT_SW_EMULATION_FAULTS = 8, - - PERF_COUNT_SW_MAX, /* non-ABI */ -}; - -/* - * Bits that can be set in attr.sample_type to request information - * in the overflow packets. - */ -enum perf_event_sample_format { - PERF_SAMPLE_IP = 1U << 0, - PERF_SAMPLE_TID = 1U << 1, - PERF_SAMPLE_TIME = 1U << 2, - PERF_SAMPLE_ADDR = 1U << 3, - PERF_SAMPLE_READ = 1U << 4, - PERF_SAMPLE_CALLCHAIN = 1U << 5, - PERF_SAMPLE_ID = 1U << 6, - PERF_SAMPLE_CPU = 1U << 7, - PERF_SAMPLE_PERIOD = 1U << 8, - PERF_SAMPLE_STREAM_ID = 1U << 9, - PERF_SAMPLE_RAW = 1U << 10, - - PERF_SAMPLE_MAX = 1U << 11, /* non-ABI */ -}; - -/* - * The format of the data returned by read() on a perf event fd, - * as specified by attr.read_format: - * - * struct read_format { - * { u64 value; - * { u64 time_enabled; } && PERF_FORMAT_ENABLED - * { u64 time_running; } && PERF_FORMAT_RUNNING - * { u64 id; } && PERF_FORMAT_ID - * } && !PERF_FORMAT_GROUP - * - * { u64 nr; - * { u64 time_enabled; } && PERF_FORMAT_ENABLED - * { u64 time_running; } && PERF_FORMAT_RUNNING - * { u64 value; - * { u64 id; } && PERF_FORMAT_ID - * } cntr[nr]; - * } && PERF_FORMAT_GROUP - * }; - */ -enum perf_event_read_format { - PERF_FORMAT_TOTAL_TIME_ENABLED = 1U << 0, - PERF_FORMAT_TOTAL_TIME_RUNNING = 1U << 1, - PERF_FORMAT_ID = 1U << 2, - PERF_FORMAT_GROUP = 1U << 3, - - PERF_FORMAT_MAX = 1U << 4, /* non-ABI */ -}; - -#define PERF_ATTR_SIZE_VER0 64 /* sizeof first published struct */ - -/* - * Hardware event_id to monitor via a performance monitoring event: - */ -struct perf_event_attr { - - /* - * Major type: hardware/software/tracepoint/etc. - */ - __u32 type; - - /* - * Size of the attr structure, for fwd/bwd compat. - */ - __u32 size; - - /* - * Type specific configuration information. - */ - __u64 config; - - union { - __u64 sample_period; - __u64 sample_freq; - }; - - __u64 sample_type; - __u64 read_format; - - __u64 disabled : 1, /* off by default */ - inherit : 1, /* children inherit it */ - pinned : 1, /* must always be on PMU */ - exclusive : 1, /* only group on PMU */ - exclude_user : 1, /* don't count user */ - exclude_kernel : 1, /* ditto kernel */ - exclude_hv : 1, /* ditto hypervisor */ - exclude_idle : 1, /* don't count when idle */ - mmap : 1, /* include mmap data */ - comm : 1, /* include comm data */ - freq : 1, /* use freq, not period */ - inherit_stat : 1, /* per task counts */ - enable_on_exec : 1, /* next exec enables */ - task : 1, /* trace fork/exit */ - watermark : 1, /* wakeup_watermark */ - /* - * precise_ip: - * - * 0 - SAMPLE_IP can have arbitrary skid - * 1 - SAMPLE_IP must have constant skid - * 2 - SAMPLE_IP requested to have 0 skid - * 3 - SAMPLE_IP must have 0 skid - * - * See also PERF_RECORD_MISC_EXACT_IP - */ - precise_ip : 2, /* skid constraint */ - mmap_data : 1, /* non-exec mmap data */ - - __reserved_1 : 46; - - union { - __u32 wakeup_events; /* wakeup every n events */ - __u32 wakeup_watermark; /* bytes before wakeup */ - }; - - __u32 bp_type; - __u64 bp_addr; - __u64 bp_len; -}; - -/* - * Ioctls that can be done on a perf event fd: - */ -#define PERF_EVENT_IOC_ENABLE _IO ('$', 0) -#define PERF_EVENT_IOC_DISABLE _IO ('$', 1) -#define PERF_EVENT_IOC_REFRESH _IO ('$', 2) -#define PERF_EVENT_IOC_RESET _IO ('$', 3) -#define PERF_EVENT_IOC_PERIOD _IOW('$', 4, __u64) -#define PERF_EVENT_IOC_SET_OUTPUT _IO ('$', 5) -#define PERF_EVENT_IOC_SET_FILTER _IOW('$', 6, char *) - -enum perf_event_ioc_flags { - PERF_IOC_FLAG_GROUP = 1U << 0, -}; - -/* - * Structure of the page that can be mapped via mmap - */ -struct perf_event_mmap_page { - __u32 version; /* version number of this structure */ - __u32 compat_version; /* lowest version this is compat with */ - - /* - * Bits needed to read the hw events in user-space. - * - * u32 seq; - * s64 count; - * - * do { - * seq = pc->lock; - * - * barrier() - * if (pc->index) { - * count = pmc_read(pc->index - 1); - * count += pc->offset; - * } else - * goto regular_read; - * - * barrier(); - * } while (pc->lock != seq); - * - * NOTE: for obvious reason this only works on self-monitoring - * processes. - */ - __u32 lock; /* seqlock for synchronization */ - __u32 index; /* hardware event identifier */ - __s64 offset; /* add to hardware event value */ - __u64 time_enabled; /* time event active */ - __u64 time_running; /* time event on cpu */ - - /* - * Hole for extension of the self monitor capabilities - */ - - __u64 __reserved[123]; /* align to 1k */ - - /* - * Control data for the mmap() data buffer. - * - * User-space reading the @data_head value should issue an rmb(), on - * SMP capable platforms, after reading this value -- see - * perf_event_wakeup(). - * - * When the mapping is PROT_WRITE the @data_tail value should be - * written by userspace to reflect the last read data. In this case - * the kernel will not over-write unread data. - */ - __u64 data_head; /* head in the data section */ - __u64 data_tail; /* user-space written tail */ -}; - -#define PERF_RECORD_MISC_CPUMODE_MASK (7 << 0) -#define PERF_RECORD_MISC_CPUMODE_UNKNOWN (0 << 0) -#define PERF_RECORD_MISC_KERNEL (1 << 0) -#define PERF_RECORD_MISC_USER (2 << 0) -#define PERF_RECORD_MISC_HYPERVISOR (3 << 0) -#define PERF_RECORD_MISC_GUEST_KERNEL (4 << 0) -#define PERF_RECORD_MISC_GUEST_USER (5 << 0) - -/* - * Indicates that the content of PERF_SAMPLE_IP points to - * the actual instruction that triggered the event. See also - * perf_event_attr::precise_ip. - */ -#define PERF_RECORD_MISC_EXACT_IP (1 << 14) -/* - * Reserve the last bit to indicate some extended misc field - */ -#define PERF_RECORD_MISC_EXT_RESERVED (1 << 15) - -struct perf_event_header { - __u32 type; - __u16 misc; - __u16 size; -}; - -enum perf_event_type { - - /* - * The MMAP events record the PROT_EXEC mappings so that we can - * correlate userspace IPs to code. They have the following structure: - * - * struct { - * struct perf_event_header header; - * - * u32 pid, tid; - * u64 addr; - * u64 len; - * u64 pgoff; - * char filename[]; - * }; - */ - PERF_RECORD_MMAP = 1, - - /* - * struct { - * struct perf_event_header header; - * u64 id; - * u64 lost; - * }; - */ - PERF_RECORD_LOST = 2, - - /* - * struct { - * struct perf_event_header header; - * - * u32 pid, tid; - * char comm[]; - * }; - */ - PERF_RECORD_COMM = 3, - - /* - * struct { - * struct perf_event_header header; - * u32 pid, ppid; - * u32 tid, ptid; - * u64 time; - * }; - */ - PERF_RECORD_EXIT = 4, - - /* - * struct { - * struct perf_event_header header; - * u64 time; - * u64 id; - * u64 stream_id; - * }; - */ - PERF_RECORD_THROTTLE = 5, - PERF_RECORD_UNTHROTTLE = 6, - - /* - * struct { - * struct perf_event_header header; - * u32 pid, ppid; - * u32 tid, ptid; - * u64 time; - * }; - */ - PERF_RECORD_FORK = 7, - - /* - * struct { - * struct perf_event_header header; - * u32 pid, tid; - * - * struct read_format values; - * }; - */ - PERF_RECORD_READ = 8, - - /* - * struct { - * struct perf_event_header header; - * - * { u64 ip; } && PERF_SAMPLE_IP - * { u32 pid, tid; } && PERF_SAMPLE_TID - * { u64 time; } && PERF_SAMPLE_TIME - * { u64 addr; } && PERF_SAMPLE_ADDR - * { u64 id; } && PERF_SAMPLE_ID - * { u64 stream_id;} && PERF_SAMPLE_STREAM_ID - * { u32 cpu, res; } && PERF_SAMPLE_CPU - * { u64 period; } && PERF_SAMPLE_PERIOD - * - * { struct read_format values; } && PERF_SAMPLE_READ - * - * { u64 nr, - * u64 ips[nr]; } && PERF_SAMPLE_CALLCHAIN - * - * # - * # The RAW record below is opaque data wrt the ABI - * # - * # That is, the ABI doesn't make any promises wrt to - * # the stability of its content, it may vary depending - * # on event, hardware, kernel version and phase of - * # the moon. - * # - * # In other words, PERF_SAMPLE_RAW contents are not an ABI. - * # - * - * { u32 size; - * char data[size];}&& PERF_SAMPLE_RAW - * }; - */ - PERF_RECORD_SAMPLE = 9, - - PERF_RECORD_MAX, /* non-ABI */ -}; - -enum perf_callchain_context { - PERF_CONTEXT_HV = (__u64)-32, - PERF_CONTEXT_KERNEL = (__u64)-128, - PERF_CONTEXT_USER = (__u64)-512, - - PERF_CONTEXT_GUEST = (__u64)-2048, - PERF_CONTEXT_GUEST_KERNEL = (__u64)-2176, - PERF_CONTEXT_GUEST_USER = (__u64)-2560, - - PERF_CONTEXT_MAX = (__u64)-4095, -}; - -#define PERF_FLAG_FD_NO_GROUP (1U << 0) -#define PERF_FLAG_FD_OUTPUT (1U << 1) - -#ifdef __KERNEL__ -/* - * Kernel-internal data types and definitions: - */ - -#ifdef CONFIG_PERF_EVENTS -# include -# include -#endif - -struct perf_guest_info_callbacks { - int (*is_in_guest) (void); - int (*is_user_mode) (void); - unsigned long (*get_guest_ip) (void); -}; - -#ifdef CONFIG_HAVE_HW_BREAKPOINT -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define PERF_MAX_STACK_DEPTH 255 - -struct perf_callchain_entry { - __u64 nr; - __u64 ip[PERF_MAX_STACK_DEPTH]; -}; - -struct perf_raw_record { - u32 size; - void *data; -}; - -struct perf_branch_entry { - __u64 from; - __u64 to; - __u64 flags; -}; - -struct perf_branch_stack { - __u64 nr; - struct perf_branch_entry entries[0]; -}; - -struct task_struct; - -/** - * struct hw_perf_event - performance event hardware details: - */ -struct hw_perf_event { -#ifdef CONFIG_PERF_EVENTS - union { - struct { /* hardware */ - u64 config; - u64 last_tag; - unsigned long config_base; - unsigned long event_base; - int idx; - int last_cpu; - }; - struct { /* software */ - struct hrtimer hrtimer; - }; -#ifdef CONFIG_HAVE_HW_BREAKPOINT - struct { /* breakpoint */ - struct arch_hw_breakpoint info; - struct list_head bp_list; - /* - * Crufty hack to avoid the chicken and egg - * problem hw_breakpoint has with context - * creation and event initalization. - */ - struct task_struct *bp_target; - }; -#endif - }; - int state; - local64_t prev_count; - u64 sample_period; - u64 last_period; - local64_t period_left; - u64 interrupts; - - u64 freq_time_stamp; - u64 freq_count_stamp; -#endif -}; - -/* - * hw_perf_event::state flags - */ -#define PERF_HES_STOPPED 0x01 /* the counter is stopped */ -#define PERF_HES_UPTODATE 0x02 /* event->count up-to-date */ -#define PERF_HES_ARCH 0x04 - -struct perf_event; - -/* - * Common implementation detail of pmu::{start,commit,cancel}_txn - */ -#define PERF_EVENT_TXN 0x1 - -/** - * struct pmu - generic performance monitoring unit - */ -struct pmu { - struct list_head entry; - - int * __percpu pmu_disable_count; - struct perf_cpu_context * __percpu pmu_cpu_context; - int task_ctx_nr; - - /* - * Fully disable/enable this PMU, can be used to protect from the PMI - * as well as for lazy/batch writing of the MSRs. - */ - void (*pmu_enable) (struct pmu *pmu); /* optional */ - void (*pmu_disable) (struct pmu *pmu); /* optional */ - - /* - * Try and initialize the event for this PMU. - * Should return -ENOENT when the @event doesn't match this PMU. - */ - int (*event_init) (struct perf_event *event); - -#define PERF_EF_START 0x01 /* start the counter when adding */ -#define PERF_EF_RELOAD 0x02 /* reload the counter when starting */ -#define PERF_EF_UPDATE 0x04 /* update the counter when stopping */ - - /* - * Adds/Removes a counter to/from the PMU, can be done inside - * a transaction, see the ->*_txn() methods. - */ - int (*add) (struct perf_event *event, int flags); - void (*del) (struct perf_event *event, int flags); - - /* - * Starts/Stops a counter present on the PMU. The PMI handler - * should stop the counter when perf_event_overflow() returns - * !0. ->start() will be used to continue. - */ - void (*start) (struct perf_event *event, int flags); - void (*stop) (struct perf_event *event, int flags); - - /* - * Updates the counter value of the event. - */ - void (*read) (struct perf_event *event); - - /* - * Group events scheduling is treated as a transaction, add - * group events as a whole and perform one schedulability test. - * If the test fails, roll back the whole group - * - * Start the transaction, after this ->add() doesn't need to - * do schedulability tests. - */ - void (*start_txn) (struct pmu *pmu); /* optional */ - /* - * If ->start_txn() disabled the ->add() schedulability test - * then ->commit_txn() is required to perform one. On success - * the transaction is closed. On error the transaction is kept - * open until ->cancel_txn() is called. - */ - int (*commit_txn) (struct pmu *pmu); /* optional */ - /* - * Will cancel the transaction, assumes ->del() is called - * for each successfull ->add() during the transaction. - */ - void (*cancel_txn) (struct pmu *pmu); /* optional */ -}; - -/** - * enum perf_event_active_state - the states of a event - */ -enum perf_event_active_state { - PERF_EVENT_STATE_ERROR = -2, - PERF_EVENT_STATE_OFF = -1, - PERF_EVENT_STATE_INACTIVE = 0, - PERF_EVENT_STATE_ACTIVE = 1, -}; - -struct file; - -#define PERF_BUFFER_WRITABLE 0x01 - -struct perf_buffer { - atomic_t refcount; - struct rcu_head rcu_head; -#ifdef CONFIG_PERF_USE_VMALLOC - struct work_struct work; - int page_order; /* allocation order */ -#endif - int nr_pages; /* nr of data pages */ - int writable; /* are we writable */ - - atomic_t poll; /* POLL_ for wakeups */ - - local_t head; /* write position */ - local_t nest; /* nested writers */ - local_t events; /* event limit */ - local_t wakeup; /* wakeup stamp */ - local_t lost; /* nr records lost */ - - long watermark; /* wakeup watermark */ - - struct perf_event_mmap_page *user_page; - void *data_pages[0]; -}; - -struct perf_sample_data; - -typedef void (*perf_overflow_handler_t)(struct perf_event *, int, - struct perf_sample_data *, - struct pt_regs *regs); - -enum perf_group_flag { - PERF_GROUP_SOFTWARE = 0x1, -}; - -#define SWEVENT_HLIST_BITS 8 -#define SWEVENT_HLIST_SIZE (1 << SWEVENT_HLIST_BITS) - -struct swevent_hlist { - struct hlist_head heads[SWEVENT_HLIST_SIZE]; - struct rcu_head rcu_head; -}; - -#define PERF_ATTACH_CONTEXT 0x01 -#define PERF_ATTACH_GROUP 0x02 -#define PERF_ATTACH_TASK 0x04 - -/** - * struct perf_event - performance event kernel representation: - */ -struct perf_event { -#ifdef CONFIG_PERF_EVENTS - struct list_head group_entry; - struct list_head event_entry; - struct list_head sibling_list; - struct hlist_node hlist_entry; - int nr_siblings; - int group_flags; - struct perf_event *group_leader; - struct pmu *pmu; - - enum perf_event_active_state state; - unsigned int attach_state; - local64_t count; - atomic64_t child_count; - - /* - * These are the total time in nanoseconds that the event - * has been enabled (i.e. eligible to run, and the task has - * been scheduled in, if this is a per-task event) - * and running (scheduled onto the CPU), respectively. - * - * They are computed from tstamp_enabled, tstamp_running and - * tstamp_stopped when the event is in INACTIVE or ACTIVE state. - */ - u64 total_time_enabled; - u64 total_time_running; - - /* - * These are timestamps used for computing total_time_enabled - * and total_time_running when the event is in INACTIVE or - * ACTIVE state, measured in nanoseconds from an arbitrary point - * in time. - * tstamp_enabled: the notional time when the event was enabled - * tstamp_running: the notional time when the event was scheduled on - * tstamp_stopped: in INACTIVE state, the notional time when the - * event was scheduled off. - */ - u64 tstamp_enabled; - u64 tstamp_running; - u64 tstamp_stopped; - - struct perf_event_attr attr; - struct hw_perf_event hw; - - struct perf_event_context *ctx; - struct file *filp; - - /* - * These accumulate total time (in nanoseconds) that children - * events have been enabled and running, respectively. - */ - atomic64_t child_total_time_enabled; - atomic64_t child_total_time_running; - - /* - * Protect attach/detach and child_list: - */ - struct mutex child_mutex; - struct list_head child_list; - struct perf_event *parent; - - int oncpu; - int cpu; - - struct list_head owner_entry; - struct task_struct *owner; - - /* mmap bits */ - struct mutex mmap_mutex; - atomic_t mmap_count; - int mmap_locked; - struct user_struct *mmap_user; - struct perf_buffer *buffer; - - /* poll related */ - wait_queue_head_t waitq; - struct fasync_struct *fasync; - - /* delayed work for NMIs and such */ - int pending_wakeup; - int pending_kill; - int pending_disable; - struct irq_work pending; - - atomic_t event_limit; - - void (*destroy)(struct perf_event *); - struct rcu_head rcu_head; - - struct pid_namespace *ns; - u64 id; - - perf_overflow_handler_t overflow_handler; - -#ifdef CONFIG_EVENT_TRACING - struct ftrace_event_call *tp_event; - struct event_filter *filter; -#endif - -#endif /* CONFIG_PERF_EVENTS */ -}; - -enum perf_event_context_type { - task_context, - cpu_context, -}; - -/** - * struct perf_event_context - event context structure - * - * Used as a container for task events and CPU events as well: - */ -struct perf_event_context { - enum perf_event_context_type type; - struct pmu *pmu; - /* - * Protect the states of the events in the list, - * nr_active, and the list: - */ - raw_spinlock_t lock; - /* - * Protect the list of events. Locking either mutex or lock - * is sufficient to ensure the list doesn't change; to change - * the list you need to lock both the mutex and the spinlock. - */ - struct mutex mutex; - - struct list_head pinned_groups; - struct list_head flexible_groups; - struct list_head event_list; - int nr_events; - int nr_active; - int is_active; - int nr_stat; - atomic_t refcount; - struct task_struct *task; - - /* - * Context clock, runs when context enabled. - */ - u64 time; - u64 timestamp; - - /* - * These fields let us detect when two contexts have both - * been cloned (inherited) from a common ancestor. - */ - struct perf_event_context *parent_ctx; - u64 parent_gen; - u64 generation; - int pin_count; - struct rcu_head rcu_head; -}; - -/* - * Number of contexts where an event can trigger: - * task, softirq, hardirq, nmi. - */ -#define PERF_NR_CONTEXTS 4 - -/** - * struct perf_event_cpu_context - per cpu event context structure - */ -struct perf_cpu_context { - struct perf_event_context ctx; - struct perf_event_context *task_ctx; - int active_oncpu; - int exclusive; - struct list_head rotation_list; - int jiffies_interval; -}; - -struct perf_output_handle { - struct perf_event *event; - struct perf_buffer *buffer; - unsigned long wakeup; - unsigned long size; - void *addr; - int page; - int nmi; - int sample; -}; - -#ifdef CONFIG_PERF_EVENTS - -extern int perf_pmu_register(struct pmu *pmu); -extern void perf_pmu_unregister(struct pmu *pmu); - -extern int perf_num_counters(void); -extern const char *perf_pmu_name(void); -extern void __perf_event_task_sched_in(struct task_struct *task); -extern void __perf_event_task_sched_out(struct task_struct *task, struct task_struct *next); - -extern atomic_t perf_task_events; - -static inline void perf_event_task_sched_in(struct task_struct *task) -{ - COND_STMT(&perf_task_events, __perf_event_task_sched_in(task)); -} - -static inline -void perf_event_task_sched_out(struct task_struct *task, struct task_struct *next) -{ - COND_STMT(&perf_task_events, __perf_event_task_sched_out(task, next)); -} - -extern int perf_event_init_task(struct task_struct *child); -extern void perf_event_exit_task(struct task_struct *child); -extern void perf_event_free_task(struct task_struct *task); -extern void perf_event_delayed_put(struct task_struct *task); -extern void perf_event_print_debug(void); -extern void perf_pmu_disable(struct pmu *pmu); -extern void perf_pmu_enable(struct pmu *pmu); -extern int perf_event_task_disable(void); -extern int perf_event_task_enable(void); -extern void perf_event_update_userpage(struct perf_event *event); -extern int perf_event_release_kernel(struct perf_event *event); -extern struct perf_event * -perf_event_create_kernel_counter(struct perf_event_attr *attr, - int cpu, - struct task_struct *task, - perf_overflow_handler_t callback); -extern u64 perf_event_read_value(struct perf_event *event, - u64 *enabled, u64 *running); - -struct perf_sample_data { - u64 type; - - u64 ip; - struct { - u32 pid; - u32 tid; - } tid_entry; - u64 time; - u64 addr; - u64 id; - u64 stream_id; - struct { - u32 cpu; - u32 reserved; - } cpu_entry; - u64 period; - struct perf_callchain_entry *callchain; - struct perf_raw_record *raw; -}; - -static inline -void perf_sample_data_init(struct perf_sample_data *data, u64 addr) -{ - data->addr = addr; - data->raw = NULL; -} - -extern void perf_output_sample(struct perf_output_handle *handle, - struct perf_event_header *header, - struct perf_sample_data *data, - struct perf_event *event); -extern void perf_prepare_sample(struct perf_event_header *header, - struct perf_sample_data *data, - struct perf_event *event, - struct pt_regs *regs); - -extern int perf_event_overflow(struct perf_event *event, int nmi, - struct perf_sample_data *data, - struct pt_regs *regs); - -/* - * Return 1 for a software event, 0 for a hardware event - */ -static inline int is_software_event(struct perf_event *event) -{ - return event->pmu->task_ctx_nr == perf_sw_context; -} - -extern atomic_t perf_swevent_enabled[PERF_COUNT_SW_MAX]; - -extern void __perf_sw_event(u32, u64, int, struct pt_regs *, u64); - -#ifndef perf_arch_fetch_caller_regs -static inline void -perf_arch_fetch_caller_regs(struct pt_regs *regs, unsigned long ip) { } -#endif - -/* - * Take a snapshot of the regs. Skip ip and frame pointer to - * the nth caller. We only need a few of the regs: - * - ip for PERF_SAMPLE_IP - * - cs for user_mode() tests - * - bp for callchains - * - eflags, for future purposes, just in case - */ -static inline void perf_fetch_caller_regs(struct pt_regs *regs) -{ - memset(regs, 0, sizeof(*regs)); - - perf_arch_fetch_caller_regs(regs, CALLER_ADDR0); -} - -static MONO_ALWAYS_INLINE void -perf_sw_event(u32 event_id, u64 nr, int nmi, struct pt_regs *regs, u64 addr) -{ - struct pt_regs hot_regs; - - JUMP_LABEL(&perf_swevent_enabled[event_id], have_event); - return; - -have_event: - if (!regs) { - perf_fetch_caller_regs(&hot_regs); - regs = &hot_regs; - } - __perf_sw_event(event_id, nr, nmi, regs, addr); -} - -extern void perf_event_mmap(struct vm_area_struct *vma); -extern struct perf_guest_info_callbacks *perf_guest_cbs; -extern int perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks); -extern int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks); - -extern void perf_event_comm(struct task_struct *tsk); -extern void perf_event_fork(struct task_struct *tsk); - -/* Callchains */ -DECLARE_PER_CPU(struct perf_callchain_entry, perf_callchain_entry); - -extern void perf_callchain_user(struct perf_callchain_entry *entry, - struct pt_regs *regs); -extern void perf_callchain_kernel(struct perf_callchain_entry *entry, - struct pt_regs *regs); - - -static inline void -perf_callchain_store(struct perf_callchain_entry *entry, u64 ip) -{ - if (entry->nr < PERF_MAX_STACK_DEPTH) - entry->ip[entry->nr++] = ip; -} - -extern int sysctl_perf_event_paranoid; -extern int sysctl_perf_event_mlock; -extern int sysctl_perf_event_sample_rate; - -static inline bool perf_paranoid_tracepoint_raw(void) -{ - return sysctl_perf_event_paranoid > -1; -} - -static inline bool perf_paranoid_cpu(void) -{ - return sysctl_perf_event_paranoid > 0; -} - -static inline bool perf_paranoid_kernel(void) -{ - return sysctl_perf_event_paranoid > 1; -} - -extern void perf_event_init(void); -extern void perf_tp_event(u64 addr, u64 count, void *record, - int entry_size, struct pt_regs *regs, - struct hlist_head *head, int rctx); -extern void perf_bp_event(struct perf_event *event, void *data); - -#ifndef perf_misc_flags -#define perf_misc_flags(regs) (user_mode(regs) ? PERF_RECORD_MISC_USER : \ - PERF_RECORD_MISC_KERNEL) -#define perf_instruction_pointer(regs) instruction_pointer(regs) -#endif - -extern int perf_output_begin(struct perf_output_handle *handle, - struct perf_event *event, unsigned int size, - int nmi, int sample); -extern void perf_output_end(struct perf_output_handle *handle); -extern void perf_output_copy(struct perf_output_handle *handle, - const void *buf, unsigned int len); -extern int perf_swevent_get_recursion_context(void); -extern void perf_swevent_put_recursion_context(int rctx); -extern void perf_event_enable(struct perf_event *event); -extern void perf_event_disable(struct perf_event *event); -extern void perf_event_task_tick(void); -#else -static inline void -perf_event_task_sched_in(struct task_struct *task) { } -static inline void -perf_event_task_sched_out(struct task_struct *task, - struct task_struct *next) { } -static inline int perf_event_init_task(struct task_struct *child) { return 0; } -static inline void perf_event_exit_task(struct task_struct *child) { } -static inline void perf_event_free_task(struct task_struct *task) { } -static inline void perf_event_delayed_put(struct task_struct *task) { } -static inline void perf_event_print_debug(void) { } -static inline int perf_event_task_disable(void) { return -EINVAL; } -static inline int perf_event_task_enable(void) { return -EINVAL; } - -static inline void -perf_sw_event(u32 event_id, u64 nr, int nmi, - struct pt_regs *regs, u64 addr) { } -static inline void -perf_bp_event(struct perf_event *event, void *data) { } - -static inline int perf_register_guest_info_callbacks -(struct perf_guest_info_callbacks *callbacks) { return 0; } -static inline int perf_unregister_guest_info_callbacks -(struct perf_guest_info_callbacks *callbacks) { return 0; } - -static inline void perf_event_mmap(struct vm_area_struct *vma) { } -static inline void perf_event_comm(struct task_struct *tsk) { } -static inline void perf_event_fork(struct task_struct *tsk) { } -static inline void perf_event_init(void) { } -static inline int perf_swevent_get_recursion_context(void) { return -1; } -static inline void perf_swevent_put_recursion_context(int rctx) { } -static inline void perf_event_enable(struct perf_event *event) { } -static inline void perf_event_disable(struct perf_event *event) { } -static inline void perf_event_task_tick(void) { } -#endif - -#define perf_output_put(handle, x) \ - perf_output_copy((handle), &(x), sizeof(x)) - -/* - * This has to have a higher priority than migration_notifier in sched.c. - */ -#define perf_cpu_notifier(fn) \ -do { \ - static struct notifier_block fn##_nb __cpuinitdata = \ - { .notifier_call = fn, .priority = CPU_PRI_PERF }; \ - fn(&fn##_nb, (unsigned long)CPU_UP_PREPARE, \ - (void *)(unsigned long)smp_processor_id()); \ - fn(&fn##_nb, (unsigned long)CPU_STARTING, \ - (void *)(unsigned long)smp_processor_id()); \ - fn(&fn##_nb, (unsigned long)CPU_ONLINE, \ - (void *)(unsigned long)smp_processor_id()); \ - register_cpu_notifier(&fn##_nb); \ -} while (0) - -#endif /* __KERNEL__ */ -#endif /* _LINUX_PERF_EVENT_H */ diff --git a/mono/profiler/proflog.c b/mono/profiler/proflog.c index 9120ae06916..9f24cae696d 100644 --- a/mono/profiler/proflog.c +++ b/mono/profiler/proflog.c @@ -80,9 +80,10 @@ #include #include -#include "perf_event.h" #ifdef ENABLE_PERF_EVENTS +#include + #define USE_PERF_EVENTS 1 static int read_perf_mmap (MonoProfiler* prof, int cpu); diff --git a/mono/sgen/sgen-alloc.c b/mono/sgen/sgen-alloc.c index 349eff54014..2c69c7d932f 100644 --- a/mono/sgen/sgen-alloc.c +++ b/mono/sgen/sgen-alloc.c @@ -101,7 +101,7 @@ alloc_degraded (GCVTable vtable, size_t size, gboolean for_mature) if (!for_mature) { sgen_client_degraded_allocation (size); SGEN_ATOMIC_ADD_P (degraded_mode, size); - sgen_ensure_free_space (size); + sgen_ensure_free_space (size, GENERATION_OLD); } else { if (sgen_need_major_collection (size)) sgen_perform_collection (size, GENERATION_OLD, "mature allocation failure", !for_mature); @@ -271,7 +271,7 @@ sgen_alloc_obj_nolock (GCVTable vtable, size_t size) * always loop we will loop endlessly in the case of * OOM). */ - sgen_ensure_free_space (real_size); + sgen_ensure_free_space (real_size, GENERATION_NURSERY); if (!degraded_mode) p = (void **)sgen_nursery_alloc (size); } @@ -288,7 +288,7 @@ sgen_alloc_obj_nolock (GCVTable vtable, size_t size) p = (void **)sgen_nursery_alloc_range (tlab_size, size, &alloc_size); if (!p) { /* See comment above in similar case. */ - sgen_ensure_free_space (tlab_size); + sgen_ensure_free_space (tlab_size, GENERATION_NURSERY); if (!degraded_mode) p = (void **)sgen_nursery_alloc_range (tlab_size, size, &alloc_size); } diff --git a/mono/sgen/sgen-conf.h b/mono/sgen/sgen-conf.h index 5a0e871e22f..11a8998478e 100644 --- a/mono/sgen/sgen-conf.h +++ b/mono/sgen/sgen-conf.h @@ -190,12 +190,6 @@ typedef mword SgenDescriptor; */ #define SGEN_DEFAULT_ALLOWANCE_HEAP_SIZE_RATIO 0.33 -/* - * How much more we allow the heap to grow, relative to the allowance, while doing - * a concurrent collection, before forcing its finish. - */ -#define SGEN_DEFAULT_CONCURRENT_HEAP_ALLOWANCE_RATIO 0.25 - /* * Default ratio of memory we want to release in a major collection in relation to the the current heap size. * diff --git a/mono/sgen/sgen-gc.c b/mono/sgen/sgen-gc.c index 11be768a007..89af85f4387 100644 --- a/mono/sgen/sgen-gc.c +++ b/mono/sgen/sgen-gc.c @@ -1972,6 +1972,7 @@ major_finish_collection (const char *reason, size_t old_next_pin_slot, gboolean time_major_fragment_creation += TV_ELAPSED (atv, btv); binary_protocol_sweep_begin (GENERATION_OLD, !major_collector.sweeps_lazily); + sgen_memgov_major_pre_sweep (); TV_GETTIME (atv); time_major_free_bigobjs += TV_ELAPSED (btv, atv); @@ -2152,12 +2153,12 @@ major_finish_concurrent_collection (gboolean forced) * LOCKING: The GC lock MUST be held. */ void -sgen_ensure_free_space (size_t size) +sgen_ensure_free_space (size_t size, int generation) { int generation_to_collect = -1; const char *reason = NULL; - if (size > SGEN_MAX_SMALL_OBJ_SIZE) { + if (generation == GENERATION_OLD) { if (sgen_need_major_collection (size)) { reason = "LOS overflow"; generation_to_collect = GENERATION_OLD; diff --git a/mono/sgen/sgen-gc.h b/mono/sgen/sgen-gc.h index afd5ba5dce8..4b2f895d890 100644 --- a/mono/sgen/sgen-gc.h +++ b/mono/sgen/sgen-gc.h @@ -802,7 +802,7 @@ enum { void sgen_pin_object (GCObject *object, SgenGrayQueue *queue); void sgen_set_pinned_from_failed_allocation (mword objsize); -void sgen_ensure_free_space (size_t size); +void sgen_ensure_free_space (size_t size, int generation); void sgen_gc_collect (int generation); void sgen_perform_collection (size_t requested_size, int generation_to_collect, const char *reason, gboolean wait_to_finish); diff --git a/mono/sgen/sgen-los.c b/mono/sgen/sgen-los.c index 8cc92e34553..a89ec99fe35 100644 --- a/mono/sgen/sgen-los.c +++ b/mono/sgen/sgen-los.c @@ -380,7 +380,7 @@ sgen_los_alloc_large_inner (GCVTable vtable, size_t size) los_segment_index += size + sizeof (LOSObject); g_assert (los_segment_index <= LOS_SEGMENT_SIZE); #else - sgen_ensure_free_space (size); + sgen_ensure_free_space (size, GENERATION_OLD); #ifdef USE_MALLOC obj = malloc (size + sizeof (LOSObject)); diff --git a/mono/sgen/sgen-marksweep.c b/mono/sgen/sgen-marksweep.c index 929d86031fe..7aaaa0221e1 100644 --- a/mono/sgen/sgen-marksweep.c +++ b/mono/sgen/sgen-marksweep.c @@ -1401,8 +1401,8 @@ bitcount (mword d) int count = 0; #ifdef __GNUC__ - if (sizeof (mword) == sizeof (unsigned long)) - count += __builtin_popcountl (d); + if (sizeof (mword) == 8) + count += __builtin_popcountll (d); else count += __builtin_popcount (d); #else diff --git a/mono/sgen/sgen-memory-governor.c b/mono/sgen/sgen-memory-governor.c index ce34f7f4a67..611ae5c118f 100644 --- a/mono/sgen/sgen-memory-governor.c +++ b/mono/sgen/sgen-memory-governor.c @@ -56,6 +56,9 @@ static gboolean debug_print_allowance = FALSE; /* use this to tune when to do a major/minor collection */ static mword major_collection_trigger_size; +static mword major_pre_sweep_heap_size; +static mword major_start_heap_size; + static mword last_major_num_sections = 0; static mword last_los_memory_usage = 0; @@ -73,6 +76,7 @@ static void sgen_memgov_calculate_minor_collection_allowance (void) { size_t new_major, new_heap_size, allowance_target, allowance; + size_t decrease; if (!need_calculate_minor_collection_allowance) return; @@ -90,6 +94,16 @@ sgen_memgov_calculate_minor_collection_allowance (void) allowance = MAX (allowance_target, MIN_MINOR_COLLECTION_ALLOWANCE); + /* + * For the concurrent collector, we decrease the allowance relative to the memory + * growth during the M&S phase, survival rate of the collection and the allowance + * ratio. + */ + decrease = (major_pre_sweep_heap_size - major_start_heap_size) * ((float)new_heap_size / major_pre_sweep_heap_size) * (SGEN_DEFAULT_ALLOWANCE_HEAP_SIZE_RATIO + 1); + if (decrease > allowance) + decrease = allowance; + allowance -= decrease; + if (new_heap_size + allowance > soft_heap_limit) { if (new_heap_size > soft_heap_limit) allowance = MIN_MINOR_COLLECTION_ALLOWANCE; @@ -129,13 +143,14 @@ sgen_need_major_collection (mword space_needed) if (heap_size <= major_collection_trigger_size) return FALSE; - /* We allow the heap to grow an additional third of the allowance during a concurrent collection */ - if ((heap_size - major_collection_trigger_size) > - (major_collection_trigger_size - * (SGEN_DEFAULT_ALLOWANCE_HEAP_SIZE_RATIO / (SGEN_DEFAULT_ALLOWANCE_HEAP_SIZE_RATIO + 1)) - * SGEN_DEFAULT_CONCURRENT_HEAP_ALLOWANCE_RATIO)) { + /* + * The more the heap grows, the more we need to decrease the allowance above, + * in order to have similar trigger sizes as the synchronous collector. + * If the heap grows so much that we would need to have a negative allowance, + * we force the finishing of the collection, to avoid increased memory usage. + */ + if ((heap_size - major_start_heap_size) > major_start_heap_size * SGEN_DEFAULT_ALLOWANCE_HEAP_SIZE_RATIO) return TRUE; - } return FALSE; } @@ -163,13 +178,25 @@ sgen_memgov_minor_collection_end (void) { } +void +sgen_memgov_major_pre_sweep (void) +{ + if (sgen_concurrent_collection_in_progress ()) { + major_pre_sweep_heap_size = get_heap_size (); + } else { + /* We decrease the allowance only in the concurrent case */ + major_pre_sweep_heap_size = major_start_heap_size; + } +} + void sgen_memgov_major_collection_start (void) { need_calculate_minor_collection_allowance = TRUE; + major_start_heap_size = get_heap_size (); if (debug_print_allowance) { - SGEN_LOG (0, "Starting collection with heap size %ld bytes", (long)get_heap_size ()); + SGEN_LOG (0, "Starting collection with heap size %ld bytes", (long)major_start_heap_size); } } diff --git a/mono/sgen/sgen-memory-governor.h b/mono/sgen/sgen-memory-governor.h index 0115ec6e060..669b59734e9 100644 --- a/mono/sgen/sgen-memory-governor.h +++ b/mono/sgen/sgen-memory-governor.h @@ -33,6 +33,7 @@ gboolean sgen_memgov_try_alloc_space (mword size, int space); void sgen_memgov_minor_collection_start (void); void sgen_memgov_minor_collection_end (void); +void sgen_memgov_major_pre_sweep (void); void sgen_memgov_major_collection_start (void); void sgen_memgov_major_collection_end (gboolean forced); diff --git a/mono/tests/Makefile.am b/mono/tests/Makefile.am index 3689ecf21b5..169a9e24c31 100644 --- a/mono/tests/Makefile.am +++ b/mono/tests/Makefile.am @@ -958,10 +958,13 @@ debug-casts: EXTRA_DIST += sgen-bridge.cs sgen-descriptors.cs sgen-gshared-vtype.cs sgen-bridge-major-fragmentation.cs sgen-domain-unload.cs sgen-weakref-stress.cs sgen-cementing-stress.cs sgen-case-23400.cs finalizer-wait.cs critical-finalizers.cs sgen-domain-unload-2.cs sgen-suspend.cs sgen-new-threads-dont-join-stw.cs sgen-bridge-xref.cs bug-17590.cs sgen-toggleref.cs -#those are actually configurations, eg plain_sgen-descriptors.exe -#DISABLE_SGEN_TESTS = +sgen-tests: + $(MAKE) sgen-regular-tests + $(MAKE) sgen-toggleref-tests + $(MAKE) sgen-bridge-tests + $(MAKE) sgen-bridge2-tests -SGEN_TESTS = \ +SGEN_REGULAR_TESTS = \ finalizer-wait.exe \ critical-finalizers.exe \ sgen-descriptors.exe \ @@ -975,132 +978,123 @@ SGEN_TESTS = \ gc-graystack-stress.exe \ bug-17590.exe -SGEN_CONFIGURATIONS = \ - "|plain" \ - "major=marksweep-conc|ms-conc" \ - "major=marksweep-conc,minor=split|ms-conc-split" \ - "minor=split|ms-split" \ - "minor=split,alloc-ratio=95|ms-split-95" \ - "|plain-clear-at-gc|clear-at-gc" \ - "major=marksweep-conc|ms-conc-clear-at-gc|clear-at-gc" \ - "minor=split|ms-split-clear-at-gc|clear-at-gc" - - -#FIXME We should move to use SGEN_CONFIGURATIONS once sgen supports trailling commas or its argument list. -SGEN_BRIDGE_CONFIGURATIONS = \ - "|plain" \ - ",major=marksweep-conc|ms-conc" \ - "minor=split|ms-split" \ - "bridge-implementation=new|plain-new-bridge" \ - "bridge-implementation=new,major=marksweep-conc|ms-conc-new-bridge" \ - "bridge-implementation=new,minor=split|ms-split-new-bridge" \ - "bridge-implementation=tarjan|plain-tarjan-bridge" \ - "bridge-implementation=tarjan,minor=split|ms-split-tarjan-bridge" - -sgen-regular-tests: $(SGEN_TESTS) - @failed=0; \ - passed=0; \ - failed_tests="";\ - if [ "x$$V" = "x1" ]; then dump_action="dump-output"; else dump_action="no-dump"; fi; \ - for test in $+; do \ - echo "...$$test"; \ - for conf in $(SGEN_CONFIGURATIONS); do \ - name=`echo $$conf | cut -d\| -f 2`; \ - params=`echo $$conf | cut -d\| -f 1`; \ - debug_opt=`echo $$conf | cut -d\| -f 3`; \ - test_name="$${test}|$${name}"; \ - if MONO_GC_PARAMS="$$params" MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="$$debug_opt" $(srcdir)/test-driver '$(with_mono_path) $(JITTEST_PROG_RUN)' $$test_name "$(DISABLED_TESTS_SGEN)" "$${dump_action}" $(RUNTIME_ARGS); \ - then \ - passed=`expr $${passed} + 1`; \ - else \ - if [ $$? = 2 ]; then break; fi; \ - failed=`expr $${failed} + 1`; \ - failed_tests="$${failed_tests} $$test_name"; \ - fi \ - done \ - done; \ - echo "$${passed} test(s) passed. $${failed} test(s) did not pass."; \ - if [ $${failed} != 0 ]; then echo -e "\nFailed tests:\n"; \ - for i in $${failed_tests}; do echo $${i}; done; exit 1; fi - -sgen-bridge-tests1: sgen-bridge.exe sgen-bridge-major-fragmentation.exe - @failed=0; \ - passed=0; \ - failed_tests="";\ - if [ "x$$V" = "x1" ]; then dump_action="dump-output"; else dump_action="no-dump"; fi; \ - for test in $+; do \ - echo "...$$test"; \ - for conf in $(SGEN_BRIDGE_CONFIGURATIONS); do \ - name=`echo $$conf | cut -d\| -f 2`; \ - params=`echo $$conf | cut -d\| -f 1`; \ - test_name="$${test}|$${name}"; \ - if MONO_GC_DEBUG="bridge=Bridge" MONO_GC_PARAMS="$${params}" MONO_ENV_OPTIONS="--gc=sgen" $(srcdir)/test-driver '$(with_mono_path) $(JITTEST_PROG_RUN)' $$test_name "$(DISABLED_TESTS_SGEN)" "$${dump_action}" $(RUNTIME_ARGS); \ - then \ - passed=`expr $${passed} + 1`; \ - else \ - if [ $$? = 2 ]; then break; fi; \ - failed=`expr $${failed} + 1`; \ - failed_tests="$${failed_tests} $$test_name"; \ - fi \ - done \ - done; \ - echo "$${passed} test(s) passed. $${failed} test(s) did not pass."; \ - if [ $${failed} != 0 ]; then echo -e "\nFailed tests:\n"; \ - for i in $${failed_tests}; do echo $${i}; done; exit 1; fi - -sgen-bridge-tests2: sgen-bridge-xref.exe - @failed=0; \ - passed=0; \ - failed_tests="";\ - if [ "x$$V" = "x1" ]; then dump_action="dump-output"; else dump_action="no-dump"; fi; \ - for test in $+; do \ - echo "...$$test"; \ - for conf in $(SGEN_BRIDGE_CONFIGURATIONS); do \ - name=`echo $$conf | cut -d\| -f 2`; \ - params=`echo $$conf | cut -d\| -f 1`; \ - test_name="$${test}|$${name}"; \ - if MONO_GC_DEBUG="bridge=2Bridge" MONO_GC_PARAMS="$${params}" MONO_ENV_OPTIONS="--gc=sgen" $(srcdir)/test-driver '$(with_mono_path) $(JITTEST_PROG_RUN)' $$test_name "$(DISABLED_TESTS_SGEN)" "$${dump_action}" $(RUNTIME_ARGS); \ - then \ - passed=`expr $${passed} + 1`; \ - else \ - if [ $$? = 2 ]; then break; fi; \ - failed=`expr $${failed} + 1`; \ - failed_tests="$${failed_tests} $$test_name"; \ - fi \ - done \ - done; \ - echo "$${passed} test(s) passed. $${failed} test(s) did not pass."; \ - if [ $${failed} != 0 ]; then echo -e "\nFailed tests:\n"; \ - for i in $${failed_tests}; do echo $${i}; done; exit 1; fi - -sgen-toggleref-tests: sgen-toggleref.exe - @failed=0; \ - passed=0; \ - failed_tests="";\ - if [ "x$$V" = "x1" ]; then dump_action="dump-output"; else dump_action="no-dump"; fi; \ - for test in $+; do \ - echo "...$$test"; \ - for conf in $(SGEN_CONFIGURATIONS); do \ - name=`echo $$conf | cut -d\| -f 2`; \ - params=`echo $$conf | cut -d\| -f 1`; \ - test_name="$${test}|$${name}"; \ - if MONO_GC_PARAMS="toggleref-test,$$params" MONO_ENV_OPTIONS="--gc=sgen" $(srcdir)/test-driver '$(with_mono_path) $(JITTEST_PROG_RUN)' $$test_name "$(DISABLED_TESTS_SGEN)" "$${dump_action}" $(RUNTIME_ARGS); \ - then \ - passed=`expr $${passed} + 1`; \ - else \ - if [ $$? = 2 ]; then break; fi; \ - failed=`expr $${failed} + 1`; \ - failed_tests="$${failed_tests} $$test_name"; \ - fi \ - done \ - done; \ - echo "$${passed} test(s) passed. $${failed} test(s) did not pass."; \ - if [ $${failed} != 0 ]; then echo -e "\nFailed tests:\n"; \ - for i in $${failed_tests}; do echo $${i}; done; exit 1; fi - -sgen-bridge-tests: sgen-bridge-tests1 sgen-bridge-tests2 - -sgen-tests: sgen-regular-tests sgen-bridge-tests sgen-toggleref-tests +sgen-regular-tests: $(SGEN_REGULAR_TESTS) + $(MAKE) sgen-regular-tests-plain + $(MAKE) sgen-regular-tests-ms-conc + $(MAKE) sgen-regular-tests-ms-conc-split + $(MAKE) sgen-regular-tests-ms-split + $(MAKE) sgen-regular-tests-ms-split-95 + $(MAKE) sgen-regular-tests-plain-clear-at-gc + $(MAKE) sgen-regular-tests-ms-conc-clear-at-gc + $(MAKE) sgen-regular-tests-ms-split-clear-at-gc + +sgen-regular-tests-plain: $(SGEN_REGULAR_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_REGULAR_TESTS) +sgen-regular-tests-ms-conc: $(SGEN_REGULAR_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="major=marksweep-conc" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_REGULAR_TESTS) +sgen-regular-tests-ms-conc-split: $(SGEN_REGULAR_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="major=marksweep-conc,minor=split" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_REGULAR_TESTS) +sgen-regular-tests-ms-split: $(SGEN_REGULAR_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="minor=split" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_REGULAR_TESTS) +sgen-regular-tests-ms-split-95: $(SGEN_REGULAR_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="minor=split,alloc-ratio=95" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_REGULAR_TESTS) +sgen-regular-tests-plain-clear-at-gc: $(SGEN_REGULAR_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="clear-at-gc" MONO_GC_PARAMS="" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_REGULAR_TESTS) +sgen-regular-tests-ms-conc-clear-at-gc: $(SGEN_REGULAR_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="clear-at-gc" MONO_GC_PARAMS="major=marksweep-conc" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_REGULAR_TESTS) +sgen-regular-tests-ms-split-clear-at-gc: $(SGEN_REGULAR_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="clear-at-gc" MONO_GC_PARAMS="minor=split" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_REGULAR_TESTS) + +SGEN_TOGGLEREF_TESTS= \ + sgen-toggleref.exe + +sgen-toggleref-tests: $(SGEN_TOGGLEREF_TESTS) + $(MAKE) sgen-toggleref-tests-plain + $(MAKE) sgen-toggleref-tests-ms-conc + $(MAKE) sgen-toggleref-tests-ms-conc-split + $(MAKE) sgen-toggleref-tests-ms-split + $(MAKE) sgen-toggleref-tests-ms-split-95 + $(MAKE) sgen-toggleref-tests-plain-clear-at-gc + $(MAKE) sgen-toggleref-tests-ms-conc-clear-at-gc + $(MAKE) sgen-toggleref-tests-ms-split-clear-at-gc + +sgen-toggleref-tests-plain: $(SGEN_TOGGLEREF_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="toggleref-test" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_TOGGLEREF_TESTS) +sgen-toggleref-tests-ms-conc: $(SGEN_TOGGLEREF_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="toggleref-test,major=marksweep-conc" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_TOGGLEREF_TESTS) +sgen-toggleref-tests-ms-conc-split: $(SGEN_TOGGLEREF_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="toggleref-test,major=marksweep-conc,minor=split" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_TOGGLEREF_TESTS) +sgen-toggleref-tests-ms-split: $(SGEN_TOGGLEREF_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="toggleref-test,minor=split" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_TOGGLEREF_TESTS) +sgen-toggleref-tests-ms-split-95: $(SGEN_TOGGLEREF_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="" MONO_GC_PARAMS="toggleref-test,minor=split,alloc-ratio=95" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_TOGGLEREF_TESTS) +sgen-toggleref-tests-plain-clear-at-gc: $(SGEN_TOGGLEREF_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="clear-at-gc" MONO_GC_PARAMS="toggleref-test" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_TOGGLEREF_TESTS) +sgen-toggleref-tests-ms-conc-clear-at-gc: $(SGEN_TOGGLEREF_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="clear-at-gc" MONO_GC_PARAMS="toggleref-test,major=marksweep-conc" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_TOGGLEREF_TESTS) +sgen-toggleref-tests-ms-split-clear-at-gc: $(SGEN_TOGGLEREF_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="clear-at-gc" MONO_GC_PARAMS="toggleref-test,minor=split" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_TOGGLEREF_TESTS) + +SGEN_BRIDGE_TESTS= \ + sgen-bridge.exe \ + sgen-bridge-major-fragmentation.exe + +sgen-bridge-tests: $(SGEN_BRIDGE_TESTS) + $(MAKE) sgen-bridge-tests-plain + $(MAKE) sgen-bridge-tests-ms-conc + $(MAKE) sgen-bridge-tests-ms-split + $(MAKE) sgen-bridge-tests-plain-new-bridge + $(MAKE) sgen-bridge-tests-ms-conc-new-bridge + $(MAKE) sgen-bridge-tests-ms-split-new-bridge + $(MAKE) sgen-bridge-tests-plain-tarjan-bridge + $(MAKE) sgen-bridge-tests-ms-split-tarjan-bridge + +sgen-bridge-tests-plain: $(SGEN_BRIDGE_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=Bridge" MONO_GC_PARAMS="" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE_TESTS) +sgen-bridge-tests-ms-conc: $(SGEN_BRIDGE_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=Bridge" MONO_GC_PARAMS="major=marksweep-conc" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE_TESTS) +sgen-bridge-tests-ms-split: $(SGEN_BRIDGE_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=Bridge" MONO_GC_PARAMS="minor=split" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE_TESTS) +sgen-bridge-tests-plain-new-bridge: $(SGEN_BRIDGE_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=Bridge" MONO_GC_PARAMS="bridge-implementation=new" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE_TESTS) +sgen-bridge-tests-ms-conc-new-bridge: $(SGEN_BRIDGE_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=Bridge" MONO_GC_PARAMS="bridge-implementation=new,major=marksweep-conc" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE_TESTS) +sgen-bridge-tests-ms-split-new-bridge: $(SGEN_BRIDGE_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=Bridge" MONO_GC_PARAMS="bridge-implementation=new,minor=split" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE_TESTS) +sgen-bridge-tests-plain-tarjan-bridge: $(SGEN_BRIDGE_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=Bridge" MONO_GC_PARAMS="bridge-implementation=tarjan" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE_TESTS) +sgen-bridge-tests-ms-split-tarjan-bridge: $(SGEN_BRIDGE_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=Bridge" MONO_GC_PARAMS="bridge-implementation=tarjan,minor=split" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE_TESTS) + +SGEN_BRIDGE2_TESTS= \ + sgen-bridge-xref.exe + +sgen-bridge2-tests: $(SGEN_BRIDGE2_TESTS) + $(MAKE) sgen-bridge2-tests-plain + $(MAKE) sgen-bridge2-tests-ms-conc + $(MAKE) sgen-bridge2-tests-ms-split + $(MAKE) sgen-bridge2-tests-plain-new-bridge + $(MAKE) sgen-bridge2-tests-ms-conc-new-bridge + $(MAKE) sgen-bridge2-tests-ms-split-new-bridge + $(MAKE) sgen-bridge2-tests-plain-tarjan-bridge + $(MAKE) sgen-bridge2-tests-ms-split-tarjan-bridge + +sgen-bridge2-tests-plain: $(SGEN_BRIDGE2_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=2Bridge" MONO_GC_PARAMS="" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE2_TESTS) +sgen-bridge2-tests-ms-conc: $(SGEN_BRIDGE2_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=2Bridge" MONO_GC_PARAMS="major=marksweep-conc" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE2_TESTS) +sgen-bridge2-tests-ms-split: $(SGEN_BRIDGE2_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=2Bridge" MONO_GC_PARAMS="minor=split" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE2_TESTS) +sgen-bridge2-tests-plain-new-bridge: $(SGEN_BRIDGE2_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=2Bridge" MONO_GC_PARAMS="bridge-implementation=new" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE2_TESTS) +sgen-bridge2-tests-ms-conc-new-bridge: $(SGEN_BRIDGE2_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=2Bridge" MONO_GC_PARAMS="bridge-implementation=new,major=marksweep-conc" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE2_TESTS) +sgen-bridge2-tests-ms-split-new-bridge: $(SGEN_BRIDGE2_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=2Bridge" MONO_GC_PARAMS="bridge-implementation=new,minor=split" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE2_TESTS) +sgen-bridge2-tests-plain-tarjan-bridge: $(SGEN_BRIDGE2_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=2Bridge" MONO_GC_PARAMS="bridge-implementation=tarjan" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE2_TESTS) +sgen-bridge2-tests-ms-split-tarjan-bridge: $(SGEN_BRIDGE2_TESTS) test-runner.exe + MONO_ENV_OPTIONS="--gc=sgen" MONO_GC_DEBUG="bridge=2Bridge" MONO_GC_PARAMS="bridge-implementation=tarjan,minor=split" $(RUNTIME) ./test-runner.exe --testsuite-name $@ --timeout 900 $(SGEN_BRIDGE2_TESTS) AOT_CONFIGURATIONS= \ "|regular" \ diff --git a/mono/tests/load-exceptions.cs b/mono/tests/load-exceptions.cs index cb2fc098375..97279d2fb6d 100644 --- a/mono/tests/load-exceptions.cs +++ b/mono/tests/load-exceptions.cs @@ -339,6 +339,16 @@ public class Tests : LoadMissing { return 2; } + public static int test_0_reflection_on_field_with_missing_custom_attr () { + var t = typeof (BadOverridesDriver).Assembly.GetType ("FieldWithMissingCustomAttribute"); + try { + Console.WriteLine (t.GetFields ()[0].CustomAttributes); + return 1; + } catch (FileNotFoundException) { + return 0; + } + return 2; + } public static int Main () { return TestDriver.RunTests (typeof (Tests)); diff --git a/mono/tests/load-missing.il b/mono/tests/load-missing.il index 3f2da10c57a..1ae933d277b 100644 --- a/mono/tests/load-missing.il +++ b/mono/tests/load-missing.il @@ -11,6 +11,10 @@ { .ver 0:0:0:0 } +.assembly extern notFoundAssembly +{ + .ver 0:0:0:0 +} .assembly 'load-missing' { @@ -725,3 +729,9 @@ .field public class [t]Missing BrokenField .field public static int32 WorkingField } + +.class public auto ansi beforefieldinit FieldWithMissingCustomAttribute +{ + .field public object f + .custom instance void class [notFoundAssembly]SomeAttribute::'.ctor'() = (01 00 00 00 ) // .... +} diff --git a/msvc/mono.def b/msvc/mono.def index 43a9f7184d5..e92d3720656 100644 --- a/msvc/mono.def +++ b/msvc/mono.def @@ -471,6 +471,7 @@ mono_install_assembly_preload_hook mono_install_assembly_refonly_preload_hook mono_install_assembly_refonly_search_hook mono_install_assembly_search_hook +mono_install_load_aot_data_hook mono_install_runtime_cleanup mono_install_unhandled_exception_hook mono_is_debugger_attached @@ -834,8 +835,12 @@ mono_thread_new_init mono_thread_set_main mono_thread_set_manage_callback mono_thread_stop +mono_threads_assert_gc_safe_region +mono_threads_assert_gc_unsafe_region mono_threads_attach_tools_thread +mono_threads_enter_gc_safe_region mono_threads_enter_gc_unsafe_region +mono_threads_exit_gc_safe_region mono_threads_exit_gc_unsafe_region mono_threads_get_default_stacksize mono_threads_request_thread_dump diff --git a/msvc/monosgen.def b/msvc/monosgen.def index 7c0bd3ae530..dc32801d088 100644 --- a/msvc/monosgen.def +++ b/msvc/monosgen.def @@ -473,6 +473,7 @@ mono_install_assembly_preload_hook mono_install_assembly_refonly_preload_hook mono_install_assembly_refonly_search_hook mono_install_assembly_search_hook +mono_install_load_aot_data_hook mono_install_runtime_cleanup mono_install_unhandled_exception_hook mono_is_debugger_attached @@ -836,8 +837,12 @@ mono_thread_new_init mono_thread_set_main mono_thread_set_manage_callback mono_thread_stop +mono_threads_assert_gc_safe_region +mono_threads_assert_gc_unsafe_region mono_threads_attach_tools_thread +mono_threads_enter_gc_safe_region mono_threads_enter_gc_unsafe_region +mono_threads_exit_gc_safe_region mono_threads_exit_gc_unsafe_region mono_threads_get_default_stacksize mono_threads_request_thread_dump diff --git a/msvc/scripts/order.xml b/msvc/scripts/order.xml index 644491b94d5..09d652d968f 100644 --- a/msvc/scripts/order.xml +++ b/msvc/scripts/order.xml @@ -252,7 +252,7 @@ false - /codepage:65001 -unsafe -nostdlib -nowarn:612,618,1635 -d:INSIDE_CORLIB,MONO_CULTURE_DATA -d:LIBC -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32,FEATURE_EXCEPTIONDISPATCHINFO,FEATURE_CORRUPTING_EXCEPTIONS,FEATURE_EXCEPTION_NOTIFICATIONS,FEATURE_STRONGNAME_MIGRATION,FEATURE_USE_LCID,FEATURE_FUSION,FEATURE_CRYPTO,FEATURE_X509_SECURESTRINGS,FEATURE_SYNCHRONIZATIONCONTEXT,FEATURE_SYNCHRONIZATIONCONTEXT_WAIT -d:FEATURE_REMOTING,MONO_COM,FEATURE_COMINTEROP,FEATURE_ROLE_BASED_SECURITY -d:MONO_FEATURE_THREAD_ABORT -d:MONO_FEATURE_THREAD_SUSPEND_RESUME -d:MONO_FEATURE_MULTIPLE_APPDOMAINS -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:DISABLE_CAS_USE -nowarn:1699 -nostdlib -lib:./../../class/lib/net_4_x -debug -optimize -r:./../../class/lib/net_4_x/mscorlib.dll -d:MONO_FEATURE_THREAD_ABORT -d:MONO_FEATURE_THREAD_SUSPEND_RESUME -d:MONO_FEATURE_MULTIPLE_APPDOMAINS -debug -nowarn:168,219,618,672 -unsafe -r:Mono.Posix.dll -r:System.Core.dll -define:MONO_DATACONVERTER_STATIC_METHODS -resource:Test/resources/Resources.resources + /codepage:65001 -unsafe -nostdlib -nowarn:612,618,1635 -d:INSIDE_CORLIB,MONO_CULTURE_DATA -d:LIBC -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32,FEATURE_EXCEPTIONDISPATCHINFO,FEATURE_CORRUPTING_EXCEPTIONS,FEATURE_EXCEPTION_NOTIFICATIONS,FEATURE_STRONGNAME_MIGRATION,FEATURE_USE_LCID,FEATURE_FUSION,FEATURE_CRYPTO,FEATURE_X509_SECURESTRINGS,FEATURE_SYNCHRONIZATIONCONTEXT,FEATURE_SYNCHRONIZATIONCONTEXT_WAIT -d:FEATURE_REMOTING,MONO_COM,FEATURE_COMINTEROP,FEATURE_ROLE_BASED_SECURITY -d:MONO_FEATURE_THREAD_ABORT -d:MONO_FEATURE_THREAD_SUSPEND_RESUME -d:MONO_FEATURE_MULTIPLE_APPDOMAINS -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:DISABLE_CAS_USE -nowarn:1699 -nostdlib -lib:./../../class/lib/net_4_x -debug -optimize -r:./../../class/lib/net_4_x/mscorlib.dll -d:MONO_FEATURE_THREAD_ABORT -d:MONO_FEATURE_THREAD_SUSPEND_RESUME -d:MONO_FEATURE_MULTIPLE_APPDOMAINS -debug -nowarn:168,219,618,672 -unsafe -r:Mono.Posix.dll -r:System.Core.dll -r:System.dll -define:MONO_DATACONVERTER_STATIC_METHODS -resource:Test/resources/Resources.resources net_4_x_corlib_test.dll net_4_x_corlib_test.dll @@ -1322,7 +1322,7 @@ false - /codepage:65001 -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:DISABLE_CAS_USE -nowarn:1699 -nostdlib -lib:./../../class/lib/net_4_x -r:mscorlib.dll -debug -optimize -r:./../../class/lib/net_4_x/System.Web.Extensions.dll -unsafe -define:NET_3_5 -define:SYSTEM_WEB_EXTENSIONS -r:mscorlib.dll -r:System.Web.ApplicationServices.dll /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjax.debug.js /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjax.js /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjaxTimer.debug.js /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjaxTimer.js /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjaxWebForms.debug.js /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjaxWebForms.js -r:System -r:System.Core -r:System.Drawing -r:System.Data -r:System.Data.Linq -r:System.Xml -r:System.Web -r:System.Web.Services -r:System.Configuration -r:System.EnterpriseServices -r:System.ServiceModel -doc:net_4_x_System.Web.Extensions_test.xml -nowarn:219,169,1591 /resource:Test/resources/Web.mono.config /resource:Test/resources/profile.config.4.x /resource:Test/resources/ListViewSort.aspx /resource:Test/resources/ListViewTest.aspx /resource:Test/resources/ListViewTotalRowCount_Bug535701_1.aspx /resource:Test/resources/ListViewTotalRowCount_Bug535701_2.aspx /resource:Test/resources/ListViewTotalRowCount_Bug604053.aspx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPage.aspx.cs /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/Global.asax /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/My.ashx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPage.aspx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPageWithDerivedMaster.aspx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPageWithMaster.aspx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPageWithMasterInvalidPlaceHolder.aspx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/My.master /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyDerived.master -r:SystemWebTestShim.dll -define:SYSTEM_WEB_EXTENSIONS + /codepage:65001 -d:NET_4_0 -d:NET_4_5 -d:NET_4_6 -d:MONO -d:DISABLE_CAS_USE -nowarn:1699 -nostdlib -lib:./../../class/lib/net_4_x -r:mscorlib.dll -debug -optimize -r:./../../class/lib/net_4_x/System.Web.Extensions.dll -unsafe -define:NET_3_5 -define:SYSTEM_WEB_EXTENSIONS -r:mscorlib.dll -r:System.Web.ApplicationServices.dll /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjax.debug.js /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjax.js /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjaxTimer.debug.js /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjaxTimer.js /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjaxWebForms.debug.js /resource:../MicrosoftAjaxLibrary/System.Web.Extensions/3.5.0.0/3.5.21022.8/MicrosoftAjaxWebForms.js -r:System -r:System.Core -r:System.Drawing -r:System.Data -r:System.Data.Linq -r:System.Xml -r:System.Web -r:System.Web.Services -r:System.Configuration -r:System.EnterpriseServices -r:System.ServiceModel -doc:net_4_x_System.Web.Extensions_test.xml -nowarn:219,169,1591 /resource:Test/resources/Web.mono.config /resource:Test/resources/profile.config.4.x /resource:Test/resources/ListViewSort.aspx /resource:Test/resources/ListViewTest.aspx /resource:Test/resources/ListViewTotalRowCount_Bug535701_1.aspx /resource:Test/resources/ListViewTotalRowCount_Bug535701_2.aspx /resource:Test/resources/ListViewTotalRowCount_Bug604053.aspx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPage.aspx.cs /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/Global.asax /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/My.ashx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPage.aspx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPageWithDerivedMaster.aspx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPageWithMaster.aspx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyPageWithMasterInvalidPlaceHolder.aspx /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/MyDerived.master /resource:../System.Web/Test/mainsoft/NunitWeb/NunitWeb/Resources/My.master -r:SystemWebTestShim.dll -define:SYSTEM_WEB_EXTENSIONS net_4_x_System.Web.Extensions_test.dll net_4_x_System.Web.Extensions_test.dll