Skip to content

Commit

Permalink
[sdb] Fix VirtualMachine.CreateEnumMirror () so it works with types f…
Browse files Browse the repository at this point in the history
…rom non-root domains.

Fixes mono#7289.
  • Loading branch information
vargaz authored and marek-safar committed Feb 27, 2018
1 parent b8da973 commit e8141fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ internal EnumMirror (VirtualMachine vm, TypeMirror type, Value[] fields) : base
if (!type.IsEnum)
throw new ArgumentException ("type must be an enum type", "type");
TypeMirror t = type.EnumUnderlyingType;
if (value.Value == null || !value.Value.GetType ().IsPrimitive || t != vm.RootDomain.GetCorrespondingType (value.Value.GetType ()))
// Can't access t's domain, so compare type names
if (value.Value == null || !value.Value.GetType ().IsPrimitive || t.Name != vm.RootDomain.GetCorrespondingType (value.Value.GetType ()).Name)
throw new ArgumentException ("Value '" + value.Value + "' does not match the type of the enum.");
}

Expand Down
4 changes: 4 additions & 0 deletions mcs/class/Mono.Debugger.Soft/Test/dtest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3511,6 +3511,10 @@ public void Domains () {
Assert.AreEqual ("domains", frames [2].Method.Name);
Assert.AreEqual (vm.RootDomain, frames [2].Domain);

// Check enum creation in other domains
var anenum = vm.CreateEnumMirror (d_method.DeclaringType.Assembly.GetType ("AnEnum"), vm.CreateValue (1));
Assert.AreEqual (1, anenum.Value);

// Test breakpoints on already JITted methods in other domains
m = entry_point.DeclaringType.GetMethod ("invoke_in_domain_2");
Assert.IsNotNull (m);
Expand Down

0 comments on commit e8141fc

Please sign in to comment.