# if used with o, x or X specifiers the value is preceeded with 0, 0x or 0X
respectively for values different than zero.
Noted by <christos>
Sponsored by <The NetBSD Foundation>
The common functions store socks of rump_servers, interfaces of rump_servers
and buses that intefaces connect and allow to destroy them with common
functions without specifying which socks, interfaces and buses we should
destroy.
This change reduces lots of similar setup/cleanup codes.
fpregs1:
Verify plain PT_GETFPREGS call without further steps
fpregs2:
Verify PT_GETFPREGS and PT_SETFPREGS calls without changing regs
Sponsored by <The NetBSD Foundation>
Introduce net_common.sh that is to share common functions used in tests
for networking. This commit commonizes extract_new_packets. Other duplicate
codes will be moved to the file in further commits.
Add new ATF tests for the general purpose register calls.
These tests require platforms to export all of the following macros:
- PT_GETREGS
- PT_SETREGS
- PTRACE_REG_PC
- PTRACE_REG_SET_PC
- PTRACE_REG_SP
- PTRACE_REG_INTRV
This has been done for the sake of C preprocessor magic simplicity.
There are ports without covering all of the above symbols -- skip them.
Added tests
===========
regs1:
Verify plain PT_GETREGS call without further steps
regs2:
Verify plain PT_GETREGS call and retrieve PC
regs3:
Verify plain PT_GETREGS call and retrieve SP
regs4:
Verify plain PT_GETREGS call and retrieve INTRV
regs5:
Verify PT_GETREGS and PT_SETREGS calls without changing regs
Sponsored by <The NetBSD Foundation>
As usual, ATF is actively interfering with test debugging. Almost all
runs in the past few days have failed this test with "stdout not
empty". In one run it timed out:
http://releng.netbsd.org/b5reports/i386/build/2016.11.22.06.51.14/test.html
but in this case ATF helpfully suppressed the log data.
Maybe if someone can figure out how to make the test hang reliably
then they can turn the logging on again and run it outside of ATF to
see what's happening.
In the meantime this problem is not likely to get fixed until we have
a less obstructive testing framework.
New tests are direct counterparts to the existing ones {,io_}read_d[1234].
PT_READ_D and PIOD_READ_D (from PT_IO) are traditionally used to transfer
data segment. New tests make use of PT_READ_I and PIOD_READ_I (from PT_IO)
in order to copy text segment from traced process.
Traditionally, ptrace() has
allowed for machines with distinct address spaces for
instruction and data, which is why there are two requests:
conceptually, PT_READ_I reads from the instruction space
and PT_READ_D reads from the data space. In the current
NetBSD implementation, these two requests are completely
identical.
--- ptrace(2)
New tests follow the traditional convention and copy only instructions from
dummy functions.
There are no new tests copying data to .text regions from the traced
process, as this is violating mprotect restrictions. This limitation may be
addressed in future, as there are dedicated sysctl(7) handlers for
debuggers (currently mainly gdb(1)).
Tests verifying identical behavior of PT_READ_I and PT_READ_D are not
planned.
Sponsored by <The NetBSD Foundation>
Rename io_read_write_handshake to io_read_d_write_d_handshake1.
io_read_d_write_d_handshake2:
Verify PT_IO with PIOD_WRITE_D and PIOD_READ_D handshake
This new test first writes and later reads data.
io_read_d_write_d_handshake1 first reads and later writes.
Sponsored by <The NetBSD Foundation>
read1:
Verify PT_READ_D called once
read2:
Verify PT_READ_D called twice
read3:
Verify PT_READ_D called three times
read4:
Verify PT_READ_D called four times
Sponsored by <The NetBSD Foundation>
write1:
Verify PT_WRITE_D called once
write2:
Verify PT_WRITE_D called twice
write3:
Verify PT_WRITE_D called three times
write4:
Verify PT_WRITE_D called four times
Sponsored by <The NetBSD Foundation>
io_write_d1:
Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint8_t)
io_write_d2:
Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint16_t)
io_write_d3:
Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint32_t)
io_write_d4:
Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint64_t)
Sponsored by <The NetBSD Foundation>
io_read_d1:
Verify PT_IO with PIOD_READ_D and len = sizeof(uint8_t)
io_read_d2:
Verify PT_IO with PIOD_READ_D and len = sizeof(uint16_t)
io_read_d3:
Verify PT_IO with PIOD_READ_D and len = sizeof(uint32_t)
io_read_d4:
Verify PT_IO with PIOD_READ_D and len = sizeof(uint64_t)
Sponsored by <The NetBSD Foundation>
These tests verifies the td_map_pth2thr().
It's rather difficult to test all aspects of pthreads_dbg(3) functions out of
context of a real application, this is the reason why these tests are
extensions of the previous ones and they test four (out of unlimited) valid
code-paths.
This function (the same as others in this class) is doing only single thing,
but its result depends on unlimited variations of the context.
The purpose of these checks is basic validation that the pthread_dbg(3) library
is still usable, but not that it's out of bugs.
threads6:
Asserts that pthread_t can be translated with td_map_pth2thr()
to td_thread_t -- and assert earlier that td_thr_iter() call is
valid.
threads7:
Asserts that pthread_t can be translated with td_map_pth2thr()
to td_thread_t -- and assert later that td_thr_iter() call is
valid.
threads8:
Asserts that pthread_t can be translated with td_map_pth2thr()
to td_thread_t -- compare thread's name of pthread_t and
td_thread_t.
threads9:
Asserts that pthread_t can be translated with td_map_pth2thr()
to td_thread_t -- assert that thread is in the TD_STATE_RUNNING
state.
All tests are passing.
Sponsored by <The NetBSD Foundation>
to stdout. Hopefully this will get reported when the test fails in the
testbed rather than just causing ATF to report that it printed
unexpected output.
Asserts that td_thr_getname() handles shorter buffer parameter and the
result is properly truncated.
Currently this test fails due to bug in pthread_dbg.
Sponsored by <The NetBSD Foundation>
threads2:
Asserts that td_thr_iter() call is executed for each thread once
threads3:
Asserts that for each td_thr_iter() call td_thr_info() is valid
These tests pass correctly.
Sponsored by <The NetBSD Foundation>
The following PR are now resolved and are reported to be properly fixed:
PR lib/51635 td_thr_iter in <pthread_dbg.h> seems broken
PR lib/51633 tests/lib/libpthread_dbg/t_dummy unreliable
Sponsored by <The NetBSD Foundation>
Source and destination were swapped. The source of this confusion was that
running these tests under gdb(1) will generate false positives as it will
initialize pthread__dbg to PID of the debugger. This means that it is
currently not possible to debug pthread_dbg code under a full-stack
debugger using NetBSD debugging library for threads.
This should address:
PR lib/51633 tests/lib/libpthread_dbg/t_dummy unreliable
PR lib/51635: td_thr_iter in <pthread_dbg.h> seems broken
After applying the fix I'm able to run all pthread_dbg tests without
indeterminism. The indeterminism was caused by overwritting source of data
with trash.
Sponsored by <The NetBSD Foundation>
This test contains threads1 test that:
Asserts that td_thr_iter() call without extra logic works
This tests fails and is linked with gnats:
PR lib/51635: td_thr_iter in <pthread_dbg.h> seems broken
Sponsored by <The NetBSD Foundation>
The dummy2 test reports failures on i386 releng machines.
The same with dummy3, but it's also reproducible sometimes on my amd64
setup. It's not always broken, neither always functional - once a while it
reports failure. So far I have not reproduced failure in dummy2.
PR lib/51633 tests/lib/libpthread_dbg/t_dummy unreliable
Sponsored by <The NetBSD Foundation>
This test verifies that it's not possible to attach twice to the same
process with td_open() -- it asserts failure with status TD_ERR_INUSE.
This test does nothing besides initializing and deinitializing pthread_dbg
debugging instance.
Refactor code to be more reusable.
Set proper description of dummy2.
Sponsored by <The NetBSD Foundation>.
This tests implements:
- .proc_read with memcpy(3)
- .proc_write with memcpy(3)
- .proc_lookup with dlopen(3) and dlsym(3) combination
td_open() is verified to return with success (TD_ERR_OK), followed by a
call to td_close().
This test does nothing else than initializing and deinitializing td_proc_t
structure, with appropriately implemented functions.
Sponsored by <The NetBSD Foundation>
At the moment this test does nothing except reports failure from td_open()
for overloaded (implemented) dummy1_proc_lookup() (.proc_lookup from
td_proc_callbacks_t) of the following form:
static int
dummy1_proc_lookup(void *arg, const char *sym, caddr_t *addr)
{
return TD_ERR_ERR;
}
This file and directory with tests is placeholder for new ones, without
further need to alter mtree and distribution sets.
The libpthread_dbg interface and library is used by gdb(1) to handle
threads in applications.
Sponsored by <The NetBSD Foundation>
These tests are exact clones for fork1 and fork2, however testing vfork(2).
vfork1:
Verify that vfork(2) is intercepted by ptrace(2) with EVENT_MASK set to
PTRACE_VFORK.
vfork2:
Verify that vfork(2) is not intercepted by ptrace(2) with empty
EVENT_MASK.
vfork1 is supposed to test currently unimplemented PTRACE_VFORK option in
EVENT_MASK, marked as failure and linked with PR kern/51630.
Sponsored by <The NetBSD Foundation>
Verify that fork(2) is not intercepted by ptrace(2) with empty EVENT_MASK.
This test works with all wait(2)-like functions.
Debugger receives only SIGCHLD from tracee, when its the child of tracee
exits. Tracer notes nothing about fork(2) events.
Sponsored by <The NetBSD Foundation>
Verify that fork(2) is intercepted by ptrace(2) with EVENT_MASK set to
PTRACE_FORK.
In this test tracee calls fork(2) and this event is noted by tracer, both
for forker and forkee with PT_GET_PROCESS_STATE reporting pe_report_event
equal to PTRACE_FORK and pe_other_pid as forkee for forker and forker for
forkee.
The fork(2) event in the current implementation stops forker and forkee
with the SIGTRAP signal.
Exited forkee stops forker with the SIGCHLD signal.
Sponsored by <The NetBSD Foundation>.