Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion man/mono.1
Original file line number Diff line number Diff line change
Expand Up @@ -1883,7 +1883,7 @@ for example, to see managed frame names on gdb backtraces.
\fBMONO_VERBOSE_METHOD\fR
Enables the maximum JIT verbosity for the specified method. This is
very helpfull to diagnose a miscompilation problems of a specific
method. This can be a comma-separated list of method names to
method. This can be a semicolon-separated list of method names to
match. If the name is simple, this applies to any method with that
name, otherwise you can use a mono method description (see the section
METHOD DESCRIPTIONS).
Expand Down
2 changes: 1 addition & 1 deletion mono/mini/mini.c
Original file line number Diff line number Diff line change
Expand Up @@ -3361,7 +3361,7 @@ mini_method_compile (MonoMethod *method, guint32 opts, MonoDomain *domain, JitFl
if (!verbose_method_inited) {
char *env = g_getenv ("MONO_VERBOSE_METHOD");
if (env != NULL)
verbose_method_names = g_strsplit (env, ",", -1);
verbose_method_names = g_strsplit (env, ";", -1);

verbose_method_inited = TRUE;
}
Expand Down
3 changes: 2 additions & 1 deletion mono/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,8 @@ TESTS_CS_SRC= \
tailcall-interface.cs \
bug-60843.cs \
nested_type_visibility.cs \
dynamic-method-churn.cs
dynamic-method-churn.cs \
verbose.cs

# some tests fail to compile on mcs
if CSC_IS_ROSLYN
Expand Down
157 changes: 157 additions & 0 deletions mono/tests/verbose.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;

public class MainClass
{
class TestCase
{
public string MethodSpec;
public string[] ExpectedMethods;
}

public static int Main (string[] args)
{
var testCase = new TestCase {
MethodSpec = "*:Method",
ExpectedMethods = new[] {
"N1.Test:Method ()",
"N2.Test:Method ()",
"N2.Test:Method (int)",
"N2.Test:Method (int,string[])",
},
};
if (!RunTest (testCase))
return 1;

testCase = new TestCase {
MethodSpec = "*:Method (int)",
ExpectedMethods = new[] {
"N2.Test:Method (int)",
},
};
if (!RunTest (testCase))
return 2;

testCase = new TestCase
{
MethodSpec = "N1.Test:Method",
ExpectedMethods = new[] {
"N1.Test:Method ()",
},
};
if (!RunTest (testCase))
return 3;

testCase = new TestCase {
MethodSpec = "Test:Method",
ExpectedMethods = new[] {
"N1.Test:Method ()",
"N2.Test:Method ()",
"N2.Test:Method (int)",
"N2.Test:Method (int,string[])",
},
};
if (!RunTest (testCase))
return 4;

testCase = new TestCase {
MethodSpec = "*:Method(int,string[])",
ExpectedMethods = new[] {
"N2.Test:Method (int,string[])",
},
};
if (!RunTest (testCase))
return 5;

testCase = new TestCase {
MethodSpec = "*:Method();N2.*:Method(int,string[])",
ExpectedMethods = new[] {
"N1.Test:Method ()",
"N2.Test:Method ()",
"N2.Test:Method (int,string[])",
},
};
if (!RunTest (testCase))
return 6;

return 0;
}

static bool RunTest (TestCase testCase)
{
var thisProcess = typeof (MainClass).Assembly.Location;

var process = StartCompileAssemblyProcess (thisProcess, testCase.MethodSpec);
var output = process.StandardOutput.ReadToEnd ();
process.WaitForExit ();

var lines = output.Split (new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
foreach (var expectedMethod in testCase.ExpectedMethods) {
var sortedExpectedMethods = testCase.ExpectedMethods.OrderBy (x => x).ToArray ();

var regex = new Regex ("converting method void (?<methodName>.*)");
var matches = regex.Matches (output);
var sortedJittedMethods = matches.Cast<Match> ().Select (x => x.Groups["methodName"])
.SelectMany (x => x.Captures.Cast<Capture> ())
.Select (x => x.Value)
.OrderBy (x => x)
.ToArray ();

if (sortedJittedMethods.Length != sortedExpectedMethods.Length)
return false;

for (int i = 0; i < sortedJittedMethods.Length; ++i) {
if (sortedJittedMethods[i] != sortedExpectedMethods[i])
return false;
}

}

return true;
}

static Process StartCompileAssemblyProcess (string process, string methodSpec)
{
var psi = new ProcessStartInfo (process) {
UseShellExecute = false,
RedirectStandardOutput = true,
};
psi.EnvironmentVariables["MONO_ENV_OPTIONS"] = "--compile-all";
psi.EnvironmentVariables["MONO_VERBOSE_METHOD"] = methodSpec;

return Process.Start (psi);
}
}

namespace N1
{
public class Test
{
public static void Method ()
{
}
}
}

namespace N2
{
public class Test
{
public static void Method (int n)
{
}

public static void Method ()
{
}

public static void Method (int n, string[] args)
{
}
}
}