Skip to content

Commit f697235

Browse files
authored
[wasm][debugger] Reverting the old behavior of scope id numeration (dotnet#59368)
* Keeping the old behavior of scope id what we have before start using debugger-agent. * Fix compilation. * Fix compilation.
1 parent b72cd48 commit f697235

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

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

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

356356
static int event_request_id = 0;
357357

358+
#ifndef TARGET_WASM
358359
static int frame_id = 0;
360+
#endif
359361

360362
static GPtrArray *event_requests;
361363

@@ -3024,7 +3026,7 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls, gboolean f
30243026
{
30253027
ComputeFramesUserData user_data;
30263028
GSList *tmp;
3027-
int i, findex, new_frame_count;
3029+
int findex, new_frame_count;
30283030
StackFrame **new_frames, *f;
30293031
MonoUnwindOptions opts = (MonoUnwindOptions)(MONO_UNWIND_DEFAULT | MONO_UNWIND_REG_LOCATIONS);
30303032

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

3088+
#ifndef TARGET_WASM
3089+
int i;
30863090
/*
30873091
* Reuse the id for already existing stack frames, so invokes don't invalidate
30883092
* the still valid stack frames.
@@ -3096,7 +3100,9 @@ compute_frame_info (MonoInternalThread *thread, DebuggerTlsData *tls, gboolean f
30963100

30973101
if (i >= tls->frame_count)
30983102
f->id = mono_atomic_inc_i32 (&frame_id);
3099-
3103+
#else //keep the same behavior that we have for wasm before start using debugger-agent
3104+
f->id = findex+1;
3105+
#endif
31003106
new_frames [findex ++] = f;
31013107
}
31023108

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)