sync: что-то химичу с точками останова

This commit is contained in:
Miheev Egor
2024-10-31 01:17:50 +03:00
parent dd6c23d79f
commit 88e75e848a
3 changed files with 36 additions and 7 deletions

View File

@ -11,6 +11,28 @@
int stats;
struct user_regs_struct regs;
void continue_execution(pid_t pid)
{
ptrace(PTRACE_CONT, pid, DONT_CARE, DONT_CARE);
int wait_status;
int options = 0;
waitpid(pid, &wait_status, options);
return;
}
void print_rax(pid_t pid)
{
ptrace(PTRACE_GETREGS, pid, DONT_CARE, &regs);
printf("rax = %llu\n", regs.rax);
return;
}
void step(pid_t pid)
{
ptrace(PTRACE_SINGLESTEP, pid, DONT_CARE, DONT_CARE);
return;
}
int main()
{
printf("procces is run ");
@ -25,15 +47,18 @@ int main()
}
else if(pid > 0)
{
char buff;
printf(" -- parrent\n");
for (int i = 0; i < 4; i++)
{
continue_execution(pid);
do {
waitpid(pid, &stats, 0);
printf("____PARENT_STAT: %d____\n", stats);
ptrace(PTRACE_GETREGS, pid, DONT_CARE, &regs);
printf("rax = %llu\n", regs.rax);
printf("stats - %d", stats);
print_rax(pid);
ptrace(PTRACE_SINGLESTEP, pid, DONT_CARE, DONT_CARE);
}
printf("enter any: ");
read(0, &buff, 1);
printf("\n");
} while(stats);
printf("____AFTER_TRACE_PARRENT____\n");
}
return 0;