feat: минимальное решение
This commit is contained in:
40
08-debugging/test.c
Normal file
40
08-debugging/test.c
Normal file
@ -0,0 +1,40 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<unistd.h>
|
||||
#include<sys/types.h>
|
||||
#include<sys/ptrace.h>
|
||||
#include<sys/user.h>
|
||||
#include<sys/wait.h>
|
||||
|
||||
#define DONT_CARE 0
|
||||
|
||||
int stats;
|
||||
struct user_regs_struct regs;
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("procces is run ");
|
||||
pid_t pid;
|
||||
pid = fork();
|
||||
if (pid==0)
|
||||
{
|
||||
printf(" -- child\n");
|
||||
ptrace(PTRACE_TRACEME, 0, 0, 0);
|
||||
execl("./testee", "testee", NULL);
|
||||
printf("____AFTER_TRACE_CHILD____\n");
|
||||
}
|
||||
else if(pid > 0)
|
||||
{
|
||||
printf(" -- parrent\n");
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
waitpid(pid, &stats, 0);
|
||||
printf("____PARENT_STAT: %d____\n", stats);
|
||||
ptrace(PTRACE_GETREGS, pid, DONT_CARE, ®s);
|
||||
printf("rax = %llu\n", regs.rax);
|
||||
ptrace(PTRACE_SINGLESTEP, pid, DONT_CARE, DONT_CARE);
|
||||
}
|
||||
printf("____AFTER_TRACE_PARRENT____\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user