Wednesday, June 23, 2010

How gdb and ioctl works

1. How gdb breakpoint works

(http://www.delorie.com/gnu/docs/gdb/gdbint_toc.html#SEC_Contents : GDB INTERNALS)

The basic theory is that GDB will replace a program instruction with a trap, illegal divide, or some other instruction that will cause an exception, and then when it's encountered, GDB will take the exception and stop the program. When the user says to continue, GDB will restore the original instruction, single-step, re-insert the trap, and continue on.

Since it literally overwrites the program being tested, the program area must be writable, so this technique won't work on programs in ROM. It can also distort the behavior of programs that examine themselves, although such a situation would be highly unusual.


2. How IOCTL works

No comments:

Post a Comment