Following is my requirement.
while process A is running.
- attach Process A from B with PTRACE_ATTACH.
- Start a Loop
- Stop Process A
- read registers
- Resume Process A
- sleep(1)
- end loop
- detach A
i am facing issue with Start and Resume Process A from the loop. i tried combination of kill(pid,SIGSTOP), kill(pid,SIGCONT), PTRACE_CONT. but didnt work.
any other solutions please?
Thanks in advance. Sandeep
Following code is working for me and seems to fulfill your requirements -
A.c
B.c - Tracing process
Signal passed -
Output of A -
Output of B -
We see that B displays EIP value for each signal delivered to client. Basically signal is not getting delivered to A instead B wakes up and examines EIP and then continues in the loop. You can modify the code to deliver the signal if you want.
This is what i understood from your question. If i understood something else please let me know and i'll update answer accordingly
Sounds like a very challenging project to undertake from scratch. Have you considered leveraging the GNU debugger in any way? In particular there is an long running sub-project called libgdb2 which may suit your purposes even though it is far from finished or stable at this time.
You could try scripting/interfacing with gdb in the same way that a lot of IDE's do. See also http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/gdb/gdb-mi.html