Commit graph

25 commits

Author SHA1 Message Date
Alan Stokes
64acdf77d6 Reading from logd in WRAP mode is expected to take a long time,
don't abort it after 30s.

Adds a new CTS test to verify the behaviour.

Bug: 64143705
Test: New and existing CTS tests pass. Manual testing with logcat.
Change-Id: Ia67175701ed8c462083e14e26123ce8ddcb226bc
2017-08-25 11:40:49 +01:00
Christopher Ferris
ac225780dd Move libc_logging to libasync_safe.
Move the name of the "private/libc_logging.h" header to <async_safe/log.h>.

For use of libc_malloc_debug_backtrace, remove the libc_logging library.
The library now includes the async safe log functions.

Remove the references to libc_logging.cpp in liblog, it isn't needed because
the code is already protected by a check of the __ANDROID__ define.

Test: Compiled and boot bullhead device.
Test: Run debuggerd unit tests.
Test: Run liblog unit tests on target and host.
Test: Run libmemunreachable unit tests (these tests are flaky though).
Change-Id: Ie79d7274febc31f210b610a2c4da958b5304e402
2017-05-02 18:38:46 -07:00
Mark Salyzyn
4d99c986d9 liblog: add LOGGER_STDERR frontend
Standalone, this logger provides no end-to-end capability.  Only
provides a writer, no reader transport.  All output goes, logcat-like,
into the stderr stream.  Output can be adjusted with environment
variables ANDROID_PRINTF_LOG and ANDROID_LOG_TAGS.

liblog_*.__android_log_bswrite_and_print___max print fails if a string
member is truncated with "Binary log entry conversion failed" and -1.
We expose the truncated content in the tests and in LOGGER_STDERR.

The purpose of this transport selection is for command-line tools,
providing a means to shunt the logs to be mixed in with the tool's
error stream.

Test: gTest liblog-unit-tests
Bug: 27405083
Change-Id: If344b6e3e67df2dc86ce317cfad8af8e857727b7
2017-03-08 07:17:31 -08:00
Mark Salyzyn
7100288532 liblog: add local_logger
- Create the local-only logger module
- Add LOGGER_LOCAL flag to android_set_log_frontend to enable
- Permit log reader for host compilation

android_set_log_frontend(LOGGER_LOCAL) will result in logs going
into application local memory.  logcat can not retrieve the data,
the user must utilize the log reading interface directly to
acquire their own logs.  Some local logger tests dropped as they
represent testing other liblog facilities.  Other local logger
tests dropped because we make the conscious decision to not
support LOG_ID_SECURITY logging.

ToDo: Some local logger tests dropped because of missing
      functionality associated with blocking reader.

Test: gTest libcutils-tests, logd-unit-tests, liblog-unit-tests,
      logcat-unit-tests, liblog-benchmarks and CtsLiblogTestCases_list
Bug: 27405083
Change-Id: Ia23b932af9e05756eaa60bab9139876b14faf72d
2017-02-08 15:07:06 -08:00
Mark Salyzyn
62d0d2d683 liblog: add logprint to host build
- cleanup of some style issues
- resolve a few minor bugs
- add -lrt for host so that clock_gettime can be issued
- enable write-only logging, logprint and event list
  handling tests for host consumption.

NB: CtsLiblogTestCases_list is only outlet for host testing of
    the interfaces, but it is not part of any automated testing

Test: gTest liblog-unit-tests, liblog-benchmarks and
      CtsLiblogTestCases_list && build mmma system/core/liblog
Bug: 27405083
Change-Id: I13db1f45f67569407587a5a909248de33809b8cf
2017-02-08 13:37:44 -08:00
Mark Salyzyn
21de8aca67 liblog: add log/log_read.h
Move log reading definitions to their own home.

struct logger_entry
struct logger_entry_v2
struct logger_entry_v3
struct logger_entry_v4
LOGGER_ENTRY_MAX_PAYLOAD
LOGGER_ENTRY_MAX_LEN
struct log_msg
android_logger_get_id()
android_logger_clear()
android_logger_get_log_size()
android_logger_get_log_readable_size()
struct logger_list
android_logger_get_statistics()
android_logger_get_prune_list()
android_logger_set_prune_list()
android_logger_list_alloc()
android_logger_list_alloc_time()
android_logger_list_free()
android_logger_list_read()
android_logger_open()
android_logger_list_open()

Deal with a possible scenario where fcntl.h was not included at the
top of the source files, and log/log_read.h inclusion of fcntl.h
conflicts with a source file inclusion of sys/cdefs.h definition of
__unused macro.

Test: gTest liblog-unit-tests --gtest_filter=\
      liblog.__android_log_write__android_logger_list_read:\
      liblog.android_logger_get_
Bug: 34250038
Change-Id: Ib33544171563d6a351164754c254c4385686025b
2017-01-26 21:13:31 +00:00
Mark Salyzyn
52c140ca72 liblog: add log/log_time.h
Move log_time definitions to their own home.

struct log_time

Test: gTest liblog-unit-tests --gtest_filter=liblog.log_time
Bug: 34250038
Change-Id: I400cf4cc865d1c167699a4654ecb69455a18e604
2017-01-25 15:41:43 -08:00
Mark Salyzyn
dd61659e73 liblog: add log/log_system.h
Move SLOG logging macros to their own home.

SLOGV
SLOGV_IF
SLOGD
SLOGD_IF
SLOGI
SLOGI_IF
SLOGW
SLOGW_IF
SLOGE
SLOGE_IF

Test: gTest liblog-unit-tests --gtest_filter=liblog.SLOG
Bug: 34250038
Change-Id: I456c7ad23152dc1c7b39143d87401a8737e24d64
2017-01-25 15:41:43 -08:00
Mark Salyzyn
c89fea44ac liblog: add log/log_radio.h
Move RLOG logging macros to their own home.

RLOGV
RLOGV_IF
RLOGD
RLOGD_IF
RLOGI
RLOGI_IF
RLOGW
RLOGW_IF
RLOGE
RLOGE_IF

Test: gTest liblog-unit-tests --gtest_filter=liblog.RLOG
Bug: 34250038
Change-Id: Iad5b5abf23c7a537ff5293bb55a6633dce2e837d
2017-01-25 15:41:43 -08:00
Mark Salyzyn
3cdbdd522f liblog: add log/log_id.h
Move common log_id_t and simple internal support function definitions
that use it from log/log.h to log/log_id.h.

log_id_t
__android_log_buf_write
__android_log_buf_print
android_name_to_log_id
android_log_id_to_name

Test: gTest liblog-unit-tests --gtest_filter=\
      liblog.log_id:\
      liblog.__android_log_buf_print:\
      liblog.__android_log_buf_write:\
      liblog.__android_log_buf_print__concurrent64
Bug: 34250038
Change-Id: Iad3704cc72943a3094e1193a6d032c7f29a6cd5c
2017-01-25 15:41:43 -08:00
Mark Salyzyn
52ed8c68ee liblog: CTS test
Utilize liblog-unit-tests as a CTS test

Replacement for EventLogTest#testWriteEventWithOversizeValue
along with some other mandatory logging functionality.

Test: run cts tests
Bug: 26235244
Change-Id: I71f549bd0b93f6c41e1f91565b0fbddf042e4991
2016-11-29 08:40:16 -08: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
807e40ecc9 liblog: logd: Add android_lookupEventTag_len()
Allows us to mitigate the impact of MAP_PRIVATE and copy on write by
calling android_lookupEventTag_len instead of android_lookupEventTag,
and delaying the copy on write impact to the later.  We return a
string length in a supplied location along with the string pointer
with android_lookupEventTag_len(const EventTagMap* map, size_t* len,
int tag).  The string is not guaranteed to be nul terminated.  Since
android_lookupEventTag() called even once can cause the memory
impact, we will mark it as deprecated, but we currently have no
timeframe for removal since this is a very old interface.

Add an API for __android_log_is_loggable_len() that accepts the non
null terminated content and fixup callers that would gain because the
length is known prior to the call either in the compiler or at
runtime.  Tackle transition to android_lookupEventTag_len() and
fixup callers.

On any application that performs logging (eg: com.android.phone)

/proc/<pid>/smaps before:

xxxxxxxxxx-xxxxxxxxxx rw-p 00000000 fd:00 463 /system/etc/event-log-tags
Size:                 20 kB
Rss:                  20 kB
Pss:                   1 kB
Shared_Clean:          0 kB
Shared_Dirty:         20 kB
Private_Clean:         0 kB
Private_Dirty:         0 kB
Referenced:            0 kB
Anonymous:            20 kB
AnonHugePages:         0 kB
Swap:                  0 kB
SwapPss:               0 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
Locked:                0 kB
VmFlags: rd wr mr mw me ac

/proc/<pid>/smaps after:

xxxxxxxxxx-xxxxxxxxxx rw-p 00000000 fd:00 1773 /system/etc/event-log-tags
Size:                 20 kB
Rss:                  20 kB
Pss:                   1 kB
Shared_Clean:         20 kB  (was 0kB)
Shared_Dirty:          0 kB  (was 20kB)
Private_Clean:         0 kB
Private_Dirty:         0 kB
Referenced:           20 kB  (was 0kB)
Anonymous:             0 kB  (was 20kB)
AnonHugePages:         0 kB
Swap:                  0 kB
SwapPss:               0 kB
KernelPageSize:        4 kB
MMUPageSize:           4 kB
Locked:                0 kB
VmFlags: rd wr mr mw me ac

Added liblog-unit-tests --gtest_filter=liblog.event_log_tags to
check for Shared_Clean: to not be 0 and Anonymous: to be 0 for
all processes referencing event-log-tags.  Which can include multiple
references to /system/etc/event-log-tags and future possible refs to
/data/misc/logd/event-log-tags and /dev/event-log-tags.  We want
failure messages to help point to errant code using the deprecated
interface.

This change saves 1/4MB of memory or more on a typical system.

Test: gTest liblog-unit-tests
Bug: 31456426
Change-Id: I9e08e44d9092bd96fe704b5709242e7195281d33
2016-10-03 11:08:34 -07:00
Mark Salyzyn
514243d5bd liblog: deprecate TARGET_USES_LOGD
This is not the kernel logger you are loiking for

Bug: 22787659
Change-Id: Id65ed2e8e7ffe4b2be1bdeed65fa8db23bd66b51
2015-07-28 09:37:07 -07:00
Mark Salyzyn
c158456f50 liblog: __android_log_is_loggable support global properties
- Add support for "log.tag" and "persist.log.tag" global
  logging properties, effectively a runtime default minimum
  logging level.
- Add a thread-safe single level cache plus selective logic for the
  four properties being checked to help speed up logging decision
  on subsequent identical calls.
- Using new __system_property_area_serial() to make for
  efficient (<100ns) handling of cache misses. Despite adding
  two new properties, we are 8 times faster on subsequent calls
  even if the properties do not exist.
- A NULL or blank tag is no longer directed to return default,
  it will check the pair of global logging properties first.
- Add liblog.is_loggable gTest
- Fixup liblog.android_logger_get_, allow no content in crash buffer
- Fixup liblog.max_payload, lowered logd priority increases latency

Bug: 19544788
Bug: 21696721
Change-Id: Ideb887755aa3f1fd14a2603bda1fe23cba49642c
2015-06-12 10:35:09 -07:00
Elliott Hughes
bcc2b5f44a Remove LOCAL_ADDITIONAL_DEPENDENCIES in cases where it's not needed.
Change-Id: I720b8ef1050da45a7833adef8219b6acb2cf3a38
2015-04-02 14:31:07 -07:00
Mark Salyzyn
53016d8949 liblog: test: ARM64: Enable 32 and 64-bit liblog_benchmark
- Enable build for 32 and 64 bit benchmark executables
- Fix some cosmetics issues in logd_write.c

Change-Id: I544446e5116607d7fec89171135f6e1eff6aebd8
2015-02-10 18:15:51 +00:00
Dan Albert
f2dedb7a5f Move liblog tests and benchmarks to libc++.
Bug: 15193147
Change-Id: Ib063eb9490e40f9d10c0b0f29b7808c729e4fff9
2014-11-12 03:44:16 +00:00
Dan Albert
e18ed89eae Merge "Remove makefile cruft." 2014-09-12 18:07:26 +00:00
Dmitriy Ivanov
5f68087efe Add -std=gnu++11 to test cflags
Change-Id: Ife92cea10021658eba6e22a7ebc9e31f3d194a25
2014-09-12 10:39:12 -07:00
Dan Albert
fbb8db2e2a Remove makefile cruft.
Don't manually include stlport, and don't use private bionic headers.

Change-Id: I0fc4e8b34ab449e9ef07c26f71e472fca5640590
2014-09-12 10:36:26 -07:00
Dmitriy Ivanov
85af05ae37 Fix typo: ifndef -> ifneq
Change-Id: Id71c70b6fcd2659078a19cc652fd02807372f3a0
2014-08-25 16:26:29 -07:00
Ying Wang
9f437d7181 Remove unused LOCAL_LDLIBS.
Change-Id: I42aeb7668183e7a06207ee063f6eee4d37d66c6e
2014-05-07 15:36:05 -07:00
Mark Salyzyn
d2e3747e70 liblog: test bionic libc_logging.cpp
Change-Id: Ia778c43513a28c85ae54e96926ee9ed56717d527
2014-04-25 10:59:29 -07:00
Mark Salyzyn
819c58a8ca liblog: Add liblog test suite
(cherry picked from commit 8d1fdb5093)

Change-Id: Ia457d518b4e7ff37e840336ff0c48583709700d4
2014-01-27 15:17:39 -08:00