aboutsummaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/sys/ptrace.266
1 files changed, 65 insertions, 1 deletions
diff --git a/lib/libc/sys/ptrace.2 b/lib/libc/sys/ptrace.2
index 8e9c5d8ab87a..6148e6d333d5 100644
--- a/lib/libc/sys/ptrace.2
+++ b/lib/libc/sys/ptrace.2
@@ -2,7 +2,7 @@
.\" $NetBSD: ptrace.2,v 1.2 1995/02/27 12:35:37 cgd Exp $
.\"
.\" This file is in the public domain.
-.Dd July 15, 2019
+.Dd April 10, 2021
.Dt PTRACE 2
.Os
.Sh NAME
@@ -807,6 +807,70 @@ and extends up to
The
.Fa data
argument is ignored.
+.It Dv PT_COREDUMP
+This request creates a coredump for the stopped program.
+The
+.Fa addr
+argument specifies a pointer to a
+.Vt "struct ptrace_coredump" ,
+which is defined as follows:
+.Bd -literal
+struct ptrace_coredump {
+ int pc_fd;
+ uint32_t pc_flags;
+ off_t pc_limit;
+};
+.Ed
+The fields of the structure are:
+.Bl -tag -width pc_flags
+.It Dv pc_fd
+File descriptor to write the dump to.
+It must refer to a regular file, opened for writing.
+.It Dv pc_flags
+Flags.
+The following flags are defined:
+.Bl -tag -width PC_COMPRESS
+.It Dv PC_COMPRESS
+Request compression of the dump.
+.It Dv PC_ALL
+Include non-dumpable entries into the dump.
+The dumper ignores
+.Dv MAP_NOCORE
+flag of the process map entry, but device mappings are not dumped even with
+.Dv PC_ALL
+set.
+.El
+.It Dv pc_limit
+Maximum size of the coredump.
+Specify zero for no limit.
+.El
+.Pp
+The size of
+.Vt "struct ptrace_coredump"
+must be passed in
+.Fa data .
+.Pp
+The process must be stopped before dumping core.
+A single thread in the target process is temporarily unsuspended
+in kernel to write the dump.
+If the
+.Nm
+call fails before a thread is unsuspended, there is no event to
+.Xr waitpid 2
+for.
+If a thread was unsuspended, it will stop again before the
+.Nm
+call returns, and the process must be waited upon using
+.Xr waitpid 2
+to consume the new stop event.
+Since it is hard to deduce whether a thread was unsuspended before
+an error occurred, it is recommended to unconditionally perform
+.Xr waitpid 2
+with
+.Dv WNOHANG
+flag after
+.Dv PT_COREDUMP ,
+and silently accept zero result from it.
.El
.Sh ARM MACHINE-SPECIFIC REQUESTS
.Bl -tag -width "Dv PT_SETVFPREGS"