[comp.unix.aix] PT_STEP parameter to ptrace

shaffer@grad1.cis.upenn.edu (John Shaffer) (04/11/91)

I am working on an RS/6000 running AIX and am trying to use ptrace()
to single step instructions, but have run into a problem.

The "request" argument to ptrace() specifies the action for the ptrace()
call to perform.  In order to execute one instruction and return control
to the parent process, the PT_STEP paremeter is used (PT_SINGLE on some
machiness.

The problem is this:  The documentation does not specify a PT_STEP 
parameter but it is included in the file /usr/include/sys/ptrace.h.  It
is defined to have a value of 9 (i think, nevertheless it IS defined).

When trying to call ptrace() with this "request", I get an errno that says
that the request parameter is invalid.

Has anyone run into this? or know of a way around it so that one can 
single step instructions??  I figure it must be able to be done since
dbx can do it.

The program compiles and runs fine on an RT running BSD.

Any insight into this would be most appreciated. 
Thanx.  

john shaffer
shaffer@dsl.cis.upenn.edu

marc@stingray.austin.ibm.com (Marc J. Stephenson/140000;1C-22) (04/12/91)

PT_STEP is not supported in the AIX 3.1 kernel.  dbx and adb do not use
PT_STEP to perform single-stepping; it is done via inserting trap instructions
in the debuggee process (then replacing the original instruction).  FYI, dbx
use a tgte r2,r2 (trap if register 2 is greater than or equal to register 2,
a normally nonsensical instruction) for its traps.

The hardware does not support single-stepping, so it was decided to leave the
software trapping code at the application level rather than in ptrace(), where
all the same software trapping would have to take place.  

-- 
Marc Stephenson		      IBM PSPA (Personal System Programming - Austin,TX)
DISCLAIMER: The content of this posting is independent of official IBM position.
marc@stingray.austin.ibm.com 	VNET: MARC at AUSVMQ  	IBM T/L: 793-3796