Implementation notes

[DavidXu] By writing first revision of fbsd-threads.c to support M:N libpthread debugging, I recognized that gdb needs to single step a thread last we wait()ed if process is stopped because the thread hit a breakpoint, gdb will turn on single step state for the thread and only resume the thread if we type 'next' or 'step' to contine the debug process, this becauses, for example, on i386, if debugger uses int3 to insert a breakpoint in process's code segment, orignal machine code will be saved somewhere in debugger, and an int3 machine code overwrites the orignal instruction code, the machine code is only one byte, if thread hits the breakpoint, process will stop there, if we type 'next', however, orignal instruction should be restored and executed before process can be continued, but after the original instruction is executed, the breakpoint should be restored to avoid any other threads sneak pass the breakpoint, the way gdb uses is turning on single step flag (on i386, it is TF flag in %eflags register) and only resuming the wait()ed thread, because single step flag is turned on, thread executing will generate SIGTRAP after it executes orignal instruction, the thread now passes the breakpoint, and gdb re-inserts the breakpoint and resume all threads. My first attempt in fbsd-threads.c to support this requirement is suspending all threads explicitly except the thread gdb wants to resume, but problem is that we always schedule upcall in kernel if a thread generates a synchronous signal, but other system scope threads which does not belong to UTS may be holding UTS schedule lock, if we resume only the lwps belong to UTS in kernel, the UTS still can not RUN in userland because it will block on schedule lock, to resolve this problem, we don't schedule upcall when the thread hits a debug breakpoint or single step trap, in trapsignal(), we check if we are being debugged and signal is SIGTRAP, if it is true, we don't schedule upcall, this way we may resume and single step the thread without bothering UTS.