diff options
author | Thays Grazia <thaystg@gmail.com> | 2019-01-14 13:16:20 +0300 |
---|---|---|
committer | Bernhard Urban <bernhard.urban@xamarin.com> | 2019-01-14 13:16:20 +0300 |
commit | 141bec26a55e5c7f69854d6a86b67dd08883128b (patch) | |
tree | 9b747468c43e1211c233b048f466f51b568125b8 /mcs/class/Mono.Debugger.Soft | |
parent | 749e93c33c302ad249c0e097bcab28649555279a (diff) |
[Debugger] Fix crash when there is a generic struct with a field that is an enumerator. (#12368)
* [Debugger] Debugger crashes when inside a class, there is an internal struct, with a field that is an enumerator.
files.myBucket.GetEnumerator().get_Current().Key
Fixes #10735
* [Debugger] Debugger crashes when there is a generic struct with a field that is an enumerator.
Example: files.get_Current().Key
A unit test that reproduces this crash was added too.
Fixes #10735
* Removing the extra space.
Diffstat (limited to 'mcs/class/Mono.Debugger.Soft')
-rw-r--r-- | mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs | 36 | ||||
-rw-r--r-- | mcs/class/Mono.Debugger.Soft/Test/dtest.cs | 19 |
2 files changed, 53 insertions, 2 deletions
diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs index cf166e5c1da..b6ea142262a 100644 --- a/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs +++ b/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs @@ -14,6 +14,7 @@ using System.Collections.Generic; using System.Linq; using System.Net.Sockets; using System.Collections.Concurrent; +using System.Collections; #if !MOBILE using MonoTests.Helpers; #endif @@ -86,6 +87,31 @@ public class Tests2 { } } +public struct TestEnumeratorInsideGenericStruct<TKey, TValue> +{ + private KeyValuePair<TKey, TValue> _bucket; + private Position _currentPosition; + internal TestEnumeratorInsideGenericStruct(KeyValuePair<TKey, TValue> bucket) + { + _bucket = bucket; + _currentPosition = Position.BeforeFirst; + } + + public KeyValuePair<TKey, TValue> Current + { + get + { + if (_currentPosition == Position.BeforeFirst) + return _bucket; + return _bucket; + } + } + private enum Position + { + BeforeFirst + } +} + public struct AStruct : ITest2 { public int i; public string s; @@ -448,6 +474,7 @@ public class Tests : TestsBase, ITest2 new Tests ().evaluate_method (); Bug59649 (); elapsed_time(); + inspect_enumerator_in_generic_struct(); return 3; } @@ -650,9 +677,9 @@ public class Tests : TestsBase, ITest2 [MethodImplAttribute (MethodImplOptions.NoInlining)] public static void ss_nested_twice_with_two_args_wrapper () { ss_nested_with_two_args(ss_nested_arg1 (), ss_nested_with_two_args(ss_nested_arg2 (), ss_nested_arg3 ())); - } + } - [MethodImplAttribute (MethodImplOptions.NoInlining)] + [MethodImplAttribute (MethodImplOptions.NoInlining)] public static void elapsed_time () { Thread.Sleep(200); Thread.Sleep(00); @@ -661,6 +688,11 @@ public class Tests : TestsBase, ITest2 } [MethodImplAttribute (MethodImplOptions.NoInlining)] + public static void inspect_enumerator_in_generic_struct() { + TestEnumeratorInsideGenericStruct<String, String> generic_struct = new TestEnumeratorInsideGenericStruct<String, String>(new KeyValuePair<string, string>("0", "f1")); + } + + [MethodImplAttribute (MethodImplOptions.NoInlining)] public static int ss_nested_with_two_args (int a1, int a2) { return a1 + a2; } diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs index c0aefeab751..0ef677e0e07 100644 --- a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs +++ b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs @@ -4603,6 +4603,25 @@ public class DebuggerTests } [Test] + public void InspectEnumeratorInGenericStruct() { + //files.myBucket.GetEnumerator().get_Current().Key watching this generates an exception in Debugger + Event e = run_until("inspect_enumerator_in_generic_struct"); + var req = create_step(e); + req.Enable(); + e = step_once(); + e = step_over(); + StackFrame frame = e.Thread.GetFrames () [0]; + var ginst = frame.Method.GetLocal ("generic_struct"); + Value variable = frame.GetValue (ginst); + StructMirror thisObj = (StructMirror)variable; + TypeMirror thisType = thisObj.Type; + variable = thisObj.InvokeMethod(e.Thread, thisType.GetMethod("get_Current"), null); + thisObj = (StructMirror)variable; + thisType = thisObj.Type; + AssertValue ("f1", thisObj["value"]); + } + + [Test] public void CheckElapsedTime() { Event e = run_until ("elapsed_time"); |