Lines Matching refs:pid

39 static inline long sys_ptrace(long request, pid_t pid, unsigned long addr, unsigned long data)  in sys_ptrace()  argument
41 return syscall(__NR_ptrace, request, pid, addr, data); in sys_ptrace()
49 static long ptrace_getregs(pid_t pid, struct pt_regs *result) in ptrace_getregs() argument
51 return sys_ptrace(PTRACE_GETREGS, pid, 0, (unsigned long)result); in ptrace_getregs()
54 static long ptrace_setregs(pid_t pid, struct pt_regs *result) in ptrace_setregs() argument
56 return sys_ptrace(PTRACE_SETREGS, pid, 0, (unsigned long)result); in ptrace_setregs()
59 static long ptrace_cont(pid_t pid, long signal) in ptrace_cont() argument
61 return sys_ptrace(PTRACE_CONT, pid, 0, signal); in ptrace_cont()
64 static long ptrace_singlestep(pid_t pid, long signal) in ptrace_singlestep() argument
66 return sys_ptrace(PTRACE_SINGLESTEP, pid, 0, signal); in ptrace_singlestep()
69 static long ppc_ptrace_gethwdbginfo(pid_t pid, struct ppc_debug_info *dbginfo) in ppc_ptrace_gethwdbginfo() argument
71 return sys_ptrace(PPC_PTRACE_GETHWDBGINFO, pid, 0, (unsigned long)dbginfo); in ppc_ptrace_gethwdbginfo()
74 static long ppc_ptrace_sethwdbg(pid_t pid, struct ppc_hw_breakpoint *bp_info) in ppc_ptrace_sethwdbg() argument
76 return sys_ptrace(PPC_PTRACE_SETHWDEBUG, pid, 0, (unsigned long)bp_info); in ppc_ptrace_sethwdbg()
79 static long ppc_ptrace_delhwdbg(pid_t pid, int bp_id) in ppc_ptrace_delhwdbg() argument
81 return sys_ptrace(PPC_PTRACE_DELHWDEBUG, pid, 0L, bp_id); in ppc_ptrace_delhwdbg()
84 static long ptrace_getreg_pc(pid_t pid, void **pc) in ptrace_getreg_pc() argument
89 err = ptrace_getregs(pid, &regs); in ptrace_getreg_pc()
98 static long ptrace_setreg_pc(pid_t pid, void *pc) in ptrace_setreg_pc() argument
103 err = ptrace_getregs(pid, &regs); in ptrace_setreg_pc()
109 err = ptrace_setregs(pid, &regs); in ptrace_setreg_pc()
116 static int perf_event_open(struct perf_event_attr *attr, pid_t pid, int cpu, in perf_event_open() argument
119 return syscall(__NR_perf_event_open, attr, pid, cpu, group_fd, flags); in perf_event_open()
175 static int check_watchpoints(pid_t pid) in check_watchpoints() argument
179 FAIL_IF_MSG(ppc_ptrace_gethwdbginfo(pid, &dbginfo), "PPC_PTRACE_GETHWDBGINFO failed"); in check_watchpoints()
190 static int ptrace_fork_child(pid_t *pid) in ptrace_fork_child() argument
194 *pid = fork(); in ptrace_fork_child()
196 if (*pid < 0) in ptrace_fork_child()
199 if (!*pid) { in ptrace_fork_child()
204 FAIL_IF_MSG(waitpid(*pid, &status, 0) == -1, "Failed to wait for child"); in ptrace_fork_child()
231 pid_t pid; /* PID of child process */ in same_watch_addr_test() local
237 err = ptrace_fork_child(&pid); in same_watch_addr_test()
241 if (!pid) { in same_watch_addr_test()
246 err = check_watchpoints(pid); in same_watch_addr_test()
251 perf_fd = perf_watchpoint_open(pid, &value, sizeof(value)); in same_watch_addr_test()
256 bp_id = ppc_ptrace_sethwdbg(pid, &bp_info); in same_watch_addr_test()
260 FAIL_IF_MSG(ptrace_cont(pid, 0), "Failed to continue child"); in same_watch_addr_test()
262 FAIL_IF_MSG(waitpid(pid, &status, 0) == -1, "Failed to wait for child"); in same_watch_addr_test()
264 FAIL_IF_MSG(ptrace_getreg_pc(pid, &pc), "Failed to get child PC"); in same_watch_addr_test()
275 FAIL_IF_MSG(ptrace_singlestep(pid, 0), "Failed to single step child"); in same_watch_addr_test()
277 FAIL_IF_MSG(waitpid(pid, &status, 0) == -1, "Failed to wait for child"); in same_watch_addr_test()
279 FAIL_IF_MSG(ptrace_getreg_pc(pid, &pc), "Failed to get child PC"); in same_watch_addr_test()
289 FAIL_IF_MSG(ppc_ptrace_delhwdbg(pid, bp_id), "Failed to remove old ptrace watchpoint"); in same_watch_addr_test()
290 bp_id = ppc_ptrace_sethwdbg(pid, &bp_info); in same_watch_addr_test()
292 FAIL_IF_MSG(ptrace_setreg_pc(pid, same_watch_addr_load), "Failed to set child PC"); in same_watch_addr_test()
293 FAIL_IF_MSG(ptrace_cont(pid, 0), "Failed to continue child"); in same_watch_addr_test()
295 FAIL_IF_MSG(waitpid(pid, &status, 0) == -1, "Failed to wait for child"); in same_watch_addr_test()
297 FAIL_IF_MSG(ptrace_getreg_pc(pid, &pc), "Failed to get child PC"); in same_watch_addr_test()
303 FAIL_IF_MSG(ptrace_cont(pid, 0), "Failed to continue child"); in same_watch_addr_test()
305 FAIL_IF_MSG(waitpid(pid, &status, 0) == -1, "Failed to wait for child"); in same_watch_addr_test()
307 FAIL_IF_MSG(ptrace_getreg_pc(pid, &pc), "Failed to get child PC"); in same_watch_addr_test()
317 FAIL_IF_MSG(ptrace_setreg_pc(pid, same_watch_addr_load), "Failed to set child PC"); in same_watch_addr_test()
318 FAIL_IF_MSG(ptrace_cont(pid, 0), "Failed to continue child"); in same_watch_addr_test()
320 FAIL_IF_MSG(waitpid(pid, &status, 0) == -1, "Failed to wait for child"); in same_watch_addr_test()
322 FAIL_IF_MSG(ptrace_getreg_pc(pid, &pc), "Failed to get child PC"); in same_watch_addr_test()
332 FAIL_IF_MSG(ppc_ptrace_delhwdbg(pid, bp_id), "Failed to remove old ptrace watchpoint"); in same_watch_addr_test()
333 bp_id = ppc_ptrace_sethwdbg(pid, &bp_info); in same_watch_addr_test()
335 FAIL_IF_MSG(ptrace_setreg_pc(pid, same_watch_addr_load), "Failed to set child PC"); in same_watch_addr_test()
336 FAIL_IF_MSG(ptrace_cont(pid, 0), "Failed to continue child"); in same_watch_addr_test()
338 FAIL_IF_MSG(waitpid(pid, &status, 0) == -1, "Failed to wait for child"); in same_watch_addr_test()
340 FAIL_IF_MSG(ptrace_getreg_pc(pid, &pc), "Failed to get child PC"); in same_watch_addr_test()
350 FAIL_IF_MSG(ptrace_setreg_pc(pid, same_watch_addr_load + 4), "Failed to set child PC"); in same_watch_addr_test()
351 FAIL_IF_MSG(ptrace_cont(pid, 0), "Failed to continue child"); in same_watch_addr_test()
353 FAIL_IF_MSG(waitpid(pid, &status, 0) == -1, "Failed to wait for child"); in same_watch_addr_test()
355 FAIL_IF_MSG(ptrace_getreg_pc(pid, &pc), "Failed to get child PC"); in same_watch_addr_test()
361 FAIL_IF_MSG(kill(pid, SIGKILL) != 0, "Failed to kill child"); in same_watch_addr_test()
385 pid_t pid; /* PID of child process */ in perf_then_ptrace_test() local
392 err = ptrace_fork_child(&pid); in perf_then_ptrace_test()
400 if (!pid) { in perf_then_ptrace_test()
405 err = check_watchpoints(pid); in perf_then_ptrace_test()
410 perf_fd = perf_watchpoint_open(pid, &perf_value, sizeof(perf_value)); in perf_then_ptrace_test()
416 bp_id = ppc_ptrace_sethwdbg(pid, &bp_info); in perf_then_ptrace_test()
420 FAIL_IF_MSG(ptrace_cont(pid, 0), "Failed to continue child"); in perf_then_ptrace_test()
422 FAIL_IF_MSG(waitpid(pid, &status, 0) == -1, "Failed to wait for child"); in perf_then_ptrace_test()
424 FAIL_IF_MSG(ptrace_getreg_pc(pid, &pc), "Failed to get child PC"); in perf_then_ptrace_test()
432 FAIL_IF_MSG(kill(pid, SIGKILL) != 0, "Failed to kill child"); in perf_then_ptrace_test()