summaryrefslogtreecommitdiff
path: root/libc/bionic/libc_logging.cpp
AgeCommit message (Collapse)Author
2017-05-03Move libc_log code into libasync_safe.Christopher Ferris
This library is used by a number of different libraries in the system. Make it easy for platform libraries to use this library and create an actual exported include file. Change the names of the functions to reflect the new name of the library. Run clang_format on the async_safe_log.cpp file since the formatting is all over the place. Bug: 31919199 Test: Compiled for angler/bullhead, and booted. Test: Ran bionic unit tests. Test: Ran the malloc debug tests. Change-Id: I8071bf690c17b0ea3bc8dc5749cdd5b6ad58478a
2017-04-11Move libc_logging.cpp over to CachedProperty.Elliott Hughes
Bug: N/A Test: ran tests Change-Id: I50f9065799e783df961e1275a4cda671fcf0fd32
2017-04-03Break android_set_abort_message out of libc_logging.Josh Gao
libc_logging is getting statically linked into the crash handler library, resulting in two copies of the abort message code existing in processes, one in the linker, and one in the crash handler. Move android_set_abort_message to its own file to solve this. Bug: http://b/36862204 Test: /data/nativetest/debuggerd_test/debuggerd_test32 Change-Id: Ie198c5a3bb07645aa43296915c9a6752693f14a9
2017-02-15Add __libc_format_buffer_va_list.Josh Gao
Bug: http://b/35367169 Test: m Change-Id: I133f231d3b93bdef56d06497679320a89c7188a9
2017-02-06Improve a comment.Elliott Hughes
Bug: http://b/23675822 Test: builds Change-Id: Ia58ffabf38012035076e4c682faa4c93f3690e24
2016-10-07Use STDERR_FILENO instead of opening /dev/stderr.Josh Gao
/dev/stderr is a symlink to /proc/self/fd/2, so this only has different behavior when we're out of file descriptors, or when STDERR_FILENO is in a different state (it's not at the end, it's not writable, etc.). Test: mma Change-Id: Ie99688d810218eca8482ff060373e88c4e001824
2016-05-03Fix google-explicit-constructor warnings.Chih-Hung Hsieh
Bug: 28341362 Change-Id: I84effbdfa1b9b39328a909b7f70fe17e7ee316c8
2016-02-27Create logging sockets with SOCK_NONBLOCK...Elliott Hughes
...rather than calling fcntl on them directly after creation. Bug: https://code.google.com/p/android/issues/detail?id=201440 Change-Id: Ia3941b7645455d69620b1a361902df009b5da2c5
2016-02-26Improve FORTIFY failure diagnostics.Elliott Hughes
Our FORTIFY _chk functions' implementations were very repetitive and verbose but not very helpful. We'd also screwed up and put the SSIZE_MAX checks where they would never fire unless you actually had a buffer as large as half your address space, which probably doesn't happen very often. Factor out the duplication and take the opportunity to actually show details like how big the overrun buffer was, or by how much it was overrun. Also remove the obsolete FORTIFY event logging. Also remove the unused __libc_fatal_no_abort. This change doesn't improve the diagnostics from the optimized assembler implementations. Change-Id: I176a90701395404d50975b547a00bd2c654e1252
2016-02-18Add backtrace_string and export to libmemunreachableColin Cross
Add backtrace_string to convert a malloc_debug backtrace to a string. Also move the backtrace functions to libc_malloc_debug_backtrace so that libmemunreachable can reuse them. Change-Id: I5ad67001c0b4d184903c762863a8588181d4873b
2015-12-08bionic: Build BreakageMark Salyzyn
Bug: 23668800 Change-Id: Ic7cf5864d3f5881e6f7105a49ecf62b1bc4a604c
2015-12-04Add monotonic logging for bionicMark Salyzyn
Primarily a debug feature that can be switched at runtime to permit developer to have the option of high-resolution Android logs with either CLOCK_REALTIME (default) or CLOCK_MONOTONIC to correlate with other system activities like kernel logs or systrace. Bug: 23668800 Change-Id: Ib29024899540f51a72cad5dde25517a7134d68f7
2015-07-28deprecate TARGET_USES_LOGDMark Salyzyn
This is not the kernel logger you are looking for Bug: 22787659 Change-Id: I340d8bb5cdaa73be9565521681ee238b7033934b
2015-04-28Add float support to binary event log.Jeff Brown
Bug: 20664753 Change-Id: I6e43c07daa727c19d87f5192bb719af63dd93654
2015-03-25Add O_APPEND flag for __libc_write_stderr.Yabin Cui
For DeathTests, we are testing the output of stderr to check if it is the death we are expecting. To collect the output, Gtest redirects stderr to a temporary file. But in __libc_write_stderr in libc_logging.cpp, we are writing to stderr without a O_APPEND flag, so a new message will overwrite a previous message. The above situation makes almost all the DeathTests fail on host. Because the expected message are always overwritten in host DeathTests. So I add O_APPEND flag in __libc_write_stderr, which makes all host DeathTests pass. Change-Id: Ic2f6044fdb181eebe132a6f170b57db43c5c3289
2015-02-05Apparently, logd does need the NULs.Elliott Hughes
Change-Id: I04b834e65c26c5821b952f78a0de7f92527cbdba
2015-02-02Small logging cleanup.Elliott Hughes
Don't send the trailing NUL bytes to the logger, call strlen if we already know the length, or cast more specifically than we need to. Change-Id: I68c9388a22bddea49120a1022dda8db8991360c1
2014-08-28Add GNU-compatible strerror_r.Elliott Hughes
We already had the POSIX strerror_r, but some third-party code defines _GNU_SOURCE and expects to get the GNU strerror_r instead. This exposed a bug in the libc internal logging functions where unlike their standard brethren they wouldn't return the number of bytes they'd have liked to have written. Bug: 16243479 Change-Id: I1745752ccbdc569646d34f5071f6df2be066d5f4
2014-08-18Expose android_set_abort_message().Dan Albert
Removes the leading underscores from __android_set_abort_message() and moves its declaration into a public header file. Bug: 17059126 Change-Id: I470c79db47ec783ea7a54b800f8b78ecbe7479ab
2014-07-28Use vsnprintf(3) in syslog(3).Elliott Hughes
It seemed like a clever trick to use the internal log message formatting code in syslog(3), but on reflection that means you can't (for example) format floating point numbers. This patch switches us over to using good old vsnprintf(3), even though that requires us to jump through a few hoops. There's no obvious way to unit test this, so I wrote a little program and ran that. (cherry-pick of b1b60c30bf321c0fc02264b953b5c16c49d34457.) Bug: 14292866 Change-Id: I9c83500ba9cbb209b6f496067a91bf69434eeef5
2014-07-23Fix belated review comments on syslog change.Elliott Hughes
Bug: 14292866 Change-Id: I3cd92084cb55b5673f6ba62d51952941b79deb51
2014-07-21Rewrite syslog(3) to use Android logging.Elliott Hughes
Since we don't have syslogd on Android and you can't run one on a non-rooted device, it's more useful if syslog output just goes to the regular Android logging system. Bug: 14292866 Change-Id: Icee7f088b97f88ccbdaf471b98cbac7f19f9210a
2014-07-21__libc_fatal should print a newline to stderr.Dan Albert
Change-Id: I088dc880d7488a65beac8cda95f530f3db41f112
2014-07-02libc_logging: Set SOCK_CLOEXEC on socketNick Kralevich
Socket file descriptors remain open across exec unless SOCK_CLOEXEC is set. Enable this option, to avoid leaking file descriptors. In practice, this isn't a big deal, since the socket only remains open for a very short period to write a message. However, this socket might leak for for multithreaded programs if an exec occurs between the open and close. Change-Id: Ica2e71fe28657c32d56de1431c8f7f1f5c7b7c58
2014-07-01Write message to stderr on __libc_fatal()Dmitriy Ivanov
Change-Id: Ia8d6e256768fa51786d0139d3f3b6e9e4bebe027
2014-05-14Switch to g_ for globals.Elliott Hughes
That's what the Google style guide recommends, and we're starting to get a mix. Change-Id: Ib0c53a890bb5deed5c679e887541a715faea91fc
2014-05-07Send bionic's fatal logging to the crash log.Elliott Hughes
Bug: 14159417 Change-Id: I7aa986fb8e11660035221f9bb4fe0bc40ac36c58
2014-05-06Change the interface for fatal logging.Elliott Hughes
This more general interface lets liblog give us any fatal log message, regardless of source. This means we can remove the special case for LOG_ALWAYS_FATAL with a simpler scheme that automatically works for the VM too. Change-Id: Ia6dbf7c3dbabf223081bd5159294835d954bb067
2014-04-23Allow liblog to pass failure reasons to debuggerd.Elliott Hughes
assert(3) already does this, but LOG_ALWAYS_FATAL and LOG_ALWAYS_FATAL_IF have been missing out. Change-Id: I1d6214c4f792fa0d4ba3c14eded3fc9c332bd3c5
2014-03-20libc: Thread IDs missing from logcat -v threadMark Salyzyn
- stuff caller's thread id into the packet. Bug: 13568206 Change-Id: If8b318ef75c7dcdddb05da8ac3038860f0fda5ec
2014-03-05libc: libc_logging 64bit compile issueMark Salyzyn
- user space logger wire format for time Change-Id: I4840653e3a6ae151a02584311d1227d2fe536d0f
2014-02-26libc: Make calls to new user-space loggerMark Salyzyn
* libc (fatal) logging now makes socket connection to the user-space logging service. * Add a TARGET_USES_LOGD make flag for BoardConfig.mk to manage whether logd is enabled for use or not. Change-Id: I96ab598c76d6eec86f9d0bc81094c1fb3fb0d9b4
2013-10-15Avoid confusing "read prevented write" log messages.Elliott Hughes
Moving to a "function: message" style avoids ambiguity. Change-Id: If9d590e50265c61725d3673bd03796e65edd2d5e
2013-10-09Fix x86_64 build, clean up intermediate libraries.Elliott Hughes
The x86_64 build was failing because clone.S had a call to __thread_entry which was being added to a different intermediate .a on the way to making libc.so, and the linker couldn't guarantee statically that such a relocation would be possible. ld: error: out/target/product/generic_x86_64/obj/STATIC_LIBRARIES/libc_common_intermediates/libc_common.a(clone.o): requires dynamic R_X86_64_PC32 reloc against '__thread_entry' which may overflow at runtime; recompile with -fPIC This patch addresses that by ensuring that the caller and callee end up in the same intermediate .a. While I'm here, I've tried to clean up some of the mess that led to this situation too. In particular, this removes libc/private/ from the default include path (except for the DNS code), and splits out the DNS code into its own library (since it's a weird special case of upstream NetBSD code that's diverged so heavily it's unlikely ever to get back in sync). There's more cleanup of the DNS situation possible, but this is definitely a step in the right direction, and it's more than enough to get x86_64 building cleanly. Change-Id: I00425a7245b7a2573df16cc38798187d0729e7c4
2013-10-08Make logging fall back to /dev/stderr if we're on the host.Elliott Hughes
Otherwise you get no logging, which sucks. Change-Id: Iea1e8f996461afbb217a55711b7967005c39cfcb
2013-06-21libc_logging: don't keep file descriptors open foreverNick Kralevich
Avoid keeping unnecessary file descriptors around when they're not needed. Libc doesn't log so much that opening / closing overhead matters. Change-Id: I590ec5c27562db9bac025f781c48ec9a7724ce77
2013-06-12Clean up abort.Elliott Hughes
* A dlmalloc usage error shouldn't call abort(3) because we want to cause a SIGSEGV by writing the address dlmalloc didn't like to an address the kernel won't like, so that debuggerd will dump the memory around the address that upset dlmalloc. * Switch to the simpler FreeBSD/NetBSD style of registering stdio cleanup. Hopefully this will let us simplify more of the stdio implementation. * Clear the stdio cleanup handler before we abort because of a dlmalloc corruption error. This fixes the reported bug, where we'd hang inside dlmalloc because the stdio cleanup reentered dlmalloc. Bug: 9301265 Change-Id: Ief31b389455d6876e5a68f0f5429567d37277dbc
2013-06-07Implement malloc_usable_size for debug impls.Christopher Ferris
- Implemented chk_memalign. - Fixed a few bugs in leak_memalign. - Implemented {leak,fill,check,qemu}_malloc_usable_size. - Make malloc_usable_size update at run time. - Add malloc_test.cpp as a small set of tests for the malloc debug routines. - Fix the qemu routines since it's been broken since it moved to C++. - Add support for the %u format to the out_vformat in libc_logging.cpp. This is used by the emulator code. Tested using the bionic-unit-tests with setprop libc.debug.malloc set to 1, 5, and 10. I tested as much as possible on the emulator, but tracing doesn't appear to be working properly. Bug: 6143477 Merge change from internal master. (cherry-picked from commit 3d594c258045783fc9e1956ce7a4d91e302f011e) Change-Id: I4ae00fffba82315a8c283f35893fd554460722fb
2013-04-05Make abort messages available to debuggerd.Elliott Hughes
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
2013-03-15Clean up internal libc logging.Elliott Hughes
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