tools/testing/selftests/powerpc/ptrace/ptrace-perf-hwbreak.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/powerpc/ptrace/ptrace-perf-hwbreak.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/powerpc/ptrace/ptrace-perf-hwbreak.c- Extension
.c- Size
- 15071 bytes
- Lines
- 446
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
asm/unistd.hlinux/hw_breakpoint.hlinux/ptrace.hmemory.hstdlib.hsys/wait.hutils.h
Detected Declarations
function sys_ptracefunction ptrace_tracemefunction ptrace_getregsfunction ptrace_setregsfunction ptrace_contfunction ptrace_singlestepfunction ppc_ptrace_gethwdbginfofunction ppc_ptrace_sethwdbgfunction ppc_ptrace_delhwdbgfunction ptrace_getreg_pcfunction ptrace_setreg_pcfunction perf_event_openfunction perf_user_event_attr_setfunction perf_watchpoint_openfunction perf_read_counterfunction ppc_ptrace_init_breakpointfunction check_watchpointsfunction forkfunction same_watch_addr_testfunction perf_then_ptrace_testfunction main
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
#include <asm/unistd.h>
#include <linux/hw_breakpoint.h>
#include <linux/ptrace.h>
#include <memory.h>
#include <stdlib.h>
#include <sys/wait.h>
#include "utils.h"
/*
* Child subroutine that performs a load on the address, then traps
*/
void same_watch_addr_child(unsigned long *addr);
/* Address of the ld instruction in same_watch_addr_child() */
extern char same_watch_addr_load[];
/* Address of the end trap instruction in same_watch_addr_child() */
extern char same_watch_addr_trap[];
/*
* Child subroutine that performs a load on the first address, then a load on
* the second address (with no instructions separating this from the first
* load), then traps.
*/
void perf_then_ptrace_child(unsigned long *first_addr, unsigned long *second_addr);
/* Address of the first ld instruction in perf_then_ptrace_child() */
extern char perf_then_ptrace_load1[];
/* Address of the second ld instruction in perf_then_ptrace_child() */
extern char perf_then_ptrace_load2[];
/* Address of the end trap instruction in perf_then_ptrace_child() */
extern char perf_then_ptrace_trap[];
static inline long sys_ptrace(long request, pid_t pid, unsigned long addr, unsigned long data)
{
return syscall(__NR_ptrace, request, pid, addr, data);
}
static long ptrace_traceme(void)
{
return sys_ptrace(PTRACE_TRACEME, 0, 0, 0);
}
static long ptrace_getregs(pid_t pid, struct pt_regs *result)
{
return sys_ptrace(PTRACE_GETREGS, pid, 0, (unsigned long)result);
}
static long ptrace_setregs(pid_t pid, struct pt_regs *result)
{
return sys_ptrace(PTRACE_SETREGS, pid, 0, (unsigned long)result);
}
static long ptrace_cont(pid_t pid, long signal)
{
return sys_ptrace(PTRACE_CONT, pid, 0, signal);
}
static long ptrace_singlestep(pid_t pid, long signal)
{
return sys_ptrace(PTRACE_SINGLESTEP, pid, 0, signal);
}
static long ppc_ptrace_gethwdbginfo(pid_t pid, struct ppc_debug_info *dbginfo)
{
return sys_ptrace(PPC_PTRACE_GETHWDBGINFO, pid, 0, (unsigned long)dbginfo);
}
static long ppc_ptrace_sethwdbg(pid_t pid, struct ppc_hw_breakpoint *bp_info)
{
return sys_ptrace(PPC_PTRACE_SETHWDEBUG, pid, 0, (unsigned long)bp_info);
}
static long ppc_ptrace_delhwdbg(pid_t pid, int bp_id)
{
return sys_ptrace(PPC_PTRACE_DELHWDEBUG, pid, 0L, bp_id);
}
static long ptrace_getreg_pc(pid_t pid, void **pc)
{
struct pt_regs regs;
long err;
err = ptrace_getregs(pid, ®s);
if (err)
Annotation
- Immediate include surface: `asm/unistd.h`, `linux/hw_breakpoint.h`, `linux/ptrace.h`, `memory.h`, `stdlib.h`, `sys/wait.h`, `utils.h`.
- Detected declarations: `function sys_ptrace`, `function ptrace_traceme`, `function ptrace_getregs`, `function ptrace_setregs`, `function ptrace_cont`, `function ptrace_singlestep`, `function ppc_ptrace_gethwdbginfo`, `function ppc_ptrace_sethwdbg`, `function ppc_ptrace_delhwdbg`, `function ptrace_getreg_pc`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.