logd/logcat use more symbols than the rest of the platform, so let's
statically link them for now while we understand the API that the
platform overall uses.
Test: build
Change-Id: I21ae1bd3ff9b310f099612fbe790f769712661df
Add FALLTHROUGH_INTENDED for clang compiler.
Bug: 112564944
Test: build with global -Wimplicit-fallthrough.
Change-Id: I40f8bbf94e207c9dd90921e9b762ba51abab5777
The units should be byte instead of bit and multiplier are kibibyte
mebibyte gibibyte respectively.
Bug: 114062206
Test: Build and logcat -g
Test: ./logcat-unit-tests
Change-Id: I995faa9a340bb63f48d117a1b8590e5d74ac1bba
Parsing logs isn't an API, and even if you want to do that, popen(3)
already exists.
Bug: N/A
Test: ran tests
Change-Id: I53c40be49141483da0a844a7af47da0b38d29781
This new event is logged by ART when hidden API accesses are detected.
Test: m
Test: $ adb lolcat -b events
Bug: 64382372
Bug: 77517571
Merged-In: I5ebb1424d83686dade0d34b118944b0c4c0c7bb1
Change-Id: I5ebb1424d83686dade0d34b118944b0c4c0c7bb1
(cherry picked from commit 8ec1c7ea7c)
This will prevent services from reaching out to logd if this tag is
present in the event log.
Bug: 64734187
Test: tree-hugger
Change-Id: If117e1c0cfa678af4190913f0ca87f4e92c54373
This change ensures that the logcatd binary is properly
included into builds which contain logpersist. logcatd
is required for logpersist to actually work.
Bug: 69171565
Test: make checkbuild
Test: verified that logcatd binary is present in build
Change-Id: I78161998763a4694ba88af43113fef39a5fbd8c8
* 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
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
Near last resort kill logcatd, set /proc/self/oom_score_adj to -600.
Can kill to keep system_server, telephony and bluetooth.
Test: manual, start logpersist, runs
Bug: 62147352
Change-Id: I3723761bf1d2b79ce6a9557d2e78f91cc5497e96
Inject a message for event_tag_filter and bucket tests. The former
registered an occasional failure.
Switch order of EXPECT checks so that constant is on the right so
that error reports make more sense.
Test: gTest logcat-unit-tests --gtest_filter=*.event_tag_filter
Test: gTest logcat-unit-tests
Bug: 37791296
Change-Id: Ic2536e6e4c95e3a913ad0ea4c22219aa3c5c01eb
Add more detail about logcat.blocking_clear test failure
Test: gTest logcat-unit-test --gtest_filter=logcat.blocking_clear
Bug: 37483775
Change-Id: I6555c13593781a1278d9106e66c2dec6009a2215
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
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
Add an internal rest() function to set the standard for how long we
should wait for a log message to land end to end into the logs. Add
a retry on -EBUSY for all descriptive tests along with a rest() after
log injection so the tests can try to survive heavy Denial Of Service
(DOS) loads. Some of the resting was done at a coarse 1 second, when
200ms will do just fine.
Fix a few pesky issues surrounding test reliability and correctness:
- stdint.h include missing.
- missing a logcat_executable, means logcatd.descriptive testing was
testing logcat instead.
- count of interfering tests is 3 now: logcat, liblogcat and logcatd, if
they all run in the same PID, we have to not fail.
- Added a missed opportunity to add uniqueness to logcat.descriptive sync
test.
Test: gTest logcat-unit-tests
Bug: 31456426
Change-Id: Iaf2bee97878957f654613bb2e78e32379bb8d1b7
logcatd is the same as logcat, except that the -L flag, if supplied,
runs once, then the command re-runs itself without the -L flag with
the same argument set. By introducing a logcatd daemon executable
we can solve the problem of the longish reads from pstore that
sometimes occur when the system is excessively busy, starving this
background cgroup daemon as we absorb the delay in a backgrounded
init "service", rather than in a forgrounded init "exec". This would
not have been efficiently possible without the introduction of
liblogcat.
There are no doubt many flags that make no sense to run twice with,
and without, the -L flag. In the general sense we expect the caller
to perform the correct set of operations and not pick these nonsense
operations. logcatd is only supplied on engineering and debug builds
for logpersist, and is only an automated aid to triage.
Test: gTest logcat-unit-tests
Test: manual confirm logpersist functions as expected, required reboot
Bug: 28788401
Bug: 30041146
Bug: 30612424
Bug: 35326290
Change-Id: I53ba31970749daf37eef42636f039f485932416f
If -h or --help argument was supplied, logcat would report the help
message but also return an error. Officially add -h and --help as
recognized flags, report all help with a (zero) success error code.
Adding this, and the associated test, was split off as a stepping
stone to resolving an issue with logcat -L or --last flag operations.
Test: gTest logcat-unit-tests --gtest_filter=*.help
Bug: 28788401
Bug: 30041146
Bug: 30612424
Bug: 35326290
Change-Id: I948e7fa4e92bd23f52717758ffd96bbd068c53d4
Measure the cost of using a known test event log tag from
system/core/logcat/event.logtags:
42 answer (to life the universe etc|3)
Test: liblog_benchmarks BM_log_event_overhead_42
Bug: 36683634
Change-Id: Ibd4be82bebfcedd381c84e8078cf6d05a636aa98
For logd daemon, heavy reader stress. For system popen fork and
execute of logcat measure baseline against liblogcat. For liblogcat
local concurrent thread, locking, argument parsing and context scaling
for popen-style pair of android_logcat_run_command_thread* functions.
NB: 1000 logcat executables ran, but did not scale well on time
blocked for more than a minute. With 343 contexts of
android_logcat_run_command_thread ran out of local resources
to even return a file descriptor, and the per-context event tag
mappings coincidentally ran out at 340 when threads ran, although
that path was consistently 15% faster than the popen test.
Test: gtest logcat-unit-tests --gtest_filter=*.End_to_End_multitude
Bug: 35326290
Change-Id: I0e1a5d4f8ffbd77fa8db13d53f4d328973731895
Upon opening, qemu pipe (a.k.a. goldfish pipe) requires a purpose
string so that emulator can route the content to the right channel
on the host.
This CL will ask emulator to send the content to pipe based 'logcat'
service on the host.
Change-Id: Icc71f81d5b95b64ea315fe10da82ff704416e449
Was leaking log_device_t in command path. Cleanup leak in command
path and add thorough clean up on destroy for insurance.
Start grouping related like-type variables in the context structure
for more effective layout.
Test: gTest logcat-unit-tests
Bug: 35326290
Change-Id: Ibfbddec2d0e1bce24b87b035d67726cac1395574
Resolve one of the threading issues by creating a private C++ified
copy of getopt_long_r that started out its life as the bionic
getopt_long, but is reentrant. Adds a new state context for the
stderr stream called optstderr. Utilize this new function in logcat.
Control opterr and optstderr to match liblogcat expectations. Correct
and fortify const.
Alternative would be to lock around _all_ getopt callers. This has
the advantage of requiring _no_ locks that could get in the way of
using liblogcat in a signal handler. The log reader interface does
run the risk of incurring locks and heap allocations though, so there
is more work to be done for that final goal.
Test: gTest logcat-unit-tests
Bug: 35326290
Change-Id: Ibb1b374c55d357d5d7fa5ad00bfaf07ae0bc4ba5
Deal with yet another reentrancy issue with strtok() and do not
treat optarg as fungible data, allocate a temporary copy. Add
support in the -v flag and environmental variable ANDROID_PRINTF_LOG
for a comma-separated list of format and format modifiers.
Test: manual + gTest logcat-unit-tests
Bug: 35326290
Change-Id: I073e5676d59ba41bfd36df86942342766ef730f1
- Replace all NULL, macro defined to 0, with nullptr. nullptr is a
keyword of type nullptr_t, with a value of (nullptr_t)0, a pointer
type of sizeof(void*) that can not confusingly promote to an int.
- Replace all boolean evaluations of values against 0, NULL, and
nullptr with direct, ! or !! as appropriate.
- Note that thread_stopped should be semaphore, defer that to
a non-code-quality improvement patch.
- Check for null context in android_logcat_destroy.
- Run clang-format to realign format with setting.
Test: compile and gTest logcat-unit-tests
Bug: 35326290
Change-Id: Iaf729cd7899c6cece78431536ed325604f0e353f
Existing dummy benchmark converted to a single-pass benchmark.
Add support for ">[filename]" interpretation in liblogcat, helpful to
provide more consistent benchmark results when sending output to
/dev/null.
NB: results are not consistent as there is a roundtrip to logd
service, but they are indicative of better performance for
liblogcat.
Benchmark Time CPU Iterations
----------------------------------------------------------------------
BM_logcat_stat_popen_libc 35221677 ns 603314 ns 100
BM_logcat_stat_popen_liblogcat 15871805 ns 579398 ns 1287
BM_logcat_stat_system_libc 39037825 ns 319882 ns 100
BM_logcat_stat_system_liblogcat 9896755 ns 762610 ns 1310
BM_logcat_dump_popen_libc 776206254 ns 131448772 ns 5
BM_logcat_dump_popen_liblogcat 610674905 ns 118709624 ns 6
BM_logcat_dump_system_libc 512191254 ns 388724 ns 10
BM_logcat_dump_system_liblogcat 443897570 ns 377215696 ns 2
Test: logcat-benchmarks --benchmark_filter='BM_logcat_stat*|BM_logcat_dump*'
Bug: 35326290
Change-Id: Ie94900a3070487f45742f6c0789b5b3cf036df34
Provide minimal redirection functionality, adding stdout redirection
to the existing stderr redirection parsing.
- stderr and stdout redirection do _not_ support append, will treat
like write only.
- stderr redirection does _not_ support filename. Only 2>&1 to
join stderr and stdout and 2>/dev/null to drop content on floor.
- stdout redirection supports filename only.
- stderr 2>&1 redirection must be last for shell compatibility.
- preserve 2>&1 through file rotation (bugfix)
Test: logcat-benchmarks --benchmark_filter='BM_logcat_popen*|BM_logcat_system*'
Bug: 35326290
Change-Id: Id36b59358167f21381bd1dbf0bd7a7e10e2a2ed9
The -Q option is used in emulator and it fails to redirect the
output of logcat to the desired file.
This CL fixes that problem.
There is no gTest because of /proc/cmdline sniffing for this option.
manually tested on /dev/qemu_pipe inside emulator
Test: manual
Bug: 35326290
Change-Id: I282da685e90450aadb2a989a0517dc3b1bb6634d
Supply a wrapper to the logcat API that provides some analogous
functionality to popen and system libc calls with some bits of
KISS shell-like parsing for environment, quotes and error
redirection handling.
Test: gTest logcat-unit-tests
Bug: 35326290
Change-Id: I9494ce71267ad2b2bec7fcccfc7d4beddae9aea6