@@ -520,105 +520,97 @@ ThreadActor.prototype = {
520520 * The location of the breakpoint as specified in the protocol.
521521 */
522522 _setBreakpoint : function TA__setBreakpoint ( aLocation ) {
523- // Fetch the list of scripts in that url.
524- let scripts = this . _scripts [ aLocation . url ] ;
525- // Fetch the outermost script in that list.
526- let script = null ;
527- for ( let i = 0 ; i <= aLocation . line ; i ++ ) {
528- // Stop when the first script that contains this location is found.
529- if ( scripts [ i ] ) {
530- // If that first script does not contain the line specified, it's no
531- // good. Note that |i === scripts[i].startLine| in this case, so the
532- // following check makes sure we are not considering a script that does
533- // not include |aLocation.line|.
534- if ( i + scripts [ i ] . lineCount < aLocation . line ) {
535- continue ;
536- }
537- script = scripts [ i ] ;
538- break ;
539- }
540- }
523+ let breakpoints = this . _breakpointStore [ aLocation . url ] ;
541524
542- let location = { url : aLocation . url , line : aLocation . line } ;
543- // Get the list of cached breakpoints in this URL.
544- let scriptBreakpoints = this . _breakpointStore [ location . url ] ;
545- let bpActor ;
546- if ( scriptBreakpoints &&
547- scriptBreakpoints [ location . line ] &&
548- scriptBreakpoints [ location . line ] . actor ) {
549- bpActor = scriptBreakpoints [ location . line ] . actor ;
550- }
551- if ( ! bpActor ) {
552- bpActor = new BreakpointActor ( this , location ) ;
553- this . _hooks . addToParentPool ( bpActor ) ;
554- if ( scriptBreakpoints [ location . line ] ) {
555- scriptBreakpoints [ location . line ] . actor = bpActor ;
556- }
525+ let actor ;
526+ if ( breakpoints [ aLocation . line ] . actor ) {
527+ actor = breakpoints [ aLocation . line ] . actor ;
528+ } else {
529+ actor = breakpoints [ aLocation . line ] . actor = new BreakpointActor ( this , {
530+ url : aLocation . url ,
531+ line : aLocation . line
532+ } ) ;
533+ this . _hooks . addToParentPool ( actor ) ;
557534 }
558535
559- if ( ! script ) {
560- return { error : "noScript" , actor : bpActor . actorID } ;
536+ let scripts = this . dbg . findScripts ( aLocation ) ;
537+ if ( scripts . length == 0 ) {
538+ return {
539+ error : "noScript" ,
540+ actor : actor . actorID
541+ } ;
561542 }
562543
563- let inner , codeFound = false ;
564- // We need to set the breakpoint in every script that has bytecode in the
565- // specified line.
566- for ( let s of this . _getContainers ( script , aLocation . line ) ) {
567- // The first result of the iteration is the innermost script.
568- if ( ! inner ) {
569- inner = s ;
570- }
571-
572- let offsets = s . getLineOffsets ( aLocation . line ) ;
573- if ( offsets . length ) {
574- bpActor . addScript ( s , this ) ;
575- for ( let i = 0 ; i < offsets . length ; i ++ ) {
576- s . setBreakpoint ( offsets [ i ] , bpActor ) ;
577- codeFound = true ;
544+ let found = false ;
545+ for ( let script of scripts ) {
546+ let offsets = script . getLineOffsets ( aLocation . line ) ;
547+ if ( offsets . length > 0 ) {
548+ for ( let offset of offsets ) {
549+ script . setBreakpoint ( offset , actor ) ;
578550 }
551+ actor . addScript ( script , this ) ;
552+ found = true ;
579553 }
580554 }
555+ if ( found ) {
556+ return {
557+ actor : actor . actorID
558+ } ;
559+ }
560+
561+ let scripts = this . dbg . findScripts ( {
562+ url : aLocation . url ,
563+ line : aLocation . line ,
564+ innermost : true
565+ } ) ;
581566
582567 let actualLocation ;
583- if ( ! codeFound ) {
584- // No code at that line in any script, skipping forward in the innermost
585- // script.
586- let lines = inner . getAllOffsets ( ) ;
587- let oldLine = aLocation . line ;
588- for ( let line = oldLine ; line < lines . length ; ++ line ) {
589- if ( lines [ line ] ) {
590- for ( let i = 0 ; i < lines [ line ] . length ; i ++ ) {
591- inner . setBreakpoint ( lines [ line ] [ i ] , bpActor ) ;
592- codeFound = true ;
568+ let found = false ;
569+ for ( let script of scripts ) {
570+ let offsets = script . getAllOffsets ( ) ;
571+ for ( let line = aLocation . line ; line < offsets . length ; ++ line ) {
572+ if ( offsets [ line ] ) {
573+ for ( let offset of offsets [ line ] ) {
574+ script . setBreakpoint ( offset , actor ) ;
593575 }
594- bpActor . addScript ( inner , this ) ;
595- actualLocation = {
596- url : aLocation . url ,
597- line : line ,
598- column : aLocation . column
599- } ;
600- // If there wasn't already a breakpoint at that line, update the cache
601- // as well.
602- if ( scriptBreakpoints [ line ] && scriptBreakpoints [ line ] . actor ) {
603- let existing = scriptBreakpoints [ line ] . actor ;
604- bpActor . onDelete ( ) ;
605- delete scriptBreakpoints [ oldLine ] ;
606- return { actor : existing . actorID , actualLocation : actualLocation } ;
576+ actor . addScript ( script , this ) ;
577+ if ( ! actualLocation ) {
578+ actualLocation = {
579+ url : aLocation . url ,
580+ line : line ,
581+ column : aLocation . column
582+ } ;
607583 }
608- bpActor . location = actualLocation ;
609- scriptBreakpoints [ line ] = scriptBreakpoints [ oldLine ] ;
610- scriptBreakpoints [ line ] . line = line ;
611- delete scriptBreakpoints [ oldLine ] ;
584+ found = true ;
612585 break ;
613586 }
614587 }
615588 }
616-
617- if ( ! codeFound ) {
618- return { error : "noCodeAtLineColumn" , actor : bpActor . actorID } ;
589+ if ( found ) {
590+ if ( breakpoints [ actualLocation . line ] &&
591+ breakpoints [ actualLocation . line ] . actor ) {
592+ actor . onDelete ( ) ;
593+ delete breakpoints [ aLocation . line ] ;
594+ return {
595+ actor : breakpoints [ actualLocation . line ] . actor . actorID ,
596+ actualLocation : actualLocation
597+ } ;
598+ } else {
599+ actor . location = actualLocation ;
600+ breakpoints [ actualLocation . line ] = breakpoints [ aLocation . line ] ;
601+ breakpoints [ actualLocation . line ] . line = actualLocation . line ;
602+ delete breakpoints [ aLocation . line ] ;
603+ return {
604+ actor : actor . actorID ,
605+ actualLocation : actualLocation
606+ } ;
607+ }
619608 }
620609
621- return { actor : bpActor . actorID , actualLocation : actualLocation } ;
610+ return {
611+ error : "noCodeAtLineColumn" ,
612+ actor : actor . actorID
613+ } ;
622614 } ,
623615
624616 /**
@@ -1488,7 +1480,7 @@ SourceActor.prototype = {
14881480 _loadSource : function SA__loadSource ( ) {
14891481 let deferred = defer ( ) ;
14901482 let scheme ;
1491- let url = this . _url ;
1483+ let url = this . _url . split ( " -> " ) . pop ( ) ;
14921484
14931485 try {
14941486 scheme = Services . io . extractScheme ( url ) ;
0 commit comments