Lines Matching refs:pid

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