diff options
author | Thays Grazia <thaystg@gmail.com> | 2020-03-27 18:00:06 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-27 18:00:06 +0300 |
commit | 4b0424cd6883f86ee9c3573feadc4f0bb81c9e5b (patch) | |
tree | ca1e101778afe2ddc3cf84a77d0396566b0994b2 /mcs/class | |
parent | 2444b38b3c5c6ae50089d61ac684dda93666a135 (diff) |
[2020- 02][debugger] Implementing step through multithreaded code. (#19343)
* [debugger] Implementing step through multithreaded code.
Backport #19103
* Bump API snapshot submodule
Co-authored-by: monojenkins <jo.shields+jenkins@xamarin.com>
Diffstat (limited to 'mcs/class')
4 files changed, 87 insertions, 1 deletions
diff --git a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/EventRequest.cs b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/EventRequest.cs index 69f35f4c0ac..4c9a536838b 100644 --- a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/EventRequest.cs +++ b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/EventRequest.cs @@ -34,6 +34,11 @@ namespace Mono.Debugger.Soft } } + public int GetId() + { + return id; + } + public EventType EventType { get { return etype; diff --git a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs index c9026a02682..12274864d4c 100644 --- a/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs +++ b/mcs/class/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachine.cs @@ -657,7 +657,9 @@ namespace Mono.Debugger.Soft internal EventRequest GetRequest (int id) { lock (requests_lock) { - return requests [id]; + EventRequest obj; + requests.TryGetValue (id, out obj); + return obj; } } diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs index 1bbb04d4709..e6b79fdd406 100644 --- a/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs +++ b/mcs/class/Mono.Debugger.Soft/Test/dtest-app.cs @@ -613,6 +613,10 @@ public class Tests : TestsBase, ITest2 pointers2 (); return 0; } + if (args.Length >0 && args [0] == "ss_multi_thread") { + ss_multi_thread (); + return 0; + } return 3; } @@ -862,6 +866,24 @@ public class Tests : TestsBase, ITest2 } [MethodImplAttribute (MethodImplOptions.NoInlining)] + public static void ss_multi_thread () { + for (int i = 0; i < 5; i++) + { + var t = new Thread(mt_ss); + t.Name = "Thread_" + i; + t.Start(); + } + } + + [MethodImplAttribute (MethodImplOptions.NoInlining)] + static void mt_ss() + { + int a = 12; + int b = 13; + int c = 13; + } + + [MethodImplAttribute (MethodImplOptions.NoInlining)] public static void test_new_exception_filter () { test_new_exception_filter1(); test_new_exception_filter2(); diff --git a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs index 473ce2f355e..d6ca7dc3255 100644 --- a/mcs/class/Mono.Debugger.Soft/Test/dtest.cs +++ b/mcs/class/Mono.Debugger.Soft/Test/dtest.cs @@ -65,6 +65,9 @@ public class DebuggerTests Event GetNextEvent () { var es = vm.GetNextEventSet (); Assert.AreEqual (1, es.Events.Length); + if (step_req != null && es [0] != null && es [0].Request != null && es [0].Request is StepEventRequest && ((StepEventRequest)es [0].Request).GetId() != step_req.GetId()) { + step_req = ((StepEventRequest)es [0].Request); + } return es [0]; } @@ -5227,6 +5230,60 @@ public class DebuggerTests if (failMessage != null) Assert.Fail (failMessage); } + + [Test] + public void InvokeSingleStepMultiThread () { + vm.Detach (); + Start (dtest_app_path, "ss_multi_thread"); + MethodMirror m = entry_point.DeclaringType.GetMethod ("mt_ss"); + int firstLineFound = m.Locations [0].LineNumber + 1; + int line_first_counter = 5; + int line_second_counter = 5; + int line_third_counter = 3; + Event e = run_until ("ss_multi_thread"); + EventRequest req = create_step (e); + req.Disable (); + ReusableBreakpoint breakpoint = new ReusableBreakpoint (this, "mt_ss"); + breakpoint.Continue (); + e = breakpoint.lastEvent; + req = create_step (e); + while (line_first_counter > 0 || line_second_counter > 0 || line_third_counter > 0) { + var thread = e.Thread; + var l = thread.GetFrames ()[0].Location; + var frame = thread.GetFrames()[0]; + + if (l.LineNumber == firstLineFound) + line_first_counter--; + if (l.LineNumber == firstLineFound + 1) + line_second_counter--; + if (l.LineNumber == firstLineFound + 2) + line_third_counter--; + + if (req.GetId() != breakpoint.req.GetId()) + req.Disable (); + + req = create_step (e); + ((StepEventRequest)req).Size = StepSize.Line; + try { + if ((e.Thread.GetFrames ()[0].Location.LineNumber == firstLineFound + 1 && (e.Thread.Name.Equals("Thread_0") || e.Thread.Name.Equals("Thread_1"))) || l.LineNumber == firstLineFound + 2) { + vm.Resume (); + e = GetNextEvent (); + } + else + e = step_over_or_breakpoint (); + req = e.Request; + } + catch (Exception z){ + //expected vmdeath + break; + } + } + Assert.AreEqual(0, line_first_counter); + Assert.AreEqual(0, line_second_counter); + Assert.AreEqual(0, line_third_counter); + vm = null; + } + #endif } // class DebuggerTests } // namespace |