History log of /src/lib/libc/sys/ptrace.2
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
Revision tags: perseant-exfatfs-base-20250801 netbsd-11-base perseant-exfatfs-base-20240630 perseant-exfatfs-base
# 1.86 12-May-2024 msaitoh

s/unitialized/uninitialized/


Revision tags: netbsd-10-1-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.85 14-May-2020 wiz

Use more markup.


# 1.84 14-May-2020 kamil

Introduce new ptrace(2) operations: PT_SET_SIGPASS and PT_GET_SIGPASS

They deliver the logic of bypassing selected signals directly to the
debuggee, without informing the debugger.

This can be used to implement the QPassSignals GDB/LLDB protocol.

This call can be useful to avoid signal races in ATF ptrace tests.


Revision tags: phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406
# 1.83 04-Jan-2020 kamil

Document PT_LWPSTATUS and PT_LWPNEXT in ptrace(2)

Remove mentions of obsolete PT_LWPINFO.


Revision tags: phil-wifi-20191119
# 1.82 09-Oct-2019 wiz

Fix xref.


# 1.81 09-Oct-2019 kamil

Document PT_STOP, update PT_KILL in the ptrace(2) man-page

Formatting by <mgorny>


# 1.80 30-Jul-2019 mgorny

Include pe_lwp member in 'struct ptrace_state'

Reviewed by kamil.


Revision tags: netbsd-9-base
# 1.79 11-Jul-2019 mgorny

branches: 1.79.2;
Fix thinko: syscalls -> signals


# 1.78 10-Jul-2019 mgorny

Improve/fix doc of PT_SETSTEP and PT_CLEARSTEP.

Reviewed by kamil.


# 1.77 10-Jul-2019 mgorny

Fix typo: SIGRAP -> SIGTRAP


# 1.76 26-Jun-2019 wiz

Use Vt for variable types. New sentence, new line. Add a missing ')'.
Add/remove some articles or other missing words.


# 1.75 26-Jun-2019 mgorny

Implement PT_GETXSTATE and PT_SETXSTATE

Introduce two new ptrace() requests: PT_GETXSTATE and PT_SETXSTATE,
that provide access to the extended (and extensible) set of FPU
registers on amd64 and i386. At the moment, this covers AVX (YMM)
and AVX-512 (ZMM, opmask) registers. It can be easily extended
to cover further register types without breaking backwards
compatibility.

PT_GETXSTATE issues the XSAVE instruction with all kernel-supported
extended components enabled. The data is copied into 'struct xstate'
(which -- unlike the XSAVE area itself -- has stable format
and offsets).

PT_SETXSTATE issues the XRSTOR instruction to restore the register
values from user-provided 'struct xstate'. The function replaces only
the specific XSAVE components that are listed in 'xs_rfbm' field,
making it possible to issue partial updates.

Both syscalls take a 'struct iovec' pointer rather than a direct
argument. This requires the caller to explicitly specify the buffer
size. As a result, existing code will continue to work correctly
when the structure is extended (performing partial reads/updates).


# 1.74 12-Jun-2019 wiz

Fix typo.


# 1.73 12-Jun-2019 kamil

Try to make posix_spawn(3) note in ptrace(2) less confusing


# 1.72 12-Jun-2019 wiz

Use Xr.


# 1.71 11-Jun-2019 kamil

Document PTRACE_POSIX_SPAWN in man-page


Revision tags: phil-wifi-20190609
# 1.70 25-May-2019 kamil

Update the ptrace(2) documentation

Document that TRAP_EXEC can be returned for PT_SYSCALL.
Document truncated byte transfers.


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502
# 1.69 01-May-2018 kamil

branches: 1.69.2;
Implement PTRACE_VFORK

Add support for tracing vfork(2) events in the context of ptrace(2).

This API covers other frontends to fork1(9) like posix_spawn(2) or clone(2),
if they cause parent to wait for exec(2) or exit(2) of the child.

Changes:
- Add new argument to sigswitch() determining whether we need to acquire
the proc_lock or whether it's already held.
- Refactor fork1(9) for fork(2) and vfork(2)-like events.
Call sigswitch() from fork(1) for forking or vforking parent, instead of
emitting kpsignal(9). We need to emit the signal and suspend the parent,
returning to user and relock proc_lock.
- Add missing prototype for proc_stop_done() in kern_sig.c.
- Make sigswitch a public function accessible from other kernel code
including <sys/signalvar.h>.
- Remove an entry about unimplemented PTRACE_VFORK in the ptrace(2) man page.
- Permin PTRACE_VFORK in the ptrace(2) frontend for userland.
- Remove expected failure for unimplemented PTRACE_VFORK tests in the ATF
ptrace(2) test-suite.
- Relax signal routing constraints under a debugger for a vfork(2)ed child.
This intended to protect from signaling a parent of a vfork(2)ed child that
called PT_TRACE_ME, but wrongly misrouted other signals in vfork(2)
use-cases.

Add XXX comments about still existing problems and future enhancements:
- correct vfork(2) + PT_TRACE_ME handling.
- fork1(2) handling of scenarios when a process is collected in valid but
rare cases.

All ATF ptrace(2) fork[1-8] and vfork[1-8] tests pass.

Fix PR kern/51630 by Kamil Rytarowski (myself).

Sponsored by <The NetBSD Foundation>


Revision tags: pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.68 05-Mar-2018 kamil

branches: 1.68.2;
Remove PT_GET_SIGMASK / PT_SET_SIGMASK

These operations cloned Linux's specific PTRACE_GETSIGMASK / PTRACE_SETSIGMASK.
This feature was useful in applications like rr/criu/reptyr-like, where
the ptrace(2) interface is abused for the purpose of constructing an arbitrary
process. It's not reliable and not portable. For the NetBSD case it will be
better to invent something dedicated for serializing and deserializing a
process with threads.

Noted on tech-toolchain@ and blog entry

"LLDB restoration and return to ptrace(2)"
https://blog.netbsd.org/tnf/entry/lldb_restoration_and_return_to


Revision tags: matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base
# 1.67 03-Jun-2017 abhinav

branches: 1.67.2;
Fix typo: s/interrput/interrupt/


Revision tags: prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1
# 1.66 08-Apr-2017 kamil

Fix typo in previous (ptrace(2))


# 1.65 08-Apr-2017 kamil

Document new calls and be more clear about PT_SYSCALL* in ptrace(2)

Document PT_SETSTEP and PT_CLEARSTEP in ptrace(2).

Try to explain more details of PT_SYSCALL and PT_SYSCALLEMU.

The description of PT_*STEP has been obtained from FreeBSD.

Sponsored by <The NetBSD Foundation>


# 1.64 07-Apr-2017 pgoyette

Fix typos and some grammar


# 1.63 07-Apr-2017 kamil

Correction in ptrace(2) about operations that emit signals

PT_STEP and PT_DETACH cannot emit signals
PT_CONTINUE and PT_SYSCALL can emit signals

Pointed out by <chs>


Revision tags: pgoyette-localcount-20170320
# 1.62 23-Feb-2017 wiz

Formatting fix.


# 1.61 23-Feb-2017 kamil

Document PT_GETDBREGS and PT_SETDBRGS in ptrace(2)

Not this interface in MD part.
Explain design choices.

Sponsored by <The NetBSD Foundation>


# 1.60 22-Feb-2017 kamil

Introduce new ptrace(2) API to allow/prevent exection of LWP

Introduce new API for debuggers to allow/prevent execution of the specified
thread.

New ptrace(2) operations:

PT_RESUME Allow execution of a specified thread, change its state
from suspended to continued. The addr argument is unused.
The data argument specifies the LWP ID.

This call is equivalent to _lwp_continue(2) called by a
traced process. This call does not change the general
process state from stopped to continued.

PT_SUSPEND Prevent execution of a specified thread, change its state
from continued to suspended. The addr argument is unused.
The data argument specifies the requested LWP ID.

This call is equivalent to _lwp_suspend(2) called by a
traced process. This call does not change the general
process state from continued to stopped.

This interface is modeled after FreeBSD, however with NetBSD specific arguments
passed to ptrace(2) -- FreeBSD passes only thread id, NetBSD passes process and
thread id.

Extend PT_LWPINFO operation in ptrace(2) to report suspended threads. In the
ptrace_lwpinfo structure in pl_event next to PL_EVENT_NONE and PL_EVENT_SIGNAL
add new value PL_EVENT_SUSPENDED.

Add new errno(2) value EDEADLK that might be returned by ptrace(2). It prevents
dead-locking in a scenario of resuming a process or thread that is prevented
from execution. This fixes bug that old API was vulnerable to this scenario.

Kernel bump delayed till introduction of PT_GETDBREGS/PT_SETDBREGS soon.

Add new ATF tests:
- resume1
Verify that a thread can be suspended by a debugger and later
resumed by the debugger

- suspend1
Verify that a thread can be suspended by a debugger and later
resumed by a tracee

- suspend2
Verify that the while the only thread within a process is
suspended, the whole process cannot be unstopped

Sponsored by <The NetBSD Foundation>


# 1.59 12-Feb-2017 kamil

Introduce new interface in ptrace(2) - PT_GET_SIGMASK and PT_SET_SIGMASK

Add new interface to add ability to get/set signal mask of a tracee.
It has been inspired by Linux PTRACE_GETSIGMASK and PTRACE_SETSIGMASK, but
adapted for NetBSD API.

This interface is used for checkpointing software to set/restore context
of a process including signal mask like criu or just to track this property
in reverse-execution software like Record and Replay Framework (rr).


Add new ATF tests for this interface