11import { Token } from '../../io/token.js' ;
22import { Var } from '../../vars/var.js' ;
33import { TypedBpCmdLet } from './bp.js' ;
4- import { BpType } from '../../breakpoints/bp.js' ;
4+ import { Bp , BpType } from '../../breakpoints/bp.js' ;
55import { Bps } from '../../breakpoints/bps.js' ;
66import { BpReplacement } from '../../breakpoints/replace.js' ;
77import { Output } from '../../io/output.js' ;
@@ -20,16 +20,28 @@ export class ReplaceCmdLet extends TypedBpCmdLet {
2020 const index = Bps . getNextFreeIndex ( this . bpType ) ;
2121 const bp = new BpReplacement ( index , address , target ) ;
2222 Bps . add ( bp ) ;
23- Output . writeln ( `Created ${ bp . toString ( ) } ` ) ;
2423 bp . enable ( ) ;
25- return bp . trampoline ;
24+ Output . writeln ( `Created ${ bp . toString ( ) } ` ) ;
25+ return Bp . idToVar ( index ) ;
2626 } catch ( error ) {
2727 throw new Error ( `failed to replace ${ address } with ${ target } , ${ error } ` ) ;
2828 }
2929 }
3030
31- protected override runModify ( _tokens : Token [ ] ) : Var | null {
32- return null ;
31+ /*
32+ * This function doesn't actually modify the breakpoint, but rather since it
33+ * is called berfore runShow in the parent it allows us to match those same
34+ * arguments and overload it to return the trampoline address in the event
35+ * that a breakpoint id was specified.
36+ */
37+ protected override runModify ( tokens : Token [ ] ) : Var | null {
38+ const vars = this . transform ( tokens , [ this . parseIndex ] ) ;
39+ if ( vars === null ) return null ;
40+ const [ index ] = vars as [ number ] ;
41+ const bp = Bps . get ( this . bpType , index ) as BpReplacement ;
42+ if ( bp === null ) throw new Error ( `breakpoint #${ index } doesn't exist` ) ;
43+ Output . writeln ( bp . toString ( ) ) ;
44+ return bp . trampoline ;
3345 }
3446
3547 protected override usageCreate ( ) : string {
0 commit comments