Commit graph

235 commits

Author SHA1 Message Date
Christopher Ferris
d13099e66c Merge "Test unwinding through a signal handler." 2017-03-24 17:22:25 +00:00
Christopher Ferris
5ea2c1f20a Test unwinding through a signal handler.
Also make backtrace_testlib.c C++.

Bug: 34468756
Test: Ran new unit test on host x86, host x86_64, angler (32 bit, 64 bit),
Test: fugu.
Change-Id: Ia810f596c2df56cd56e8ab17e6c19be0c48d737f
2017-03-23 16:16:02 -07:00
Brian Carlstrom
6d1da7c607 Fix spelling error in warning
Test: m -j32 -k
Bug: 36450628
Change-Id: I0f6463f3de3dcf45f396c7f406f8c1d6b79bf7f9
2017-03-23 11:29:57 -07:00
Christopher Ferris
f5e568e653 Do not access device maps.
It's possible that a device map has memory controlled by a single entry
device driver. Thus, you can deadlock if a process is touching that
device memory and we try to unwind it and also touch that device memory.
Simply skip any attempts to step through, or get function names from
device memory maps.

Bug: 36130325

Test: Ran new unit tests, ran bionic unit tests, ran art ThreadStress.
Change-Id: Ibc62d7ec8106c619ee08968f05e04aea55d7cbfa
2017-03-22 14:55:05 -07:00
Christopher Ferris
82f3bbdc25 Allow calling GetFunctionName before unwinding.
Some extra initialization needs to occur before calling the local/remote
GetFunctioneName.

Also, cleanup the test code a bit:

- Make all local functions static.
- Create a common function to create and finish remote processes.
- Remove unused function.
- Fix the formatting a bit by making it match clang format.

Test: Ran the unit tests.
Change-Id: I998bed1378d582df59fdf9263df6f208db5d795a
2017-03-21 14:21:49 -07:00
Dan Willemsen
e0cd1e043d Enable more modules on linux_bionic builds
Bug: 31559095
Test: Enable host bionic, run soong
Change-Id: Ib4ebd909322cf464b6a40040e4b60ece7d905b6f
2017-03-15 15:44:00 -07:00
Christopher Ferris
f161e00289 Merge "Restore errno in signal handlers." 2017-03-13 20:50:20 +00:00
Christopher Ferris
a78d9a293c Add a 2 width option of clang format.
Make the default the 4 tab space version.

Add a link to the 2 space version for libbacktrace.

The only other difference between the 4 space and 2 space tab version
is that the 2 space tab version allows short functions on a single line.
This is for things like constructors, short destructors, or accessor
functions. I believe this is closer to the Google C++ style guide.

Bug: 36046320

Test: NA
Change-Id: Ida08db18902eeb101f42869dd5590182529d54ef
2017-03-10 13:01:39 -08: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
Yabin Cui
26369a3a01 libbacktraceoffline: make it thread-safe.
Make libbacktraceoffline thread-safe by protecting the global variable with
a lock. So it can be used in a multi-thread environment, like by
simpleperf inplace sampling.

Bug: http://b/30974760
Test: no
Change-Id: I4699bf15dfa69ac75faeb4e79a73fb3af0f08dfc
2017-02-13 10:35:06 -08:00
Yabin Cui
c4a480e423 libbacktraceoffline: choose correct debug section for a given address.
1. In /system/lib/libart.so, the ranges of functions covered by .eh_frame
and .ARM.exidx overlap with each other. Currently, we don't check .eh_frame
if the address is in the ranges of functions covered by .ARM.exidx. It leads
to a wrong unwinding result. So change the logic to first try .eh_frame and
.debug_frame, if it fails, then try .ARM.exidx.
2. Add test for Item 1.

Bug: http://b/35251937
Test: run backtrace_test.

Change-Id: Ic412705617c300bc69b4ece178cc2e1bb3eb765b
2017-02-10 17:51:16 -08:00
Mark Salyzyn
30f991f251 liblog: use log/log.h when utilizing ALOG macros
Test: compile
Bug: 30465923
Change-Id: Id6d76510819ebd88c3f5003d00d73a0dbe85e943
2017-01-11 09:31:15 -08:00
Colin Cross
d233c2752b Remove obsolete mentions of LLVM_HOST_BUILD_MK
The libbacktrace common flags don't need the flags from
LLVM_HOST_BUILD_MK, they are added directly to libbacktrace_offline.
The -fno-omit-frame-pointer is unnecessary, as we no longer import
flags only used to build LLVM into everything that depends on LLVM.
Removing -Wno-extern-c-compat doesn't cause any warnings.

Test: mma -j
Change-Id: Ia01380e8572c3d84268843291a54ec8c932a327f
2016-12-17 13:34:05 -08:00
Colin Cross
da9bd5902f Convert the rest of libbacktrace to Android.bp
See build/soong/README.md for more information.

Reapplies I61c49fb62fdeafb66db25b8f97621239b8fd6e75 after fixing
an unused parameter warning on mips builds.

Test: mma -j
Test: backtrace_test
Change-Id: I6dc353a274cafcdb05ee866b41c3c2731612941c
2016-12-15 12:57:47 -08:00
Colin Cross
06d314917f Fix unused parameter warning for mips builds
libbacktrace_offline was inheriting -Wno-unused-parameter from llvm's
makefiles.  Fix an unused parameter warning when compiling for an
unsupported architecture, and return false since *value wasn't
written.

Test: lunch aosp_mips-eng && mma -j
Change-Id: I7df990f01e1025ca17ec3717107df56d2349f3cb
2016-12-15 12:57:45 -08:00
Colin Cross
ced030892d Revert "Convert the rest of libbacktrace to Android.bp"
This reverts commit 9a3603622f.

Broke the mips build with an unused parameter warning

Change-Id: If36964ea189b58a9825de8904f1cf49010548b59
2016-12-15 20:44:30 +00:00
Colin Cross
9a3603622f Convert the rest of libbacktrace to Android.bp
See build/soong/README.md for more information.

Test: mma -j
Test: backtrace_test
Change-Id: I61c49fb62fdeafb66db25b8f97621239b8fd6e75
2016-12-14 17:24:46 -08:00
Yabin Cui
5d991bc351 libbacktrace_offline: support .ARM.exidx.
1. Read .ARM.exidx and .ARM.extab, provides these data to libunwind
through AccessMem.
2. In FindProcInfo, search .ARM.exidx for the idx entry of function
containing ip.
3. Add structures to store .ARM.exidx info in DebugFrameInfo, and
clean up the structure.
4. Add tests to test each unwind information (.eh_frame, .debug_frame,
.gnu_debugdata, .ARM.exidx) separately.

Bug: http://b/30974693
Test: run backtrace_test.
Test: run simpleperf runtest.py.
Change-Id: I9377a54379158bd35860efcf0e011423be7350d4
2016-12-07 10:25:33 -08:00
Pirama Arumuga Nainar
c198b150d4 Statically link LLVM libraries into backtrace_test
Bug: http://b/28866258

Remove dependency of backtrace_test on libLLVM.  Also clean up
specification for libbacktrace_offline module.  Since it is a static
library now, dependencies are only needed to automatically include
necessary headers.

Test: 32-bit and 64-bit backtrace_test passes on host and on Angler.
      mma in system/extras/simpleperf, cts/tests/tests/simpleperf
      m test-art-host

Change-Id: I76b0db14d067fa7b140a99edd237370ac04fe873
2016-11-30 17:43:20 +00:00
Christopher Ferris
f96e7446fd Merge "Revert "Use process_vm_readv to read memory."" 2016-11-14 20:14:18 +00:00
Christopher Ferris
fdb02f8b9c Revert "Use process_vm_readv to read memory."
This reverts commit 279843e139.

Bug: 32806783

Change-Id: I61df26d979a8139a571ff5a6442fb5499ca20547
Test: Verified that the stack and read data works with the revert.
2016-11-10 23:19:30 +00:00
Pirama Arumuga Nainar
80fb4b09f4 Make libbacktrace build with LLVM r275480
Bug: http://b/31320715

Test: No regression in 32-bit and 64-bit backtrace_test on host and
angler.

Change-Id: Ic5c5511e89ca7707ed9c13d5ba0539e09310dfe3
2016-10-25 22:16:47 -07:00
Colin Cross
fc75f94643 Merge "Add missing host ldlibs" 2016-10-20 19:21:25 +00:00
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