0

If I understand correctly, linux gdb breakpoints now work by overwriting opcodes with 'int 3' and ptracing when those are hit. Ptrace hasn't been around forever. How did breakpoints work before ptrace was introduced into the kernel?

user2856949
  • 317
  • 2
  • 6

1 Answers1

3

I'd have to disagree with you assumption: ptrace has been around practically forever:

ptrace was first implemented in Seventh Edition Unix [1979], and was present in both the SVr4 [1989] and 4.3BSD [1986] branches of Unix.

(source: Wikipedia, 'ptrace', I added the years)

gdbs initial release was in 1986.

As far as Linux is concerned, ptrace has been a syscall since Linux 1.0 - you can find the initial versions in man 2 syscalls.

(I am aware that this does not answer the question "how do you debug without ptrace" and I'm happy to delete this as soon as a more technical answer comes along, but until then I think this provides some relevant historical perspective.)

us2012
  • 16,083
  • 3
  • 46
  • 62