David Xu cbf4e354ec Add code to support debugging threaded process.
1. Add tm_lwpid into kse_thr_mailbox to indicate which kernel
   thread current user thread is running on. Add tm_dflags into
   kse_thr_mailbox, the flags is written by debugger, it tells
   UTS and kernel what should be done when the process is being
   debugged, current, there two flags TMDF_SSTEP and TMDF_DONOTRUNUSER.

   TMDF_SSTEP is used to tell kernel to turn on single stepping,
   or turn off if it is not set.

   TMDF_DONOTRUNUSER is used to tell kernel to schedule upcall
   whenever possible, to UTS, it means do not run the user thread
   until debugger clears it, this behaviour is necessary because
   gdb wants to resume only one thread when the thread's pc is
   at a breakpoint, and thread needs to go forward, in order to
   avoid other threads sneak pass the breakpoints, it needs to remove
   breakpoint, only wants one thread to go. Also, add km_lwp to
   kse_mailbox, the lwp id is copied to kse_thr_mailbox at context
   switch time when process is not being debugged, so when process
   is attached, debugger can map kernel thread to user thread.

2. Add p_xthread to proc strcuture and td_xsig to thread structure.
   p_xthread is used by a thread when it wants to report event
   to debugger, every thread can set the pointer, especially, when
   it is used in ptracestop, it is the last thread reporting event
   will win the race. Every thread has a td_xsig to exchange signal
   with debugger, thread uses TDF_XSIG flag to indicate it is reporting
   signal to debugger, if the flag is not cleared, thread will keep
   retrying until it is cleared by debugger, p_xthread may be
   used by debugger to indicate CURRENT thread. The p_xstat is still
   in proc structure to keep wait() to work, in future, we may
   just use td_xsig.

3. Add TDF_DBSUSPEND flag, the flag is used by debugger to suspend
   a thread. When process stops, debugger can set the flag for
   thread, thread will check the flag in thread_suspend_check,
   enters a loop, unless it is cleared by debugger, process is
   detached or process is existing. The flag is also checked in
   ptracestop, so debugger can temporarily suspend a thread even
   if the thread wants to exchange signal.

4. Current, in ptrace, we always resume all threads, but if a thread
   has already a TDF_DBSUSPEND flag set by debugger, it won't run.

Encouraged by: marcel, julian, deischen
2004-07-13 07:20:10 +00:00
..
2003-06-11 00:56:59 +00:00
2003-06-11 00:56:59 +00:00
2003-06-11 00:56:59 +00:00
2003-06-11 00:56:59 +00:00
2004-07-02 00:38:56 +00:00
2004-06-17 17:16:53 +00:00
2004-07-10 21:36:01 +00:00
2003-06-11 00:56:59 +00:00
2004-05-03 22:54:46 +00:00
2004-07-10 21:36:01 +00:00
2003-06-11 00:56:59 +00:00
2004-07-10 21:36:01 +00:00
2004-07-10 21:36:01 +00:00
2004-07-10 21:36:01 +00:00
2004-07-10 21:36:01 +00:00
2003-06-11 00:56:59 +00:00
2004-06-21 22:34:57 +00:00
2004-06-11 11:16:26 +00:00
2004-06-29 03:13:54 +00:00
2003-06-11 00:56:59 +00:00
2003-06-11 06:34:30 +00:00
2003-06-11 06:34:30 +00:00
2004-07-10 21:38:22 +00:00
2003-06-11 00:56:59 +00:00
2003-06-11 00:56:59 +00:00
2003-06-11 00:56:59 +00:00
2004-07-10 21:43:23 +00:00
2004-07-10 21:42:16 +00:00
2004-07-02 00:38:56 +00:00
2003-06-11 00:56:59 +00:00
2004-05-30 20:34:58 +00:00
2004-05-30 20:34:58 +00:00
2004-07-10 21:43:23 +00:00
2004-06-25 22:10:20 +00:00
2004-06-17 17:16:53 +00:00
2004-05-30 20:34:58 +00:00
2004-07-06 23:40:40 +00:00
2004-07-10 21:47:53 +00:00