summaryrefslogtreecommitdiffstats
path: root/tests/sys/kern/ptrace_test.c
Commit message (Collapse)AuthorAgeFilesLines
* Add ptrace(2) reporting for LWP events.jhb2015-12-291-7/+186
| | | | | | | | Add two new LWPINFO flags: PL_FLAG_BORN and PL_FLAG_EXITED for reporting thread creation and destruction. Newly created threads will stop to report PL_FLAG_BORN before returning to userland and exiting threads will stop to report PL_FLAG_EXIT before exiting completely. Both of these events are only enabled and reported if PT_LWP_EVENTS is enabled on a process.
* Tweak: use 'mainlwp' instead of 'mainpid' since this is a thread (LWP)jhb2015-10-061-3/+3
| | | | identifier, not a pid.
* Fix build with older GCC which, doesn't like 'main' being a variable name.bdrewery2015-10-061-3/+3
|
* Fix various edge cases related to system call tracing.jhb2015-10-061-15/+244
| | | | | | | | | | | | | | | | | | | | | | | - Always set td_dbg_sc_* when P_TRACED is set on system call entry even if the debugger is not tracing system call entries. This ensures the fields are valid when reporting other stops that occur at system call boundaries such as for PT_FOLLOW_FORKS or when only tracing system call exits. - Set TDB_SCX when reporting the stop for a new child process in fork_return(). This causes the event to be reported as a system call exit. - Report a system call exit event in fork_return() for new threads in a traced process. - Copy td_dbg_sc_* to new threads instead of zeroing. This ensures that td_dbg_sc_code in particular will report the system call that created the new thread or process when it reports a system call exit event in fork_return(). - Add new ptrace tests to verify that new child processes and threads report system call exit events with a valid pl_syscall_code via PT_LWPINFO. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D3822
* Use _exit() instead of exit() in child processes created during tests.jhb2015-09-091-10/+10
| | | | Suggested by: kib
* Add a test to verify that a traced process sees its original parent viajhb2015-09-091-0/+87
| | | | | | | getppid() after a debugger process that is not the parent has attached. Reviewed by: kib (earlier version) Differential Revision: https://reviews.freebsd.org/D3615
* Properly size the children[] arrays in the follow fork tests.jhb2015-09-091-6/+6
|
* Clear P_TRACED before reparenting a detached process back to itsjhb2015-08-011-54/+527
| | | | | | | | | | | original parent. Otherwise the debugee will be set as an orphan of the debugger. Add tests for tracing forks via PT_FOLLOW_FORK. Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D2809
* Add a CHILD_REQUIRE macro similar to ATF_REQUIRE for use in child processesjhb2015-06-041-25/+47
| | | | | | | of the main test process. Differential Revision: https://reviews.freebsd.org/D2664 Reviewed by: ngie (previous version)
* Consistently only use one end of the pipe in the parent and debuggerjhb2015-05-311-3/+5
| | | | | | | | processes and do not rely on EOF due to a close() in the debugger. PR: 200489 Differential Revision: https://reviews.freebsd.org/D2674 Reviewed by: kib, ngie, rodrigc
* Tweak the description of when waitpid() doesn't return any status for ajhb2015-05-281-6/+6
| | | | | | non-blocking wait to avoid the word "empty". Requested by: ngie
* Do not allow a process to reap an orphan (a child currently beingjhb2015-05-261-0/+246
| | | | | | | | | | | | | | | | | traced by another process such as a debugger). The parent process does need to check for matching orphan pids to avoid returning ECHILD if an orphan has exited, but it should not return the exited status for the child until after the debugger has detached from the orphan process either explicitly or implicitly via wait(). Add two tests for for this case: one where the debugger is the direct child (thus the parent has a non-empty children list) and one where the debugger is not a direct child (so the only "child" of the parent is the orphan). Differential Revision: https://reviews.freebsd.org/D2644 Reviewed by: kib MFC after: 2 weeks
* Only reparent a traced process to its old parent if the tracing process isjhb2015-05-221-0/+143
not the old parent. Otherwise, proc_reap() will leave the zombie in place resulting in the process' status being returned twice to its parent. Add test cases for PT_TRACE_ME and PT_ATTACH which are fixed by this change. Differential Revision: https://reviews.freebsd.org/D2594 Reviewed by: kib MFC after: 2 weeks
OpenPOWER on IntegriCloud