Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Commit

Permalink
support log statements with no expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Loring committed May 23, 2016
1 parent fbd31fe commit da40e94
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/v8debugapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,12 +491,16 @@ module.exports.create = function(logger_, config_, fileStats_) {
if (breakpoint.action === 'LOG') {
// TODO: This doesn't work with compiled languages if there is an error
// compiling one of the expressions in the loop above.
var frame = execState.frame(0);
var evaluatedExpressions = breakpoint.expressions.map(function(exp) {
var result = state.evaluate(exp, frame);
return result.error ? result.error : result.mirror.value();
});
breakpoint.evaluatedExpressions = evaluatedExpressions;
if (!breakpoint.expressions) {
breakpoint.evaluatedExpressions = [];
} else {
var frame = execState.frame(0);
var evaluatedExpressions = breakpoint.expressions.map(function(exp) {
var result = state.evaluate(exp, frame);
return result.error ? result.error : result.mirror.value();
});
breakpoint.evaluatedExpressions = evaluatedExpressions;
}
} else {
var captured = state.capture(execState, breakpoint.expressions, config);
breakpoint.stackFrames = captured.stackFrames;
Expand Down
20 changes: 20 additions & 0 deletions test/test-v8debugapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,26 @@ describe('v8debugapi', function() {

});

it('should be possible to wait on a logpoint without expressions',
function(done) {
var bp = {
id: breakpointInFoo.id,
action: 'LOG',
log_message_format: 'Hello World',
location: breakpointInFoo.location
};
api.set(bp, function(err) {
assert.ifError(err);
api.wait(bp, function(err) {
assert.ifError(err);
api.clear(bp);
done();
});
process.nextTick(function() {foo(1);});
});

});

it('should capture state', function(done) {
// clone a clean breakpointInFoo
var bp = {id: breakpointInFoo.id, location: breakpointInFoo.location};
Expand Down

0 comments on commit da40e94

Please sign in to comment.