Skip to content

Commit 720d298

Browse files
[release/6.0-rc2] [wasm][debugger] Reverting the old behavior of scope id numeration (#59372)
* 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>
1 parent 826f81a commit 720d298

3 files changed

Lines changed: 53 additions & 2 deletions

File tree

src/mono/mono/component/debugger-agent.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,9 @@ static int objref_id = 0;
357357

358358
static int event_request_id = 0;
359359

360+
#ifndef TARGET_WASM
360361
static int frame_id = 0;
362+
#endif
361363

362364
static GPtrArray *event_requests;
363365

@@ -3026,7 +3028,7 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls, gboolean f
30263028
{
30273029
ComputeFramesUserData user_data;
30283030
GSList *tmp;
3029-
int i, findex, new_frame_count;
3031+
int findex, new_frame_count;
30303032
StackFrame **new_frames, *f;
30313033
MonoUnwindOptions opts = (MonoUnwindOptions)(MONO_UNWIND_DEFAULT | MONO_UNWIND_REG_LOCATIONS);
30323034

@@ -3085,6 +3087,8 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls, gboolean f
30853087
for (tmp = user_data.frames; tmp; tmp = tmp->next) {
30863088
f = (StackFrame *)tmp->data;
30873089

3090+
#ifndef TARGET_WASM
3091+
int i;
30883092
/*
30893093
* Reuse the id for already existing stack frames, so invokes don't invalidate
30903094
* the still valid stack frames.
@@ -3098,7 +3102,9 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls, gboolean f
30983102

30993103
if (i >= tls->frame_count)
31003104
f->id = mono_atomic_inc_i32 (&frame_id);
3101-
3105+
#else //keep the same behavior that we have for wasm before start using debugger-agent
3106+
f->id = findex+1;
3107+
#endif
31023108
new_frames [findex ++] = f;
31033109
}
31043110

src/mono/wasm/debugger/DebuggerTestSuite/SteppingTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -928,5 +928,25 @@ await EvaluateAndCheck(
928928
await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 719, 8, "MoveNext");
929929
await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 720, 4, "MoveNext");
930930
}
931+
932+
[Fact]
933+
public async Task CheckResetFrameNumberForEachStep()
934+
{
935+
var bp_conditional = await SetBreakpointInMethod("debugger-test.dll", "SteppingInto", "MethodToStep", 1);
936+
await EvaluateAndCheck(
937+
"window.setTimeout(function() { invoke_static_method('[debugger-test] SteppingInto:MethodToStep'); }, 1);",
938+
"dotnet://debugger-test.dll/debugger-test.cs",
939+
bp_conditional.Value["locations"][0]["lineNumber"].Value<int>(),
940+
bp_conditional.Value["locations"][0]["columnNumber"].Value<int>(),
941+
"MethodToStep"
942+
);
943+
var pause_location = await StepAndCheck(StepKind.Into, "dotnet://debugger-test.dll/debugger-test.cs", 799, 4, "Increment");
944+
pause_location = await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 800, 8, "Increment");
945+
Assert.Equal(pause_location["callFrames"][0]["callFrameId"], "dotnet:scope:1");
946+
pause_location = await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 801, 8, "Increment");
947+
Assert.Equal(pause_location["callFrames"][0]["callFrameId"], "dotnet:scope:1");
948+
pause_location = await StepAndCheck(StepKind.Over, "dotnet://debugger-test.dll/debugger-test.cs", 806, 8, "Increment");
949+
Assert.Equal(pause_location["callFrames"][0]["callFrameId"], "dotnet:scope:1");
950+
}
931951
}
932952
}

src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,3 +782,28 @@ public static void LoopToBreak()
782782
}
783783
}
784784

785+
public class SteppingInto
786+
{
787+
static int currentCount = 0;
788+
static MyIncrementer incrementer = new MyIncrementer();
789+
public static void MethodToStep()
790+
{
791+
currentCount = incrementer.Increment(currentCount);
792+
}
793+
}
794+
795+
public class MyIncrementer
796+
{
797+
private Func<DateTime> todayFunc = () => DateTime.Now;
798+
799+
public int Increment(int count)
800+
{
801+
var today = todayFunc();
802+
if (today.DayOfWeek == DayOfWeek.Sunday)
803+
{
804+
return count + 2;
805+
}
806+
807+
return count + 1;
808+
}
809+
}

0 commit comments

Comments
 (0)