Commit graph

312 commits

Author SHA1 Message Date
Colin Cross
53783b1976 Add missing host ldlibs
Host builds were compiling without -Wl,--no-undefined.  Add missing
host ldlibs so that -Wl,--no-undefined can be added again.

Test: m -j host
Bug: 32305815
Change-Id: I0ceabc3f4ec74e2f737afaac58810c5d53d6ccb6
2016-10-20 10:39:51 -07:00
Mark Salyzyn
cfd5b080af system/core: preparation to pull back interfaces from android/log.h
Point to log/log.h where necessary, define LOG_TAG where necessary.
Accept that private/android_logger.h is suitable replacement for
log/logger.h and android/log.h.

Correct liblog/README

Effectively a cleanup and controlled select revert of
'system/core: drop or replace log/logger.h' and
'system/core: Replace log/log.h with android/log.h'.

Test: compile
Bug: 30465923
Change-Id: Ic2ad157bad6f5efe2c6af293a73bb753300b17a2
2016-10-20 08:11:39 -07:00
Treehugger Robot
955648a915 Merge "Rely on the platform -std default." 2016-10-14 02:28:38 +00:00
Christopher Ferris
279843e139 Use process_vm_readv to read memory.
Modify BacktracePtrace::Read to use the process_vm_readv syscall
instead of doing multiple ptrace calls.

Test: Ran the backtrace unit tests on host and on x86_64 emulator.

Change-Id: I24c2787f6713d8eb44312f3aa751d1f6d9d34719
2016-10-12 12:43:55 -07:00
Elliott Hughes
36e0d390a2 Rely on the platform -std default.
Bug: http://b/32019064
Test: builds
Change-Id: I18a1d816d63b64601485045070851f32d44e85eb
2016-10-10 14:31:12 -07:00
Mark Salyzyn
ff2dcd9af9 system/core Replace log/log.h with android/log.h
Should use android/log.h instead of log/log.h as a good example
to all others.  Adjust header order to comply with Android Coding
standards.

Test: Compile
Bug: 26552300
Bug: 31289077
Change-Id: I33a8fb4e754d2dc4754d335660c450e0a67190fc
2016-09-30 12:47:05 -07:00
Colin Cross
99f6b86733 Replace libziparchive-host with libziparchive
libziparchive-host is no longer necessary, and mixing libziparchive-host
and libziparchive can cause ODR violations.

Change-Id: I27b2cc9974000ee7bf1d1ac15fd7b069862d9b01
2016-08-26 11:12:38 -07:00
Chih-Hung Hsieh
4c4fa90462 Merge \"Fix clang-tidy performance warnings in syste/core.\"
am: 4efbce14b5

Change-Id: I84f6b0134fae6e9f40710f243f4825e3f31fa15f
2016-08-01 20:23:10 +00:00
Treehugger Robot
4efbce14b5 Merge "Fix clang-tidy performance warnings in syste/core." 2016-08-01 20:13:54 +00:00
Chih-Hung Hsieh
8f7b9e3d39 Fix clang-tidy performance warnings in syste/core.
* Use const reference type for parameters to avoid unnecessary copy.
* Suppress warning of not using faster overloaded string find function.

Bug: 30407689
Bug: 30411878
Change-Id: I6cfdbbd50cf5e8f3db6e5263076d3a17a9a791ee
Test: build with WITH_TIDY=1
Merged-In: Ie79dbe21899867bc62031f8618bb1322b8071525
2016-08-01 11:55:42 -07:00
Chih-Hung Hsieh
89cc78b77f Merge \"Fix google-explicit-constructor warnings in system/core.\"
am: 6dc68cb5f9

Change-Id: I5a010465364b6e14423b19e8c0f9cffa58ee3152
2016-07-29 17:01:17 +00:00
Chih-Hung Hsieh
034c475931 Fix google-explicit-constructor warnings in system/core.
* Declare explicit conversion constructors.
* Add NOLINT for implicit conversion constructors.
* Fix also some misaligned indendations.

Bug: 28341362
Change-Id: Idf911f35923b408d92285cc1a053f382ba08c63e
Test: build with clang-tidy
2016-07-26 11:26:01 -07:00
Colin Cross
2fedbf79bb resolve merge conflicts of 41e82a3 to stage-aosp-master
Change-Id: I5a7faca3249f0c038914540b1dd29edf0084c0e1
2016-07-12 23:53:04 -07:00
Dan Willemsen
2e1591bef9 Convert libbacktrace, libutils to Soong
Change-Id: I8b578f671f92246aca61f98937d75a60b56bc5c6
2016-07-12 17:20:18 -07:00
Christopher Ferris
e1eb2272d6 Merge \"Fix race condition updating local map data.\"
am: 863d8e11b9

Change-Id: I00899ce500c2ae8bc58b6eb42c01d8688dd232c0
2016-06-18 00:05:26 +00:00
Christopher Ferris
3a14004c7f Fix race condition updating local map data.
If the underlying local map changes, it's possible for multiple
threads to try and modify the map data associated with the UnwindLocalMap
object. Add a lock when generating the local map to avoid this problem.

In addition, add a read lock whenever any caller gets the maps iterator.
Updated all iterator callers to make this lock.

Bug: 29387050
Change-Id: Ie34822c3d8fd3bdb3dd126aeeb399969c36508c1
2016-06-16 23:28:11 -07:00
Dan Willemsen
823d5bbc20 Merge "Remove invalid uses of -l and -I" am: 5d6193c658
am: 9ae3c079dc

* commit '9ae3c079dca647869dcbc5a5075609f0895e4f4c':
  Remove invalid uses of -l and -I

Change-Id: Id0ddd34cee10579684cdde36f3c095658a50784b
2016-06-01 21:57:27 +00:00
Dan Willemsen
ee2da03e26 Remove invalid uses of -l and -I
LOCAL_LDLIBS should only be used with -l flags for NDK and some host
libraries. Other uses should use LOCAL_SHARED_LIBRARIES.

LOCAL_LDFLAGS should not contain -l entries, they should be in
LOCAL_LDLIBS instead.

LOCAL_CFLAGS should not contain -I entries, those should use
LOCAL_C_INCLUDES instead.

Change-Id: Ic901aa14651572ac682166becd4f0cd86baecc34
2016-06-01 13:41:23 -07:00
Chih-Hung Hsieh
dccd3a3698 Merge "Fix misc-macro-parentheses warnings in adb, debuggerd, libbacktrace." am: dab7d9de03
am: fa7569c921

* commit 'fa7569c921b9ca0db894287ea826cbd3b041d880':
  Fix misc-macro-parentheses warnings in adb, debuggerd, libbacktrace.

Change-Id: I63223e36f3627d312051c86d54919b6cef33766c
2016-05-19 00:05:39 +00:00
Chih-Hung Hsieh
67867dbd79 Fix misc-macro-parentheses warnings in adb, debuggerd, libbacktrace.
Bug: 28705665
Change-Id: I469b2a882f6d1f399bfc22c75a26da245991fc33
2016-05-18 15:53:15 -07:00
Chih-hung Hsieh
fb44ca5178 Merge "Fix google-explicit-constructor warnings." am: 7bdd6a8b5a
am: 427d8d840f

* commit '427d8d840f6ec5ce5767b2ee521e4ac5b7ebd619':
  Fix google-explicit-constructor warnings.

Change-Id: I26dc45aca83f991aa7993f6d4233e0439dd44a22
2016-04-30 05:16:35 +00:00
Chih-Hung Hsieh
1c563d96f0 Fix google-explicit-constructor warnings.
Bug: 28341362
Change-Id: I4504e98a8db31e0edcbe63c23f9af43eb13e9d86
2016-04-29 15:44:04 -07:00
Chih-hung Hsieh
f648232165 Merge "Fix google-runtime-int warnings." am: 603df0e
am: 6eaa916

* commit '6eaa91685fa69bd7bb4309933899a9e33fa61dfd':
  Fix google-runtime-int warnings.

Change-Id: I2e0fd77a2c841e5279973f08e961bf2ffdd41c09
2016-04-19 16:25:05 +00:00
Chih-Hung Hsieh
ec2ff8c176 Fix google-runtime-int warnings.
Bug: 28220065
Change-Id: I6b8e121ddf98355d1c1ac034c2e3522b2b49e14b
2016-04-18 14:45:46 -07:00
Yabin Cui
3424eaa01d Merge "libbacktrace: only build libbacktrace_offline static library." am: f20e4b1
am: b150324

* commit 'b1503248f4baa28ed739948a51da370bf40037ea':
  libbacktrace: only build libbacktrace_offline static library.

Change-Id: I903f82a38022f7094b70bc8e4d59ac5098456571
2016-04-14 21:38:12 +00:00
Yabin Cui
51e607056d libbacktrace: only build libbacktrace_offline static library.
As device may not have libbacktrace_offline shared library, simpleperf
no longer rely on it. So there is no reason to keep libbacktrace_offline
shared library.

Bug: 28152982
Change-Id: If8e31b1434646dbbfed60264eb25f034bc5d6946
2016-04-14 10:31:08 -07:00
Yabin Cui
566692fa11 Merge "libbacktrace_offline: support unwinding of shared libraries in apk file." am: d8c88fc
am: f63704e

* commit 'f63704ed5a9daa40b9e471c7020ae4e4541dee79':
  libbacktrace_offline: support unwinding of shared libraries in apk file.

Change-Id: If880c04da5ab6b4faa232b80fbfceca37f63d41d
2016-03-29 18:30:19 +00:00
Yabin Cui
b791a76ed7 libbacktrace_offline: support unwinding of shared libraries in apk file.
Bug: 26962895
Change-Id: I009080f26e7323247c3ab24eea614eec4432ca6a
2016-03-26 16:06:23 -07:00
Josh Gao
c7d8777d56 Don\'t demangle symbol names. am: fbbc744 am: 0edda64 am: 9bf0b81 am: 0fb3191
am: 05e1e1f

* commit '05e1e1fb4100bb52fab2af41dc6caaf31c527819':
  Don't demangle symbol names.
2016-03-23 20:58:50 +00:00
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
Pirama Arumuga Nainar
922e151ba2 Merge "Update BacktraceOffline for LLVM rebase to r256229." 2016-03-18 21:54:51 +00: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
Christopher Ferris
206a3b9798 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
Change-Id: Ie81718d53fb0e519fa0a7db9fd5f314b72bfa431
2016-03-10 12:39:15 -08:00
Christopher Ferris
26cf352637 Merge "Don't fail if the new pss is less than stable." 2016-03-08 18:09:18 +00:00
Stephen Hines
19c30e9516 Update BacktraceOffline for LLVM rebase to r256229.
Bug: http://b/26987366
Change-Id: I3c5f3349a669c04bb40dd7175f840b57dc46f7f6
2016-03-08 01:23:43 -08:00
Christopher Ferris
5ccdfa6349 Don't fail if the new pss is less than stable.
Sometimes, the new pss is significantly less than the stable pss. Do
not fail if this case occurs.

Change-Id: Ic7da87275a821818e375d05cac10e84c62710c5e
2016-03-07 19:18:31 -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
Andreas Gampe
04dcb00ab7 Revert "Do not do local unwinds through .oat or .dex maps."
This reverts commit 4265ed7cc8.

Workaround in libunwind instead: change-id I98be5754cc4de4071616db334dc0c9862d3a2504

Bug: 27391690
Change-Id: Id77dc081b655dc0fcb513ad0ee95221d91a301f9
2016-03-02 19:39:21 +00: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
4265ed7cc8 Do not do local unwinds through .oat or .dex maps.
Bug: 27391690
Change-Id: I88a49537544b507a3b0bfa61eafc27400a05281b
2016-03-01 18:07:59 -08:00
James Hawkins
588a2cad7f system/core: Cleanup direct calls to opendir by containing in a
std::unique_ptr.

Bug: 26643633
Change-Id: Ia3491fdbff086558da694ae949cf08e4c89d0307
2016-02-18 14:52:46 -08:00
Yabin Cui
9946a8f755 libbacktrace: support building static libraries on target.
Bug: 27125711

Change-Id: I28a49e3e128fa4291815a54cf942452bd1f9f756
2016-02-10 15:20:44 -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
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
Ian Rogers
8396e75192 am 2b958116: am a31dab8a: am a9aa0f2c: Merge "Build the libc++ variant of libbacktrace on the host for Mac."
* commit '2b95811601b05db7894359f037005a008274a973':
  Build the libc++ variant of libbacktrace on the host for Mac.
2014-06-11 21:48:41 +00:00
Ian Rogers
deebae596b Build the libc++ variant of libbacktrace on the host for Mac.
Bug: 13751317
Change-Id: Iefadec1cd9b3ca109ac436bd5eb7c096c2dcbe40
2014-06-11 12:55:50 -07:00
Christopher Ferris
5a19885641 am 012090e5: am a0962b68: am d917d64f: Merge "Only copy mcontext data from sigcontext."
* commit '012090e57b697133ad6f7d989e103d71302749f8':
  Only copy mcontext data from sigcontext.
2014-05-23 22:40:58 +00:00
Christopher Ferris
e484607622 Only copy mcontext data from sigcontext.
The ucontext_t data structure could be bigger than the kernel data
structure. Since the unwinder only cares about the mcontext data, only
copy that out of the structure. The mcontext data is the same size in
the kernel and in the ucontext_t structure.

Bug: 15189014
Change-Id: I5978169c4425b8212e11db85a57eb319cd0e264b
2014-05-23 15:11:26 -07:00
Dan Albert
425ed96a38 am 633a2e3b: am 3ab1d61b: am 3b5cd911: Merge "Remove libstdc++ dependency from host libbacktrace"
* commit '633a2e3b6a1d00257965a5772a5467a6df9911a5':
  Remove libstdc++ dependency from host libbacktrace
2014-05-22 18:28:01 +00:00
Dan Albert
3b5cd9117d Merge "Remove libstdc++ dependency from host libbacktrace" 2014-05-22 17:21:52 +00:00
Dan Albert
e2a3d37c8f am 219e867f: am 7f8ebb81: am 30291f21: Merge "Add missing headers"
* commit '219e867f61755720af3cddb5e8d2fe0e198a27ab':
  Add missing headers
2014-05-22 13:32:56 +00:00
Dan Albert
a3a8f6d2ab Remove libstdc++ dependency from host libbacktrace
The libc++ version of libbacktrace on the host was still linking against
libstdc++, and this was causing problems in art.

Change-Id: I1d14fb9e18abd074affcf46c8044407041970669
2014-05-21 20:10:02 -07:00
Dan Albert
ac2fe7eb81 Add missing headers
These headers are needed for pid_t and free when using libc++ headers (POSIX
does not require that the symbols be exposed with the previous includes).

Change-Id: Ia51a4fdfdbae7377130a43c401c2d8d241671d1e
2014-05-21 20:08:35 -07:00
Dan Albert
fbc5ca28c9 am c6112ca4: am 5b654f15: am 201bf676: Merge "Really fixes the ub branches"
* commit 'c6112ca4b8d0712fdd4c0ab3258d3ceaf2f8064e':
  Really fixes the ub branches
2014-05-20 00:23:03 +00:00
Dan Albert
ad51136267 Really fixes the ub branches
Change-Id: I1d78f4e6c1d8086c2895f6739c3202e9ef74fee2
2014-05-19 14:49:13 -07:00
Dan Albert
917152b8cc am 3f01965b: am 121f209d: am e1efe23f: Merge "Fix unbundled branches"
* commit '3f01965b3d1335ffff57e15fd47e5d99400dad3f':
  Fix unbundled branches
2014-05-19 19:31:17 +00:00
Dan Albert
a8b8460220 Fix unbundled branches
Change-Id: Ic8a58a6cf55221ec361bbb80c7c9636fe1349943
2014-05-19 11:40:27 -07:00
Dan Albert
7ce29b5826 am e9b36f1a: am 888f95e2: am f03bd953: Merge "Adds libc++ versions of libbacktrace"
* commit 'e9b36f1a9a280877cb130452c50af6a51360a203':
  Adds libc++ versions of libbacktrace
2014-05-19 18:33:51 +00:00
Dan Albert
40a46dde9c Adds libc++ versions of libbacktrace
Change-Id: I4a1ce30e7c2166ac1846cc90de0252beee542ee6
2014-05-19 10:23:16 -07:00
Christopher Ferris
d8698d739f am 413001aa: am 3a49aa7b: am 9428a289: Merge "Only include ucontext.h when necessary."
* commit '413001aa6cd4addcf544348020f992ebc6d3e2d4':
  Only include ucontext.h when necessary.
2014-05-10 00:27:42 +00:00
Christopher Ferris
c58287d601 Only include ucontext.h when necessary.
Change-Id: I29014f6c6b82e0a9797e5d76147b3c4e3d82a7f5
2014-05-09 16:59:06 -07:00
Christopher Ferris
e49e43d4aa am 3adbe79d: am 66e31dc5: am 3a088524: Merge "Rewrite unwind thread handling."
* commit '3adbe79d2f14665ff55a9b0db245abebc105658d':
  Rewrite unwind thread handling.
2014-05-09 16:45:35 +00:00
Christopher Ferris
3a088524cb Merge "Rewrite unwind thread handling." 2014-05-09 16:33:12 +00:00
Christopher Ferris
a2efd3ac7a Rewrite unwind thread handling.
This new version doesn't require any specialized thread
implementation, it uses the Current implementation to do its job.
In addition, it runs much faster when multiple threads are trying
to unwind at the same time since the global signal lock is held for
only a small amount of time. Even running through the threads one at
a time should be faster since it no longer requires two passes through
the unwound stacks.

The new code now allows multiple simultaneous unwinds of the
same thread.

Finally, add the ability to unwind from a ucontext_t passed in. This
functionality doesn't work for remote unwinds yet.

Change-Id: I4d181d7ca5ffd2acfd1686e668e6d21e36b425cb
2014-05-08 14:42:16 -07:00
Ying Wang
da6a0aa0df am b18da571: am 1e6cd741: am 803fb62b: Merge "Remove unused LOCAL_LDLIBS."
* commit 'b18da571f90eebedd99fe5607a6b0d7ae4e91893':
  Remove unused LOCAL_LDLIBS.
2014-05-08 18:23:57 +00:00
Ying Wang
9f437d7181 Remove unused LOCAL_LDLIBS.
Change-Id: I42aeb7668183e7a06207ee063f6eee4d37d66c6e
2014-05-07 15:36:05 -07:00
Christopher Ferris
68831f852e am 7e250b00: am fbd2a506: am 9ed86eff: Merge "Use real time signal for threads instead of SIGURG."
* commit '7e250b002b5a28a3919bc704e9bc6610b3a4096f':
  Use real time signal for threads instead of SIGURG.
2014-05-01 00:24:30 +00:00
Christopher Ferris
aa63d9f980 Use real time signal for threads instead of SIGURG.
This guarantees that any application is not also using this signal
for some other purpose.

Change-Id: I7c9bbb0ec8bb4e13322ecda951bcd43c6bf6ee1a
2014-04-30 16:32:47 -07:00
Christopher Ferris
873dc35b74 am c79e511d: am 481b551a: am 0b0e0eae: Merge "Small cleanup of duplicated test values."
* commit 'c79e511d828cd3dfdd79af40ce5be556a4c2ff9b':
  Small cleanup of duplicated test values.
2014-04-29 16:09:06 +00:00
Christopher Ferris
11b5fcb9f1 Small cleanup of duplicated test values.
A few flags were duplicates of flags already passed when using the TEST
targets.

Change-Id: I8f0d09915f5b830050fe25635a0852e8536e3aca
2014-04-28 21:06:31 -07:00
Christopher Ferris
8439e3249e am 2d3bccde: am 61af820e: am 2317287d: Merge "Remove libcorkscrew."
* commit '2d3bccdedc058e2f9e10d507c43e1da51d32260f':
  Remove libcorkscrew.
2014-04-25 22:38:21 +00:00
Christopher Ferris
8f36be3cdb am e3615230: am 8c526578: am 4a5966b9: Merge "Change sprintf to snprintf calls."
* commit 'e36152308da6b1e67b05ad790081bc7e4424ae4e':
  Change sprintf to snprintf calls.
2014-04-25 22:38:10 +00:00
Christopher Ferris
688a8a7232 Remove libcorkscrew.
All unwinding is now done through libunwind.

Change-Id: I93ba6f5bd5ad41eeb5f6a93113b7894f842cc8e0
2014-04-25 11:25:56 -07:00
Christopher Ferris
b8c72957f0 Change sprintf to snprintf calls.
Change-Id: I8893246fcd541d97b02a1a4cac81c53c6cd2e394
2014-04-24 16:20:50 -07:00
Christopher Ferris
04c5192ff5 am 3af88bc6: am e87dab14: am 07fa0433: Merge "Remove the arm64 special case."
* commit '3af88bc6377f50904ad3172b06f76d95ceda9cda':
  Remove the arm64 special case.
2014-04-22 13:37:44 +00:00
Christopher Ferris
04fd4389fb Remove the arm64 special case.
The stack-protector option is handled by the global makefiles.

Change-Id: I99c4a1624e72ad91ac10eef27c0e3758fe9af8ba
2014-04-21 17:57:56 -07:00
Christopher Ferris
17224d57fb Avoid logging functions from signal handler.
(cherry picked from commit 9007677fcb)

Change-Id: Ic0163f43308c6a281ab3757d90933e5127843fed
2014-04-15 12:18:44 -07:00
Christopher Ferris
9007677fcb Avoid logging functions from signal handler.
Change-Id: Ic61f7054ced223631f95efb519fa1825fb3e1010
2014-04-11 13:05:07 -07:00
Christopher Ferris
7962e4acc7 am 6a8c3164: am e35cba9a: am a97798af: Merge "Create an UnwindMapLocal object."
* commit '6a8c316438032c72ffdd2988cc1eb2717f477254':
  Create an UnwindMapLocal object.
2014-04-04 03:19:39 +00:00
Christopher Ferris
e296091060 Create an UnwindMapLocal object.
The way libunwind handles local unwinds is different from remote unwinds,
so create a new map object to handle the differences.

Add new test to verify the map data is being generated correctly.

Add new tests to check for leaks.

Refactor the BACK_LOGW code into a single header file.

Change-Id: I01f3cbfc4b927646174ea1b614fa25d23b9b3427
2014-04-03 14:19:24 -07:00
Christopher Ferris
dc6d9241de am a6631bb3: am 3bcefc66: am 62f12bd9: Merge "Enable libunwind for mips."
* commit 'a6631bb38fbf77415592c10734710df8afa0deab':
  Enable libunwind for mips.
2014-02-26 22:39:08 +00:00