Commit graph

459 commits

Author SHA1 Message Date
Jayant Chowdhary
12f56a00d3 Make liblog headers compile stand-alone.
Test: process liblog headers individually with header-abi-dumper.

Test: mm -j64

Bug: 66971285

Change-Id: If7dec611b84eb9fa8e1e5a974b444d4ddf54759a
2017-10-03 14:06:33 -07:00
Jayant Chowdhary
541428a13b Merge "Hide implementation details of log_time struct" 2017-10-03 20:01:13 +00:00
Jiyong Park
0d047642eb Hide implementation details of log_time struct
In the future, the sizes of tv_sec and tv_nsec (or even the size of
log_time struct itself) can change due to the 32-bit overflow expected
to happen in the year 2138. In order to hide such implementation details
to the clients of liblog, the two macros LOG_TIME_SEC and LOG_TIME_NSEC
are introduced.

Furthermore, vendors are provided with a simplified version of log_time.h
without C++ APIs. In doing so, log_time.h no longer includes time.h.
This breaks several modules that implicitly relied on the hidden
dependency, which should be fixed.

Bug: 37629934
Test: build with BOARD_VNDK_VERSION=current

Merged-In: If213fc291395554fd8de5f5d1fb005ceaaa5ca57
Change-Id: I01b36078c1d8f3f44824be20ae769ba1465b6feb
(cherry picked from commit 98c0d030c9)
2017-10-03 17:45:17 +00:00
Dan Willemsen
1e45d533b3 Remove default libraries
libdl is part of system_shared_libs now. -ldl -lpthread -lm are now defaults
for host_ldlibs on Linux and Darwin. -lrt is a default for host_ldlibs on
Linux.

Test: m host
Change-Id: I0b3c147b00a8ab6ff289b85db55b88836c905f5c
Exempt-From-Owner-Approval: build system cleanup
2017-09-29 13:17:06 -07:00
Steven Moreland
25db8dc21b Add vendor_available to liblog_headers.
Renamed NDK headers to "liblog_ndk_headers"
(these names aren't used anywhere).

libutils_headers now properly export liblog_headers.

Test: with BOARD_VNDK_VERSION=current
Change-Id: I7b2d9e77e313e3f2ef362a19a03f4c23874d589a
Merged-In: I3a85385f588b84393c57fd6d1bcac620f708f0f1
2017-09-06 12:55:32 -07:00
Yifan Hong
e2c51809f7 Add sys/cdefs.h to log/log_main.h.
for liblog.vendor. __ANDROID_API__ is __ANDROID_API_FUTURE__
with BOARD_VNDK_VERSION=current, so we need it defined.

Bug: 33241851
Test: BOARD_VNDK_VERSION=current m libgui.vendor
      (that uses liblog.vendor)

Change-Id: I340ec048094c027828f516d891250651e0c88eea
Merged-In: I340ec048094c027828f516d891250651e0c88eea
2017-09-06 12:54:41 -07:00
Treehugger Robot
0c89aaec1f Merge "Suppress false-positive static analyzer warnings" 2017-09-06 05:04:29 +00:00
Ting-Yuan Huang
249bd05038 Suppress false-positive static analyzer warnings
by hinting the analyzer with assertions.

Test: built without seeing warnings.
Change-Id: I0d43d4ceafd7f68be89cad6c930c85ee7b6d5165
2017-09-05 16:46:40 -07:00
Alan Stokes
332370d14d Merge "Small liblog test fixes & readability improvements." 2017-08-25 16:35:55 +00:00
Alan Stokes
81e63d0515 Small liblog test fixes & readability improvements.
liblog concurrent printf tests now check every write succeeds.
logd timeout_negative tests exits as soon as one run succeeds.

Test: CTS tests till pass.
Change-Id: I9a166a0abcb8b9aa5c055c35c5dccf30616a4e24
2017-08-25 14:53:21 +01:00
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
Chih-hung Hsieh
18f9c66823 Merge "Fix clang-tidy performance warnings in system/core."
am: 69ff5009c7

Change-Id: I74373e9f0e7f83c9280f4700ea55b387c3384c2c
2017-08-04 21:14:30 +00:00
Chih-hung Hsieh
69ff5009c7 Merge "Fix clang-tidy performance warnings in system/core." 2017-08-04 21:05:51 +00:00
Chih-Hung Hsieh
e5d975c7cc Fix clang-tidy performance warnings in system/core.
* Use const reference parameter type to avoid unnecessary copy.
* Use more efficient overloaded string methods.

Bug: 30407689
Bug: 30411878
Test: build with WITH_TIDY=1
Change-Id: Ia5a00581e718d412255d6177e5a7c286cdfbec11
2017-08-03 13:58:05 -07:00
Chih-Hung Hsieh
dfaa20c069 Merge "Fix misc-macro-parentheses warnings in system/core."
am: e4bd153e55

Change-Id: I6b38149a0fa15874eff68cbf7ee62e4acd41c595
2017-08-01 23:26:06 +00:00
Chih-Hung Hsieh
85244e8bc2 Fix misc-macro-parentheses warnings in system/core.
Add NOLINT comment to work around clang-tidy
error in checking macro arguments used in
type expressions.

Bug: 28705665
Test: make with WITH_TIDY=1 WITH_TIDY_CHECKS=-*,misc-macro-* \
      WITH_TIDY_FLAGS=-header-filter=system/core/.*

Change-Id: I7619978c1804e151a11a8b0477e80076bcf21cab
2017-08-01 22:12:57 +00:00
Steven Moreland
c30f248cd4 Add vendor_available to liblog_headers.
Renamed NDK headers to "liblog_ndk_headers"
(these names aren't used anywhere).

libutils_headers now properly export liblog_headers.

Test: with BOARD_VNDK_VERSION=current
Merged-In: I3a85385f588b84393c57fd6d1bcac620f708f0f1
Change-Id: I3a85385f588b84393c57fd6d1bcac620f708f0f1
2017-07-12 12:59:30 -07:00
Ian Elliott
cbe556ee62 Merge "Use void instead of no parameters in 2 function declarations."
am: 11b91e7c28

Change-Id: Ie41c3cbf8c6017994d3728c638fc85c55df3ec94
2017-07-10 12:09:43 +00:00
Ian Elliott
58e06c5f94 Use void instead of no parameters in 2 function declarations.
In compiling some code with a picky "Android.mk" file, it is not happy
with a function declaration that looks like:

    void foo();

It requires:

    void foo(void);

This commit changes that for 2 functions in "log.h".

Test: Build both Android and the code with a picky "Android.mk".
Change-Id: Icd624df34db57e642fe6b1c7da77be9b05936936
2017-07-07 16:11:32 -06:00
Jiyong Park
eacf704a6c Merge "Allow SLOG* to vendors"
am: 6afbd476ab

Change-Id: I56d66068757cd962c237a8292aa481d96b417f17
2017-06-29 03:58:59 +00:00
Jiyong Park
9ffeab85bf Allow SLOG* to vendors
Not only vendor libs, but also Android libs that are marked as
vendor_available are using SLOG*. Since both pure vendor libs and
Android libs available to vendors are using the same liblog headers for
VNDK, SLOG* needs to be visible via the headers.

Bug: 63088165
Test: BOARD_VNDK_VERSION=current m -j ATFWD-daemon
(or any other vendor modules using SLOG*)

Change-Id: Idfb74887a42d2418d3896bfdf5be3b4fc8e4c27f
2017-06-29 10:25:25 +09:00
Guang Zhu
c2fbcf6f67 add component metadata tag to CTS liblog test acses
am: de29bf4884

Change-Id: I4bc7c46b9498227ccd19c558fd821d80974bd404
2017-06-06 19:28:39 +00:00
Guang Zhu
de29bf4884 add component metadata tag to CTS liblog test acses
Bug: 36140955
Bug: 35360169
Test: new unit test to ensure that all modules have this field
Change-Id: I352145965e8cd20371ccce3ba2b25f3a166bc3e8
Merged-In: Ifb7a14817265b4624f1dc6414b547c86aafcf4ac
2017-06-05 23:21:23 +00:00
Mark Salyzyn
e09e9a503e liblog: add bool to android_log_event_list
Test: compile
Bug: 62241642
Change-Id: I977702456417ceec21be96ff8463a5ed047560ec
2017-06-05 07:50:13 -07:00
Mark Salyzyn
067e8a0725 liblog: test: CTS: enoent does not qualify
Eliminate liblog@enoent CTS test as it is bypassed on "user" builds
in commit "liblog: test: enoent requires userdebug or eng to run".
This prevents time wasted running a test that bypasses during CTS.

Test: CtsLiblogTestCases_list --gtest_list_tests |
      (grep enoent && echo FAILED)
Bug: 62030441
Change-Id: Ia440db3e74dacdc5c311c640aab3a11844cc195a
2017-05-24 15:30:07 -07:00
Mark Salyzyn
558f2a166b liblog: test: android_logger_get_ "kernel" log buffer can be empty
(cherry picked from commit 37eaefa9a0)

If user build and for the "kernel" log buffer, allow an empty report.

Test: CTS: User: liblog#android_logger_get_
Test: remove ro.debuggable line from /default.prop,
      run liblog-unit-tests --gtest_filter=*.android_logger_get_
Bug: 62030309
Change-Id: I5f91af07608988f322b3c46574becc308e1d8b13
2017-05-24 12:50:38 -07:00
Mark Salyzyn
37eaefa9a0 liblog: test: android_logger_get_ "kernel" log buffer can be empty
If user build and for the "kernel" log buffer, allow an empty report.

Test: CTS: User: liblog#android_logger_get_
Test: remove ro.debuggable line from /default.prop,
      run liblog-unit-tests --gtest_filter=*.android_logger_get_
Bug: 62030309
Change-Id: I5f91af07608988f322b3c46574becc308e1d8b13
2017-05-24 12:45:41 -07:00
Mark Salyzyn
928e606d5a liblog: test: enoent requires userdebug or eng to run
(cherry picked from commit 38dad6c9e4)

Bypass test if we do not have all the prerequisites to run this check
of liblog failure propagation.  We need to be root, or be able to
call su, in order to temporarily stop logd to measure the error
response from liblog.  Basically a "user" build can not have the
levers to deny or fail the logger, preventing our ability to run the
liblog.enoent test.

Test: CTS: User: liblog#enoent
Test: remove ro.debuggable line from /default.prop,
      run liblog-unit-tests --gtest_filter=*.enoent
Bug: 62030441
Change-Id: I52177b8dd3c66d433bddf630e840ee088e13cddc
2017-05-24 09:15:27 -07:00
Mark Salyzyn
38dad6c9e4 liblog: test: enoent requires userdebug or eng to run
Bypass test if we do not have all the prerequisites to run this check
of liblog failure propagation.  We need to be root, or be able to
call su, in order to temporarily stop logd to measure the error
response from liblog.  Basically a "user" build can not have the
levers to deny or fail the logger, preventing our ability to run the
liblog.enoent test.

Test: CTS: User: liblog#enoent
Test: remove ro.debuggable line from /default.prop,
      run liblog-unit-tests --gtest_filter=*.enoent
Bug: 62030441
Change-Id: I52177b8dd3c66d433bddf630e840ee088e13cddc
2017-05-24 07:50:29 -07:00
Mark Salyzyn
f7690d9196 liblog: tests: crashes in logcat.descriptive
scanTagLine has some loops that do not check for a terminating nul,
problematic for responses from the logger via __getEventTag.

Test: gTest logcat-unit-tests --gtest_filter=*.descriptive
Bug: 37791296
Change-Id: Ib4e900b765b407bdee43e009d6625fe289863ddc
2017-05-12 13:07:08 -07:00
Dan Willemsen
f3452d8178 Remove old simulator support from liblog
As far as I know, this isn't used anymore, and is causing problems when
building with bionic on the host (with the cast of open).

Bug: 31559095
Test: host bionic compiles
Change-Id: I8b6e802e2d6dcc6e8476e387a5a365903aec3be1
2017-05-07 13:21:35 -07: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
Steven Moreland
64328403b5 liblog: __android_log_error_write in vndk
Also added log_safetynet.h header. This contains a memory sensitive logging
function which is used to detect attack attempts.

Fixes: 37442967
Test: liblog-unit-tests on internal marlin
Test: build liblog with BOARD_VNDK_VERSION := current on aosp_arm
Test: libbinder vendor variant links with BOARD_VNDK_VERSION := current

Change-Id: Icfcc2b1acbb3712bf4c84403870dc93401eafb15
2017-05-01 14:40:55 +00:00
Mark Salyzyn
b7140c26d5 liblog: test: liblog.__security miscalculation
(cherry pick from commit b867beac56)

The gTest should not be able to set ro.device_owner, either as a unit
test or a CTS test.  The CTS test should not be able to set
persist.logd.security, the gTest may as it is run on userdebug with
root, so check if we are root to discern expectations.

Test: gTest liblog-unit-tests --gtest_filter=liblog.__security
Test: cts-tradefed run cts-dev -a armeabi-v7a -m CtsLiblogTestCases -t liblog#__security
Bug: 36480230
Change-Id: I1da88aae34da4e2fca8dd88d740eeb879d9c65bb
2017-04-21 08:20:56 -07:00
Mark Salyzyn
ad8d533a04 Merge changes Iec369a50,I78959464,I3f9f8d56 into oc-dev
* changes:
  logd: instrument tests better for failure
  logd: iterator corruption paranoia
  liblog: log_time add explicit to some constructors.
2017-04-20 20:44:28 +00:00
Mark Salyzyn
b867beac56 liblog: test: liblog.__security miscalculation
The gTest should not be able to set ro.device_owner, either as a unit
test or a CTS test.  The CTS test should not be able to set
persist.logd.security, the gTest may as it is run on userdebug with
root, so check if we are root to discern expectations.

Test: gTest liblog-unit-tests --gtest_filter=liblog.__security
Test: cts-tradefed run cts-dev -a armeabi-v7a -m CtsLiblogTestCases -t liblog#__security
Bug: 36480230
Change-Id: I1da88aae34da4e2fca8dd88d740eeb879d9c65bb
2017-04-20 13:26:12 -07:00
Mark Salyzyn
0dd92d5b92 liblog: log_time add usec() and msec()
Test: build
Bug: 37254265
Change-Id: Ie7a5303e85e565800f2066e53e19a83496acae72
2017-04-19 09:18:40 -07:00
Mark Salyzyn
86b136a4a4 liblog: __android_logger_property_bool svelte+eng default
(cherry pick from commit 9fcaaba85d)

When BOOL_DEFAULT_FLAG_ENG and/or BOOL_DEFAULT_FLAG_SVELTE is set for
flags parameter in __android_logger_property_get_bool, they can not be
overridden by a supplied property value.  Reset these two flags if
there is something in the specified property.

Test: gTest liblog-unit-tests, logcat-unit-tests and logd-unit-tests
Bug: 37425809
Change-Id: I5fc2d727e8c30bc1e781f8b365f44ec62dd36b4d
2017-04-19 08:24:31 -07:00
Mark Salyzyn
9fcaaba85d liblog: __android_logger_property_bool svelte+eng default
When BOOL_DEFAULT_FLAG_ENG and/or BOOL_DEFAULT_FLAG_SVELTE is set for
flags parameter in __android_logger_property_get_bool, they can not be
overridden by a supplied property value.  Reset these two flags if
there is something in the specified property.

Test: gTest liblog-unit-tests, logcat-unit-tests and logd-unit-tests
Bug: 37425809
Change-Id: I5fc2d727e8c30bc1e781f8b365f44ec62dd36b4d
2017-04-18 15:36:36 -07:00
Treehugger Robot
f358bed624 Merge "libcutils: compile with BOARD_VNDK_VERSION current" 2017-04-18 14:46:27 +00:00
Mark Salyzyn
219ef270a6 liblog: log_time add explicit to some constructors.
(cherry pick from commit d87d47f7dd)

Add explicit to constructors, to prevent implicit conversions.

Test: compile
Bug: 37378309
Change-Id: I3f9f8d561e84c492eafa6528db7c238da072dad8
2017-04-18 07:23:38 -07:00
Mark Salyzyn
d87d47f7dd liblog: log_time add explicit to some constructors.
Add explicit to constructors, to prevent implicit conversions.

Test: compile
Bug: 37378309
Change-Id: I3f9f8d561e84c492eafa6528db7c238da072dad8
2017-04-17 15:10:26 -07:00
Steven Moreland
d73be1b96b libcutils: compile with BOARD_VNDK_VERSION current
- moved __android_log_is_debuggable to a new public header
    (log_properties.h)
- vendor version of sched_policy uses ALOG* instead SLOG*

Test: (sanity) liblog-unit-tests
Test: (sanity) libcutils_test (noting b/b/32972117, two tests continue
  to fail)
Test: system/core as a whole makes with BOARD_VNDK_VERSION := current
  now with no problems.
Test: boots/works on internal marlin
Bug: 33241851

(cherry picked from commit 1f83aa424f)

Merged-In: I5bc1f348dc0f0c8814bec5b5c3d2c52c825ab640
Change-Id: I5bc1f348dc0f0c8814bec5b5c3d2c52c825ab640
2017-04-17 14:44:17 -07:00
Steven Moreland
1f83aa424f libcutils: compile with BOARD_VNDK_VERSION current
- moved __android_log_is_debuggable to a new public header
    (log_properties.h)
- vendor version of sched_policy uses ALOG* instead SLOG*

Test: (sanity) liblog-unit-tests
Test: (sanity) libcutils_test (noting b/b/32972117, two tests continue
  to fail)
Test: system/core as a whole makes with BOARD_VNDK_VERSION := current
  now with no problems.
Test: boots/works on internal marlin
Bug: 33241851

Change-Id: I5bc1f348dc0f0c8814bec5b5c3d2c52c825ab640
2017-04-17 12:18:36 -07:00
Mark Salyzyn
01bdb04be6 liblog: allow event tags to include some punctuations
event_log_tag parser complains about a period (.) in the name,
we would consider such an enhancement to the tag names possible.
I expect we would want to be able to support alphanumerics,
underscore (_), period (.), minus (-), at (@) and comma (,) for
starters as they are present in the other text log buffer tags.

We introduce a local endOfTag function that is used during parsing and
during android_lookupEventTagNum for submitting new tags.  This
function caused us to enforce const char more closely.  By filtering
in both places we resolve an issue that could have plagued us if
garbage requests were made.

Test: gTest liblog-unit-tests, logd-unit-tests & logcat-unit-tests
Bug: 31456426
Change-Id: I596b8706e843719ddac07ec40e1cd2875c214bed
2017-04-14 12:56:06 -07:00
Mark Salyzyn
5768d3d976 liblog: logprint supports number of seconds time event field
Add s to report time in seconds.  The time could be a period, duration
or monotonic, expanded to seconds, minutes, hours and days.  gTest has
to acquire a dynamic tag allocation as there are no users of this
feature yet.

Looking to the future, audio media logging has binary content similar
to the binary events structures Android logging uses and they have
a definition of a duration field in their internal binary logging, so
may be of use when we unify the logs.

Test: gTest logcat-unit-tests --gtest_filter=*.descriptive
Bug: 31456426
Change-Id: I262c03775983b3bc7b1b00227ce2bb2b0f357bec
2017-04-14 12:54:25 -07:00
Mark Salyzyn
7ecfd6ac10 liblog: android_log_event_list class permit -EBUSY retry
write() method was one-shot, a second shot on -EBUSY would always
return -EBUSY even if successful.  Reset internal error if -EBUSY
when retransmitting.  write() now reports a positive count for
transmission success.  Composition errors trump transmission errors.

Test: gTest logcat-unit-tests --gtest_filter=*.descriptive while
      under heavy DOS stress levels of logging.
Bug: 31456426
Change-Id: Ib1920c3f10cf1df8ad8eb6a884724794b577b29d
2017-04-13 13:16:59 -07:00
Dan Willemsen
ab89b34b6f Remove .(ll)ndk suffix from (ll)ndk_library
Soong handles these automatically now.

Bug: 33241851
Test: Android-aosp_arm.mk is the same before/after
Test: build.ninja is the same before/after
Test: build-aosp_arm.ninja is the same before/after
Merged-In: Ica4eedda51bb34db2f39d2c64ea436e1f633bfc3
Change-Id: Ica4eedda51bb34db2f39d2c64ea436e1f633bfc3
2017-04-11 15:14:28 +00:00
TreeHugger Robot
ce4c78224d Merge changes from topic 'llndk_rename' into oc-dev
* changes:
  Remove .(ll)ndk suffix from (ll)ndk_library
  Remove .(ll)ndk suffix from (ll)ndk_library
2017-04-11 07:22:26 +00:00
Mark Salyzyn
b07c58758b Merge "liblog: adapt to removal of property name size limit" into oc-dev 2017-04-10 21:15:27 +00:00