Skip to content

Commit 0159ac9

Browse files
ofrobotsrvagg
authored andcommitted
src: apply debug force load fixups from 41e63fb
Apply the src/node_contextify.cc and lib/module.js fixups from @bnoordhuis 41e63fb PR-URL: #2509 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent 9fddd83 commit 0159ac9

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

lib/module.js

+4
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,10 @@ Module.prototype._compile = function(content, filename) {
423423

424424
// Set breakpoint on module start
425425
if (filename === resolvedArgv) {
426+
// Installing this dummy debug event listener tells V8 to start
427+
// the debugger. Without it, the setBreakPoint() fails with an
428+
// 'illegal access' error.
429+
global.v8debug.Debug.setListener(function() {});
426430
global.v8debug.Debug.setBreakPoint(compiledWrapper, 0, 0);
427431
}
428432
}

src/node_contextify.cc

+6
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,12 @@ class ContextifyContext {
261261
if (script_source.IsEmpty())
262262
return; // Exception pending.
263263
Local<Context> debug_context = Debug::GetDebugContext();
264+
if (debug_context.IsEmpty()) {
265+
// Force-load the debug context.
266+
Debug::GetMirror(args.GetIsolate()->GetCurrentContext(), args[0]);
267+
debug_context = Debug::GetDebugContext();
268+
CHECK(!debug_context.IsEmpty());
269+
}
264270
Environment* env = Environment::GetCurrent(args);
265271
ScopedEnvironment env_scope(debug_context, env);
266272
Context::Scope context_scope(debug_context);

0 commit comments

Comments
 (0)