This repository was archived by the owner on Feb 1, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -255,6 +255,18 @@ function createRepl(inspector) {
255255 }
256256 }
257257
258+ function listBreakpoints ( ) {
259+ function formatLocation ( location ) {
260+ if ( ! location ) return '<unknown location>' ;
261+ const script = knownScripts [ location . scriptId ] ;
262+ const scriptUrl = script ? script . url : location . scriptUrl ;
263+ return `${ getRelativePath ( scriptUrl ) } :${ location . lineNumber + 1 } ` ;
264+ }
265+ knownBreakpoints . forEach ( ( bp , idx ) => {
266+ print ( `#${ idx } ${ formatLocation ( bp . location ) } ` ) ;
267+ } ) ;
268+ }
269+
258270 function setBreakpoint ( script , line , condition , silent ) {
259271 function registerBreakpoint ( { breakpointId, actualLocation } ) {
260272 handleBreakpointResolved ( { breakpointId, location : actualLocation } ) ;
@@ -398,6 +410,10 @@ function createRepl(inspector) {
398410 return currentBacktrace ;
399411 } ,
400412
413+ get breakpoints ( ) {
414+ return listBreakpoints ( ) ;
415+ } ,
416+
401417 scripts : listScripts ,
402418 setBreakpoint,
403419 list,
Original file line number Diff line number Diff line change @@ -48,6 +48,12 @@ test('stepping through breakpoints', (t) => {
4848 // Prepare additional breakpoints
4949 . then ( ( ) => cli . command ( 'sb("break.js", 6)' ) )
5050 . then ( ( ) => cli . command ( 'sb("otherFunction()")' ) )
51+ . then ( ( ) => cli . command ( 'sb(16)' ) )
52+ . then ( ( ) => cli . command ( 'breakpoints' ) )
53+ . then ( ( ) => {
54+ t . match ( cli . output , '#0 examples/break.js:6' ) ;
55+ t . match ( cli . output , '#1 examples/break.js:16' ) ;
56+ } )
5157
5258 . then ( ( ) => cli . command ( 'list()' ) )
5359 . then ( ( ) => {
@@ -69,9 +75,14 @@ test('stepping through breakpoints', (t) => {
6975 'entered timers.js' ) ;
7076 } )
7177 . then ( ( ) => cli . stepCommand ( 'cont' ) )
78+ . then ( ( ) => {
79+ t . match ( cli . output , 'break in examples/break.js:16' ,
80+ 'found breakpoint we set above w/ line number only' ) ;
81+ } )
82+ . then ( ( ) => cli . stepCommand ( 'cont' ) )
7283 . then ( ( ) => {
7384 t . match ( cli . output , 'break in examples/break.js:6' ,
74- 'found breakpoint we set above' ) ;
85+ 'found breakpoint we set above w/ line number & script ' ) ;
7586 } )
7687 . then ( ( ) => cli . stepCommand ( '' ) )
7788 . then ( ( ) => {
You can’t perform that action at this time.
0 commit comments