Permalink
Browse files

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>
  • Loading branch information...
ofrobots authored and rvagg committed Aug 23, 2015
1 parent c431725 commit 808de0da032381a8ea0993fce3f0a333db7c1eb1
Showing with 10 additions and 0 deletions.
  1. +4 −0 lib/module.js
  2. +6 −0 src/node_contextify.cc
View
@@ -423,6 +423,10 @@ Module.prototype._compile = function(content, filename) {
// Set breakpoint on module start
if (filename === resolvedArgv) {
+ // Installing this dummy debug event listener tells V8 to start
+ // the debugger. Without it, the setBreakPoint() fails with an
+ // 'illegal access' error.
+ global.v8debug.Debug.setListener(function() {});
global.v8debug.Debug.setBreakPoint(compiledWrapper, 0, 0);
}
}
View
@@ -261,6 +261,12 @@ class ContextifyContext {
if (script_source.IsEmpty())
return; // Exception pending.
Local<Context> debug_context = Debug::GetDebugContext();
+ if (debug_context.IsEmpty()) {
+ // Force-load the debug context.
+ Debug::GetMirror(args.GetIsolate()->GetCurrentContext(), args[0]);
+ debug_context = Debug::GetDebugContext();
+ CHECK(!debug_context.IsEmpty());
+ }
Environment* env = Environment::GetCurrent(args);
ScopedEnvironment env_scope(debug_context, env);
Context::Scope context_scope(debug_context);

0 comments on commit 808de0d

Please sign in to comment.