I'm using gdb
to inspect the boot process of xv6
. More specifically, I'm running xv6
using qemu
with gdb
support in a terminal. And in another terminal, I'm running gdb
remotely connected to the qemu
stub.
Now, stepping through the boot process with the si
command yields the following instructions
[f000:e05b] 0xfe05b: cmpw $0xffc8,%cs:(%esi)
[f000:e062] 0xfe062: jne 0xd241d416
[f000:e066] 0xfe066: xor %edx,%edx
[f000:e068] 0xfe068: mov %edx,%ss
[f000:e06a] 0xfe06a: mov $0x7000,%sp
[f000:e070] 0xfe070: mov $0x2d4e,%dx
[f000:e076] 0xfe076: jmp 0x5575ff02
Whereas, dumping the instructions from memory directly using the (gdb) x /20i 0xfe05b
command yields the following instructions
0xfe05b: cmpw $0xffc8,%cs:(%esi)
0xfe060: jo 0xfe062
0xfe062: jne 0xd241d416
0xfe068: mov %edx,%ss
0xfe06a: mov $0x7000,%sp
0xfe06e: add %al,(%eax)
0xfe070: mov $0x2d4e,%dx
0xfe074: verw %cx
0xfe077: xchg %ebx,(%esi)
0xfe079: push %bp
0xfe07b: push %di
0xfe07d: push %si
0xfe07f: push %bx
0xfe081: sub $0x70,%sp
0xfe085: mov %ax,%di
0xfe088: mov 0x4(%bx,%si),%si
0xfe08d: mov %cs:0x2c(%bp),%bl
0xfe093: icebp
0xfe094: ljmp *(%esi)
As you can see the instructions are not the same at all; why is this the case? I suspect that gdb
is failing to recognise where individual instructions end and begin, so it's interpreting them incorrectly. But then again, why so?