ptrace and thread

David Xu davidxu at freebsd.org
Tue Jan 13 19:18:03 PST 2004


I am current working on debug support for KSE thread program, however I 
found
ptrace interface is not thread-aware,  in a threaded program, I need to 
get/set registers
set for individual threads,  current ptrace can not support that 
features, there are two
ways to support these requirements:

1. keep current ptrace interface,  add a command for example 
PT_SETDTHREAD to
   set current thread for debug, and subsequent request for example 
PT_SETREGS and
   PT_GETREGS will work on the thread, for single thread process, the 
default current
   thread is always the first thread in the process, this way we needn't 
change legacy debugger
   code.

2. introduce a second ptrace syscall, and accept a new parameter tid 
(thread id),
   the PT_SETREGS and PT_GETREGS will use the tid to operate on 
corresponding
   thread.

For first method, I have a  patch  there:
http://people.freebsd.org/~davidxu/kse/ptrace.diff
The patch also includes some bits to support KSE debug,  not just for 
pure 1:1 threading.

David Xu




More information about the freebsd-arch mailing list