Commit graph

570 commits

Author SHA1 Message Date
Suren Baghdasaryan
bb20b9e6b8 liblog: Add functions to reset log context
Add android_log_parser_reset and android_log_reset to reset reader/writer
log context. This allows to generate multiple log messages of the same
format without context reallocation.

Change-Id: Icb0f15855378aa4e66fc671ffefd15d9df6fee1e
2018-08-02 00:55:01 +00:00
Chih-Hung Hsieh
cd3965e425 Suppress gnu-zero-variadic-macro-arguments warning.
Bug: 111614304
Test: make with WITH_TIDY=1
Change-Id: I2a52073202f42d1912363ae864f2f7f892589cea
2018-07-26 14:33:12 -07:00
Chih-Hung Hsieh
62b0ef556d Declare __fake_use_va_args as a variadic function.
* New clang compiler requires variadic function to have
  at least one named parameter type.
* Use ##__VA_ARGS__ to work with empty __VA_ARGS__.
* Fix one ALOG_ASSERT parameter bug in lmkd/lmkd.c.

Bug: 111614304
Test: make with WITH_TIDY=1
Change-Id: I90f35aa88527a6897954f69a35b256a157a725c5
2018-07-25 14:36:35 -07:00
Chih-Hung Hsieh
67f72bde26 Declare __FAKE_USE_VA_ARGS as a variadic function.
This avoids 2 static analysis warnings:
* assigned but unused variables in __VA_ARGS__
* unused expression result in __VA_ARGS__

Bug: 111614304
Test: make with WITH_TIDY=1
Change-Id: I4faae8787f6cc76de7ff4b6d08d25d0cb47324ea
2018-07-23 13:03:19 -07:00
Chih-Hung Hsieh
fdd3f5ec74 Use __VA_ARGS__ when in clang static analyzer.
Clang static analyzer can optimize out if (false) ...
and report unused variables in __VA_ARGS__.

Bug: 111614304
Test: make with WITH_TIDY=1
Change-Id: I214ced736230fda847031fd4eee23015fd988ffc
2018-07-18 17:07:45 -07:00
Yi Kong
c8d09ddceb [logd] Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.

Test: m
Bug: 68236239
Change-Id: I15ccb9cfc9967dae4320d9690f5097bc2f7d5bfe
2018-07-13 17:50:55 -07:00
Yi Kong
c1a1562548 Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning for binder.

Test: m
Bug: 68236239
Change-Id: I8184bd6aa4ebff1bd8c88dad16886e98df853b03
2018-07-13 15:28:59 -07:00
Treehugger Robot
b8f4fe4fd4 Merge changes from topic "mingw-clang"
* changes:
  Do not customize __format__ for Windows/MinGW to gnu_printf
  Adapt to switch to Clang for Windows host builds
  Update cflags for building Windows modules with Clang
2018-06-26 19:47:53 +00:00
Pirama Arumuga Nainar
a2df1ef441 Do not customize __format__ for Windows/MinGW to gnu_printf
Bug: http://b/69933090
Bug: http://b/69933068

MinGW uses gnu_printf to force C99 printf analysis with GCC, but clang
does not support gnu_printf.  So just use the default that's used for
other platforms.  This also mirrors upstream commit
015e637b4b/.

Test: m native-host-cross with Clang.
Change-Id: I3deb266d70e25296c4ae1d58637afbabc3d949c1
2018-06-25 11:52:54 -07:00
chenhg
7d8880e50c Remove pstore case ibc.__pstore_append from CTS
BUG: 110118705
Change-Id: I946c645af0cfb3f3b0e9344c51940da226fd08ce
2018-06-21 16:04:10 -07:00
Elliott Hughes
6427c363df logd: remove failing test.
Bug: N/A
Test: ran tests manually
Change-Id: I3ebb97d757077acaab1b51809a1c2be90ceb1ad9
2018-06-19 15:06:53 -07:00
Mark Salyzyn
42fb2821cc liblog: expect content only if ro.logd.kernel is enabled
On svelte devices, CTS test liblog#android_logger_get_ fails on the
missing kernel buffer because it is not enabled to save space.

Test: gTest liblog_unit_tests
Bug: 109669791
Change-Id: Iaf46fe9713d3462a56885515a67db640544345ab
2018-06-05 07:43:15 -07:00
Chih-Hung Hsieh
462df10d91 Work around b/24465209, do not pack relocation table.
Global flag --pack-dyn-relocs=android is used with clang lld.
For b/24465209, we need to override that with pack_relocations:false.

Bug: 24465209
Bug: 80093890
Test: build with USE_CLANG_LLD=true and run dlext.compat_elf_hash_and_relocation_tables
Change-Id: I4edcdf49e184fa45ea2b6b6417654d81bcd09e1d
2018-05-24 09:34:54 -07:00
Chih-hung Hsieh
85bd9ca978 Merge "Work around b/24465209, do not use clang lld" 2018-05-23 17:17:14 +00:00
Chih-Hung Hsieh
0f975a2099 Work around b/24465209, do not use clang lld
See longer explanation in b/80093890.
Clang lld does not generate expected DT_REL and DT_RELA tags
with --hash-style=both and --pack-dyn-relocs=android.
I am not sure about the extent of b/24465209, so
I would rather not to use lld for these .so files for now.

Bug: 80093890
Bug: 24465209
Test: build with USE_CLANG_LLD=true and run dlext.compat_elf_hash_and_relocation_tables
Change-Id: I645dbe25c5b9975605e3af5e717ed36c276f14d4
2018-05-23 17:15:48 +00:00
Treehugger Robot
2a1c0dd6df Merge "Simplify code" 2018-05-22 22:44:56 +00:00
George Burgess IV
487de27345 Simplify code
The static analyzer is concerned about the strcpys below this, since it
apparently doesn't try to model snprintf's potential behaviors. (In
particular, it was concerned that suffixLen might be >=
sizeof(suffixBuf)). While that's clearly suboptimal, this code can also
be simplified to make it more obvious what's happening and to appease
the analyzer.

No functionality change is intended.

Bug: None
Test: Ran the analyzer. It's no longer angry about strcpy overflows.

Change-Id: I4aa812144c90f6d3e833bbcb23c0694476a0e53e
2018-05-16 03:06:59 +00:00
Jiyong Park
612210c75b Mark as recovery_available: true
Libraries that are direct or indirect dependencies of modules installed
to recovery partition (e.g. toybox) are marked as recovery_available:
true. This allows a recovery variant of the lib is created when it is
depended by other recovery or recovery_available modules.

Bug: 67916654
Bug: 64960723
Test: m -j
Change-Id: Ie59155c08890e96ce1893fa3687afcf763d7aea3
2018-05-15 09:47:04 +09:00
Dan Albert
55a76719e2 Add missing @addtogroup tags.
These NDK docs weren't in any groups, so they don't show up in the
new site.

Test: https://irina-dot-devsite.googleplex.com/ndk/reference/group/logging
Test: https://irina-dot-devsite.googleplex.com/ndk/reference/group/sync
Bug: http://b/77236573
Change-Id: I300f96585dec94359ecf96fbf39c6dc3ec4579e5
2018-04-13 14:49:41 -07:00
Mark Salyzyn
72d3724ee5 liblog: save errno through log writing
Test: compile
Bug: 74258013
Change-Id: I5163527826855bc506ed324aaba47f8695aaf668
2018-03-07 10:56:51 -08:00
Tom Cherry
73ac28b408 Expose __android_log_buf_print and __android_log_buf_write to NDK
These are needed to build libbase with the NDK.

Bug: 73658597
Test: tree hugger
Change-Id: Icf4a82c5c08975731c180be155743ac63f4bfd50
2018-02-20 14:59:28 -08:00
Pavel Grafov
446d01c2c7 Make log_event_list.h available to vendor code.
This is required in order to be able to log audit
events from wpa_supplicant. Only log writing functions
from log_event_list.h are made available.

Test: manually
Bug: 70886042
Change-Id: I097d4ad1de573662658678e6a9f1fc8f17820542
2018-02-13 19:21:43 +00:00
Elliott Hughes
65725ac464 Doxygen format <android/log.h>.
Bug: N/A
Test: ran doxygen manually.
Change-Id: I164de255dbbc6c0312e656ddd886dcac231c893a
2018-01-26 10:57:57 -08:00
Ian Pedowitz
7bb9785a1d Fixing app compat issue b/72143978
Revert "Remove obsolete workaround."

This reverts commit 1f3ac7583f.

Bug: 72143978
Bug: 24465209
Test: Tested failing case on sailfish, reverted back all CL's since
Test: 3471433 for b/24465209 and apps open
2018-01-18 16:25:24 -08:00
Mark Salyzyn
dc3c14720f liblog: clock_gettime, clock_getres and time benchmarks
Add local BM_time_clock_gettime_*, BM_time_clock_getres_* and
BM_time_time benchmarks.  Relates to the bionic benchmarks of
the same names, except adds CLOCK_MONOTONIC_RAW.  Added here for
developer convenience whenever updates to the liblog or logd
code base need integration testing.

ToDo: add liblog gTests that analyse the benchmark data to confirm
that the specified integrated device has vdso access to all the
pertinent clock sources.  Add liblog local benchmarks and tests to
measure the device clock drift of each possible liblog clock
source to help evaluate device configuration.

Test: liblog_benchmarks --benchmark_filter=BM_time*
Bug: 63737556
Bug: 69423514
Change-Id: Ibafe0880d976ef2b3885765f71e0ba6c99d56f2a
2018-01-16 08:11:59 -08:00
Mark Salyzyn
1520bd43b0 liblog: benchmarks use google-benchmark library
Remove our circa 2014 snapshot of the google benchmarking library, and
use the now very stable google-benchmark suite. Some porting effort,
and deal with some benchmarking saddle points that take too long to
sort out. Focus on minimal API changes, _odd_ new behaviors, and style.

Test: liblog_benchmarks, ensure results in about the same range
Bug: 69423514
Change-Id: I2add1df9cb664333bcf983b57121ae151b26935b
2018-01-16 08:11:26 -08:00
Krzysztof Wesolowski
b0e17c9e91 Improve ALOGV compatiblity with clang-tidy
Currently used clang tidy does not filter the warnings caused
by macros, even if macros come from filtered headers.

This change allows projects using ALOGV to use
readability-implicit-bool-conversion without spreading //NOLINT everywhere.

Bug: 71533509
Change-Id: Id1b193d1e56d13f00171e04f600292877c5f6cb3
2018-01-11 11:11:20 -08:00
Elliott Hughes
1f3ac7583f Remove obsolete workaround.
Bug: http://b/24465209
Test: manually ran the app.
Change-Id: I573d2480c70632b100096ba6b2029bfc335595d6
2018-01-09 14:43:00 -08:00
Steven Moreland
e1c834db04 Use override_export_include_dirs.
Bug: 62878521
Test: soong build system finds renamed attribute
Change-Id: I51e42f4378db366b8711cd373fb835fecda88416
2018-01-05 14:42:12 -08:00
Julien Desprez
5b585791db Add suite component to test modules
Test: build
Bug: 65303193
Change-Id: I620c7034b9bdfa056dbde97c28bc5abc3375cc42
2017-12-18 18:08:53 +00:00
Elliott Hughes
3289b9c928 Merge "Add OWNERS." 2017-12-07 23:21:26 +00:00
Elliott Hughes
693d63f9cf Add OWNERS.
Bug: N/A
Test: N/A
Change-Id: Ie785058c0f5eb9b4086c98ccba6e63e3ed411b65
2017-12-07 13:30:03 -08:00
Yao Chen
9e28024b42 Merge "make log.tag.stats_log work for stats buffer."
am: 1e2ed53ffc

Change-Id: I5b81edb2c221eb8a7c5ab64316d788879d727c58
2017-12-04 21:17:18 +00:00
Treehugger Robot
1e2ed53ffc Merge "make log.tag.stats_log work for stats buffer." 2017-12-04 21:02:26 +00:00
Yao Chen
025f05a225 make log.tag.stats_log work for stats buffer.
Test: adb shell setprop log.tag.stats_log S
      And saw the stats logs are silent.

Change-Id: I7a9313f5f12029f9b8a8f070de1e1db659675525
2017-12-04 10:07:12 -08:00
Elliott Hughes
152d7e0f6c Merge "std::string_view is no longer experimental."
am: c8022a3efc

Change-Id: I75fa251cb6a959e7dfd32524b8d0ffcf839c3dc4
2017-12-01 16:51:24 +00:00
Elliott Hughes
e805883a2b std::string_view is no longer experimental.
Bug: N/A
Test: builds
Change-Id: I8f022fdc3ebaebd8aa250414569485a752f98da7
2017-11-30 16:32:15 -08:00
yaochen
11bb6bbf41 Merge changes from topic "stats_log"
am: 68f2c85354

Change-Id: I2dce867c04ea61a05b32063f321414f459cbe26c
2017-11-15 19:26:12 +00:00
Stefan Lafon
701a0658e6 Create stats buffer in logd.
Bug: 69323063
Test: ran unit tests.
Change-Id: Icfb827ab4674172c26b4bbfe1a9b3bffc03dc24b
(cherry picked from commit 1b1b6f50c7)
2017-11-14 16:20:00 -08:00
Xin Li
23e27db576 Merge commit 'a63ccea6abc7ea02e2d98e41c80793ca97237bd3' from
oc-mr1-dev-plus-aosp into stage-aosp-master

Change-Id: Ia33311cd1fd26dfaea59a69317b306fb91203c40
Merged-In: I03d06b10807e8a313c9654c2e1db36bfb59e3f99
2017-11-14 13:19:45 -08:00
Yao Chen
07320dc0a3 Allow stats buffer to be empty in liblog CTS.
Bug: 68205209
Test: CtsLiblogTestCases
Change-Id: I846c7cf72c54b02c2bc67c9c9e37b5cf4ae3da2b
2017-10-25 13:46:42 -07:00
Steven Moreland
95d7cbb77a 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
(cherry picked from commit 42b485cc53)
2017-10-17 12:09:50 +09:00
Jayant Chowdhary
f4778e827f Merge "Make liblog headers compile stand-alone." am: fe3551e9dc am: b637860732
am: 7b9c789d23

Change-Id: Ie4227d04492fdb6d571eca3f7637e650180b4716
2017-10-04 01:00:52 +00:00
Jayant Chowdhary
b637860732 Merge "Make liblog headers compile stand-alone."
am: fe3551e9dc

Change-Id: I20b97d38d356f720c74954200f40b8315cdd0c21
2017-10-04 00:55:47 +00:00
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
1511cbb439 Merge "Hide implementation details of log_time struct"
am: 541428a13b

Change-Id: I170a1f983e7752bb318973a30d761376ecff7f05
2017-10-03 20:05:15 +00: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
2c6b2ebe7c Merge "Remove default libraries" am: 8b7feee38f am: a0113de2f3
am: 55181f7cdd

Change-Id: I2fa1d556537ee4f3b2e67cd35aa3ce090b3684a6
2017-09-30 23:36:25 +00:00
Dan Willemsen
a0113de2f3 Merge "Remove default libraries"
am: 8b7feee38f

Change-Id: Ic39ecabd37ffe06ba3a119410b5dcd4885fb584c
2017-09-30 23:32:45 +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
Yoshitaka Seto
1d444319d7 Remove pstore related unit tests from CTS
am: 5dec8e22c3

Change-Id: Ifba13f9d714e58eaa3358a48246c71f90687629e
2017-09-21 23:25:34 +00:00
Yoshitaka Seto
5dec8e22c3 Remove pstore related unit tests from CTS
Pstore test cases should not belong to CTS.
The test cases should be a part of GTS if really required.

Test: manual
Bug: 66431569
Bug: 63969981
Bug: 63913130
Signed-off-by: Srinavasa Nagaraju <Srinavasa.Nagaraju@sony.com>
Signed-off-by: Yoshitaka Seto <yoshitaka.seto@sony.com>
Signed-off-by: Mark Salyzyn <salyzyn@google.com>
Tested-by: Srinavasa Nagaraju <Srinavasa.Nagaraju@sony.com>
Change-Id: Icd326403711ad268ce28a3863045fc9b2f211461
2017-09-21 13:37:50 -07:00
Jiyong Park
88618e2b30 Merge changes from topic "hide_log_time" into oc-mr1-dev
am: cd00582000

Change-Id: I28004046f32523b4445cce9036c7170fc3a52f37
2017-09-07 17:37:59 +00: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
Jiyong Park
98c0d030c9 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
Change-Id: I01b36078c1d8f3f44824be20ae769ba1465b6feb
2017-09-06 15:30:50 +09:00
Ting-Yuan Huang
5d1706346c Merge "Suppress false-positive static analyzer warnings" am: 0c89aaec1f am: 2ee27bfd0d
am: d3ffb4344e

Change-Id: Ica8a4b2e224e278308e9dca377751e462be4ae6d
2017-09-06 05:16:45 +00: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
e0515d6dba 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.

(cherry picked from commit 64acdf77d6)

Change-Id: Ic2ec131a3aee293ee865c46e62566ddd82ec2507
2017-08-25 18:21:36 +01:00
Alan Stokes
e751059975 Merge "Small liblog test fixes & readability improvements." am: 332370d14d am: 511cc67633
am: 32636f0f4c

Change-Id: I5dd5e1b7267ff3f96aa264eede616dfb30b68884
2017-08-25 16:50:50 +00:00
Alan Stokes
332370d14d Merge "Small liblog test fixes & readability improvements." 2017-08-25 16:35:55 +00:00
Alan Stokes
328ba7c8e6 Merge "Reading from logd in WRAP mode is expected to take a long time, don't abort it after 30s." am: 974ab46561 am: 9181fe6427
am: 50289204e5

Change-Id: I88069714a32ec83f318a1a1dded0b0d8553be07f
2017-08-25 14:55:43 +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
2f41895b90 Merge "Fix clang-tidy performance warnings in system/core." am: 69ff5009c7 am: 18f9c66823 am: b083ff4329
am: 36557667f3

Change-Id: I72bf60cf94547867f7eaf4aeddf60ff67c29dad5
2017-08-04 21:32:37 +00: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
b7486369df Merge "Fix misc-macro-parentheses warnings in system/core." am: e4bd153e55 am: dfaa20c069 am: 3d0ff4ee98
am: c3357de3fd

Change-Id: I3c3c048851fe44a260a7f952b89d5b5dd72a4b4e
2017-08-01 23:38:19 +00: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
Yifan Hong
79b1a3027b 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
2017-07-17 17:59:35 -07: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
TreeHugger Robot
67dec06c7c Merge "Add vendor_available to liblog_headers." 2017-07-12 15:29:20 +00:00
Steven Moreland
42b485cc53 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: I3a85385f588b84393c57fd6d1bcac620f708f0f1
2017-07-10 16:55:32 -07:00
nickrose
653d49a245 Add logd CTS tests to VTS
Follow-up to  Change-Id: Id52ac1639447276171006c33bdfa7b4e6c874745

Test: make vts
Change-Id: Ibeb5082439ada49a6eccd6fb699e466ca71730c9
2017-07-10 11:17:38 -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