Lines Matching +full:wait +full:- +full:on +full:- +full:read
1 // SPDX-License-Identifier: GPL-2.0+
8 #include <sys/wait.h>
13 * Child subroutine that performs a load on the address, then traps
24 * Child subroutine that performs a load on the first address, then a load on
126 attr->type = PERF_TYPE_BREAKPOINT; in perf_user_event_attr_set()
127 attr->size = sizeof(struct perf_event_attr); in perf_user_event_attr_set()
128 attr->bp_type = HW_BREAKPOINT_R; in perf_user_event_attr_set()
129 attr->bp_addr = (u64)addr; in perf_user_event_attr_set()
130 attr->bp_len = len; in perf_user_event_attr_set()
131 attr->exclude_kernel = 1; in perf_user_event_attr_set()
132 attr->exclude_hv = 1; in perf_user_event_attr_set()
140 return perf_event_open(&attr, child_pid, -1, -1, 0); in perf_watchpoint_open()
146 * A perf counter is retrieved by the read() syscall. It contains in perf_read_counter()
149 ssize_t len = read(perf_fd, count, sizeof(*count)); in perf_read_counter()
152 return -1; in perf_read_counter()
160 info->version = 1; in ppc_ptrace_init_breakpoint()
161 info->trigger_type = type; in ppc_ptrace_init_breakpoint()
162 info->condition_mode = PPC_BREAKPOINT_CONDITION_NONE; in ppc_ptrace_init_breakpoint()
163 info->addr = (u64)addr; in ppc_ptrace_init_breakpoint()
164 info->addr2 = (u64)addr + len; in ppc_ptrace_init_breakpoint()
165 info->condition_value = 0; in ppc_ptrace_init_breakpoint()
167 info->addr_mode = PPC_BREAKPOINT_MODE_EXACT; in ppc_ptrace_init_breakpoint()
169 info->addr_mode = PPC_BREAKPOINT_MODE_RANGE_INCLUSIVE; in ppc_ptrace_init_breakpoint()
173 * Checks if we can place at least 2 watchpoints on the child process
187 * ptrace-ing. Both the parent and child return from this, though
203 /* Synchronise on child SIGSTOP */ in ptrace_fork_child()
204 FAIL_IF_MSG(waitpid(*pid, &status, 0) == -1, "Failed to wait for child"); in ptrace_fork_child()
214 * We expect ptrace to take 'priority', as it is has before-execute
217 * The perf counter should not be incremented yet because perf has after-execute
234 unsigned long value; /* Dummy value to be read/written to by child */ in same_watch_addr_test()
250 /* Place a perf watchpoint counter on value */ in same_watch_addr_test()
254 /* Place a ptrace watchpoint on value */ in same_watch_addr_test()
259 /* Let the child run. It should stop on the ptrace watchpoint */ in same_watch_addr_test()
262 FAIL_IF_MSG(waitpid(pid, &status, 0) == -1, "Failed to wait for child"); in same_watch_addr_test()
265 FAIL_IF_MSG(pc != same_watch_addr_load, "Child did not stop on load instruction"); in same_watch_addr_test()
271 FAIL_IF_MSG(perf_read_counter(perf_fd, &perf_count), "Failed to read perf counter"); in same_watch_addr_test()
277 FAIL_IF_MSG(waitpid(pid, &status, 0) == -1, "Failed to wait for child"); in same_watch_addr_test()
281 FAIL_IF_MSG(perf_read_counter(perf_fd, &perf_count), "Failed to read perf counter"); in same_watch_addr_test()
285 * Set up a ptrace watchpoint on the value again and trigger it. in same_watch_addr_test()
295 FAIL_IF_MSG(waitpid(pid, &status, 0) == -1, "Failed to wait for child"); in same_watch_addr_test()
298 FAIL_IF_MSG(pc != same_watch_addr_load, "Child did not stop on load trap"); in same_watch_addr_test()
299 FAIL_IF_MSG(perf_read_counter(perf_fd, &perf_count), "Failed to read perf counter"); in same_watch_addr_test()
305 FAIL_IF_MSG(waitpid(pid, &status, 0) == -1, "Failed to wait for child"); in same_watch_addr_test()
308 FAIL_IF_MSG(pc != same_watch_addr_trap, "Child did not stop on end trap"); in same_watch_addr_test()
309 FAIL_IF_MSG(perf_read_counter(perf_fd, &perf_count), "Failed to read perf counter"); in same_watch_addr_test()
314 * we should reach the end trap (because ptrace is one-shot) and have in same_watch_addr_test()
320 FAIL_IF_MSG(waitpid(pid, &status, 0) == -1, "Failed to wait for child"); in same_watch_addr_test()
323 FAIL_IF_MSG(pc != same_watch_addr_trap, "Child did not stop on end trap"); in same_watch_addr_test()
324 FAIL_IF_MSG(perf_read_counter(perf_fd, &perf_count), "Failed to read perf counter"); in same_watch_addr_test()
329 * watchpoint on the load, then continue, we should immediately get in same_watch_addr_test()
338 FAIL_IF_MSG(waitpid(pid, &status, 0) == -1, "Failed to wait for child"); in same_watch_addr_test()
341 FAIL_IF_MSG(pc != same_watch_addr_load, "Child did not stop on load instruction"); in same_watch_addr_test()
342 FAIL_IF_MSG(perf_read_counter(perf_fd, &perf_count), "Failed to read perf counter"); in same_watch_addr_test()
346 * If we change the PC while stopped on the load instruction, we should in same_watch_addr_test()
347 * not increment the perf counter (because ptrace is before-execute, in same_watch_addr_test()
348 * perf is after-execute). in same_watch_addr_test()
353 FAIL_IF_MSG(waitpid(pid, &status, 0) == -1, "Failed to wait for child"); in same_watch_addr_test()
356 FAIL_IF_MSG(pc != same_watch_addr_trap, "Child did not stop on end trap"); in same_watch_addr_test()
357 FAIL_IF_MSG(perf_read_counter(perf_fd, &perf_count), "Failed to read perf counter"); in same_watch_addr_test()
370 * 3. The perf value is read, then the ptrace value is read immediately after
419 /* Let the child run. It should stop on the ptrace watchpoint */ in perf_then_ptrace_test()
422 FAIL_IF_MSG(waitpid(pid, &status, 0) == -1, "Failed to wait for child"); in perf_then_ptrace_test()
425 FAIL_IF_MSG(pc != perf_then_ptrace_load2, "Child did not stop on ptrace load"); in perf_then_ptrace_test()
428 FAIL_IF_MSG(perf_read_counter(perf_fd, &perf_count), "Failed to read perf counter"); in perf_then_ptrace_test()