Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger improvements 3 #852

Merged
merged 18 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
369 changes: 221 additions & 148 deletions Jint.Tests/Runtime/Debugger/CallStackTests.cs

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions Jint.Tests/Runtime/Debugger/DebugHandlerTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using Jint.Native.Object;
using Jint.Runtime.Debugger;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;

namespace Jint.Tests.Runtime.Debugger
{
public class DebugHandlerTests
{
[Fact]
public void AvoidsPauseRecursion()
{
// While the DebugHandler is in a paused state, it shouldn't relay further OnStep calls to Break/Step.
// Such calls would occur e.g. if Step/Break event handlers evaluate accessors. Failing to avoid
// reentrance in a multithreaded environment (e.g. using ManualResetEvent(Slim)) would cause
// a deadlock.
string script = @"
const obj = { get name() { 'fail'; return 'Smith'; } };
'target';
";

var engine = new Engine(options => options.DebugMode());

bool didPropertyAccess = false;

engine.Step += (sender, info) =>
{
// We should never reach "fail", because the only way it's executed is from
// within this Step handler
Assert.False(info.ReachedLiteral("fail"));

if (info.ReachedLiteral("target"))
{
var obj = info.CurrentScopeChain.Global["obj"] as ObjectInstance;
var prop = obj.GetOwnProperty("name");
// This is where reentrance would occur:
var value = prop.Get.Invoke();
didPropertyAccess = true;
}
return StepMode.Into;
};

engine.Execute(script);

Assert.True(didPropertyAccess);
}
}
}