[release/6.0-rc2] [wasm][debugger] Reverting the old behavior of scope id numeration...
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Tue, 21 Sep 2021 17:06:23 +0000 (10:06 -0700)
committerGitHub <noreply@github.com>
Tue, 21 Sep 2021 17:06:23 +0000 (10:06 -0700)
* Keeping the old behavior of scope id what we have before start using debugger-agent.

* Fix compilation.

* Fix compilation.

Co-authored-by: Thays <thaystg@gmail.com>
src/mono/mono/component/debugger-agent.c
src/mono/wasm/debugger/DebuggerTestSuite/SteppingTests.cs
src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs

index a266190..308c0b5 100644 (file)
@@ -357,7 +357,9 @@ static int objref_id = 0;
 
 static int event_request_id = 0;
 
+#ifndef TARGET_WASM
 static int frame_id = 0;
+#endif
 
 static GPtrArray *event_requests;
 
@@ -3026,7 +3028,7 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls, gboolean f
 {
        ComputeFramesUserData user_data;
        GSList *tmp;
-       int i, findex, new_frame_count;
+       int findex, new_frame_count;
        StackFrame **new_frames, *f;
        MonoUnwindOptions opts = (MonoUnwindOptions)(MONO_UNWIND_DEFAULT | MONO_UNWIND_REG_LOCATIONS);
 
@@ -3085,6 +3087,8 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls, gboolean f
        for (tmp = user_data.frames; tmp; tmp = tmp->next) {
                f = (StackFrame *)tmp->data;
 
+#ifndef TARGET_WASM
+               int i;
                /* 
                 * Reuse the id for already existing stack frames, so invokes don't invalidate
                 * the still valid stack frames.
@@ -3098,7 +3102,9 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls, gboolean f
 
                if (i >= tls->frame_count)
                        f->id = mono_atomic_inc_i32 (&frame_id);
-
+#else //keep the same behavior that we have for wasm before start using debugger-agent                 
+               f->id = findex+1;
+#endif
                new_frames [findex ++] = f;
        }
 
index e64348b..de1bd7a 100644 (file)
@@ -928,5 +928,25 @@ namespace DebuggerTests
             await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 719, 8, "MoveNext");
             await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 720, 4, "MoveNext");
         }
+
+        [Fact]
+        public async Task CheckResetFrameNumberForEachStep()
+        {
+            var bp_conditional = await SetBreakpointInMethod("debugger-test.dll", "SteppingInto", "MethodToStep", 1);
+            await EvaluateAndCheck(
+                "window.setTimeout(function() { invoke_static_method('[debugger-test] SteppingInto:MethodToStep'); }, 1);",
+                "dotnet://debugger-test.dll/debugger-test.cs",
+                bp_conditional.Value["locations"][0]["lineNumber"].Value<int>(),
+                bp_conditional.Value["locations"][0]["columnNumber"].Value<int>(),
+                "MethodToStep"
+            );
+            var pause_location = await StepAndCheck(StepKind.Into, "dotnet://debugger-test.dll/debugger-test.cs", 799, 4, "Increment");
+            pause_location = await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 800, 8, "Increment");
+            Assert.Equal(pause_location["callFrames"][0]["callFrameId"], "dotnet:scope:1");
+            pause_location = await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 801, 8, "Increment");
+            Assert.Equal(pause_location["callFrames"][0]["callFrameId"], "dotnet:scope:1");
+            pause_location = await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 806, 8, "Increment");
+            Assert.Equal(pause_location["callFrames"][0]["callFrameId"], "dotnet:scope:1");
+        }
     }
 }
index 4ef8045..2338c9e 100644 (file)
@@ -782,3 +782,28 @@ public class LoopClass
     }
 }
 
+public class SteppingInto
+{
+    static int currentCount = 0;
+    static MyIncrementer incrementer = new MyIncrementer();
+    public static void MethodToStep()
+    {
+        currentCount = incrementer.Increment(currentCount);
+    }
+}
+
+public class MyIncrementer
+{
+    private Func<DateTime> todayFunc = () => DateTime.Now;
+
+    public int Increment(int count)
+    {
+        var today = todayFunc();
+        if (today.DayOfWeek == DayOfWeek.Sunday)
+        {
+            return count + 2;
+        }
+
+        return count + 1;
+    }
+}