Jesus Ramos
Jesus Ramos

Reputation: 23266

Single step a process by one assembly instruction

When you execute a single step operation using ptrace does the process do one "line" of code or does it do one line of assembly instead. If it's the former case is there a way to step a process in linux by one processor instruction only?

I mean to do this within the kernel but the GDB source is kind of large and it's hard to track exactly what it's doing to do it's ASM singlestepping. I want to single step a process it's just that I'm not sure what the exact behavior of ptrace's single step is (just 1 instruction or more?)

Upvotes: 0

Views: 1195

Answers (2)

Samir Baid
Samir Baid

Reputation: 1178

It does one line of assembly. You can verify this by opening two sessions, in one session you can have your program running which displays the contents of IP register( EIP in 32 bit and RIP in 64 bit) and in other run objdump using the following command - objdump -d -j.code | less and verify

Upvotes: 2

Mahmoud Al-Qudsi
Mahmoud Al-Qudsi

Reputation: 29579

Use gdb: http://condor.depaul.edu/glancast/373class/docs/gdb.html#Running_the_Program_being_Debugged

If you have access to the source code or debug symbols, you can step one line at a time. If you don't, you'll have to step one instruction at a time.

Upvotes: 0

Related Questions