Commit graph

406 commits

Author SHA1 Message Date
Mark Salyzyn
5c967da341 ndk: reverse course on android/log.h
move LOG macros to log/log_main.h

move include/android/log.h to liblog/include/android/log.h

Test: compile of all components and gTest liblog-unit-tests
Bug: 34250038
Bug: 30465923
Change-Id: If182dd9b83689e8b7bc1a44b2f5d913c7ee5eeee
2017-01-25 15:41:43 -08:00
Vijay Venkatraman
651f8383e6 Revert "Revert "Exporting C headers from system/core""
This reverts commit a3f2be2b73.

Test: compile
Change-Id: I04b3a8e47e1fa3eb9d80c14ae3a90c68a780e858
2017-01-25 12:50:29 -08:00
Vijay Venkatraman
22b7f76a00 Merge "Revert "Exporting C headers from system/core"" 2017-01-25 00:53:07 +00:00
Vijay Venkatraman
a3f2be2b73 Revert "Exporting C headers from system/core"
This reverts commit 3c6763ca21.

Change-Id: If3b3e106478d28a5df927d57649abdca0a99dd0e
2017-01-25 00:44:08 +00:00
Evgenii Stepanov
f38ae34bbc Merge "Don't disable all sanitizers in liblog, just asan." 2017-01-24 23:00:54 +00:00
Evgenii Stepanov
ffdabdc6f2 Don't disable all sanitizers in liblog, just asan.
ASan runtime library depends on liblog, so we have to disable ASan,
but nothing else.

Bug: 33091541
Test: SANITIZE_TARGET=address keeps working
Change-Id: I6e22925b7f1d5ec86fe1bd8c00dba4c3e86ddf3f
2017-01-24 12:57:23 -08:00
Vijay Venkatraman
3c6763ca21 Exporting C headers from system/core
Moved headers from include/libcutils and include/liblog to
libcutils/include and liblog/include respectively, so they can be
exported via these libs. They needed to be moved since Soong does
not allow export from external folder.

Added symlink from old locations. They are needed since Soong
includes system/core/include by default. Once all modules are
cleaned up to explicitly add the required libs, the symlinks will be
removed.

Also added liblog_vndk_headers that exports a special log/log.h for
VNDK.

Moved headers of libcutils to libcutils_headers. They should be used
by modules for header-only inlines. Added libcutils_headers as
dependency of libcutils.

Added libcutils_vndk_headers that exports a special cutils/log.h
deprecating usage of the file. A later CL will deprecate the one in
libcutils_headers

Test: Add above libs to shared lib of local module
Change-Id: I6e1f9c5f23d8b6eae13dc3b7e5dfe7fae93b8510
2017-01-22 19:45:38 -08:00
Mark Salyzyn
142b43d4ab liblog: BM_log_latency improvement
This reduces BM_log_latency from ~300ns to ~100ns.  Because, well, we
read the clock earlier and that is what BM_log_latency tries to
measure.  The one major improvement in the switch from kernel logger
to user space logger was that we picked up the timestamp in the
context of the caller before doing anything else, but alas changes
over time neglected this fact and placed isloggable checking ahead
of this important fact.

Test: liblog_benchmarks, check results
Change-Id: I4bc9fc3cf8b1659e88417d967b1d0f3743f9e456
2017-01-20 17:53:27 +00:00
Jorge Lucangeli Obes
f4ae42f6a8 Check the return value of setuid(2).
I'd like to mark setuid() WARN_UNUSED_RESULT to prevent security bugs.
This line would break because the file is compiled with -Werror.

Bug: 34251640
Test: Build, run unit test.
Change-Id: Ibb6fa5e5b899d47f77f2a32da762165de310101d
2017-01-13 15:43:45 +00:00
Mark Salyzyn
65e1e6284c liblog: retry -ENOTCONN | -ECONNREFUSED | -ENOENT indefinitely
Deal with recovering after transitory failures surrounding logd
crash or recovery.  Improve the chances that the logging functions
can work in a signal handler, not officially supported, but making
sure logging is not blamed for system lockups when misused.

Reorder gTests so that setuid(AID_SYSTEM) is performed after
liblog.enoent test, and that this occurs after other tests that
like to see buffers with content in them as we stop logd.

Test: gTest liblog-unit-tests --gtest_filter=liblog.enoent
Bug: 33755074
Change-Id: I66f88599534614b7b61da6b2ae5fe099ebaced3a
2017-01-09 15:51:09 +00:00
Mark Salyzyn
b52f445dbb liblog: test: switch to private event structures
Some tests use hard-coded offsets to interpret the binary
events buffers.  Switch to using the private event structures
to access the components of common event messages.

Test: gTest liblog-unit-tests
Bug: 33755074
Change-Id: I17447814583099d5ec417a54389e962158456005
2017-01-06 22:13:34 +00:00
Dan Albert
9a41bcecc6 Unversion NDK stub libraries.
The system versions of these libraries aren't versioned yet.

Bug: https://github.com/android-ndk/ndk/issues/278
Test: make ndk
Change-Id: Icf5ff9921441d3e252771aef37002c772c08cbd0
2017-01-06 11:04:15 -08:00
Elliott Hughes
9b3b119912 Don't use bare noreturn in log.h.
toybox has a #define noreturn that trips over this.

Also move `format` out of the way, just in case.

Bug: https://github.com/android-ndk/ndk/issues/271
Test: builds
Change-Id: Ib8811136b4b422ff74625509539a5464a3c9af18
2017-01-03 13:17:42 -08:00
Mark Salyzyn
af3503cff4 liblog: test failures due to permission issues
Test: gTest liblog-unit-tests passes
Change-Id: Ia9452b3ee9e6068723e8bef48c4d88d3769951a8
2016-12-27 10:01:42 -08:00
Mark Salyzyn
fc148f7f33 liblog: add IF_ALOG_RATELIMIT
IF_ALOG_RATELIMIT()
    ALOGE("Only one message globally using IF_ALOG_RATELIMIT()"
          " in the process may appear ever ten seconds,"
          " (%s)", strerror(errno));

static time_t last; /* initial state zero */
IF_ALOG_RATELIMIT_LOCAL(60, &last)
    ALOGE("Only one message locally may appear every minute,"
          " (%s)", strerror(errno));

These new calls are guaranteed not to affect the value of a
non-zero errno to simplify logging of errors.  However, the
ALOGE calls in the above examples may update the errno value
upon their return.

Test: gTest liblog-unit-tests --gtest_filter=liblog.__android_log_ratelimit
Bug: 33535908
Change-Id: Id8cc192fc7d14504ffd418933cf88ae945c089f2
2016-12-21 21:36:14 +00:00
Mark Salyzyn
5bd8f2d956 liblog: pmsg read permissions for AID_LOGD
Test: gTest liblog-unit-test and logd-unit-tests
Bug: 31456426
Change-Id: I7a2fe8245ecd651883f7851ce71b6c45e373af82
2016-12-19 15:57:01 +00:00
Mark Salyzyn
774e04f779 liblog: move log_is_loggable.c to properties.c
Just makes sense cleanup

Test: gTest liblog-unit-tests
Bug: 33535908
Change-Id: I85de049f3cd73a473d56db5970d42eee5f9f70a8
2016-12-16 08:43:56 -08:00
Treehugger Robot
8b99ef6c21 Merge "liblog: event_tag_map use unordered_map" 2016-12-16 01:57:03 +00:00
Mark Salyzyn
700fb87648 liblog: event_tag_map use unordered_map
>3 times faster access for lookup functions.  Code simplification and
C++ coding style conversion.  android_lookupEventTagNum has been
expanded to utilize the Format match, and then drops down to just
Tag match.

Performance testing on Hikey, all services stopped, shell only access,
CPU not locked had good repeatability.

$ adb reboot ; adb wait-for-device ; adb shell su root stop

Before this adjustment using binary search:

$ /data/nativetest64/liblog-benchmarks/liblog-benchmarks BM_lookupEvent*
                          iterations      ns/op
Precharge: start
Precharge: stop 231
BM_lookupEventTag           10000000        153
BM_lookupEventTag_NOT       20000000        139
BM_lookupEventFormat        10000000        153

After this adjustment strictly using std::unordered_map lookup:

$ /data/nativetest64/liblog-benchmarks/liblog-benchmarks BM_lookupEvent*
                          iterations      ns/op
Precharge: start
Precharge: stop 231
BM_lookupEventTag           50000000         56
BM_lookupEventTag_NOT      100000000         21
BM_lookupEventFormat        50000000         56

Test: gTest logd-unit-tests and liblog-unit-tests, liblog-benchmarks.
Bug: 31456426
Change-Id: I1cfc3d641c3ea9ab08d455efe0c844d3a6381440
2016-12-15 22:32:37 +00:00
Mark Salyzyn
a91b426268 liblog: clean up SafetyNet unit tests
Move active code into helpers.

Test: gTest liblog-unit-tests
Change-Id: I5ade96edd71b7d773386f4d99eddbad076d10405
2016-12-13 13:47:48 -08:00
Mark Salyzyn
ed9dc8abe2 liblog: switch event_tag_map.c to event_tag_map.cpp
NB: recent activities on event_tag_map.c were to allow
    this transition to be unremarkable.

Test: compile
Bug: 31456426
Change-Id: I13e1771a001874244711a5ac3023861c2a5f8c7d
2016-12-01 15:42:03 -08:00
Mark Salyzyn
3cd9e31446 liblog: fortify event_log_tags test
Robustness fortification.  Deal with gtest failure if event-log-tags
file is updated, adb sync for example, and thus will report
Shared_Dirty instead of Shared_Clear.  Add check for Private_Dirty
and Private_Clean being clear at zero too as a bonus.

Test: gTest liblog-unit-tests --gtest_filter=liblog.event_log_tags
Bug: 31456426
Change-Id: Id912929fdd65499aa532a15653ef387a997a5054
2016-11-30 11:08:46 -08:00
Treehugger Robot
f1f7333e7c Merge "liblog: CTS test" 2016-11-30 16:25:11 +00:00
Treehugger Robot
4afb3ef952 Merge "liblog: event_tag_map benchmark" 2016-11-30 15:31:11 +00:00
Treehugger Robot
1abc3cd641 Merge changes Ia0ca36fc,Ib42c0635
* changes:
  Enable liblog on host bionic
  Enable libbase/libutils/libziparchive on host bionic
2016-11-30 05:59:53 +00:00
Dan Willemsen
0910d2dbb9 Enable liblog on host bionic
Some of the __BIONIC__ checks were actually looking for an android
device. Host bionic has __BIONIC__, but not __ANDROID__.

Bug: 31559095
Test: Test linux_bionic compile
Change-Id: Ia0ca36fc9486fe8ea7e5d1b2e26ab0491903723c
2016-11-29 13:39:55 -08:00
Treehugger Robot
9bfd9f558b Merge "system/core: replace EVENT_TAG_MAP_FILE with NULL" 2016-11-29 19:37:48 +00: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
Mark Salyzyn
0b37d01f72 liblog: event_tag_map benchmark
Tested on Hikey, all services stopped, shell only access, CPUs not
locked.

$ /data/nativetest64/liblog-benchmarks/liblog-benchmarks BM_lookupEvent*
                          iterations      ns/op
Precharge: start
Precharge: stop 231
BM_lookupEventTag           10000000        153
BM_lookupEventTag_NOT       20000000        139
BM_lookupEventFormat        10000000        153

Test: run benchmarks
Bug: 31456426
Change-Id: Ice3ffa0b061d9a6b917718b2d9aedcc2348b7005
2016-11-28 15:15:58 -08:00
Mark Salyzyn
1179eb8048 system/core: replace EVENT_TAG_MAP_FILE with NULL
NULL represents system default.  In the future, NULL could represent
static and dynamic tags, which can come from multiple files based on
implementation details in the liblog library.

Test: gTest logd-unit-tests & liblog-unit-tests
Bug: 31456426
Change-Id: I0e3d296de81ca299ae63d7b83781639ee67ec298
2016-11-21 11:13:02 -08:00
Mark Salyzyn
2ca4f49476 liblog: add private android_log_write_list_buffer()
Allows us to compose an event message for our own in-memory purposes.
Will be used to compose an event message in logd and directly write
it to just the pmsg buffer.  Provide an internal enhanced C++ wrapper
for event handling.

Test: gTest liblog-unit-tests --gtest_filter=liblog.android_log_write_list_buffer
Bug: 31456426
Change-Id: I98246898ba580f9e506baba8af2fd1b26a2a8aae
2016-11-21 09:46:39 -08:00
Mark Salyzyn
472245d962 liblog: move android_log_event_context class to log/log_event_list.h
rename class from android_log_event_context to android_log_event_list

Test: gTest logcat-unit-tests
Bug: 31992412
Bug: 31456426
Change-Id: Ib61cbca7d453837d64959c56b0e11f8c5edbfbdd
2016-11-21 09:46:34 -08:00
Mark Salyzyn
538bc12c08 logcat: add hidden --debug flag and cleanup
Allow us to debug corrupted log messages. Fix liblog to propagate
errors correctly and repair a gtest that failed.

Test: liblog-unit-tests --gtest_filter=liblog.__android_log_bswrite_and_print___max
      logcat -b events --debug -t 50
Bug: 32903864
Change-Id: Ib4eb9f466777cd23b8b54728d36354590d07869a
2016-11-16 15:46:42 -08:00
Mark Salyzyn
1a57ae3a7d liblog: logprint: report truncated event log contents if error
We need to accept that a log tag can contain no payload.  For those
that are corrupted, and to aid debugging, report what we did manage
to interpret.  Report last character as a ! for corruption, and ^
for truncation.  Fix a few Android Coding standard issues.

Test: gTest logcat-unit-tests
Bug: 32903864
Change-Id: Id11bef3a7b6569305c51701dd66c45d2038d6628
2016-11-15 14:46:34 -08:00
Mark Salyzyn
53e9fc7915 liblog: android_closeEventTagMap pointer check
Followup to c/278768 where failure to open tag map can
result in segment violation in android_closeEventTagMap.
Add check for pointer value = -1 to bypass call to close.

Test: gTest liblog-unit-tests, logcat-unit-tests & logd-unit-tests
Bug: 30963384
Bug: 31456426
Change-Id: I20547e55d7e29682fde4538bc1fc6d83b4535d49
2016-11-09 10:16:38 -08:00
Mark Salyzyn
4fd0507b20 liblog: logcat: logprint support -v descriptive
Expand logprint feature to pull out the log tag description
fields, parse them and merge into the logging content.  Add
-v descriptive, -v colour(british, hidden) and -v help. Also
added a unit test for the descriptive format borrowing from
event tags that have been unchanged since 2009.

Had to add -v help because we have too many undocumented
formats and format adverbs.

Test: gTest logcat-unit-tests --gtest_filter=logcat.descriptive
Bug: 31456426
Change-Id: I93a1c003b7a3f4c332544946fdedb7277919cec3
2016-11-04 15:22:52 -07:00
Mark Salyzyn
530711b39e liblog: add android_lookupEventFormat_len
Test: compile
Bug: 31456426
Change-Id: I283fec89431c18af788fa0477a2ab78792221878
2016-11-04 15:22:52 -07:00
Mark Salyzyn
5febc51318 liblog: test report pmsg not configured if ENOMEM return
NB: bionic stdio is broken when providing appropriate errno value(s)
    on failure so libc.__pstore_append will not report pmsg
    misconfigured correctly on android for now.

Test: misconfigured kernel, watch for this message in liblog-unit-tests
Change-Id: Ifb1b550c7d3a3888000459c2f68c392cc23c379f
2016-11-03 11:20:59 -07:00
Mark Salyzyn
a28525293d liblog: remove reference to log/logger.h
Test: compile
Bug: 31992412
Change-Id: Idd52072d0f8c657ac53dc3e6b505a66c47a94357
2016-10-26 14:59:42 -07:00
Mark Salyzyn
aeaaf81c2c liblog: logd: logcat: Split out log/logger.h into public and private.
log/logger.h pieces moved into log/log.h.  Correct for some
minor Android Coding standards.

Test: gTests liblog-unit-tests, logd-unit-tests and logcat-unit-tests
Bug: 19235719
Bug: 26552300
Bug: 31289077
Bug: 31456426
Change-Id: I0a19fd8788eec20a582e72e4c62c04534bdb1b9a
2016-10-24 11:12:49 -07:00
Mark Salyzyn
749a298dfd liblog: restructure log/log.h and android/log.h
We went too far, so this is a partial revert, part deux.

Keep general purpose logging macros in android/log.h for the NDK.
More internal features like Radio, System and Events logging are
moved back to log/log.h.  Correct liblog ndk symbols.  Correct for
some Android Coding standards.

Test: compile
Bug: 31992412
Change-Id: Id3731496fa226e8c170305d0d2a1859e8cf67e14
2016-10-24 11:03:49 -07:00
Treehugger Robot
c741dd4838 Merge "Add license to ndk_headers." 2016-10-20 22:12:40 +00:00
Dan Albert
286b2eaa52 Add license to ndk_headers.
Test: make ndk
Bug: None
Change-Id: Iaba7368b89ec446b5c65c7c127a98914bd949496
2016-10-20 10:18:27 -07:00
Mark Salyzyn
cfd5b080af system/core: preparation to pull back interfaces from android/log.h
Point to log/log.h where necessary, define LOG_TAG where necessary.
Accept that private/android_logger.h is suitable replacement for
log/logger.h and android/log.h.

Correct liblog/README

Effectively a cleanup and controlled select revert of
'system/core: drop or replace log/logger.h' and
'system/core: Replace log/log.h with android/log.h'.

Test: compile
Bug: 30465923
Change-Id: Ic2ad157bad6f5efe2c6af293a73bb753300b17a2
2016-10-20 08:11:39 -07:00
Mark Salyzyn
e455373b57 liblog: Add private interfaces for buffer size properties
Add private function __android_logger_get_buffer_size() to read
properties and compose the default buffer size.  This interface
complements the existing android_looger_get_size() which returns
the logd setting which can differ at runtime.  For use in logd
and dumpstate.  Side effect is we also add the private functions
__android_logger_property_get_bool() and
__android_logger_valid_buffer_size() for reuse in logd.

Test: gTest liblog-unit-test, logd-unit-tests and logcat-unit-tests in
      combination with commit 'logd: Use private interfaces for
      buffer size properties'
Bug: 31750617
Change-Id: Id95cb68f775ef6b427c122e10f6f8291d336d184
2016-10-18 09:48:55 -07:00
Treehugger Robot
915d620359 Merge "liblog: LIBLOG_ABI_PRIVATE __android_log_is_debuggable()" 2016-10-17 21:46:37 +00:00
Treehugger Robot
6da1ea0e48 Merge "liblog: __android_log_pmsg_file_write() cleanup" 2016-10-17 14:16:46 +00:00
Dan Albert
b7c3996f7c Continue using the legacy NDK android/log.h.
system/core/android/log.h needs some work before it can be included in
the NDK. It defines a *lot* of macros that previously were usable
names in NDK sources that used android/log.h. As an example, the
following file defines LOG_TAG as a variable, but the variable name
gets macro replaced if we use the current android/log.h.
4adc1515f8/framework/platform/android/tcuTestLogParserJNI.cpp (41)

For now, we keep a copy of the old NDK android/log.h in
legacy-ndk-includes.

Test: make checkbuild
Bug: http://b/30465923
Change-Id: I8ce942d1ee2f8f0d4c27130802c03992a1b85ec4
2016-10-14 13:12:29 -07:00
Mark Salyzyn
9ea359fce0 liblog: LIBLOG_ABI_PRIVATE __android_log_is_debuggable()
Allow our own libraries to use this privately instead of
running the less efficient get_properties and doing the math.

Test: compile and boot smoke test
Bug: 27566046
Bug: 31456426
Change-Id: I2f677276d27fbcb6af01b600ac1d9891c8938d43
2016-10-14 08:00:41 -07:00
Treehugger Robot
955648a915 Merge "Rely on the platform -std default." 2016-10-14 02:28:38 +00:00
Mark Salyzyn
db8a266aea liblog: __android_log_pmsg_file_write() cleanup
__android_log_pmsg_file_write() will open /dev/pmsg0 if not
already, and will close it if we opened it.

Added atomic access to the android_log_context as insurance.

Fortify and correct pmsg tests.

Test: gTest liblog-unit-tests --gtest_filter=liblog.__android_log_pmsg_file_*
Bug: 31958686
Change-Id: I2cf6f971b6968938f471fda67367efe20dae3004
2016-10-13 21:43:42 +00: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
6debf985aa liblog: adb: move security interfaces to private
Test: Compile & adb functioning
Bug: 19235719
Bug: 26552300
Bug: 31289077
Bug: 31456426
Change-Id: I7ad8963bcca3d8b5c37b547c11d163b652d35556
2016-10-10 15:15:45 +00:00
Mark Salyzyn
37c9451349 system/core: drop or replace log/logger.h
debuggerd does not require log/logger.h, can use android/log.h
In some cases, mark why log/logger.h was required.

Test: Compile and boot smoke test
Bug: 26552300
Bug: 31289077
Bug: 31456426
Change-Id: Ia34987e25a01d81971ec8d785415f732b8376c4f
2016-10-04 09:09:10 -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
9633b919d7 liblog: Move liblog tag from 1005 to 1006
Allow logd to add another "consecutive" log tag

Test: gTest liblog-unit-tests, check for liblog in logcat afterwards
Bug: 31456426
Change-Id: I0c25e038878ec9a0cf368a33a63f8345c68749c3
2016-09-30 12:47:05 -07:00
Mark Salyzyn
6584d0a35a liblog: Replace log/log.h with android/log.h
Move all liblog related content into android/log.h, and make
log/log.h points to android/log.h.

Test: Compile
Bug: 26552300
Bug: 31289077
Change-Id: I858e0ebe047b86f2a8530a99bc9c380d3d58edbb
2016-09-30 12:47:05 -07:00
Mark Salyzyn
a166708d15 liblog: logcat: Replace log/logd.h with log/log.h
Should use log/log.h and in some cases android/log.h instead. Can
not remove file because still in use by partners, so log/logd.h
points to log/log.h.

Test: Compile
Bug: 26552300
Bug: 31289077
Change-Id: I3580d46154617abb7231027a44f4ab9ee023febf
2016-09-30 12:47:05 -07:00
Mark Salyzyn
004cd3c55d liblog: logd: logcat: deprecate log/log_read.h
Always used in combination with log/logger.h except in log_time.cpp,
and not used externally.  As a result liblog has to support stl, a
small price to pay since goal is to convert liblog to C++ internally.

Test: compile
Bug: 31456426
Bug: 26552300
Bug: 31289077
Change-Id: I72828ec807d0a2c8e40bbdebd7a69f147a7ca5a9
2016-09-30 12:47:05 -07:00
Treehugger Robot
dfd30c4a16 Merge "liblog: fix errno issues with event tag map" 2016-09-28 18:07:09 +00:00
Treehugger Robot
1dfa8112ce Merge "liblog: free event tag map in __android_log_close()" 2016-09-28 14:58:39 +00:00
Mark Salyzyn
70a83dc7b3 liblog: fix errno issues with event tag map
Cleanup.

Save the errno for the calls that fail, and reinstate them for
return. Drop fprintf stutter, one succinct line. Solve a memory
leak in close.  Change android_lookupEventTag() to use an
unsigned int so that we can use the full range of uint32_t tags.

Make sure this file compiles clean in C++.

Test: gTest liblog-unit-tests
Bug: 30963384
Bug: 31456426
Change-Id: I6a5efa6fb7e991431caba75ef0971e111968f6bf
2016-09-26 09:23:55 -07:00
Mark Salyzyn
ba1a798fd8 liblog: free event tag map in __android_log_close()
There is no leak since a reference always remained and could get
reused.  It just makes sense to also close the event tag map as well
if logging is closed.  If we close we also have to fix a tagArray
leak in android_closeEventTagMap().

NB: __android_log_close() already makes an assumption that another
thread is not logging at the same time, which is true in all callers
at this time.  There are some partial mitigation strategies if
__android_log_close() is called asynchronously, but not completely
solved at the cost of a lock for every logging call.

Test: gTest liblog-unit-tests
Bug: 30963384
Bug: 31456426
Change-Id: Ib76ad9302dba4d3f35250213f4dfef22498af238
2016-09-26 08:21:13 -07:00
Dan Albert
ddce8c70c4 Migrate liblog to ndk_library.
Test: make native
Bug: http://b/30465923
Change-Id: I3db7ede817a57b3505c0556ea28f08b9e8331e1a
2016-09-23 15:43:23 -07:00
Narayan Kamath
b2f019ec1e liblog: don't bother keeping FD around once it's mapped.
Posix and linux explicitly state that this isn't necessary.

bug: 30963384
Change-Id: I2cc16ded04f0ebc909dc3027e02867594fb49d05
2016-09-01 19:31:08 +01:00
Mark Salyzyn
6322efe522 Merge "liblog: add __android_log_close()"
am: 812d1c7ea2

Change-Id: I2ba5ed22e78564a864bab6b550b6d2bd2609a629
2016-08-24 16:05:05 +00:00
Mark Salyzyn
2d562c9dce Merge "logger: validate hdr_size field in logger entry"
am: fcf7ab8b1b

Change-Id: Ic88fe616256ab4949040771d3bed1dfb823ab981
2016-08-24 16:05:04 +00:00
Treehugger Robot
812d1c7ea2 Merge "liblog: add __android_log_close()" 2016-08-24 15:58:48 +00:00
Mark Salyzyn
df7a4c6bae liblog: add __android_log_close()
Bug: 30963384
Change-Id: I901e6ac2cc3c601bbecc2d64e00a98e2ab448210
2016-08-23 15:25:03 -07:00
Mark Salyzyn
305374cf0f logger: validate hdr_size field in logger entry
- check hdr_size to make sure it is in the expected range
  from sizeof entry_v1 to entry (entry_v4).
- alter msg() method to report NULL on invalid hdr_size
- alter all users of msg() method.

Bug: 30947841
Change-Id: I9bc1740d7aa9f37df5be966c18de1fb9de63d5dd
2016-08-23 14:51:50 -07:00
Elliott Hughes
33f8c194f9 Merge "liblog: use SOCK_NONBLOCK directly."
am: fca43d3ec5

Change-Id: I4d959d9091adbf8bf2d7b68653a3c6064893a65a
2016-08-23 01:20:36 +00:00
Elliott Hughes
5ba3003467 liblog: use SOCK_NONBLOCK directly.
No need to have a race, even if it doesn't matter.

Change-Id: Ia79f2633643bc63618de0fd85953b3226415484f
2016-08-22 16:19:58 -07:00
Chih-Hung Hsieh
89cc78b77f Merge \"Fix google-explicit-constructor warnings in system/core.\"
am: 6dc68cb5f9

Change-Id: I5a010465364b6e14423b19e8c0f9cffa58ee3152
2016-07-29 17:01:17 +00:00
Chih-Hung Hsieh
034c475931 Fix google-explicit-constructor warnings in system/core.
* Declare explicit conversion constructors.
* Add NOLINT for implicit conversion constructors.
* Fix also some misaligned indendations.

Bug: 28341362
Change-Id: Idf911f35923b408d92285cc1a053f382ba08c63e
Test: build with clang-tidy
2016-07-26 11:26:01 -07:00
Mark Salyzyn
0d9ce37382 Merge \"liblog: pmsg_read add validity checking for prio\"
am: 73cc6edf0e

Change-Id: Iba5e7b7c2325e127eb9f040c8ab86ba24efd5b20
2016-07-15 19:04:48 +00:00
Mark Salyzyn
56da612ec4 Merge \"liblog: reset pid and uid cache after a vfork()\"
am: d4f6324176

Change-Id: I3b59f56b2b5f399b079ab9439600dc3a72c669a6
2016-07-14 15:55:55 +00:00
Mark Salyzyn
3d8afe9b01 liblog: pmsg_read add validity checking for prio
Improve pmsg data corruption detection.

Bug: 30085794
Change-Id: I215da4fff07797b8c0a3462f850bafb090adfc68
2016-07-14 07:34:53 -07:00
Mark Salyzyn
ec4f5c776d liblog: reset pid and uid cache after a vfork()
Bionic getuid() and getpid() calls cache to reduce the need to
perform a syscall, and also reset their own cache after a vfork().
No more need for liblog to be performing this flawed cache operation.

Bug: 30085794
Change-Id: I70feed8bff0ddd919c2885a348ba67b14ddc0e0d
2016-07-14 07:34:53 -07:00
Colin Cross
68bfe51348 Merge \"Rename Android.soong.mk to Android.mk\"
am: b07df4dd3f

Change-Id: I9d9a232539b9991ab935e143140a3b77d896ebc7
2016-07-12 16:20:21 +00:00
Colin Cross
b39e4025ae Rename Android.soong.mk to Android.mk
Soong is always on now, so we don't have to distinguish between
makefiles that should be ignored because Soong is handling them with an
Android.bp file, and makefiles that are still needed with Soong.  All
obsolete Android.mk files have been removed, rename all Android.soong.mk
files to Android.mk.

Change-Id: Iabbddcbfb2c837cfd4556241b570474452cc5d4d
2016-07-11 16:56:51 -07:00
Elliott Hughes
016ad16100 Merge "Use alignas for alignment." am: bb1e7977fb
am: 689b998ab2

* commit '689b998ab26f2a04e079312aee2f8e32fbe7f26c':
  Use alignas for alignment.

Change-Id: Ic81a88146df0f407849800c63d2edb7404efe0ac
2016-06-07 15:55:12 +00:00
Elliott Hughes
5f4a946c09 Use alignas for alignment.
Change-Id: I427c407a188682a360c74b2bd5a44dd62551ea66
2016-06-06 19:59:45 -07:00
Colin Cross
bfcb1b779f Merge "Remove deprecated Android.mk files" am: ce5b4fee23
am: 5806404e4d

* commit '5806404e4d693699fef2e710fd8ad836815f8852':
  Remove deprecated Android.mk files

Change-Id: I8a87996377bd53a16d330c0df9bfff84c92e10a2
2016-06-02 16:41:27 +00:00
Colin Cross
ce5b4fee23 Merge "Remove deprecated Android.mk files" 2016-06-02 16:31:42 +00:00
Dan Willemsen
9ce49be616 Merge "Fix liblog logtags" am: 59e6afc617
am: 6b5255722e

* commit '6b5255722e7497fc7c854cf1ae9e51322bc7ceae':
  Fix liblog logtags

Change-Id: I6225d8fd338b9ffc5b4406d5dbb92e2816bcaaad
2016-06-01 23:47:45 +00:00
Dan Willemsen
d119101807 Fix liblog logtags
This was broken because we didn't have logtags support in Soong.

Bug: 28989759
Change-Id: I8370a73cf14703b86aafd85e7ea74fc570c3ff0f
2016-06-01 15:32:35 -07:00
Colin Cross
b50216ed86 Remove deprecated Android.mk files
These directories all have Android.bp files that are always used now,
delete the Android.mk files.

Change-Id: I8b0c89072a660c4a7a30fcefc76a7bbe247df977
2016-05-26 16:58:28 -07:00
Chih-hung Hsieh
d581f2c47d Merge "Fix misc-macro-parentheses warnings in liblog." am: 2bd428e1f9
am: 1cff850bb3

* commit '1cff850bb383d75c395d4627086b6baa63639a18':
  Fix misc-macro-parentheses warnings in liblog.

Change-Id: I318ab4909ba59e7181b9ec9c3e73f58ea8b0c0d8
2016-05-19 01:02:34 +00:00
Chih-hung Hsieh
2bd428e1f9 Merge "Fix misc-macro-parentheses warnings in liblog." 2016-05-19 00:48:44 +00:00
Chih-Hung Hsieh
f0f94fe49b Fix misc-macro-parentheses warnings in liblog.
Bug: 28705665
Change-Id: Ib272a83cb93b09d986c19a40e23a2679b9e17558
2016-05-18 15:48:50 -07:00
Mark Salyzyn
5d32a9821d Merge "liblog: log reader validate headers" am: 0321476fe2
am: 0a7dec432c

* commit '0a7dec432ce3a72edcf5bf092871296225cd814b':
  liblog: log reader validate headers

Change-Id: Ic035cf9d3e765e95799a25c1441d5fa88ab3fda7
2016-05-18 14:27:54 +00:00
Mark Salyzyn
8fd1faa596 liblog: log reader validate headers
Ensure len and hdr_size fields are valid and match the return value.
Truncate or zero content as necessary, but do not drop the message.

Bug: 28610769
Change-Id: I10785fa5b03aa3da7d07b368188e3f7c36a84b4f
2016-05-17 13:54:42 -07:00
Mark Salyzyn
5d76be85a4 Merge "liblog: sleep 20ms before critical property_set" am: 1d560ff24a
am: 03ac8fe0be

* commit '03ac8fe0be882b09d7faba4d5f96e536a94198ab':
  liblog: sleep 20ms before critical property_set

Change-Id: I91d3262a478f83556851881208fb1f83de62f189
2016-05-12 16:48:21 +00:00
Mark Salyzyn
5cceee6404 liblog: sleep 20ms before critical property_set
Going too fast can result in the property not being set
and causing an extreme corner case failure being reported
and blamed on is_loggable functionality.

Bug: 25792367
Change-Id: Idda6f67d655d8a84d2809daf695394d5293e7431
2016-05-12 15:58:57 +00:00
Rubin Xu
7dcdd52cf6 Merge "Return correct length from pmsgRead()" am: fc2a8b2bd6
am: a76e171bf3

* commit 'a76e171bf351e3d26b3eb596188b6c9b2fcab3f4':
  Return correct length from pmsgRead()

Change-Id: I616c3c889e99292454b0a7c33f999a56ada2c939
2016-05-09 15:36:23 +00:00
Rubin Xu
9c2f803e9d Return correct length from pmsgRead()
Bug: 28610769
Change-Id: I38cac786ca43ef8d9530f4e2e5a0bdd4cc3bccef
2016-05-05 16:50:44 +01:00
Mark Salyzyn
9fd5df3816 Merge "liblog: O_CLOEXEC flag on opens" am: fc80b22752
am: a0afba8a87

* commit 'a0afba8a8721319233e788cf723e979d3f0781e2':
  liblog: O_CLOEXEC flag on opens

Change-Id: I4c018e556b645ab58477cc537d65489d904fa78b
2016-04-29 15:44:52 +00:00
Mark Salyzyn
a3692040fa Merge "liblog: logcat -g readable size wrong" am: 7f18790bd7
am: 7a5b8c7f53

* commit '7a5b8c7f53ca79f99e74655b2f68356c7184532a':
  liblog: logcat -g readable size wrong

Change-Id: I1461a41dc0b1bff3394caa5a107d7ad80cc7d068
2016-04-29 14:53:23 +00:00
Mark Salyzyn
78786da116 liblog: O_CLOEXEC flag on opens
Bug: 28455828
Change-Id: Ic00101a6192aab7271cb0c3461e249a77d7f29ed
2016-04-29 07:52:36 -07:00
Mark Salyzyn
ccfb244b36 liblog: logcat -g readable size wrong
Bug: 28451229
Change-Id: I4bbc2bed933d69416c23cc7af617be3fb55d0b62
2016-04-29 07:39:51 -07:00