When creating an UnwindMapLocal fails in the Build() function call,
the destructor for UnwindMap is called. Unfortunately, the map_cursor_
member variable has not been initialized, so the call to destroy it
winds up operating on garbage data.
Part of this is a result of a bad class hierarchy, so this refactors
the classes slightly, and properly initializes the map_cursor_ member
variable in the base class.
Bug: 26931578
Change-Id: I885596bf65e4ef63559cee2c56cd41576d5ecc1b
BacktraceOffline is the only code that uses libLLVM. Create
a new shared library, backtrace_offline.so, that references this
so that including libbacktrace.so doesn't wind up pulling in libLLVM.
Change-Id: I90c502d833f6c464c3810dffde52a0c6da241cce
The check_unreadble_elf_* tests only create a readable map. I changed
libunwind to disallow unwinding through non-executable maps, so make
the maps executable too.
Bug: 26589772
Change-Id: Idbe6426ac4d3243779b819c8f1aebdcdacb0669f
Before, an anonymous map wound up printing the pc as relative.
Unfortunately, this meant that it was impossible to tell the actual
pc. The new code prints the map name as <anonymous:map_start> and
still prints the pc as relative.
In addition, add the start of the map for map names that begin with a
'[' character.
Bug: 25844836
Change-Id: Ie0b6149dde258fe13f0e5a3e5739d85374512f4b
This change makes sure -fno-omit-frame-pointer flag is not
overrided by flags set in $(LLVM_HOST_BUILD_MK).
Change-Id: I53037b0eab6bd1272cec0f5c9caa058ad1a55419
(This might want to be unified with the very similar code in bionic, but
that's a job for another day.)
Change-Id: I5dade498f781305fa9909ee01f1f4bebc537c169
This reverts commit ab5e583327.
And statically link llvm libraries on host to remove dependency
on 32-bit llvm shared library which is not included in the prebuilt.
Bug: 22229391
Change-Id: I8210687655ee1809fd820ab2a6ca5dfaf3f9096d
Using llvm makes libbacktrace stops building for 32 bit on linux host x86_64.
This reverts commit c9c6b6ee77.
Change-Id: Ieb807db881d7bb3132cd09e25fd08c28766ca0a8
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
The dlopen of a shared library in an apk results in large map offsets.
Unfortunately, the current way that the frame data is printed, it's
impossible to tell what the relative pc is relative to. With the
addition of the offset, it's possible to figure out what the relative
pc actually references.
Bug: 23348999
(cherry picked from commit e0ab23223a)
Change-Id: I950f92c1cb29ee05eed777f47453efa03318cf3e
Upstream clang has a new diagnostic, '-Wmismatched-new-delete' to
generate a warning (that becomes an error with -Werror) when delete is
used to deallocate pointers created with 'new[]'. This patch fixes
'delete's that trigger this warning/error.
Change-Id: I7551e856b4b13bfae4cb78b5664d8652322683cf
This error message has no meaning and makes it look like an unwinding
failure occurred. These messages are showing up more often now
that a lot more of debuggerd is using the ReadWord and Read calls.
If a higher level function wants to indicate there is an error, then
it can add a more meaningful error.
Bug: 21818730
Change-Id: I83aca9cf241aee99e7425059b1b6e0d229c08a5e
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
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
The BacktracePtrace::Read function crashes if the number of bytes to
read is less than the number of bytes needed to align the read to
a word_t boundary.
Fix this and add a test for this case.
Change-Id: I50808849ece44928f65dba1d25309e3885c829a2
The new linker relocation packing support uses non-zero load bases,
so we better handle them properly.
Also print out the load base for a map if it's non-zero.
Bug: 20687795
(cherry picked from commit 329ed7dae4)
Change-Id: Ibc37d8c8bb032820dca4e7531184349ba6d402d2
Also simplifies the Darwin implementation of gettid, because
apparently libbacktrace had a better way of doing it.
Change-Id: I9e14f9176b167405a5aaa5b8a0db0327c7126271
When doing a local unwind, do not include the frames that come
from either libunwind or libbacktrace.
Bug: 11518609
Change-Id: I0ec8d823aebbfa0903e61b16b7e5663f3fd65e78
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
The latest clang (r230699) does not allow SP/PC to be declared in inline asm
lists. This is a problem for libraries that are attempting to save all
register state.
Change-Id: I1ce80530f8be85fd74e949d0c65b60080e0aaf2a
Included tests for this new feature.
Changed the NULLs to nullptr in backtrace_test.
Changed UniquePtr to std::unique_ptr in backtrace_test.
Change-Id: I92375465b8f8ba84589834cc162db5915bf1be81
The backtrace structure used to include a pointer to a backtrace_map_t
that represented the map data for a particular pc. This introduced a
race condition where the pointer could be discarded, but the backtrace
structure still contained a pointer to garbage memory. Now all of the map
information is right in the structure.
Bug: 19028453
Change-Id: If7088a73f3c6bf1f3bc8cdd2bb4b62e7cab831c0
Switch to the better supported pthread_cond to handle the Wait/Wake
functions.
Also, increase the number of simultaneous threads in the thread tests.
Bug: 18381207
(cherry picked from commit db44538387)
Change-Id: Id326a7a7b92cb61573def3f761597c40f3ef2f4b