summaryrefslogtreecommitdiffstats
path: root/linker/debugger.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix regression in crash reportingJohn Reck2015-05-151-9/+0
| | | | | | | | Bug: 19532651 Partial revert of be0e43b77676338fd5e6a82c9cc2b6302d579de2 Change-Id: I99e220328aff985facb920ebcd84ac1a016759b5
* Fix long lines and replace macros with functions.Dmitriy Ivanov2015-03-311-1/+1
| | | | Change-Id: I4e1cab488d5b2c8e4289da617350a86e72a4ba12
* Only one crashing thread should contact debuggerd.Christopher Ferris2015-01-281-1/+20
| | | | | | | | | | If two or more threads crash at the same time, only let one talk to debuggerd. It's possible for a race to occur that two threads send data to debuggerd, the second one will cause errors in debuggerd since the process will die once debuggerd lets the crashing pid start again. Bug: 19183955 Change-Id: I17dfce46102117ab4a870f7381bd526488d37fb5
* Enable -Wold-style-cast warnings for linkerDmitriy Ivanov2015-01-221-1/+1
| | | | | | And fix old style casts. Change-Id: I37e7a3e3fd852528ea76f02d967c7bd8cd5b06c9
* Contact proper debuggerd when crashing.Christopher Ferris2015-01-201-10/+7
| | | | | | | | | | Make the request structure match the new structure found in debuggerd code. On 64 bit systems, make sure that the 32 bit compiled linker is contacted. Bug: https://code.google.com/p/android/issues/detail?id=97024 Change-Id: I675b8ff222fcf836b05de4e9b5976ff91ca929bf
* Fix a couple more cases of missing CLOEXEC.Elliott Hughes2014-09-221-1/+1
| | | | | | | The debuggerd case can probably never happen, because you're crashing at this point anyway. The system property one seems possible though. Change-Id: Idba6a4f1d68587ec5b320d1e25f0b6a987ea32a0
* Replace NULL with nullptrDmitriy Ivanov2014-08-291-13/+13
| | | | Change-Id: Iad50be617d318ca98883b843229c960ad5b9afa9
* Replace snprintf calls in linker.Christopher Ferris2014-08-271-2/+2
| | | | | | | | | | | | | | | | | | | When enabling debug malloc, the snprintf calls in the linker fails to update the buffer. The problem is that snprintf makes a call to pthread_getspecific that returns a valid pointer, but the data it points to is zero. This should never happen and causes the snprintf to stop and do nothing. Temporarily replace snprintf with a different implementation to work around this issue. Bug: 16874447 Bug: 17302493 (cherry pick from commit 172955a4e30b88ce8239a7ef426b4e8903e9923c) Change-Id: Idca9d417978403d61debfd0434aaa82fd770f33b
* debuggerd: if PR_GET_DUMPABLE=0, don't ask for dumpingNick Kralevich2014-07-231-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | PR_GET_DUMPABLE is used by an application to indicate whether or not core dumps / PTRACE_ATTACH should work. Security sensitive applications often set PR_SET_DUMPABLE to 0 to disable core dumps, to avoid leaking sensitive memory to persistent storage. Similarly, they also set PR_SET_DUMPABLE to zero to prevent PTRACE_ATTACH from working, again to avoid leaking the contents of sensitive memory. Honor PR_GET_DUMPABLE when connecting to debuggerd. If an application has said it doesn't want its memory dumped, then we shouldn't ask debuggerd to dump memory on its behalf. FORTIFY_SOURCE tests: Modify the fortify_source tests to set PR_SET_DUMPABLE=0. This reduces the total runtime of /data/nativetest/bionic-unit-tests/bionic-unit-tests32 from approx 53 seconds to 25 seconds. There's no need to connect to debuggerd when running these tests. Bug: 16513137 Change-Id: Idc7857b089f3545758f4d9b436b783d580fb653f
* Rethrow SIGTRAP too.Elliott Hughes2014-05-161-0/+1
| | | | | Bug: 15024256 Change-Id: I0347da9698a6ccd317ce6e6f7916d710d66e0f8a
* debugger.cpp should know the names of the signals it catches.Elliott Hughes2014-05-161-6/+9
| | | | Change-Id: I37908b07739ad465652f143848c52bc1ef19e421
* Switch to g_ for globals.Elliott Hughes2014-05-141-1/+1
| | | | | | | That's what the Google style guide recommends, and we're starting to get a mix. Change-Id: Ib0c53a890bb5deed5c679e887541a715faea91fc
* Pass si_code through to debuggerd.Elliott Hughes2014-04-251-36/+42
| | | | | | | | Because we re-raise various signals, we corrupt the si_code that debuggerd sees when it ptraces our siginfo. One possible solution (shown here) is to pass the original si_code value in the message we send to debuggerd. Change-Id: I76f9aa2c0442e5cab611d132532409e700383907
* Make libc signal handler output more like debuggerd.Elliott Hughes2014-04-181-162/+185
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This has been annoying me for a while, because it's often quite misleading. Today, for example, I saw: Fatal signal 13 (SIGPIPE) at 0x6573 (code=0), thread 25971 (top) where the apparent address is actually the pid of the signal source (in this case the kernel on behalf of the thread itself). This patch isn't as fancy as strace, but it at least means we never say anything misleading. We could decode the si_code field like strace and debuggerd, but I'm reluctant to do that without some way to share the code between at least bionic and debuggerd. Examples after: Fatal signal 13 (SIGPIPE), code 0 in tid 9157 (top) Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 9142 (crasher64) Fatal signal 6 (SIGABRT), code -6 in tid 9132 (crasher64) (Note that the code still shows as 0 for SIGPIPE in the signal handler itself but as -6 (SI_TKILL) in debuggerd; this is actually correct --- debuggerd is showing the re-raised signal sent at the end of the signal handler that initially showed the correct code 0.) Change-Id: I71cad4ab61f422a4f6687a60ac770371790278e0
* Clean up debugger.cpp slightly.Elliott Hughes2014-01-311-29/+24
| | | | | | In particular, don't do weird things with 'int tid'. Change-Id: I0fd9158a452967163508ada8987de9494ad5f9af
* LP64 binaries should talk to debuggerd64.Elliott Hughes2014-01-311-0/+4
| | | | Change-Id: I7eb30f9d04f80b6b45d3148757970d3f1117493c
* AArch64: Linker64 support for AArch64Marcus Oakland2013-12-171-1/+1
| | | | | | | Addition of support for AArch64 in the linker64 target. Change-Id: I8dfd9711278f6706063e91f626b6007ea7a3dd6e Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
* Clean up linker architecture macros.Elliott Hughes2013-10-281-1/+1
| | | | | | | | | | | | | | | | We don't need our own architecture macros; the standard ones will do. This patch also fixes some __x86_64__ tests to be USE_RELA tests instead, because they're not actually x86_64-specific. I've cleaned up architecture-specific code slightly so where possible all the code corresponding to a particular architecture is together. This patch also fixes a bug in LP64 DT_PLTGOT handling, which should be an error rather than falling through into DT_DEBUG! There was another #ifdef bug where we'd only report unexpected DT_ entries on MIPS. Change-Id: Id1d04e372611f641c1aa278a18e379f28af9eaf5
* Fix sigaction(3) for 64-bit.Elliott Hughes2013-10-171-9/+0
| | | | | | | Also clean up <signal.h> and revert the hacks that were necessary for 64-bit in linker/debugger.cpp until now. Change-Id: I3b0554ca8a49ee1c97cda086ce2c1954ebc11892
* x86_64 linker.Elliott Hughes2013-10-081-0/+9
| | | | | | | Based on I8dc3e2cb596f75dc58ae82e4dc58f8c177dd3323 by Pavel Chupin <pavel.v.chupin@intel.com>. Change-Id: Icd582d277cbe273477b450f2848343d72c86ec9f
* Remove 32-bit assumptions from the ELF code.Elliott Hughes2013-09-301-3/+3
| | | | Change-Id: I2c1f3d34c33685799aade8866eec44479ff9f963
* Improve stack overflow diagnostics (take 2).Elliott Hughes2013-07-171-29/+34
| | | | | | | | | | This reverts commits eb1b07469f2b5a392dc1bfd8adc211aea8c72bc5 and d14dc3b87fbf80553f1cafa453816b7f11366627, and fixes the bug where we were calling mmap (which might cause errno to be set) before __set_tls (which is required to implement errno). Bug: 8557703 Change-Id: I2c36d00240c56e156e1bb430d8c22a73a068b70c
* Revert "Improve stack overflow diagnostics."Guang Zhu2013-07-171-34/+29
| | | | | | This reverts commit aa754dca90487356cabf07ade0e8d88c2630b784. Change-Id: Ifa76eee31f7f44075eb3a48554315b2693062f44
* Improve stack overflow diagnostics.Elliott Hughes2013-07-161-29/+34
| | | | | | | | | We notify debuggerd of problems by installing signal handlers. That's fine except for when the signal is caused by us running off the end of a thread's stack and into the guard page. Bug: 8557703 Change-Id: I1ef65b4bb3bbca7e9a9743056177094921e60ed3
* Make abort messages available to debuggerd.Elliott Hughes2013-04-051-14/+16
| | | | | | | | | | | | | This adds __libc_fatal, cleans up the internal logging code a bit more, and switches suitable callers over to __libc_fatal. In addition to logging, __libc_fatal stashes the message somewhere that the debuggerd signal handler can find it before calling abort. In the debuggerd signal handler, we pass this address to debuggerd so that it can come back with ptrace to read the message and present it to the user. Bug: 8531731 Change-Id: I416ec1da38a8a1b0d0a582ccd7c8aaa681ed4a29
* Clean up internal libc logging.Elliott Hughes2013-03-151-9/+6
| | | | | | | | | | | We only need one logging API, and I prefer the one that does no allocation and is thus safe to use in any context. Also use O_CLOEXEC when opening the /dev/log files. Move everything logging-related into one header file. Change-Id: Ic1e3ea8e9b910dc29df351bff6c0aa4db26fbb58
* Minor linker cleanup, primarily to use Elf32_DynBrian Carlstrom2013-03-051-3/+3
| | | | Change-Id: Ifa9408e9859c6f79444715bed4808b7c13fdced5
* Clean up debuggerd-related logging.Elliott Hughes2013-01-221-32/+25
| | | | | Bug: 7291287 Change-Id: Ia7aa386e8b75b8058d7d9e707e11b1da7dc62f00
* Fix the duplication in the debugging code.Elliott Hughes2013-01-181-5/+5
| | | | | | | | | | | | | | | | | | | We had two copies of the backtrace code, and two copies of the libcorkscrew /proc/pid/maps code. This patch gets us down to one. We also had hacks so we could log in the malloc debugging code. This patch pulls the non-allocating "printf" code out of the dynamic linker so everyone can share. This patch also makes the leak diagnostics easier to read, and makes it possible to paste them directly into the 'stack' tool (by using relative PCs). This patch also fixes the stdio standard stream leak that was causing a leak warning every time tf_daemon ran. Bug: 7291287 Change-Id: I66e4083ac2c5606c8d2737cb45c8ac8a32c7cfe8
* Make dynamic linker debugging always available.Elliott Hughes2012-11-021-2/+3
| | | | | | | If you need to build your own linker to get debugging, the debugging is never available when you need it. Change-Id: I5ff7e55753459d49a2990f25d9aa155e0b8602e0
* Keep the dynamic linker's soinfo pools mostly read-only.Elliott Hughes2012-11-011-1/+0
| | | | | | | We'll need a lot more refactoring of this code before we can reduce the granularity, but this is a step forward. Change-Id: I07061720e734b571a8399c1d5b4f2f35cd681307
* More dynamic linker cleanup.Elliott Hughes2012-10-301-0/+271
I still want to break linker_format out into its own library so we can reuse it for malloc debugging and so forth. (There are many similar pieces of code in bionic, but the linker's one seems to be the most complete/functional.) Change-Id: If3721853d28937c8e821ca1d23cf200e228a409a