We've talked about this many times in the past, but partners struggle to
understand "expected 38, got 22" in these contexts, and I always have to
go and check the header files just to be sure I'm sure.
I actually think the glibc geterrorname_np() function (which would
return "ENOSYS" rather than "Function not implemented") would be more
helpful, but I'll have to go and implement that first, and then come
back.
Being forced to go through all our errno assertions did also make me
want to use a more consistent style for our ENOSYS assertions in
particular --- there's a particularly readable idiom, and I'll also come
back and move more of those checks to the most readable idiom.
I've added a few missing `errno = 0`s before tests, and removed a few
stray `errno = 0`s from tests that don't actually make assertions about
errno, since I had to look at every single reference to errno anyway.
Test: treehugger
Change-Id: Iba7c56f2adc30288c3e00ade106635e515e88179
We'll want to come back to this once either Zcmp's push/pop instructions
or V's vector loads/stores are available. But for now, we have no >64b
stores.
But at least this builds.
Test: treehugger
Change-Id: I9503e890cacb198f4ba987bfc92f6eff21c290b0
The mips/mips64 targets were never able to pass these tests, and the
supported architectures don't need any of these workarounds.
Test: treehugger
Change-Id: I640a8b7a98ae13d9d9cdb09b0fbef61d31d4c79a
The code was checking PTRACE_GETREGSET output even in case of error.
This seems not correct. Though ptrace can still write some output in
case of EINVAL, implementation should still check updated iov_len before
reading it.
Change the code to avoid checking output in case of error at all.
Test: bionic-unit-tests --gtest_filter=sys_ptrace.watchpoint_stress
Change-Id: I7b1ca18ac64f81055ff89f56b453aff0ce8e1057
The tests were patched earlier to run with tagging heap allocator.
This change enables hwasan code instrumentation in the tests themselves,
and fixes the issues that arise, mainly in the code that:
* compares addresses of unrelated stack variables
* compares address of a stack variable with stack limits as found in
/proc/self/maps
* writes address of a stack variable to a hardware watchpoint register
etc.
Note that static tests are broken at the moment, like all static
binaries. Dynamic tests pass 100% with this change.
Bug: 114279110, 124007027
Test: SANITIZE_TARGET=hwaddress; run dynamic bionic tests
Change-Id: I68b8df9dd3e30b47734ddc083811a75a7f27deaa
This change enables the tracer process to be able to call ptrace(2) on
the worker process, which is does not have a direct-ancestor dependency.
Bug: 77146512
Test: adb shell \
/data/nativetest{,64}/bionic-unit-tests{,-static}/bionic-unit-tests-{,-static} \
--gtest_filter='spawn*' # aosp_sailfish and Chrome OS
Test: cts-tradefed run singleCommand cts --skip-preconditions \
-m CtsBionicTestCases --test 'PtraceResumptionTest*' # aosp_sailfish
# and Chrome OS
Change-Id: I9e41b3ddde64c0623ba9299cede9d5b2001c8e30
Bionic gtest runner kills a test when it runs over 90s, so there
is no need to use timeout signal in ptrace test.
Bug: http://b/69525592
Test: run bionic-unit-tests.
Change-Id: I767b81a412724ee40fb0f031103a1f05bd7358c4
Strictly not needed in the WNOHANG case, but it's probably best to have
every waitpid wrapped for future copy & pasters.
Bug: https://issuetracker.google.com/69525592
Test: ran tests
Change-Id: I013b0a52d2753e3d32638e9b84c79af7327fb405
If the hardware debug support is missing from the CPU, the kernel can
end up in the state where it reports that it supports N(>0) watchpoints,
but the "maximum supported watchpoint size" is zero.
This is not a really sensible API, but it is what we have. I'm going to
speak to folks upstream about whether we can have it report something
more sensible, but that will take a while (if ever).
So, for the time being, detect this situation and treat it as if no
hardware watchtpoints/breakpoints are supported.
Test: bionic-unit-tests --gtest_filter="sys_ptrace.*"
Change-Id: Id6a013c9bec8d8b450b4a36c28431f6b7fd15879
Bug: 63116544
8-byte watchpoints are not supported on 32-bit kernels (at least on x86,
probably arm as well). 8-byte watchpoints are not required for this
test, so just decrease the size of watchpoints on these architectures.
Change-Id: Ie96b4bc8ce0ad8c924ac737083cf9fe0182aee4d
Test: bionic-unit-tests-static --gtest_filter=sys_ptrace.*
Bug: 37662849
This tests for the presence of a kernel bug that meant that the kernel
would sometimes fail to report the watchpoint hit if the hardware
reported a address which did not exactly match the address range being
watched (which it is allowed to do per ARM spec if the instruction
accesses a larger block of memory than the region being watched). This
bug was fixed in linux kernel 4.9, and has been backported to older
android kernels.
Bug: 30802222
Bug: 30919905
Test: bionic-unit-tests --gtest_filter="sys_ptrace.*"
Change-Id: I80c35b29eaf28e2dbacb9e8ee5317fdea653fc87
Add tests that ensure that the kernel behaves properly w.r.t.
resumption of ptraced processes when the tracer dies.
Bug: http://b/34516140
Test: /data/nativetest/bionic-unit-tests/bionic-unit-tests --gtest_filter="PtraceResumption*"
Change-Id: Id35e069a7e5edd6964637dd3f6358ad59db19792
This fixes the mips build broken by
I7d8a7d79585477d78da1f033c85f8d2cc3b34340.
Change-Id: Ib960bdb51ac81be068f1fdf702aa7c10b183f2a0
Test: lunch mips && cd bionic && mma
This adds a ptrace test which tests the hardware breakpoint
functionality of the ptrace api.
I've also renamed the test case to sys_ptrace to better match the naming
scheme in the other files. I've ran the tests on angler (32 and 64 bit)
and fugu.
Test: run the test
Change-Id: I7d8a7d79585477d78da1f033c85f8d2cc3b34340
This adds a test which verifies that watchpoints work on devices
which support them. It is motivated by issues experienced by Nexus
5 devices, where watchpoints work only sporadically.
These tests spawn a process, trace it, and verify it hits a
watchpoint of various sizes while executing on all available CPUs
(to help catch a recent bug, where some debugging functionality
was not available on non-boot CPUs). All x86(_64) targets are
expected to support this functionality. In case of arm(64),
watchpoints are expected to work on devices where the relevant
syscall indicates watchpoint presence. In case of mips, this test
is skipped as I could not verify that the test would work
correctly due to lack of hardware, and this test is intrinsically
hardware-dependend.
Change-Id: I035ac1822816cd1a3f3b56b985c2fb5fd664185d