freebsd-nq/sys
David Xu 4d47dc5549 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:33:40 +00:00
..
alpha Push down the acquisition and release of the page queues lock into 2004-07-13 02:49:22 +00:00
amd64 Add ptrace_clear_single_step(), alpha already has it for years, the function 2004-07-13 07:22:56 +00:00
arm Push down the acquisition and release of the page queues lock into 2004-07-13 02:49:22 +00:00
boot Change the following environment variables to kernel options: 2004-07-08 22:35:36 +00:00
cam Update for the KDB framework: 2004-07-10 20:56:43 +00:00
coda Remove 'td = curthread' that shadows the arguments to coda_root(). 2004-07-12 14:11:26 +00:00
compat Make NdisReadPcmciaAttributeMemory() and NdisWritePcmciaAttributeMemory() 2004-07-11 00:19:30 +00:00
conf pccard no longer requires a count because the floppy driver that 2004-07-13 02:37:40 +00:00
contrib Clean up a bunch of white-space difference with IPFilter source as well as 2004-07-11 10:13:05 +00:00
crypto Use __FBSDID(). 2004-06-14 00:38:54 +00:00
ddb Re-add the gdb command. It was removed to be replaced by something 2004-07-12 01:38:07 +00:00
dev Set fdc_dev in attach 2004-07-13 02:44:40 +00:00
doc Experimental support for using doxygen to generate kernel documentation. 2004-07-11 16:13:57 +00:00
fs Remove 'td = curthread' that shadows the arguments to coda_root(). 2004-07-12 14:11:26 +00:00
gdb Introduce the GDB debugger backend for the new KDB framework. The 2004-07-10 17:47:22 +00:00
geom Implement "FAST" mode for GEOM_STRIPE class and turn it on by default. 2004-07-09 14:30:09 +00:00
gnu Make VFS_ROOT() and vflush() take a thread argument. 2004-07-12 08:14:09 +00:00
i4b Catch up with the new world order of Netgraph metas. 2004-07-06 06:43:45 +00:00
i386 Add ptrace_clear_single_step(), alpha already has it for years, the function 2004-07-13 07:22:56 +00:00
ia64 Add ptrace_clear_single_step(), alpha already has it for years, the function 2004-07-13 07:22:56 +00:00
isa Partially revert previous commit. Calling getit() unconditionally fixed 2004-07-11 17:50:59 +00:00
isofs/cd9660 Make VFS_ROOT() and vflush() take a thread argument. 2004-07-12 08:14:09 +00:00
kern Add code to support debugging threaded process. 2004-07-13 07:33:40 +00:00
libkern Import libkern arm specific bits. 2004-05-14 12:28:31 +00:00
modules Remove stray line with just a tab 2004-07-12 21:59:06 +00:00
net Use ETHER_IS_MULTICAST() consistently in ether_resolvemulti(). 2004-07-09 05:26:27 +00:00
net80211 Link ALTQ to the build and break with ABI for struct ifnet. Please recompile 2004-06-13 17:29:10 +00:00
netatalk Procotol control block locking for netatalk DDP. 2004-07-12 18:39:59 +00:00
netatm The socket field so_state is used to hold a variety of socket related 2004-06-14 18:16:22 +00:00
netgraph Introduce a global mtx 'ngsocketlist_mtx' to protect the global 2004-07-12 04:45:46 +00:00
netinet After each label in tcp_input(), assert the inpcbinfo and inpcb lock 2004-07-12 19:28:07 +00:00
netinet6 Link ALTQ to the build and break with ABI for struct ifnet. Please recompile 2004-06-13 17:29:10 +00:00
netipsec Add required includes for post-sorwakeup() change to fix FAST_IPSEC 2004-06-23 01:58:22 +00:00
netipx Constify 'spx_backoff'. 2004-07-12 19:35:29 +00:00
netkey Merge next step in socket buffer locking: 2004-06-21 00:20:43 +00:00
netnatm Constify send and receive space constants in natm. 2004-06-24 03:11:29 +00:00
netncp Do the dreaded s/dev_t/struct cdev */ 2004-06-16 09:47:26 +00:00
netsmb Merge additional socket buffer locking from rwatson_netperf: 2004-06-17 22:48:11 +00:00
nfs
nfs4client Make VFS_ROOT() and vflush() take a thread argument. 2004-07-12 08:14:09 +00:00
nfsclient Turn off SO_REUSEADDR and SO_REUSEPORT, they were causing EADDRINUSE 2004-07-13 05:42:59 +00:00
nfsserver Do not call sorecieve() in the context of a socket callback as it causes 2004-07-13 07:05:38 +00:00
opencrypto Do the dreaded s/dev_t/struct cdev */ 2004-06-16 09:47:26 +00:00
pc98 Add ptrace_clear_single_step(), alpha already has it for years, the function 2004-07-13 07:22:56 +00:00
pccard Do the dreaded s/dev_t/struct cdev */ 2004-06-16 09:47:26 +00:00
pci Update for the KDB framework: 2004-07-10 21:47:53 +00:00
posix4
powerpc Add ptrace_clear_single_step(), alpha already has it for years, the function 2004-07-13 07:22:56 +00:00
rpc Constify 'rpcclnt_backoff'. 2004-07-12 19:37:08 +00:00
security Update for the KDB framework: 2004-07-10 21:47:53 +00:00
sparc64 Add ptrace_clear_single_step(), alpha already has it for years, the function 2004-07-13 07:22:56 +00:00
sys Implement following commands: PT_CLEARSTEP, PT_SETSTEP, PT_SUSPEND 2004-07-13 07:25:24 +00:00
tools Pass doxygen doc comments through to the output. 2004-07-11 16:14:24 +00:00
ufs Make VFS_ROOT() and vflush() take a thread argument. 2004-07-12 08:14:09 +00:00
vm Remove an unused and unimplemented sysctl. (For the record, it was marked 2004-07-12 17:45:37 +00:00
Makefile Try harder not to compile anything in sys/boot for arm. 2004-05-16 00:19:12 +00:00