@@ -4,6 +4,7 @@ import { Format } from '../../misc/format.js';
44import { Token } from '../../io/token.js' ;
55import { Var } from '../../vars/var.js' ;
66import { Mem } from '../../memory/mem.js' ;
7+ import { Overlay } from '../../memory/overlay.js' ;
78
89export class AssemblyCmdLet extends CmdLet {
910 name = 'l' ;
@@ -47,6 +48,7 @@ l address <bytes> - show disassembly listing
4748 try {
4849 const minLength = this . maxInstructionLen ( ) ;
4950 const copy = Memory . alloc ( Process . pageSize ) ;
51+ let hasOverlaps = false ;
5052
5153 for ( let i = 1 ; i <= length ; i ++ ) {
5254 if ( buffer . byteLength < minLength ) {
@@ -58,7 +60,15 @@ l address <bytes> - show disassembly listing
5860 }
5961
6062 Mem . writeBytes ( copy , buffer ) ;
61- const insn = Instruction . parse ( copy . add ( isThumb ? 1 : 0 ) ) ;
63+
64+ let insn = Instruction . parse ( cursor . add ( isThumb ? 1 : 0 ) ) ;
65+ const overlaps = Overlay . overlaps ( cursor , insn . size ) ;
66+
67+ if ( overlaps ) {
68+ hasOverlaps = true ;
69+ insn = Instruction . parse ( copy . add ( isThumb ? 1 : 0 ) ) ;
70+ }
71+
6272 if ( insn . size > buffer . length )
6373 throw new Error (
6474 `failed to parse instruction at ${ cursor } , not enough bytes: ${ buffer . length } ` ,
@@ -71,14 +81,26 @@ l address <bytes> - show disassembly listing
7181 . join ( ' ' ) ;
7282
7383 Output . writeln (
74- `${ Output . bold ( idx ) } : ${ Output . green ( Format . toHexString ( cursor ) ) } : ${ Output . yellow ( insn . toString ( ) . padEnd ( 40 ) ) } ${ Output . blue ( bytesStr ) } ` ,
84+ [
85+ `${ Output . bold ( idx ) } :` ,
86+ `${ Output . green ( Format . toHexString ( cursor ) ) } :` ,
87+ `${ Output . yellow ( insn . toString ( ) . padEnd ( 40 ) ) } ` ,
88+ `${ Output . blue ( bytesStr ) } ` ,
89+ overlaps ? `${ Output . red ( '*' ) } ` : '' ,
90+ ] . join ( ' ' ) ,
7591 true ,
7692 ) ;
7793
7894 cursor = cursor . add ( insn . size ) ;
7995 buffer = buffer . slice ( insn . size ) ;
8096 }
8197
98+ if ( hasOverlaps ) {
99+ Output . writeln (
100+ `${ Output . red ( '*' ) } offset in RIP relative instruction may be incorrect due to conflicting breakpoint` ,
101+ ) ;
102+ }
103+
82104 return new Var ( uint64 ( cursor . toString ( ) ) ) ;
83105 } catch ( error ) {
84106 throw new Error (
0 commit comments