Debugging Sandboxes
I run most of my code in custom NodeJS sandboxes, which I create via the vm
module. I would like to add some (automated) debugging tools for the sandboxed code, so I am looking for ways to debug the sandboxed code.
What I found so far is vm.runInDebugContext(code), which returns an object for debugging the code directly (GREAT!). unfortunately, I cannot find any documentation on that API at all. Using the NodeJS REPL, I discovered the properties listed below, but some of them yield an illegal access
error when called and others require additional parameters.
Does anyone of you have any experience with the debug API or any more info or documentation? Is there a better way tap what's happening in sandboxes?
> const vm = require('vm');
> const Debug = vm.runInDebugContext('Debug');
> Debug
{ DebugEvent:
{ Break: 1,
Exception: 2,
NewFunction: 3,
BeforeCompile: 4,
AfterCompile: 5,
CompileError: 6,
PromiseEvent: 7,
AsyncTaskEvent: 8 },
ExceptionBreak: { Caught: 0, Uncaught: 1 },
StepAction: { StepOut: 0, StepNext: 1, StepIn: 2, StepFrame: 3 },
ScriptType: { Native: 0, Extension: 1, Normal: 2 },
ScriptCompilationType: { Host: 0, Eval: 1, JSON: 2 },
ScriptBreakPointType: { ScriptId: 0, ScriptName: 1, ScriptRegExp: 2 },
BreakPositionAlignment: { Statement: 0, BreakPosition: 1 },
setListener: [Function],
breakLocations: [Function],
findScript: [Function],
scriptSource: [Function],
source: [Function],
sourcePosition: [Function],
findFunctionSourceLocation: [Function],
findScriptSourcePosition: [Function],
findBreakPoint: [Function],
findBreakPointActualLocations: [Function],
setBreakPoint: [Function],
setBreakPointByScriptIdAndPosition: [Function],
enableBreakPoint: [Function],
disableBreakPoint: [Function],
changeBreakPointCondition: [Function],
clearBreakPoint: [Function],
clearAllBreakPoints: [Function],
disableAllBreakPoints: [Function],
findScriptBreakPoint: [Function],
setScriptBreakPoint: [Function],
setScriptBreakPointById: [Function],
setScriptBreakPointByName: [Function],
setScriptBreakPointByRegExp: [Function],
enableScriptBreakPoint: [Function],
disableScriptBreakPoint: [Function],
changeScriptBreakPointCondition: [Function],
scriptBreakPoints: [Function],
clearStepping: [Function],
setBreakOnException: [Function],
clearBreakOnException: [Function],
isBreakOnException: [Function],
setBreakOnUncaughtException: [Function],
clearBreakOnUncaughtException: [Function],
isBreakOnUncaughtException: [Function],
showBreakPoints: [Function],
scripts: [Function],
debuggerFlags: [Function],
MakeMirror: [Function: MakeMirror],
LiveEdit:
{ SetScriptSource: [Function: SetScriptSource],
ApplyPatchMultiChunk: [Function: ApplyPatchMultiChunk],
Failure: [Function: Failure],
GetPcFromSourcePos: [Function: GetPcFromSourcePos],
TestApi:
{ PosTranslator: [Object],
CompareStrings: [Function: CompareStrings],
ApplySingleChunkPatch: [Function: ApplySingleChunkPatch] } } }
>