> Good. In any case I believe utrace_get_signal() and utrace_report_jctl() > should not play with ->stopped. This really simplifies the code and > what ->stopped == T means.
I am open to any such sort of clean-up. If you change something that had a special rationale, I'll explain what it was so we address the original intent. > Yes, I thought about this too. > > But until we kill the ->stopped flag as you suggested, > > > It means exactly: > > ->state == TASK_TRACED || > > (->exit_state && !(->utrace_flags & _UTRACE_DEATH_EVENTS)) > > we still have to clear ->stopped after wake up from TASK_STOPPED. Yes. > (this change also breaks ptrace_resume() but this is fixeable). I can't tell which code you are talking about here. But the only ptrace_resume I care about is the new one true ptrace based from scratch on cleaned-up utrace, which you haven't written yet. > But personally I never liked the fact that ptrace_check_attach() does > s/TASK_STOPPED/TASK_TRACED/. Because I think this creates the unfixeable > ptrace && jctl-group-stop problems. The bookkeeping of ->group_stop_count > in utrace_stop() (and in ptrace_stop()) is just wrong and imho should be > removed. And do_signal_stop() should not take TASK_TRACED threads into > account. Why do you think they are unfixable? The reason that switching into TASK_TRACED is good is that it (and only it) ensures that SIGCONT won't wake the thread up. As long as it's in TASK_STOPPED, any examination loop (prepare/finish_examine, or task_current_syscall, i.e. the "wait_task_inactive before and after" check for no csw) can experience a hiccup if a normal SIGCONT comes along. It seems far better that it just not wake up (i.e. any csw) while UTRACE_STOP, except for SIGKILL (and stray wake_up_process or whatever, but any of those are most-bets-off anyway and we hope few or none still exist). For do_signal_stop it's right to consider TASK_TRACED threads as stopped. The purpose of the group-stop bookkeeping is to make sure that when we declare the whole process stopped (SIGNAL_STOP_STOPPED, send SIGCHLD to real parent, wait_task_stopped reports, etc.) then no more user instructions will run in any thread, nor any user syscall in progress complete. If some threads are in TASK_TRACED, then they won't run any such things (if we get the bookkeeping right). It would be wrong to make the whole-process stop fail to finish while the debugger holds one thread in TASK_TRACED. The bookkeeping should ensure that when a TASK_TRACED thread was counted as stopped, then utrace never wakes it up but instead puts it in TASK_STOPPED so it's as if it had been in TASK_STOPPED throughout. If SIGCONT came along and woke the other threads up, then the whole process can safely be considered resumed when every thread is out of TASK_STOPPED--either resumed, or still in TASK_TRACED because of UTRACE_STOP. Then UTRACE_RESUME et al must be sure that each task winds up correctly either running or in TASK_STOPPED as now appropriate for the process. I'm open to all manner of reorganization of the bookkeeping. But please explain how what you propose addresses these ideas. Thanks, Roland