Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Keeping the old behavior of scope id what we have before start using …
…debugger-agent.
  • Loading branch information
thaystg committed Sep 20, 2021
commit d7c1e8dcf03879f0e7689b4c45f4312225bb6775
5 changes: 4 additions & 1 deletion src/mono/mono/component/debugger-agent.c
Original file line number Diff line number Diff line change
Expand Up @@ -3083,6 +3083,7 @@ 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
/*
* Reuse the id for already existing stack frames, so invokes don't invalidate
* the still valid stack frames.
Expand All @@ -3096,7 +3097,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;
}

Expand Down
20 changes: 20 additions & 0 deletions src/mono/wasm/debugger/DebuggerTestSuite/SteppingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -928,5 +928,25 @@ await EvaluateAndCheck(
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");
}
}
}
25 changes: 25 additions & 0 deletions src/mono/wasm/debugger/tests/debugger-test/debugger-test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -782,3 +782,28 @@ public static void LoopToBreak()
}
}

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;
}
}