Commit graph

174 commits

Author SHA1 Message Date
Josh Gao
05e1e1fb41 Don\'t demangle symbol names. am: fbbc744 am: 0edda64 am: 9bf0b81
am: 0fb3191

* commit '0fb3191840680f7e084aa9ee53a1906074a16b68':
  Don't demangle symbol names.
2016-03-23 20:52:26 +00:00
Josh Gao
0edda648fb Don\'t demangle symbol names.
am: fbbc744

* commit 'fbbc744130c85538a754d245e958d7d79f24309c':
  Don't demangle symbol names.
2016-03-23 20:40:48 +00:00
Josh Gao
fbbc744130 Don't demangle symbol names.
Bug: http://b/27299236
Change-Id: I26ef47f80d4d6048a316ba51e83365ff65d70439
2016-03-23 11:43:35 -07:00
Stephen Hines
a0062cfc31 Update BacktraceOffline for LLVM rebase to r256229.
Bug: http://b/26987366

(cherry picked from commit 19c30e9516)

Change-Id: I5e4568292c0b4bbd2daefc0abd3d36c691622eb4
2016-03-20 22:58:29 -07: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
Andreas Gampe
a7a7369343 Revert "Do not do local unwinds through .oat or .dex maps."
This reverts commit 4265ed7cc8.

Workaround in libunwind instead: change-id I98be5754cc4de4071616db334dc0c9862d3a2504

Bug: 27391690

(cherry picked from commit 04dcb00ab7)

Change-Id: Id77dc081b655dc0fcb513ad0ee95221d91a301f9
2016-03-02 13:20:35 -08:00
Christopher Ferris
b035a19e4f Do not do local unwinds through .oat or .dex maps.
Bug: 27391690

(cherry picked from commit 4265ed7cc8)

Change-Id: I88a49537544b507a3b0bfa61eafc27400a05281b
2016-03-01 18:19:42 -08:00
Christopher Ferris
d4c884330c Fix use of uninitialized memory.
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
2016-02-05 15:22:34 -08:00
Than McIntosh
1e0fea291a Fix for host simpleperf 'gettid' unsat.
Bug: 26900419
Change-Id: Ifefd017f4b62ecfb2521bd1c38dbb3b09054f205
2016-02-01 15:59:40 -05:00
Christopher Ferris
8540216028 Put BacktraceOffline code into a separate library.
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
2016-01-25 16:26:48 -08:00
Christopher Ferris
61c48ac854 Modify tests to use executable memory.
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
2016-01-15 16:08:58 -08:00
Yabin Cui
2ad59db75f libbacktrace: check if elf file paths are valid before reading them.
Bug: 25194400
Change-Id: If6e60585673226392d38fab9ad14bd7b94261316
2015-12-08 19:22:29 -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
Elliott Hughes
4f71319df0 Track rename of base/ to android-base/.
Change-Id: Idf9444fece4aa89c93e15640de59a91f6e758ccf
2015-12-04 22:00:26 -08:00
Christopher Ferris
da750a79c9 Change the way some maps are printed.
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
2015-11-30 14:39:52 -08:00
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
d9a06afb19 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

(cherry picked from commit d7226f9a14)

Change-Id: Ib990a06733cc93717752ab4998f4ae26afd7e249
2015-09-03 19:06:06 -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
Christopher Ferris
e0ab23223a 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
Change-Id: Ia51b669ea3f810158cfd0d71d9ae89bf9a3170d3
2015-08-20 11:16:54 -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
5c57518b6f 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
(cherry picked from commit 35c8136d96)

Change-Id: Ie6e20fbc18702fde935f2cf8cbf1b297fda43282
2015-06-12 23:32:20 -07: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
7e2cb84e9c 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
(cherry picked from commit 2d09171758)

Change-Id: I414c500eb08983a5017caf3fce4f499465575a9d
2015-06-01 14:10:17 -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
eb19e76632 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
(cherry picked from commit 30c942cf10)
2015-05-15 11:32:53 -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
684fb77c82 Add tests for elf unwinding in memory.
Bug: 19517541
(cherry picked from commit 67aba6881d)

Change-Id: I914636ccd814e041475b6b2d81119cac1745a9ff
2015-05-13 13:44:47 -07:00
Dan Albert
428fad97a0 Remove libbacktrace definition of gettid.
Also simplifies the Darwin implementation of gettid, because
apparently libbacktrace had a better way of doing it.

Bug: 19517541

(cherry picked from commit 23f750b068)

Change-Id: I2f888e8ed7a2f5719973786cbcbb399a81867ee9
2015-05-13 13:44:34 -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
8bd4a4ecdc 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
(cherry picked from commit 944f417ccb)
2015-05-06 19:08:52 -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
af67fb2475 Add offset to map data.
Also, print the offset in the maps section.

Bug: 20864928
Change-Id: I71f005726e5ef73cf75bbcb8f829fd5127cb9d61
(cherry picked from commit 5c8856854d)
2015-05-06 16:35:50 -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
Christopher Ferris
329ed7dae4 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
Change-Id: Iec2d1db2051e7b4a278c1dfa57d745128a7f2974
2015-05-01 16:04:24 -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