Skip to content

Instantly share code, notes, and snippets.

@sidorares
Created February 24, 2014 04:03
Show Gist options
  • Save sidorares/9181766 to your computer and use it in GitHub Desktop.
Save sidorares/9181766 to your computer and use it in GitHub Desktop.
examle: capture all scopes on exception
function bbb(x) {
var cc = x + 1;
var dd = cc + 2;
debugger;
return dd;
}
setInterval(function() {
var aa = 123;
//debugger;
try {
bbb(345);
//throw new Error('aaaa');
} catch(e) {
console.log(e);
}
console.log('here');
}, 1000);
var d = global.v8debug.Debug;
d.setBreakOnException();
d.setListener(function(e,exec_state, event_data, data) {
var scopes = [];
for (var i=0; i < exec_state.frame(0).scopeCount(); ++i)
scopes.push(exec_state.frame(0).scope(i).details_.details_[1]));
console.log(scopes);
});
@remy
Copy link

remy commented Feb 24, 2014

Noting the original tweet said to start node as:

node --expose_debug_as=v8debug example.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment