Commit graph

149 commits

Author SHA1 Message Date
Yabin Cui
af8ac0c498 libbacktrace: don't let llvm cflags cover libbacktrace's cflags.
Change-Id: Ib2783bf5d145599ffed822eec0a2d9f7df2fddf5
2015-09-24 17:46:27 -07:00
Elliott Hughes
9ea0ff343f Merge "Clean up maps parsing in libbacktrace." 2015-09-23 05:35:05 +00:00
Yabin Cui
9e1dd67de4 libbacktrace: enable -fno-omit-frame-pointer for host build.
This change makes sure -fno-omit-frame-pointer flag is not
overrided by flags set in $(LLVM_HOST_BUILD_MK).

Change-Id: I53037b0eab6bd1272cec0f5c9caa058ad1a55419
2015-09-22 22:07:21 -07:00
Elliott Hughes
fe3593dc2a Clean up maps parsing in libbacktrace.
(This might want to be unified with the very similar code in bionic, but
that's a job for another day.)

Change-Id: I5dade498f781305fa9909ee01f1f4bebc537c169
2015-09-22 17:26:24 -07:00
Yabin Cui
9e402bb20c Revert "Revert "Revert "Revert "Add BacktraceOffline for offline backtracing.""""
This reverts commit 94ece83270.

Change-Id: Ie06465c89a5fc115517130f9f2904cc855973155
2015-09-22 04:46:57 +00:00
Yabin Cui
94ece83270 Revert "Revert "Revert "Add BacktraceOffline for offline backtracing."""
This reverts commit 0a411c934a.

Change-Id: Ic1824afac6c32f1087b66de9d6368a561f235d13
2015-09-22 01:38:17 +00:00
Yabin Cui
0a411c934a Revert "Revert "Add BacktraceOffline for offline backtracing.""
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
2015-09-21 12:54:45 -07:00
Yabin Cui
ab5e583327 Revert "Add BacktraceOffline for offline backtracing."
Using llvm makes libbacktrace stops building for 32 bit on linux host x86_64.

This reverts commit c9c6b6ee77.

Change-Id: Ieb807db881d7bb3132cd09e25fd08c28766ca0a8
2015-09-17 22:54:22 +00:00
Yabin Cui
c9c6b6ee77 Add BacktraceOffline for offline backtracing.
It is used by simpeleprf for stack unwinding.

Bug: 22229391
Change-Id: I26d698610ccdc9545da837bc5a8a9ec787f27a6b
2015-09-16 17:38:23 -07: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
600017332c Display the map offset for each frame.
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
2015-08-20 14:07:30 -07:00
Pirama Arumuga Nainar
837eff22c8 Use delete[] to de-allocate pointers from new[]
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
2015-07-09 10:50:04 -07:00
Calin Juravle
28042b5627 Add static versions for libbacktrace and libnativebridge. Bug fixes.
Change-Id: Ic68ac15b2676e4f475330c8e7bb34e0d48783686
2015-07-02 02:09:20 +01:00
Christopher Ferris
35c8136d96 Remove PtraceRead error message.
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
2015-06-12 23:03:22 -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
Christopher Ferris
67aba6881d Add tests for elf unwinding in memory.
Bug: 19517541
Change-Id: Ib42360a82934ff7103e2ccb64c1105c59aa3fdea
2015-05-12 16:11:47 -07:00
Christopher Ferris
944f417ccb Fix small ptrace reads.
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
2015-05-06 16:39:17 -07:00
Christopher Ferris
5c8856854d Add offset to map data.
Also, print the offset in the maps section.

Bug: 20864928
Change-Id: I71f005726e5ef73cf75bbcb8f829fd5127cb9d61
2015-05-06 12:50:09 -07:00
Christopher Ferris
2106f4ba95 Add load base to map for relocation packing.
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
2015-05-01 17:09:49 -07:00
Colin Cross
5b439eaf93 Fix unused argument error on darwin
Change-Id: Ie90f7f32b5bd1496bd663c969d729ea3f96d2588
2015-04-30 15:11:34 -07:00
Colin Cross
db134ca20c Remove libbacktrace dependency on libcutils
libbacktrace doesn't use libcutils, it uses liblog.

Change-Id: Ie1328b18a9f189c081891ba3b9a28487e830e579
2015-04-30 14:25:57 -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
3b9d14ac4b Remove libunwind-ptrace dependency.
Change-Id: Iae4a73546f672c208ffe1b224e8d9a9e693f95f0
2015-04-15 14:50:39 -07:00
Christopher Ferris
97e00bb25a Update the test for better output on error.
Change-Id: Id3b0b96a33441ce5d908aac38e639ac3598a7a89
2015-04-02 15:36:09 -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
9dc41d5d34 Merge "Refactor the code." 2015-03-31 21:11:36 +00:00
Stephen Hines
9c01c44bd6 Merge "Add -Wno-inline-asm to Clang flags." 2015-03-31 20:56:06 +00: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
Stephen Hines
035e9ba97e Add -Wno-inline-asm to Clang flags.
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
2015-03-31 09:41:24 -07:00
Dan Albert
d0a793dca3 Remove uses of libcxx.mk.
This is a no-op.

Change-Id: Iecbcd5f6d818abbf98767a2e996c10f454b652e4
2015-03-27 11:24:04 -07:00
Andreas Gampe
dce8f2923d Libbacktrace: Use frame-pointer on host
Otherwise it may have problems unwinding over itself.

Change-Id: I9b0d108018ae3f5d98b9ae6fb62d0af83a77d18e
2015-03-26 16:21:13 -07:00
Christopher Ferris
2b4a63fc6a Add variable length read to Backtrace.
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
2015-03-17 14:56:02 -07:00
Christopher Ferris
12385e3ad0 Move map data into backtrace data proper.
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
2015-02-06 15:00:09 -08:00
Christopher Ferris
2a176a89c2 Remove link to gccdemangle.
Bug: 18930951
Change-Id: Ib7fd332b6e02241c0676ef33d2fa210a72efe1b1
2015-02-05 19:33:11 -08:00
Trevor Drake
5e4d0a5ec8 Cleanup libbacktrace Android.mk
Removed unnecessary libbacktrace_c_includes variable

Change-Id: I2ef29dc9810f7d9a7dcf5c232e9e85d2fc2fd5e8
2014-12-12 04:40:06 +00:00
Christopher Ferris
3cdbfdce6a Convert futex to cond wait.
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
2014-11-14 10:46:39 -08:00
Dan Albert
5570c9b174 Add LOCAL_MULTILIB := both to Darwin libbacktrace.
This was previously set for libbacktrace_libc++, but apparently never
was for libbacktrace.

Change-Id: I85dc44b356710c6367f5cea3bc0a4d6c817ca202
2014-11-13 14:55:06 -08:00
Dan Albert
0d7164d4dd Remove the stlport linked libbacktrace.
Rename the libc++ linked libbacktrace to the normal name.

Bug: 15193147
Change-Id: I75caf1ee527e3703825e0db757497fb8fa3dd122
2014-11-11 15:57:38 -08:00
Brian Carlstrom
34f9b1e9f2 am 2ea89b63: am 936a236b: Merge "Add uncached argument to BacktraceMap::Create on darwin"
* commit '2ea89b631d58ecd8edd7165ed8840d1e1047aa72':
  Add uncached argument to BacktraceMap::Create on darwin
2014-08-05 13:11:42 +00:00
Christopher Ferris
1cbdb2f773 am f02593b0: Allow getting an uncached process map.
* commit 'f02593b0e61f8108449770094caa7bb39a646ec1':
  Allow getting an uncached process map.
2014-08-05 02:28:01 +00:00
Brian Carlstrom
b978a329ef Add uncached argument to BacktraceMap::Create on darwin
Change-Id: I247a98fc3b98879a0c34a975f9914ccec95d1a04
2014-08-05 00:15:49 -07:00
Christopher Ferris
dda47b7868 Allow getting an uncached process map.
(cherry picked from commit f02593b0e6)

Change-Id: I2012bf2dc553ebc663345b9eac6d794e80df9c00
2014-08-04 19:21:23 -07:00
Christopher Ferris
f02593b0e6 Allow getting an uncached process map.
Change-Id: I58d7e90a7b5c4476a4b9f51640c54d13748ac220
2014-08-04 17:17:57 -07:00
Tim Murray
650f43d0d5 am 83ddddaa: am 4795ce06: Merge "Update makefiles for host clang."
* commit '83ddddaaba0fea8a1c0dcc64e795112bed67815f':
  Update makefiles for host clang.
2014-07-25 01:03:31 +00:00
Tim Murray
06fce9db05 Update makefiles for host clang.
bug 16172793

Change-Id: If7484c5dbcccce7d925bec97bff0a3e4c30e9434
2014-07-24 12:18:22 -07:00
Ian Rogers
91c73f6c51 am 38dda3b8: am c309b97e: am e4022279: Merge "libbacktrace_libc++ needs to be multilib on the Mac too."
* commit '38dda3b8887286c44964dda0ce1c96425d9744f0':
  libbacktrace_libc++ needs to be multilib on the Mac too.
2014-06-25 10:15:34 +00:00
Ian Rogers
c132aaf0c3 libbacktrace_libc++ needs to be multilib on the Mac too.
Change-Id: I2053345253c1d57c3485b790163ba0b4b10cc326
2014-06-24 21:57:55 -07:00
Ian Rogers
9db200f7ad am 44367492: am 4ac17e3b: am 4dfe6faa: Merge "Enable host multilib for ART testing."
* commit '4436749284dc2b74e6e0f430d0f803d1b7862d19':
  Enable host multilib for ART testing.
2014-06-17 18:58:34 +00:00
Ian Rogers
5af80aa119 Enable host multilib for ART testing.
Change-Id: Ic3ae5122eba13565fb5a4cb1bd0e7e465fb2140c
2014-06-17 01:50:25 -07:00