Change:
Test must be run with securelevel >= 1
To:
Test must be run with securelevel >= 0
In attach_pid1_securelevel.
Sponsored by <The NetBSD Foundation>
Move common function code into shared subroutine.
While there remove checks for defined(HAVE_DBREGS). All x86 ports offer
debug register accessors.
Sponsored by <The NetBSD Foundation>
PR kern/52117 ptrace(2) PTRACE_FORK fails on some platforms
Add message similar to:
We expect two SIGTRAP events, for child 22199 (TRAP_CHLD,
pe_report_event=PTRACE_FORK, state.pe_other_pid=child2) and for child2
(TRAP_CHLD, pe_report_event=PTRACE_FORK, state.pe_other_pid=child)
This should make the expected behavior more clear.
Sponsored by <The NetBSD Foundation>
There is a definition of PT_STEP for userland, but no implementation
in the kernel.
PR kern/52119 PT_STEP not supported on arm 32-bit
Sponsored by <The NetBSD Foundation>
Mark timeout for this test 5 sec. It sometimes works sometimes does not.
Add a local sleep(3) at the end to get consisten report about timeouting
always.
PR kern/51995
Sponsored by <The NetBSD Foundation>
PR kern/52117 ptrace(2) PTRACE_FORK fails on some platforms
These tests work on amd64, i386 and xen.
They are part of t_ptrace_wait*.
Sponsored by <The NetBSD Foundation>
This test is marked as PR kern/51918.
Timeout has been reported on i386, amd64, alpha, sparc, sparc64, evbarm.
xen.
Sponsored by <The NetBSD Foundation>
activate it for the current process. It does not work and tests should
not change global system state anyway.
Instead: skip the test is pax.mprotect is not globally enabled. We could
use a better check for this (querying the current processes pax flags),
but unfortunately we don't have one.
Add 6 extra tests for the 12am/12pm bug - all currently expected to fail.
(That is, 6 subtests of the "times" test will fail, all new ones)>
While here, when parsedate() fails (returns -1) avoid converting that
failure value (-1) to a struct tm (1969-12-31T23:59:59 UTC) and then
comparing the values with those expected by the test, and complaining
about all of those (where ANY was not permitted) that don't match...
Add 5 new test cases to test various ways that $* can be expanded.
Currently 3 of the 5 are marked as "expected to fail" because of the
bug in this PR.
I don't know if <if_index> is expected to be accepted instead of
an interface name. Please update the test case if the behavior is
just a bug and ifconfig gets fixed.
an 'a' partition covering the whole disk, instead use the raw partition.
Also skip this test if the fss device is not available.
With lots of help from pgoyette.
ash based shell bug
echo ${unset_var##$(echo a)}$(echo b)
should say "b" but instead says "a" ... the first "echo a" is not
evaluated because it cannot possibly match an unset variable, but is
not removed from the list of command substitutions, when the shell
needs to execute the 2nd cmdsub, "echo b" should be at the head of
the list, but isn't, "echo a" is still there...
This test should fail (for now) - should show 4 of 40 subtests failing.
It isn't marked as atf_expect_fail as the fix for this will be coming
later today (I will just wait at least 1 b5 build cycle so the failure
can be observed).
Detecting the bug, and the fix, are from FreeBSD.
[v]fork() produces pid==1 (init) (if it were useful to test that, an
entirely different test would be appropriate) change the tests so
they check for [v]fork() failure, as probably intended, instead.
Mark this test broken with kern/52012 as the tracee does not stop on syscall
entry. Check for siginfo(2) in syscall1 and unveil two new bugs.
PR kern/52012: PT_SYSCALL does not stop on syscall entry
PR kern/52018: ptrace(2) PT_SYSCALL generates SIGTRAP without si_code
PR kern/52019: ptrace(2) PT_SYSCALL generate SIGTRAP to the parent but
returns SIGSTOP in PT_GET_SIGINFO
Sponsored by <The NetBSD Foundation>
resume1:
PR kern/51995 ptrace(2) PT_RESUME is not reliable
syscallemu1:
PR kern/52012 PT_SYSCALL does not stop on syscall entry
Sponsored by <The NetBSD Foundation>
syscallemu1:
Verify that exit(2) can be intercepted with PT_SYSCALLEMU
This test is failing as PT_SYSCALL does not stop the process on syscall
entry. This renders PT_SYSCALL broken on NetBSD.
Sponsored by <The NetBSD Foundation>
syscall1:
Verify that getpid(2) can be traced with PT_SYSCALL
Enforce usage of syscall(2), it should prevent failing on any possible
optimizations in future as a libc can ship this information not through
syscall (shared struct with kernel or similar).
Sponsored by <The NetBSD Foundation>
can't be opened (which more accurately reflects when mixerctl is going
to fail...)
Based upon an idea from Andreas Gustafsson (gson@) - except that using
/dev/audio0 for this purpose doesn't work, if the only audio device
configured is pad0 an open of audio fails with EIO (???)
While here, perpare for the updated mixerctl coming soon to a repository
near you...
Use correct usage in the test of a bogus -d arg (otherwise the
new mixerctl will complain about usage, and never even
attempt to open the bogus device)
Don't require /dev/mixer for the noargs -> generate usage msg
test ... this will now generate a failing test with the
old mixerctl if there is no working /dev/mixer, but
that mixerctl won't be around much longer.
as the kernel that runs them has no audio (and no mixers) configured.
The usage message test might be returned some day if /usr/bin/mixerctl
gets modified so it doesn't attempt to open the device (and error out)
in cases where the device isn't actually going to be used (and -d wasn't
given to set the device name explicitly).
Use proper check for LW_SYSTEM, don't depend on PT_GETREGS/PT_SETREGS.
Don't allow to mask SA_CANTMASK signals with PT_SET_SIGMASK (this covers
SIGSTOP and SIGKILL).
Add new ATF tests:
- setsigmask5
Verify that sigmask cannot be set to SIGKILL
- setsigmask6
Verify that sigmask cannot be set to SIGSTOP
Sponsored by <The NetBSD Foundation>
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>
Add a test program for the bug described in this PR.
This is the first pkill/pgrep/prenice test (more would be good!)
This test has been confirmed to work once the bug described in the PR
has been fixed, so the test is not marked "expected to fail" even
though initially that is what should happen.
Note: the test cana also fail if the system running the tests happens
to be running processes with names that match the patterns searched for
by the test, other than the test program itself. This is expected to be
unlikely.
New tests:
- dbregs_dr6_dont_inherit_lwp
- dbregs_dr7_dont_inherit_lwp
Debug Registers are set always per-LWP and they are never inherited.
If a user wants to reuse them, there is need to set trap on thread creation
(PTRACE_LWP_CREATE) and set them from a debugger on newly created LWP.
Sponsored by <The NetBSD Foundation>
Add new tests:
- dbregs_dr0_dont_inherit_lwp
- dbregs_dr1_dont_inherit_lwp
- dbregs_dr2_dont_inherit_lwp
- dbregs_dr3_dont_inherit_lwp
Fix memcmp(3) usage when comparing registers. Comparing with len is
incorrect as it should be len*sizeof(register) or just sizeof(registers).
Don't check for 16 Debug Registers, it's amd64 specific and not portable
to i386.
Don't compare registers before and after triggering a trap, it's a bug that
was hidden by incorrect usage of memcmp(3).
Sponsored by <The NetBSD Foundation>
Add new tests:
- dbregs_dr0_trap_code
- dbregs_dr1_trap_code
- dbregs_dr2_trap_code
- dbregs_dr3_trap_code
This is the final set of tests for trap types that are supposed to be
supported by all amd64 CPUs.
Traps for code (instruction) execution must be set to 1 byte, otherwise
they are undefined. x86 code traps must point to the first byte of an
instruction.
Sponsored by <The NetBSD Foundation>
Replace the following tests:
- dbregs_dr0_trap_variable
- dbregs_dr1_trap_variable
- dbregs_dr2_trap_variable
- dbregs_dr3_trap_variable
With new ones:
- dbregs_dr0_trap_variable_writeonly_byte
- dbregs_dr1_trap_variable_writeonly_byte
- dbregs_dr2_trap_variable_writeonly_byte
- dbregs_dr3_trap_variable_writeonly_byte
- dbregs_dr0_trap_variable_writeonly_2bytes
- dbregs_dr1_trap_variable_writeonly_2bytes
- dbregs_dr2_trap_variable_writeonly_2bytes
- dbregs_dr3_trap_variable_writeonly_2bytes
- dbregs_dr0_trap_variable_writeonly_4bytes
- dbregs_dr1_trap_variable_writeonly_4bytes
- dbregs_dr2_trap_variable_writeonly_4bytes
- dbregs_dr3_trap_variable_writeonly_4bytes
All tests pass with my local implementation of debug registers. Once the
interface will be verified, I will prepare it for commit to HEAD.
Sponsored by <The NetBSD Foundation>
Currently this code is disabled in HEAD and the dbreg struct has to be
committed first in order to be used. Before enabling it I'm working on
reducing needless differences with FreeBSD and Linux.
Sponsored by <The NetBSD Foundation>
ftp with rumphijack is unstable probably because ftp uses siglongjmp from
a signal hander. So stop using ftp and use nc instead. This fixes test
failures of t_mtudisc on some environments such as my development machine
(amd64) and anita on sparc64.
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
====================================
getsigmask1:
Verify that plain PT_SET_SIGMASK can be called
getsigmask2:
Verify that PT_SET_SIGMASK reports correct mask from tracee
setsigmask1:
Verify that plain PT_SET_SIGMASK can be called with empty mask
setsigmask2:
Verify that sigmask is preserved between PT_GET_SIGMASK and
PT_SET_SIGMASK
setsigmask3:
Verify that sigmask is preserved between PT_GET_SIGMASK, process
resumed and PT_SET_SIGMASK
setsigmask4:
Verify that new sigmask is visible in tracee
Kernel ABI bump delayed as there are more interfaces to come in ptrace(2).
Sponsored by <The NetBSD Foundation>
libpthread_dbg(3) is a remnant library from the M:N thread model
(pre-NetBSD-5.0) API to introspect threads within a process and for use
of debuggers.
Currently in the 1:1 model it's not used in GDB neither in LLDB and it's
not either planned to be used. It's current function to read pthread_t
structures is realizable within a regular debugger capable to
instrospect objects within a tracee (GDB, LLDB...).
Remaining users of this API can still use this library from
pkgsrc/devel/libpthread_dbg.
Sponsored by <The NetBSD Foundation>
signal9:
Verify that masking SIGTRAP in tracee does not stop tracer from
catching PTRACE_LWP_CREATE breakpoint
signal10:
Verify that masking SIGTRAP in tracee does not stop tracer from
catching PTRACE_LWP_EXIT breakpoint
Both tests are broken and linked with PR kern/51918.
Sponsored by <The NetBSD Foundation>
signal8:
Verify that masking SIGTRAP in tracee does not stop tracer from
catching PTRACE_VFORK_DONE breakpoint
This test is marked as broken and linked with PR kern/51918.
Sponsored by <The NetBSD Foundation>
signal6:
Verify that masking SIGTRAP in tracee does not stop tracer from
catching PTRACE_FORK breakpoint
signal7:
Verify that masking SIGTRAP in tracee does not stop tracer from
catching PTRACE_VFORK breakpoint
signal6 fails due to PR kern/51918
signal6 fails due to PR kern/51918 and PR kern/51630
Sponsored by <The NetBSD Foundation>
signal5:
Verify that masking SIGTRAP in tracee does not stop tracer from
catching exec() breakpoint
signal5 is failing and linked with PR kern/51918
Sponsored by <The NetBSD Foundation>
signal4:
Verify that masking SIGTRAP in tracee does not stop tracer from
catching single step trap
signal4 is marked as failing and referenced with PR kern/51918.
Sponsored by <The NetBSD Foundation>
signal2:
Verify that masking SIGTRAP in tracee stops tracer from
catching this raised signal
signal3:
Verify that masking SIGTRAP in tracee does not stop tracer from
catching software breakpoints
signal3 is marked as failing and refrenced with PR kern/51918
Currently signal3 requires code for other architectures than x86_64
Sponsored by <The NetBSD Foundation>
To this end, carpattach needs to be delayed from RUMP_COMPONENT_NET to
RUMP_COMPONENT_NET_IF on rump_server. Otherwise mutex_enter via carpattach
for if_clone_mtx is called before mutex_init for it in ifinit1.
This change makes sure that the fired expected watchpoint with expected
property. It's done with PT_GET_SIGINFO and checking SIGTRAP codes.
Sponsored by <The NetBSD Foundation>
Add new field pw_type in the ptrace_watchpoint structure.
amd64 and i386 offer the current set of watchpoints as
PTRACE_PW_TYPE_DBREGS.
On other archs than x86, there are readily available different types of
hardware assisted watchpoints like for code-only or data-only registers on
ARM. Also in future there is an option to implement MMU-based watchpoints
and future per-port or per-cpu extensions.
Next step is to alter this interface on x86 to generate SIGTRAP with
si_code TRAP_HWWTRAP with additional information on occurred event:
- which watchpoint fired,
- additional watchpoint-type specific information, like on amd64 with
PTRACE_PW_TYPE_DBREGS.:
* only watchpoint fired
* watchpoint fired and single step occurred
Adjust ATF tests for the pw_type change.
Sponsored by <The NetBSD Foundation>
Add interface in ptrace(2) to track thread (LWP) events:
- birth,
- termination.
The purpose of this thread is to keep track of the current thread state in
a tracee and apply e.g. per-thread designed hardware assisted watchpoints.
This interface reuses the EVENT_MASK and PROCESS_STATE interface, and
shares it with PTRACE_FORK, PTRACE_VFORK and PTRACE_VFORK_DONE.
Change the following structure:
typedef struct ptrace_state {
int pe_report_event;
pid_t pe_other_pid;
} ptrace_state_t;
to
typedef struct ptrace_state {
int pe_report_event;
union {
pid_t _pe_other_pid;
lwpid_t _pe_lwp;
} _option;
} ptrace_state_t;
#define pe_other_pid _option._pe_other_pid
#define pe_lwp _option._pe_lwp
This keeps size of ptrace_state_t unchanged as both pid_t and lwpid_t are
defined as int32_t-like integer. This change does not break existing
prebuilt software and has minimal effect on necessity for source-code
changes. In summary, this change should be binary compatible and shouldn't
break build of existing software.
Introduce new siginfo(5) type for LWP events under the SIGTRAP signal:
TRAP_LWP. This change will help debuggers to distinguish exact source of
SIGTRAP.
Add two basic t_ptrace_wait* tests:
lwp_create1:
Verify that 1 LWP creation is intercepted by ptrace(2) with
EVENT_MASK set to PTRACE_LWP_CREATE
lwp_exit1:
Verify that 1 LWP creation is intercepted by ptrace(2) with
EVENT_MASK set to PTRACE_LWP_EXIT
All tests are passing.
Surfing the previous kernel ABI bump to 7.99.59 for PTRACE_VFORK{,_DONE}.
Sponsored by <The NetBSD Foundation>
eventmask3:
Verify that PTRACE_VFORK in EVENT_MASK is preserved
eventmask4:
Verify that PTRACE_VFORK_DONE in EVENT_MASK is preserved
Currently eventmask3 is failing and marked with PR kern/51630
Sponsored by <The NetBSD Foundation>
PTRACE_VFORK and PTRACE_VFORK_DONE are now parts of <sys/ptrace.h>.
PTRACE_VFORK tests are still failing as the support for it is currently
a stub.
Sponsored by <The NetBSD Foundation>
vforkdone1:
Verify that vfork(2) is intercepted by ptrace(2) with EVENT_MASK
set to PTRACE_VFORK_DONE
vforkdone2:
Verify that vfork(2) is intercepted by ptrace(2) with EVENT_MASK
set to PTRACE_FORK | PTRACE_VFORK_DONE
As of now PTRACE_VFORK_DONE is undefined in <sys/ptrace.h>.
Sponsored by <The NetBSD Foundation>