Commit graph

15 commits

Author SHA1 Message Date
Yi Kong
c91e6f9e5f [libbacktrace] Fix sign-compare warning
static_cast GetThreadId result to pid_t.

Test: m checkbuild
Change-Id: Id3f541c1cb6cad9471e0cedf2ca49ce0fc38df38
2018-12-17 12:51:36 -08:00
Elliott Hughes
38488907a0 Move libbacktrace off cutils.
There's still <cutils/atomic.h> in a test, but I don't understand why
that isn't just std::atomic.

Also add a shared tgkill wrapper to libbase.

Bug: N/A
Test: ran tests
Change-Id: Idd4baa1e1670a84b3a8f35803cc5ffe5aae008a6
2018-07-11 13:55:07 -07:00
Christopher Ferris
c8bec5aa91 Use new unwinder for offline in libbacktrace.
libbbacktrace changes:
- Completely rewrite the BacktraceOffline class to use the new unwinder.
- Modify the test data to save ucontext_t data instead of unw_context data.
- Convert the previous tests from unw_context data to ucontext_t data.

Bug: 65682279

Test: New unit tests pass in libunwindstack.
Test: All offline tests continue to pass.
Change-Id: I540345c304b20199d46deeb0349a0638a0f3ab2f
2018-01-29 10:41:11 -08:00
Christopher Ferris
7937a36c8e Change all uintptr_t to uint64_t in API.
In order to support the offline unwinding properly, get rid of the
usage of non-fixed type uintptr_t from all API calls.

In addition, completely remove the old local and remote unwinding code
that used libunwind.

The next step will be to move the offline unwinding to the new unwinder.

Bug: 65682279

Test: Ran unit tests for libbacktrace/debuggerd.
Test: Ran debuggerd -b on a few arm and arm64 processes.
Test: Ran crasher and crasher64 and verified tombstones look correct.
Change-Id: Ib0c6cee3ad6785a102b74908a3d8e5e93e5c6b33
2018-01-18 17:26:20 -08:00
Yabin Cui
f88082811a libbacktrace: export offline unwinding failures.
This is to help debugging different offline unwiding failures.

Bug: http://b/69383534
Test: run backtrace_test.
Change-Id: I5ed4837027a9f17d032925e97e9f5927161444b3
2017-12-15 13:29:53 -08:00
Christopher Ferris
f30a810bce Use async safe logging in signal handlers.
Test: Boot on bullhead.
Test: Ran the libbacktrace tests on bullhead.
Test: Added a temporary log message in the signal handler, and ran the
Test: backtrace tests.
Change-Id: I0a6888c9f311af2c8cc7fbb4929315911bd2bb3c
2017-05-04 17:15:17 -07:00
Christopher Ferris
10ab87f646 Restore errno in signal handlers.
There was a problem where errno could be set in a signal handler
and cause bugs if other system calls were interrupted.

There isn't strong evidence this is causing any issues, but add this
proactively.

Bug: 31448909

Test: Ran the backtrace unit tests, backtraces few random processes,
Test: forced the ANR path for some zygote based processes.
Test: Ran the art ThreadStress test a few times.
Change-Id: I5abc9e330a5e86cea7015e2362f66044c6bc37d0
2017-03-10 10:13:48 -08:00
Christopher Ferris
c463ba45c4 Add error reporting mechanism for failing Unwind.
Remove the logging of an error if a thread disappears before the unwind
can begin. This can happen, so allow the caller to determine if this
is really a problem worth logging.

Bug: 27449879

(cherry picked from commit 206a3b9798)

Change-Id: If9e7cfeb6eb7b122679a734c1a9eacee8354ef18
2016-03-10 14:14:43 -08:00
Yabin Cui
6405bb3aee Fix libbacktrace host build.
On host build, libbacktrace relies on libcutils to provide gettid()
function.

Change-Id: Iad83384ea699ca024b71b73cef26755287c9e6fe
2015-12-07 20:09:24 -08:00
Christopher Ferris
d7226f9a14 Add a logging handler on timeout.
If the signal handler doesn't fire in the given time when trying to unwind
a thread, put on a logging handler. This prevents crashes if the signal
does eventually fire.

Bug: 23783762
Change-Id: Ib7abb36b71d079a7043117697c41b535319586fd
2015-09-03 12:27:57 -07:00
Christopher Ferris
2d09171758 Modify the code to avoid potential deadlocks.
If the signal to dump a thread is never delivered, then it's
possible for a deadlock. The signal handler is responsible for
unlocking and deleting the ThreadEntry created for the pid/tid
combination. This means if the signal is lost, the ThreadEntry
gets stuck locked and never deleted. If a second attempt to get
a backtrace of this thread occurs, there is a deadlock.

Also, decrease the timeout from 10 seconds to 5 seconds. The original
10 seconds was because the unwind was actually done in the signal
handler. Now the signal handler does nothing but copy the ucontext
structure and let the caller do the unwind.

Bug: 21086132
Change-Id: Idc735dbf6147ec879d35bd4f034c5d227e26a98d
2015-06-01 13:51:51 -07:00
Christopher Ferris
30c942cf10 Prevent crashes if a map cannot be created.
Under some conditions, /proc/<pid>/maps might return nothing. If we
try and unwind in this case, we'll crash. Check this case and fail
the unwind.

Add checks that no other functions try and use map_ without
checking for nullptr.

Add logging when an unwind fails so it's clear what happened.

Bug: 21162746
Change-Id: I56ce51dda0cfc9db20475a441f118108196aa07c
2015-05-14 17:56:41 -07:00
Dan Albert
23f750b068 Remove libbacktrace definition of gettid.
Also simplifies the Darwin implementation of gettid, because
apparently libbacktrace had a better way of doing it.

Change-Id: I9e14f9176b167405a5aaa5b8a0db0327c7126271
2015-04-30 12:52:21 -07:00
Christopher Ferris
ca09ce902c Discards frames for code within library.
When doing a local unwind, do not include the frames that come
from either libunwind or libbacktrace.

Bug: 11518609
Change-Id: I0ec8d823aebbfa0903e61b16b7e5663f3fd65e78
2015-04-01 15:58:20 -07:00
Christopher Ferris
2c43cff01d Refactor the code.
The object hierarchy was confusing and convoluted. This removes
a lot of unnecessary code, and consolidates the BacktraceCurrent
and BacktraceThread code into BacktraceCurrent.

Change-Id: I01c8407d493712a48169df49dd3ff46db4a7c3ae
2015-03-31 10:51:44 -07:00