Page 1 of 1

bochs/gdb weirdness with register values

Posted: Sun Jan 27, 2013 11:53 am
by justin
I am using gdb with bochs and it is mixing up the values of the different registers. Below is the output from gdb followed by the output from bochs when I terminate bochs at the breakpoint. It seems that bochs is getting the registers correct while gdb is mixing them up. gdb is getting the right numbers but calling them by the wrong register name. For example, gdb reports eip as "4" while it is actually esi which has the value "4". Does anybody know why this is happening? Thank you.

Code: Select all

(gdb) b SyscallHandler
Breakpoint 1 at 0x1a3a4: file kernel/syscall.c, line 43.
(gdb) c
Continuing.

Program received signal SIGTRAP, Trace/breakpoint trap.
0x00000004 in ?? ()
(gdb) info registers
eax            0xffbf7fbf	-4227137
ecx            0x0	0
edx            0x1	1
ebx            0x0	0
esp            0x4025a4	0x4025a4
ebp            0x0	0x0
esi            0xffbf7fbf	-4227137
edi            0x0	0
eip            0x4	0x4
eflags         0x0	[ ]
cs             0x0	0
ss             0x0	0
ds             0xffbf7fb3	-4227149
es             0x0	0
fs             0xffbf7f47	-4227257
gs             0x0	0

Code: Select all

00021550785i[CPU0 ] | RAX=00000000ffbf7fbf  RBX=0000000000000001
00021550785i[CPU0 ] | RCX=00000000004025a4  RDX=00000000ffbf7fbf
00021550785i[CPU0 ] | RSP=00000000ffbf7f47  RBP=00000000ffbf7fb3
00021550785i[CPU0 ] | RSI=0000000000000004  RDI=0000000000000000
00021550785i[CPU0 ] |  R8=0000000000000000   R9=0000000000000000
00021550785i[CPU0 ] | R10=0000000000000000  R11=0000000000000000
00021550785i[CPU0 ] | R12=0000000000000000  R13=0000000000000000
00021550785i[CPU0 ] | R14=0000000000000000  R15=0000000000000000
00021550785i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df if tf sf ZF af PF cf
00021550785i[CPU0 ] | SEG selector     base    limit G D
00021550785i[CPU0 ] | SEG sltr(index|ti|rpl)     base    limit G D
00021550785i[CPU0 ] |  CS:0008( 0001| 0|  0) 00000000 ffffffff 1 1
00021550785i[CPU0 ] |  DS:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00021550785i[CPU0 ] |  SS:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00021550785i[CPU0 ] |  ES:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00021550785i[CPU0 ] |  FS:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00021550785i[CPU0 ] |  GS:0010( 0002| 0|  0) 00000000 ffffffff 1 1
00021550785i[CPU0 ] |  MSR_FS_BASE:0000000000000000
00021550785i[CPU0 ] |  MSR_GS_BASE:0000000000000000
00021550785i[CPU0 ] | RIP=000000000001a3a4 (000000000001a3a4)

Re: bochs/gdb weirdness with register values

Posted: Sun Jan 27, 2013 4:34 pm
by Combuster
It looks like GDB is reading bochs' 64-bit CPU dump as a 32-bit one. Do you have a x86_64 gdb?

Re: bochs/gdb weirdness with register values

Posted: Sun Jan 27, 2013 9:00 pm
by justin
Thanks Combuster. Adding

Code: Select all

set archi i386:x86-64
to my .gdbinit did the trick.