0xC0000022L
0xC0000022L

Reputation: 21259

How to skip (not execute!) a call in GDB when debugging without symbols?

I am debugging a Linux program to which I have no symbols. The binary is stripped. No big deal, I can handle that. However, how can I skip a call inside the debugger when I reach a particular piece of code?

What I am asking is not this: Use gdb to debug assembly, how to skip a call

I am interested if I have a:

 call 0x12345678
 ...

to jump to the ... straight without executing the call.

How can I do that?

Upvotes: 1

Views: 484

Answers (2)

0xC0000022L
0xC0000022L

Reputation: 21259

After some more reading I found the solution.

In my case I know the opcode for the call is fives bytes long, so I can resolve it by setting the GDB register name $pc ("program counter") to jump over it:

set $pc+=5

According to the comment on this answer by Employed Russian the following provides the same functionality:

jump *$pc+5

Assuming you have the call at address 0x01234567 and want to skip five bytes, you can do the following in your .gdbinit:

b *0x01234567
commands 1
x/i $pc
echo Not executing the call\n
set $pc+=5
x/i $pc
end

Upvotes: 2

Alexey Frunze
Alexey Frunze

Reputation: 62048

Set the rip value to the address of the instruction right after this call 0x12345678.

Upvotes: 1

Related Questions