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

Ntsl2 debugger addition #9

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 0 additions & 6 deletions ByondInterpretedLanguage.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ VisualStudioVersion = 16.0.30011.22
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ByondLang", "ByondLang\ByondLang.csproj", "{06AAC521-E559-48EA-B58C-BF69C37D0416}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ByondLang.Api", "ByondLang.Api\ByondLang.Api.csproj", "{C92D3FBA-C22A-42CC-BFED-3D0CE0539733}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -17,10 +15,6 @@ Global
{06AAC521-E559-48EA-B58C-BF69C37D0416}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06AAC521-E559-48EA-B58C-BF69C37D0416}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06AAC521-E559-48EA-B58C-BF69C37D0416}.Release|Any CPU.Build.0 = Release|Any CPU
{C92D3FBA-C22A-42CC-BFED-3D0CE0539733}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C92D3FBA-C22A-42CC-BFED-3D0CE0539733}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C92D3FBA-C22A-42CC-BFED-3D0CE0539733}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C92D3FBA-C22A-42CC-BFED-3D0CE0539733}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
5 changes: 5 additions & 0 deletions ByondLang.Api/Protos/Program.proto
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,14 @@ message TerminalState {
string buffer = 1;
}

message DebugingState {
bool enabled = 1;
}

service Program {
rpc recycle (VoidMessage) returns (VoidMessage);
rpc status (StatusRequest) returns (StatusResponse);
rpc execute (ExecuteRequest) returns (VoidMessage);
rpc handleTopic (TopicRequest) returns (VoidMessage);
rpc setDebugingState (DebugingState) returns (VoidMessage);
}
5 changes: 0 additions & 5 deletions ByondLang/ByondLang.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Grpc.AspNetCore" Version="2.34.0" />
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64" Version="3.9.1" />
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.win-x64" Version="3.9.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
Expand All @@ -22,8 +21,4 @@
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ByondLang.Api\ByondLang.Api.csproj" />
</ItemGroup>

</Project>
21 changes: 21 additions & 0 deletions ByondLang/ChakraCore/Hosting/JsDiagBreakOnExceptionAttributes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace ByondLang.ChakraCore.Hosting
{
/// <summary>
/// Break on Exception attributes.
/// </summary>
public enum JsDiagBreakOnExceptionAttributes
{
/// <summary>
/// Don't break on any exception.
/// </summary>
None = 0x0,
/// <summary>
/// Break on uncaught exception.
/// </summary>
Uncaught = 0x1,
/// <summary>
/// Break on first chance exception.
/// </summary>
FirstChance = 0x2
};
}
37 changes: 37 additions & 0 deletions ByondLang/ChakraCore/Hosting/JsDiagDebugEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace ByondLang.ChakraCore.Hosting
{
/// <summary>
/// Debug events reported from ChakraCore engine.
/// </summary>
public enum JsDiagDebugEvent
{
/// <summary>
/// Indicates a new script being compiled, this includes script, eval, new function.
/// </summary>
SourceCompile = 0,
/// <summary>
/// Indicates compile error for a script.
/// </summary>
CompileError,
/// <summary>
/// Indicates a break due to a breakpoint.
/// </summary>
Breakpoint,
/// <summary>
/// Indicates a break after completion of step action.
/// </summary>
StepComplete,
/// <summary>
/// Indicates a break due to debugger statement.
/// </summary>
DebuggerStatement,
/// <summary>
/// Indicates a break due to async break.
/// </summary>
AsyncBreak,
/// <summary>
/// Indicates a break due to a runtime script exception.
/// </summary>
RuntimeException
};
}
15 changes: 15 additions & 0 deletions ByondLang/ChakraCore/Hosting/JsDiagDebugEventCallback.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;

namespace ByondLang.ChakraCore.Hosting
{
/// <summary>
/// User implemented callback routine for debug events.
/// </summary>
/// <remarks>
/// Use <c>JsDiagStartDebugging</c> to register the callback.
/// </remarks>
/// <param name="debugEvent">The type of JsDiagDebugEvent event.</param>
/// <param name="eventData">Additional data related to the debug event.</param>
/// <param name="callbackState">The state passed to <c>JsDiagStartDebugging</c>.</param>
public delegate void JsDiagDebugEventCallback(JsDiagDebugEvent debugEvent, JsValue eventData, IntPtr callbackState);
}
33 changes: 33 additions & 0 deletions ByondLang/ChakraCore/Hosting/JsDiagStepType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace ByondLang.ChakraCore.Hosting
{
/// <summary>
/// Stepping types.
/// </summary>
public enum JsDiagStepType
{
/// <summary>
/// Perform a step operation to next statement.
/// </summary>
StepIn = 0,
/// <summary>
/// Perform a step out from the current function.
/// </summary>
StepOut,
/// <summary>
/// Perform a single step over after a debug break if the next statement is a function call, else behaves as a stepin.
/// </summary>
StepOver,
/// <summary>
/// Perform a single step back to the previous statement (only applicable in TTD mode).
/// </summary>
StepBack,
/// <summary>
/// Perform a reverse continue operation (only applicable in TTD mode).
/// </summary>
ReverseContinue,
/// <summary>
/// Perform a forward continue operation. Clears any existing step value.
/// </summary>
Continue
};
}
30 changes: 30 additions & 0 deletions ByondLang/ChakraCore/Hosting/JsRuntime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,35 @@ public JsContext CreateContext()
Native.ThrowIfError(Native.JsCreateContext(this, out JsContext reference));
return reference;
}

/// <summary>
/// Starts debugging in the given runtime.
/// </summary>
/// <param name="debugEventCallback">Registers a callback to be called on every JsDiagDebugEvent.</param>
/// <param name="callbackState">User provided state that will be passed back to the callback.</param>
/// <remarks>
/// The runtime should be active on the current thread and should not be in debug state.
/// </remarks>
public void StartDebugging(JsDiagDebugEventCallback debugEventCallback, IntPtr callbackState)
{
Native.ThrowIfError(Native.JsDiagStartDebugging(this, debugEventCallback, callbackState));
}

/// <summary>
/// Stops debugging in the given runtime.
/// </summary>
/// <param name="runtime">Runtime to stop debugging.</param>
/// <param name="callbackState">User provided state that was passed in JsDiagStartDebugging.</param>
/// <returns>
/// The code <c>JsNoError</c> if the operation succeeded, a failure code otherwise.
/// </returns>
/// <remarks>
/// The runtime should be active on the current thread and in debug state.
/// </remarks>
public IntPtr StopDebugging()
{
Native.ThrowIfError(Native.JsDiagStopDebugging(this, out IntPtr callbackState));
return callbackState;
}
}
}
4 changes: 2 additions & 2 deletions ByondLang/ChakraCore/Hosting/JsValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ public JsValue CallFunction(params JsValue[] arguments)

if (arguments.Length > ushort.MaxValue)
{
throw new ArgumentOutOfRangeException("arguments");
throw new ArgumentOutOfRangeException(nameof(arguments));
}

Native.ThrowIfError(Native.JsCallFunction(this, arguments, (ushort)arguments.Length, out JsValue returnReference));
Expand All @@ -939,7 +939,7 @@ public JsValue ConstructObject(params JsValue[] arguments)
{
if (arguments.Length > ushort.MaxValue)
{
throw new ArgumentOutOfRangeException("arguments");
throw new ArgumentOutOfRangeException(nameof(arguments));
}
Native.ThrowIfError(Native.JsConstructObject(this, arguments, (ushort)arguments.Length, out JsValue returnReference));
return returnReference;
Expand Down
Loading