Commit graph

309 commits

Author SHA1 Message Date
Jaegeuk Kim
5327d931ac logcatd: fallocate and fadvise to logcat files
1. Pinning and fallocating blocks can avoid filesystem fragmentation.
2. Dropping caches can avoid memory pressure.
3. Use 2MB files

Bug: 136483670
Bug: 137180754
Change-Id: I0827bd903a677cbcbf3688983e847301cd541cdd
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2019-09-04 22:45:48 +00:00
Elliott Hughes
addd852165 logcat: switch to <regex>.
This was the only user of the google3 additions to external/pcre.

Test: adb logcat --grep camera
Change-Id: Iaa9dae38d30f60470f6a65b0a0fdd93e01abfc99
2019-08-08 08:53:59 -07:00
Steven Moreland
b0e867a1e6 logcat: error on multiple PID argument
Since they are dropped.

Bug: N/A
Test: manual try w/ 1 and 2 --pid arguments
Change-Id: I5945c12dc080a8c046b8071106f7d87ecb2b018c
2019-08-02 10:14:37 -07:00
Tian Baofeng
8415a5c45e Logcatd: remove some extra logic
There will be some unnecessary error logs caused
by extra logic was reported by init when some properties
were set default values. This patch remove these logic
codes to remove these avoidable error logs.

Bug: 137567691
Test: Can use logcat -r -n with configures

Change-Id: I9b8fa2025bcbef5d39438a8243f9ff5dc0a645df
Signed-off-by: Tian, Baofeng <baofeng.tian@intel.com>
Signed-off-by: Duan, YayongX <yayongx.duan@intel.com>
2019-07-25 06:27:36 +00:00
Steven Moreland
fe535f5e68 logcat: add 'kernel' to defaults
I'm asked at least once a week or more why a new service isn't starting.
Usually, the reason is that "File ... has incorrect label or no domain
transition from ... to another SELinux domain defined. ..." from init.
Even in permissive mode, this is required.

Bug: 63014404
Test: boot, check logcat
Change-Id: I7244a56fc46f84e9592e1eccf2d23461691965b3
2019-07-08 15:59:25 -07:00
Tian, Baofeng
00813a585a Logcatd: Add new properties control logcat file size and file count.
Logcatd has capability to output logs to filesystem with certain size
and certain file count, however file size is not configurable, fixed
as 1024 kbytes, file count is configurable, but original property
name didn't match the logcat parameter well.
This patch add interface rotate_kbytes and count into logcatd.rc.
rotate_kbytes used to control each logcat file size.
count is another alias for logd.logpersistd.size to control file number.

Bug: 133362078
Test: Can use logcat -r -n with configures

Change-Id: I9954c9c125a4ab4e49310986f81c734bf8ee96b3
Signed-off-by: Tian, Baofeng <baofeng.tian@intel.com>
Signed-off-by: Duan, YayongX <yayongx.duan@intel.com>
2019-05-24 07:23:22 +00:00
Treehugger Robot
29d2b05194 Merge "Logtags for com.android.server.policy" 2019-03-27 14:41:12 +00:00
Siarhei Vishniakou
6bd71b979c Logtags for com.android.server.policy
The definitions for event log tags are currently in system/core. Instead
of keeping them there, reserve a range for these event tags and move
them into com.android.server.policy.

Currently it is only used by PhoneWindowManager.

Bug: 128933363
Test: build only
Change-Id: Ida903499e9af8650299e3965787b4ac966b66915
Merged-In: Ida903499e9af8650299e3965787b4ac966b66915
2019-03-26 12:36:53 -07:00
Josh Gao
c6ad69d1d4 liblog: don't return 0xFFFFFFFF as an invalid log id.
There are a bunch of branches that check "id >= LOG_ID_MAX", but because
C++ hates you, this does a promotion to signed int despite the
fact that both sides of the comparison are the same enum with an
underlying type of unsigned int. (C++17 §7.6.3)

Return LOG_ID_MAX instead of a value that gets promoted to signed -1, to
avoid this.

Bug: http://b/129272512
Test: /data/nativetest64/logcat-unit-tests/logcat-unit-tests
Change-Id: I4b3ee662d76d5cc80d9a9625d17f7e5b5980de41
2019-03-25 16:41:39 -07:00
Suren Baghdasaryan
9491078300 DO NOT MERGE: Revert "Revert "Add dependencies on libprocessgroup for sched_policy users""
This reverts commit 1bef8c550c.

Reason for revert: AOSP is fixed with new vendor image

Change-Id: Ib341ac80e2f88c13a7815a490ea2d9422ebdf55f
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-01-25 16:49:18 +00:00
Suren Baghdasaryan
1bef8c550c DO NOT MERGE: Revert "Add dependencies on libprocessgroup for sched_policy users"
This reverts commit 02843339f9.

Reason for revert: Broke AOSP

Change-Id: I62f91c0adf440b5da0a145862b04dd27a7016faf
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-01-23 20:43:28 -08:00
Suren Baghdasaryan
02843339f9 Add dependencies on libprocessgroup for sched_policy users
After moving sched_policy functions into libprocessgroup its users require
additional dependency and inclusion of sched_policy_ctrl.h header.

Exempt-From-Owner-Approval: janitorial

Bug: 111307099
Test: builds, boots

Merged-In: Icc052080e1bce46ce06f7264446950cab0490a95
Change-Id: Icc052080e1bce46ce06f7264446950cab0490a95
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-01-22 18:19:45 +00:00
Tom Cherry
9e12433760 Statically link liblog to logd/logcat and their tests
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
2019-01-17 11:37:22 -08:00
Elliott Hughes
da94ca4d28 Stop using __STRING unnecessarily.
Bug: N/A
Test: builds
Change-Id: I8748abf834ec3a808eb2fc6ee0f288562fb0b4ea
2018-11-14 14:27:22 -08:00
Dan Willemsen
3e963f9df7 Convert more modules to Android.bp
Test: cd system/core; mma
Test: check for mkbootfs in build artifacts
Test: out/host/linux-x86/nativetest64/libcrypto_utils_test/libcrypto_utils_test
Test: out/host/linux-x86/nativetest64/libnativebridge-tests/*_test
Change-Id: I71141bd85f052d5d86763a8b79b219cc4c46aafb
2018-10-31 21:53:37 -07:00
Tom Cherry
d2c7613fc0 logcat: include 'kernel' and 'security' buffers in logcat --help
Bug: 115798272
Test: documentation looks right
Change-Id: I35dcc51e6779e7382843d4d92fb6182ddf0e0202
2018-10-22 11:16:07 -07:00
Chih-Hung Hsieh
502f4864d6 Suppress implicit-fallthrough warnings.
Add FALLTHROUGH_INTENDED for clang compiler.

Bug: 112564944
Test: build with global -Wimplicit-fallthrough.
Change-Id: I40f8bbf94e207c9dd90921e9b762ba51abab5777
2018-09-17 16:50:11 +00:00
Greg Kaiser
5b0bf8ae55 logcat: Fix buffer size
We need an additional byte for the NUL terminator in two
buffers.

Test: TreeHugger
Change-Id: I891f64fb29170c803da65743d6b911b69ce6e4f4
2018-09-06 06:20:09 -07:00
Wei Wang
c27d481695 logcat: fix print of logcat -g
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
2018-09-05 14:11:18 -07:00
Eric Laurent
ab2ced57f1 add event log range for audioserver
Test: make.
Change-Id: I32a198b075a4c07f000ae311188ea61f71a69dab
2018-07-10 14:21:38 -07:00
Elliott Hughes
66680bd8a8 logcat: tidy "logcat.h".
Bug: N/A
Test: builds
Change-Id: Ibe434221060b2e1fb0973d1c840d943ad3a4ee8d
2018-06-18 10:16:46 -07:00
Elliott Hughes
61b580e15e Remove liblogcat.
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
2018-06-15 15:32:52 -07:00
Mathew Inwood
e07d90dd9d Add event log tag for hidden API access logging.
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)
2018-05-08 10:26:36 +01:00
Tom Cherry
dcc4b2bb4a Add a dummy entry for the 70220 event tag
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
2018-04-18 16:25:56 -07:00
Elliott Hughes
dc699a269f bpfmt.
Bug: N/A
Test: builds
Change-Id: I89ad00e1c4c7e0767bc80a7ac7935a4d55e090ac
2018-02-16 17:58:14 -08: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
c6eafeb5bf Register an event logtag for stats logs.
Bug: 69323063
Test: manual
Change-Id: I244aa15c74ad70ba228c2128a3cdc829537ce5e2
2017-11-14 16:24:13 -08: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
Calvin On
24e7a25836 Fix logcatd dependency in logpersist.
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
2017-11-13 12:22:47 -08:00
Brendan Jackman
a5141130f3 logcat: Note in help that regexps are Perl-compatible
The expressions accepted by the '-e'/'--grep' command line option are
PCRE:

https://android.googlesource.com/platform/system/core/+/master/logcat/logcat.cpp#1018

Say so in the help string.

Change-Id: I7f6af130d5e39570bb49310a928f5d495e5b269b
2017-10-31 12:44:54 +00:00
Josh Gao
03d055d6ff liblogcat: avoid double close.
Bug: http://b/67960705
Test: mma
Change-Id: I0b9015f0b4e64631a3476966decce3b6210bb801
2017-10-19 13:19:19 -07:00
Elliott Hughes
a0f73f9bff <stdbool.h> not necessary in C++.
Bug: N/A
Test: builds
Change-Id: I1f32b202e353414e74ace87a7d5b495b5deb5f99
Merged-In: I1f32b202e353414e74ace87a7d5b495b5deb5f99
2017-10-17 16:21:33 +00:00
Dan Willemsen
e1cf0f5f73 Don't try to strip a shell script
Test: lunch aosp_mips-eng; mmma system/core/logcat
Change-Id: I4e641701522fb5b042d52e460d40b42ed12f22c8
2017-08-09 20:20:48 -07:00
Mark Salyzyn
507f69f80e logcat: transition to Android.bp
Switch logcat, logcatd and liblogcat to use Android.bp.

Test: compile
Change-Id: I01c0d8cbc6a713ad5b4b413677574e3c6463afcb
2017-08-09 13:30:03 -07:00
Mark Salyzyn
210e43c354 logcat: fix error propagation.
Fix some _serious_ error propagation issues discovered with
additional warning flags (-Wextra).

Test: compile
Change-Id: I5148550092e4ecb6cafba91229c350c516e7e244
2017-08-08 15:49:21 -07: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
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
Luca Stefani
0870514d29 logcat: Add missing newline to read failure
Change-Id: I468b3bd00f1effa43eb139a3c514ba042ae3dff7
2017-07-08 17:51:27 +02:00
Mark Salyzyn
30ea96e14e logcat: logcatd: make logcatd killable
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
2017-05-31 11:27:22 -07:00
Mark Salyzyn
c74f8d91a5 logcat: -v thread help missing
KISS documentation for -v thread added

Test: manual logcat -v --help
Bug: 37030280
Change-Id: If1ad9d3862a68dfe570b524c36efd4fae5b03262
2017-05-15 13:41:16 -07:00
Mark Salyzyn
24b79ce2bc logcat: test: inject for *.event_tag_filter
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
2017-05-11 12:16:06 -07:00
Mark Salyzyn
0a1424e196 logcat: test: also check "failed to clear" in blocking_clear
Add more detail about logcat.blocking_clear test failure

Test: gTest logcat-unit-test --gtest_filter=logcat.blocking_clear
Bug: 37483775
Change-Id: I6555c13593781a1278d9106e66c2dec6009a2215
2017-04-20 08:24:38 -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
46186a7238 logcat: test: standardize rest() to let logs land when injecting
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
2017-04-14 12:50:59 -07:00
Mark Salyzyn
a073c39616 logcatd: introduce logcatd executable
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
2017-04-04 08:01:50 -07:00
Mark Salyzyn
e74e51ded7 logcat: Add -h and --help flags
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
2017-04-04 08:01:11 -07:00
Mark Salyzyn
fe8c96d152 liblog: benchmark add BM_log_event_overhead_42 for a well known tag
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
2017-03-31 13:25:36 -07:00
Mark Salyzyn
fbc0fe429b logcat: test: run 256 simultaneous logcats
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
2017-03-27 11:57:53 -07:00