06-26-04 04:07 PM
In article <55b15169.0406260622.4b5864a@posting.google.com>,
jabro <jabroeng@yahoo.com> wrote:
>Years ago, in the time of IRIX-6.2, I wrote a very tiny (just one
>screen of code) debugger for single-stepping, inspired in the code I
>found in an old book (whose name I don't remember). Such code was
>based on ptrace(). It used to work fine, but I tried it today with a
>current IRIX version, and it no longer works (once the child is in
>trace mode, all subsequent ptrace calls return "No such process" --I
>tried it with a lot of executables and the error was always the same
>--that error never happened with 6.2).
>
>After googling, I found that ptrace() is not recommended in IRIX, and
>that the "/proc" way of life should be used instead. Maybe that's the
>reason of the errors I'm getting.
We have not tested ptrace in years.
So your result is not particularly surprising.
>Can anybody point me to sample code of the simplest single-stepping
>debugger which could be written with /proc? I already looked at the
>source code of some debuggers, but they're too big to be used as a
>sample for learning.
>
>Can the simplest /proc-based debugger be as _tiny_ as the simplest
>ptrace-based one?
I believe so, but am not going to try to prove it :-)
Use open(2) on the /proc/<pid>.
Use the resulting fd to do ioctl()s on the process.
Use PIOCSTOP to stop the process, PIOCRUN (with flag PRSTEP) to step
the process.
The documented /proc operations work on the process.
Not per-thread, but on all threads (if it is a pthreads process, I mean).
david anderson
[ Post a follow-up to this message ]
|