@@ -381,10 +381,26 @@ function listener(event, execState, eventData, data) {
381381
382382 // if what we're currently executing isn't inside of userscript.js,
383383 // then PUNT, since we're probably in the first line of console.log()
384- // or some other utility function
384+ // or some other utility function (except for exceptions, heh)
385385 if ( script !== 'userscript.js' ) {
386- execState . prepareStep ( debug . StepAction . StepOut ) ;
387- return ;
386+ // this is SUPER hacky ... but if we encounter an exception in a
387+ // library function AND we've already been running userscript.js
388+ // (i.e., curTrace.length > 0), then still log that exception but
389+ // adjust the line and column numbers to the proper values within
390+ // the user's script.
391+ if ( isException && curTrace . length > 0 ) {
392+ stepType = debug . StepAction . StepOut ; // step out of the library func
393+
394+ // SUPER HACKY -- use the line and column numbers from the
395+ // previous trace entry since that was in userscript.js
396+ line = _ . last ( curTrace ) . line ;
397+ col = _ . last ( curTrace ) . col ;
398+ } else {
399+ // any non-exception event should just be steppd out of
400+ // immediately without logging to the trace ...
401+ execState . prepareStep ( debug . StepAction . StepOut ) ;
402+ return ;
403+ }
388404 } else {
389405 // NB: StepInMin is slightly finer-grained than StepIn
390406 stepType = debug . StepAction . StepIn ;
@@ -395,7 +411,7 @@ function listener(event, execState, eventData, data) {
395411 }
396412 }
397413
398- assert ( script === 'userscript.js' ) ;
414+ // assert(script === 'userscript.js');
399415
400416 // VERY VERY VERY IMPORTANT, or else we won't properly capture heap
401417 // object mutations in the trace!
@@ -713,7 +729,7 @@ function listener(event, execState, eventData, data) {
713729 // GET OUTTA HERE so that the user's script doesn't keep infinite looping
714730 process . exit ( ) ;
715731 } else {
716- assert ( stepType ) ;
732+ assert ( stepType !== undefined ) ;
717733 execState . prepareStep ( stepType ) ; // set debugger to stop at next step
718734 }
719735}
0 commit comments