Single-stepping through /proc
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > Single-stepping through /proc




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Single-stepping through /proc  
jabro


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
06-26-04 03:11 PM

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.

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?

TIA





[ Post a follow-up to this message ]



    Re: Single-stepping through /proc  
David Anderson


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
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 ]



    Sponsored Links  




 





   All times are GMT. The time now is 08:35 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register