Hi,
Just found step-jump-cont (utrace wiki page) is updated. So take a quick
test on x86_64/i686 with upstream 2.6.25-rc5 kernel.
With the help of stap marker, I got the following analysis:
Non-strict case:
1. Wait child stop upon SIGUSR1
2. Set singlestep on child: enable TIF_FORCED_TF and set
regs->flags |= X86_EFLAGS_TF.
3. Read child flags, return value contains no TF (the real value
hiddend by TIF_FORCED_TF)
4. Write next instruction to child
5. Continue the child, disable TIF_SINGLESTEP, test and clear
TIF_FORCED_TF, unset regs->flags
6. Child stop on SIGUSR2
7. Write next instruction to child
8. Continue the child, disable TIF_SINGLESTEP
9. Child stop on SIGUSR2
Strict case:
1. Wait child stop upon SIGUSR1
2. Set singlestep on child: enable TIF_FORCED_TF and set
regs->flags |= X86_EFLAGS_TF.
3. Read child flags, return value contains no TF (the real value
hiddend by TIF_FORCED_TF)
4. Write next instruction to child and Set regs->flags.
TIF_FORCED_TF is cleared because value contains TF
5. Continue the child, disable TIF_SINGLESTEP
6. Child stop on SIGTRAP because of X86_EFLAGS_TF in flags
Both of them are correct in current kernel path. For non-strict case,
PTRACE_CONT couldn't clear TF in the
absence of TIF_FORCED_TF. I think it will keep failed until modifying
kernel/testcase.
Regards,
Wenji