Results 1 to 1 of 1
Enjoy an ad free experience by logging in. Not a member yet? Register.
- Join Date
- Jul 2010
waitpid unreliable to determine enf of ptrace singlestep
single step a ptraced thread.
wait fro the singlestep to end.
ptrace(PTRACE_SINGLESTEP, pid, 0,0);
int child = waitpid(pid, &status,, WUNTRACED);
problem is that some of the time I get:
child = -1 and errno=ECHILD
I dont know why sine I believe I am the only thread waithing for this pid
Anyway some of the time the thread just hasnt finished the single step and trying to use ptrace after the trace fails.
To overcome this I put an artificial "wait" which seems to work
struct user_regs_struct regs;
ptrace(PTRACE_GETREGS, _activePid, ®s, 0) ;
} while(ptrace(PTRACE_PEEKDATA, _activePid, regs.eip, 0) ==-1);
basically using busy ptrace to determine that the thread has stopped (otherwise ptrace fails).
I would appreciate if anyone can shed light on how exactly wait and ptrace work together. I have other places in my code where I have these spurious problems which I am putting similar hacks to.