tags:

views:

24

answers:

2

suppose the following is the asm code

 8048deb:       e8 41 05 00 00          call   8049331 <explode_bomb>
 8048df0:       03 73 f4                add    -0xc(%ebx),%esi
 8048df3:       83 c3 04                add    $0x4,%ebx
 8048df6:       8d 45 f8                lea    -0x8(%ebp),%eax
 8048df9:       39 c3                   cmp    %eax,%ebx
 8048dfb:       75 e7                   jne    8048de4 <phase_2+0x22>

i set a breakpoint at the last line, by this time, i am expecting both %eax and %ebx to have something stored in them.

in gdb, i do

p/x $ebx and get

No registers.

What does this error mean? How can i get the current content stored in a register?

Please steer me in the right direction

+1  A: 

Just do

 info register

It will give you the registers and their current values.

I do not believe there is a way to print/get just the value of ebx, eax, ecx, etc. You can, however print the value of the frame pointer, program counter, process status, and stack pointer registers using

p $fp
p $pc
p $ps
p $sp
Kizaru
+2  A: 

p/x $ebx works just fine for me. (Or rather, p/x $rbx, because i'm testing in a 64-bit OS, but I imagine that p/x $ebx would work in 32-bit.) The application must be running. If I try to do p/x $rbx when the application has not started or has already exited, I do get "no registers". Are you sure that the breakpoint is hit?

indeed you are right. i kept missing the fact that while breakpoint was set, i was never getting to it. program was exiting before that due to another thing i missed. Again, thank you
mac