summaryrefslogtreecommitdiff
path: root/debuggerd/debuggerd_test.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add stack trace coverage to MTE tests.Peter Collingbourne2020-05-081-3/+14
| | | | | | | | | It's impractical to test the contents of the stack trace, but we should at least test that *a* stack trace is present, which would have caught the bug fixed by r.android.com/1306754 . Bug: 135772972 Change-Id: Ic5e0b997caa53c7eeec4e5185df5c043c9d4fe3d
* Add support for MTE error reports in tombstones.Peter Collingbourne2020-04-271-0/+170
| | | | | | | | | Teach debuggerd to use the new scudo APIs proposed in https://reviews.llvm.org/D77283 for extracing MTE error reports from crashed processes, and include those reports in tombstones if possible. Bug: 135772972 Change-Id: I082dfd0ac9d781cfed2b8c34cc73562614bb0dbb
* Read fault address on arm64 using proposed kernel API.Peter Collingbourne2020-03-271-0/+26
| | | | | | | | | | | | | | | | On aarch64, the top 8 bits of the address (i.e. the tag bits) of the fault address in si_addr are always clear. This isn't ideal for MTE which will require these bits in order to correctly diagnose tag mismatches. A proposed kernel patch [1] exposes the full fault address including the tag bits as part of the ucontext. Change debuggerd to read this fault address if available. [1] https://patchwork.kernel.org/patch/11435077/ Bug: 135772972 Change-Id: Ia05be574113860f4e9ecc36a310c4b740e0c4afb
* debuggerd: switch to using platform headers for DEBUGGER_SIGNAL.Josh Gao2019-12-171-4/+5
| | | | | Test: treehugger Change-Id: Ie9736c4a077dba1029d2352bd94d47ce07323aec
* [debuggerd] fix -Wreorder-init-listNick Desaulniers2019-10-101-1/+4
| | | | | | | | | C++20 wants members to be ordered unlike C99. Bug: 139945549 Test: mm Change-Id: I3cbca589511c1e0bbc10c691949e18de77e16031 Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
* Increase timeouts.Christopher Ferris2019-09-201-4/+2
| | | | | | | | | | | | There is still some flakiness, so increase the timeout values. Also remove the TEMP_FAILURE_RETRY macro usage in TIMEOUT calls. That macro disables the ability of the alarm code to interrupt the system call. Bug: 141045754 Test: Unit tests pass. Change-Id: Ia3c95dccc3076a3fd5ef6432097a57e4ccee4df3
* Add TEMP_FAILURE_RETRY where appropriate.Christopher Ferris2019-09-181-11/+12
| | | | | | | Bug: 141045754 Test: Ran unit tests in a loop on walleye and cuttlefish. Change-Id: I87b912e76889ed207ab17b862e4786ee44a382ba
* Allow getrlimit/ugetrlimit syscalls in tests.Christopher Ferris2019-09-171-0/+2
| | | | | | | | | | The fdsan code uses getrlimit/ugetrlimit so need to allow that when running the debuggerd unit tests. Bug: 141045754 Test: Ran the offending tests hundreds of times without failure. Change-Id: Iece94f03e7895d61ca8a8f3ab17dce7e54ddf9cd
* Add cause message when stack overflow is detected.Christopher Ferris2019-07-171-0/+27
| | | | | | | | | Test: Ran new unit tests. Test: Ran crasher stack-overflow, crasher64 stack-overflow and verified Test: stack overflow cause is shown. Test: Ran stack overflow app and verified tombstone includes stack-overflow Test: message. Change-Id: I9bb01186dff5ed81c77d84b6aaedb5332ddd7256
* Increase timeout to avoid flaky tests.Christopher Ferris2019-06-261-2/+3
| | | | | | | Also, print extra information when an error occurs. Test: Ran unit tests. Change-Id: I3404549db0ac18a4a82a99b2620556db96376bca
* debuggerd: switch to base::{Send,Receive}FileDescriptors.Josh Gao2019-02-131-2/+7
| | | | | | Bug: http://b/12204763 Test: debuggerd_test Change-Id: I0be40916214de51ab36fd6bd6d44090a84312e51
* tombstoned: don't generate tombstones for native backtraces.Josh Gao2018-09-141-0/+40
| | | | | | | | | | Previously, if an intercept ends before we ask for a file descriptor when doing a backtrace, we'll create a tombstone file instead. Bug: http://b/114139908 Bug: http://b/115349586 Test: debuggerd_test32 Change-Id: I23c7bb8ae5a982a4374a862d0a4f17bee03eb1d9
* Fix multithreaded backtraces for seccomp processes.Josh Gao2018-09-121-4/+40
| | | | | | | | | | | Add threads to the existing seccomp backtrace test to prevent regressing this. Bug: http://b/114139908 Bug: http://b/115349586 Test: debuggerd_test32 Test: debuggerd_test64 Change-Id: I07fbe1619b60f0008deb045a249f9045404478c2
* debuggerd_test: add test for fdsan abort message.Josh Gao2018-08-271-0/+26
| | | | | | | Bug: http://b/112770187 Test: debuggerd_test Test: bionic-unit-tests Change-Id: Ia93761e89074aea4629b8d0f232c580d6f0f249c
* Expect optional (offset ...) in frame dump.Chih-Hung Hsieh2018-05-141-1/+6
| | | | | | | | | * New lld could create files that map to non-zero offset at run time. Test: debuggerd_test Bug: 79590156 Change-Id: I12db0ebef489ba8a1e648a29d214f8d3c3703996
* Fix a debuggerd test expectation.Elliott Hughes2018-05-021-1/+3
| | | | | | | | | 70d8f289454c9b691ec5421b0ed0354b6baaace8 broke a test that was not expecting to see the new detail about the signal's sender. Bug: http://b/78594105 Test: ran tests Change-Id: Idfa3a53b9e664308efdba560ffbb1401c1904530
* debuggerd: remove maximum abort message length.Josh Gao2018-04-131-2/+9
| | | | | | | | Let the logging implementation be the imposer of limits. Bug: http://b/64759619 Test: debuggerd_test Change-Id: I8bc73bf2301ce071668993b740880224846a4e75
* debuggerd_fallback: don't recursively abort.Josh Gao2018-02-221-1/+50
| | | | | | | | | | | | Calls to abort() will always result in our signal handler being called, because abort will manually unblock SIGABRT before raising it. This can lead to deadlock when handling address space exhaustion in the fallback handler. To fix this, switch our mutex to a recursive mutex, and manually keep track of our lock count. Bug: http://b/72929749 Test: debuggerd_test --gtest_filter="CrasherTest.seccomp_crash_oom" Change-Id: I609f263ce93550350b17757189326b627129d4a7
* debuggerd: add seccomp policies and tests.Josh Gao2018-01-181-3/+140
| | | | | | Bug: http://b/38508369 Test: debuggerd_test32/64 on walleye and aosp_x86_64 Change-Id: I7e69e37bcd1823d271b9f2b0a13b8c9cba9a8e84
* base: extract {ASSERT,EXPECT}_MATCH helpers from debuggerd_test.Josh Gao2017-12-191-16/+1
| | | | | | | | Add some helper macros that perform regex string matching to <android-base/test_utils.h>. Test: libbase_test32/64 on host Change-Id: I1b0f03dc73f8b4fdfb8ac6c75d59ef421e0e9640
* crash_dump: fork a copy of the target's address space.Josh Gao2017-12-151-22/+12
| | | | | | | | | | | | | | Reduce the amount of time that a process remains paused by pausing its threads, fetching their registers, and then performing unwinding on a copy of its address space. This also works around a kernel change that's in 4.9 that prevents ptrace from reading memory of processes that we don't have immediate permissions to ptrace (even if we previously ptraced them). Bug: http://b/62112103 Bug: http://b/63989615 Test: treehugger Change-Id: I7b9cc5dd8f54a354bc61f1bda0d2b7a8a55733c4
* crash_dump: don't inherit environment from parent.Josh Gao2017-11-031-0/+21
| | | | | | Bug: http://b/68381717 Test: debuggerd_test Change-Id: Ie1b342bc9901cb9ae9b79147899928a19052cbad
* Add missing includes.Dan Albert2017-10-111-0/+1
| | | | | | Test: mma Bug: None Change-Id: I5ee2d09eeac2b4e2056719498916cbdfb79725d2
* crash_dump: print the identity of tracers.Josh Gao2017-08-181-1/+36
| | | | | | | | | | | Instead of printing a useless "ptrace attach failed: strerror(EPERM)" message, print the name and pid of a competing tracer when we fail to attach because a process is already being ptraced. Bug: http://b/31531918 Test: debuggerd_test32, debuggerd_test64 on aosp_angler Test: strace -p `pidof surfaceflinger`; debuggerd -b surfaceflinger Change-Id: Ifd3f80fe03de30ff38c0e0068560a7b12875f29d
* Debuggerd: Fix debuggerd_testAndreas Gampe2017-06-221-3/+3
| | | | | | | | | | Follow-up to commit 695713e931f0436aca56be9c0dacf2a5dd4e56e7 in bionic. Change expectations of the abort callstack. Test: mmma system/core/debuggerd Test: adb shell /data/nativetest/debuggerd_test/debuggerd_test32 Test: adb shell /data/nativetest64/debuggerd_test/debuggerd_test64 Change-Id: I350a29ee1713a7ebdd50f2b9bdc2078c671e22c7
* debuggerd_test: find backtrace frame in all lines in CrasherTestJaesung Chung2017-06-161-6/+10
| | | | | | | | | | | Kernel can use vsyscall for system calls. The vsyscall implementation in the kernel gives one more depth in the backtrace. It leads to failures on CrasherTest. This CL makes tests find a system call frame not only in the first line but also in all lines on the backtrace. Bug: 62600694 Test: passes all CrasherTests. Change-Id: Ice383bb94db097e7e9a9e4f74d8fa5ecc528122a
* tombstoned: turn on java trace support + unit tests.Narayan Kamath2017-06-071-6/+76
| | | | | | | | | | The SELinux changes that this depends on have now landed. This change also adds a few lower level unit tests of intercept functionality. Test: make; debuggerd_test Change-Id: I0be5e85e7097e26b71db269c9ed92d9b438bfb28
* debuggerd_client: increase pipe buffer size to max.Josh Gao2017-06-011-0/+2
| | | | | | | | | | | If a process tries to dump itself (e.g. system_server during ANRs), crash_dump will block trying to write to its pipe if it's not sufficiently large. Increase the pipe size to the max, and add a test to make sure that it's always at least 1MB (the default value). Bug: http://b/38427757 Test: debuggerd_test Change-Id: Iddb0cb1e5ce9e687efa9e94c2748a1edfe09f119
* tombstoned: allow intercepts for java traces.Narayan Kamath2017-05-311-11/+12
| | | | | | | | | | | | | | | | | All intercept requests and crash dump requests must now specify a dump_type, which can be one of kDebuggerdNativeBacktrace, kDebuggerdTombstone or kDebuggerdJavaBacktrace. Each process can have only one outstanding intercept registered at a time. There's only one non-trivial change in this changeset; and that is to crash_dump. We now pass the type of dump via a command line argument instead of inferring it from the (resent) signal, this allows us to connect to tombstoned before we wait for the signal as the protocol requires. Test: debuggerd_test Change-Id: I189b215acfecd08ac52ab29117e3465da00e3a37
* tombstoned: Add a shared library version of libtombstoned_client...Narayan Kamath2017-05-221-4/+5
| | | | | | | | | | | | | | | | | | | .. for ART and the frameworks to link against. In the new stack dumping scheme (see related bug), the Java runtime will communicate with tombstoned in order to obtain a FD to which it can write its traces. Also move things around to separate headers that are private implementation details from headers that constitute the public debuggerd API. There are currently only three such headers : - tombstoned/tombstoned.h - debuggerd/client.h - debuggerd/handler.h Bug: 32064548 Test: make Change-Id: If1b8578550e373d84828b180bbe585f1088d1aa3
* debuggerd_handler: use syscall(__NR_get[pt]id) instead of get[pt]id.Josh Gao2017-05-051-3/+35
| | | | | | | | | | | | | | bionic's cached values for getpid/gettid can be invalid if the crashing process manually invoked clone to create a thread or process, which will lead the crash_dump refusing to do anything, because it sees the actual values. Use the getpid/gettid syscalls directly to ensure correct values on this end. Bug: http://b/37769298 Test: debuggerd_test Change-Id: I0b1e652beb1a66e564a48b88ed7fa971d61c6ff9
* debuggerd_handler: don't assume that abort message implies fatal.Josh Gao2017-04-271-5/+35
| | | | | | | | | | Applications can set abort messages via android_set_abort_message without actually aborting. This leads to following non-fatal dumps printing their output to logcat in the same format as a regular crash. Bug: http://b/37754992 Test: debuggerd_test Change-Id: I9c5e942984dfda36448860202b0ff1c2950bdd07
* Merge changes Ib8369088,I743433bcJosh Gao2017-04-051-3/+0
|\ | | | | | | | | | | * changes: debuggerd_test: remove useless pipe. debuggerd_client: fix infinite timeouts.
| * debuggerd_test: remove useless pipe.Josh Gao2017-04-041-3/+0
| | | | | | | | | | | | Bug: http://b/36897117 Test: none Change-Id: Ib8369088153fe44de2af9037299bdfce7b709b98
* | debuggerd_test: add test for process/thread names.Josh Gao2017-04-031-0/+2
|/ | | | | | | | | Make sure that we can get the process/thread names for nondumpable processes with capabilities. Bug: http://b/36237221 Test: /data/nativetest/debuggerd_test/debuggerd_test32 Change-Id: Iedd4eae18065c2e64abeebff15e3b9b09a630550
* tombstoned: add tests for b/36685795.Josh Gao2017-03-301-0/+95
| | | | | | | | Add some tests for edge cases which may have triggered b/36685795. Bug: http://b/36685795 Test: debuggerd_test Change-Id: I20670684c8dae422af157be21e44ba5d6d3214d3
* tombstoned: fix a race between intercept and crash_dump.Josh Gao2017-03-301-33/+50
| | | | | | | | | | | Previously, there was no way to detect when tombstoned processed an intercept request packet, making it possible for a intercept request followed by a crash_dump being processed in the wrong order. Add a response to intercept registration, to eliminate this race. Test: debuggerd_test Change-Id: If38c6d14081ebc86ff1ed0edd7afaeafc40a8381
* debuggerd_test: add capability test.Josh Gao2017-02-171-30/+99
| | | | | | | | | | Also, remove the dependency on crasher. Bug: http://b/35100921 Bug: http://b/35241370 Test: /data/nativetest/debuggerd_test/debuggerd_test32 Test: /data/nativetest64/debuggerd_test/debuggerd_test64 Change-Id: I318f6de764d435251417953bf175ba321b59981f
* debuggerd_handler: don't use waitpid(..., __WCLONE).Josh Gao2017-02-131-0/+32
| | | | | | | | | | waitpid(..., __WCLONE) fails with ECHILD when passed an explicit PID to wait for. __WALL and __WCLONE don't seem to be necessary when waiting for a specific pid, so just pass 0 in the flags instead. Bug: http://b/35327712 Test: /data/nativetest/debuggerd_test/debuggerd_test32 --gtest_filter="*zombie*" Change-Id: I3dd7a1bdf7ff35fdfbf631429c089ef4e3172855
* debuggerd_test: improve error when crasher fails to exec.Josh Gao2017-02-071-2/+4
| | | | | | Bug: http://b/35100742 Test: rm /system/bin/crasher && /data/nativetest/debugerd_test/debuggerd_test32 Change-Id: I02faec3b7f7ef62bb8a2ac2af730506e3d28e03e
* debuggerd_test: fix crasher path.Josh Gao2017-02-071-2/+2
| | | | | | | | | | | https://android-review.googlesource.com/#/c/331200 moved crasher to using soong, which changed its location from /system/xbin/crasher to /system/bin/crasher. Bug: http://b/35100742 Test: /data/nativetest/debuggerd_test/debuggerd_test32 Test: /data/nativetest64/debuggerd_test/debuggerd_test64 Change-Id: I16a2050b257277023773cc0c960b5ab36e0c7cd4
* debuggerd_handler: properly crash when PR_GET_DUMPABLE is 0.Josh Gao2017-01-231-4/+30
| | | | | | | | | | Actually exit when receiving a signal via kill(2) or raise(2) and PR_GET_DUMPABLE is 0. Bug: none Test: /data/nativetest/debuggerd_test/debuggerd_test32 Test: /data/nativetest64/bionic-unit-tests/bionic-unit-tests --gtest_filter=pthread_DeathTest.pthread_mutex_lock_null_64 Change-Id: I833a2a34238129237bd9f953959ebda51d8d04d7
* crash_dump: set a watchdog timer.Josh Gao2017-01-231-12/+3
| | | | | | | | | | | | | PTRACE_DETACH is only necessary if the process is in group-stop state, the tracer exiting is sufficient to detach and resume tracees. Using this, set a 5 second timer with alarm(2) that just kills us, to avoid leaving processes stopped. Bug: http://b/34472671 Test: debuggerd_test Test: crasher + manually inserting a 10 second sleep into crash_dump Change-Id: Iacaa796f79037aa1585f3f2159abe45ef0069311
* debuggerd: advance our amazing bet.Josh Gao2017-01-171-0/+390
Remove debuggerd in favor of a helper process that gets execed by crashing processes. Bug: http://b/30705528 Test: debuggerd_test Change-Id: I9906c69473989cbf7fe5ea6cccf9a9c563d75906