Changeset View
Standalone View
sys/sys/ptrace.h
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | |||||
#define PT_LWP_EVENTS 24 /* report LWP birth and exit */ | #define PT_LWP_EVENTS 24 /* report LWP birth and exit */ | ||||
#define PT_GET_EVENT_MASK 25 /* get mask of optional events */ | #define PT_GET_EVENT_MASK 25 /* get mask of optional events */ | ||||
#define PT_SET_EVENT_MASK 26 /* set mask of optional events */ | #define PT_SET_EVENT_MASK 26 /* set mask of optional events */ | ||||
#define PT_GET_SC_ARGS 27 /* fetch syscall args */ | #define PT_GET_SC_ARGS 27 /* fetch syscall args */ | ||||
#define PT_GET_SC_RET 28 /* fetch syscall results */ | #define PT_GET_SC_RET 28 /* fetch syscall results */ | ||||
#define PT_COREDUMP 29 /* create a coredump */ | |||||
kib: Why not PT_COREDUMP? | |||||
Done Inline ActionsI'm using the same name as NetBSD already does. And yes, I would prefer PT_DUMPCORE. If we don't care about NetBSD compatibility, then I suppose it's fine to change it. mgorny_gentoo.org: I'm using the same name as NetBSD already does. And yes, I would prefer `PT_DUMPCORE`. If we… | |||||
#define PT_GETREGS 33 /* get general-purpose registers */ | #define PT_GETREGS 33 /* get general-purpose registers */ | ||||
#define PT_SETREGS 34 /* set general-purpose registers */ | #define PT_SETREGS 34 /* set general-purpose registers */ | ||||
#define PT_GETFPREGS 35 /* get floating-point registers */ | #define PT_GETFPREGS 35 /* get floating-point registers */ | ||||
#define PT_SETFPREGS 36 /* set floating-point registers */ | #define PT_SETFPREGS 36 /* set floating-point registers */ | ||||
#define PT_GETDBREGS 37 /* get debugging registers */ | #define PT_GETDBREGS 37 /* get debugging registers */ | ||||
#define PT_SETDBREGS 38 /* set debugging registers */ | #define PT_SETDBREGS 38 /* set debugging registers */ | ||||
#define PT_VM_TIMESTAMP 40 /* Get VM version (timestamp) */ | #define PT_VM_TIMESTAMP 40 /* Get VM version (timestamp) */ | ||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | struct ptrace_vm_entry { | ||||
u_long pve_start; /* Start VA of range. */ | u_long pve_start; /* Start VA of range. */ | ||||
u_long pve_end; /* End VA of range (incl). */ | u_long pve_end; /* End VA of range (incl). */ | ||||
u_long pve_offset; /* Offset in backing object. */ | u_long pve_offset; /* Offset in backing object. */ | ||||
u_int pve_prot; /* Protection of memory range. */ | u_int pve_prot; /* Protection of memory range. */ | ||||
u_int pve_pathlen; /* Size of path. */ | u_int pve_pathlen; /* Size of path. */ | ||||
long pve_fileid; /* File ID. */ | long pve_fileid; /* File ID. */ | ||||
uint32_t pve_fsid; /* File system ID. */ | uint32_t pve_fsid; /* File system ID. */ | ||||
char *pve_path; /* Path name of object. */ | char *pve_path; /* Path name of object. */ | ||||
}; | |||||
/* Argument structure for PT_COREDUMP. */ | |||||
struct ptrace_coredump { | |||||
int pc_fd; /* File descriptor to write dump to. */ | |||||
}; | }; | ||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
Not Done Inline ActionsNote that you continue execution of the target process to get the coredump. Two notes. First, I believe this action should be similar to PT_CONTINUE, ie. caller should be able to specify $pc or signal to deliver. Second issue is more delicate. Currently we continue all threads in the process, but the first thread that notices P2_COREDUMP on exit to userspace, and should do thread_single(). But it is racy, other threads might not notice AST/P2_COREDUMP, continue execution, return to userspace and do something that would break consistency of the coredump (comparing with the moment when the PT_COREDUMP request was issued). I am not sure yet how to handle it. kib: Note that you continue execution of the target process to get the coredump. Two notes.
First… | |||||
Done Inline Actions
I know but I presume we want to eventually fix the patch to stop it after taking the coredump.
To be honest, I don't see the purpose of that, given the above.
Yes, it doesn't sound that we're doing it right. I suppose one option would be to temporarily suspend all remaining threads. Or maybe even all threads if that's legal; I suppose that could prevent the program from continuing. mgorny_gentoo.org: > Note that you continue execution of the target process to get the coredump.
I know but I… | |||||
int ptrace_set_pc(struct thread *_td, unsigned long _addr); | int ptrace_set_pc(struct thread *_td, unsigned long _addr); | ||||
int ptrace_single_step(struct thread *_td); | int ptrace_single_step(struct thread *_td); | ||||
int ptrace_clear_single_step(struct thread *_td); | int ptrace_clear_single_step(struct thread *_td); | ||||
#ifdef __HAVE_PTRACE_MACHDEP | #ifdef __HAVE_PTRACE_MACHDEP | ||||
int cpu_ptrace(struct thread *_td, int _req, void *_addr, int _data); | int cpu_ptrace(struct thread *_td, int _req, void *_addr, int _data); | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |
Why not PT_COREDUMP?