Commit graph

241 commits

Author SHA1 Message Date
Mark Salyzyn
15e585853f logcat: test: inject messages if necessary for tail test requirements
For the gTests logcat.tz, logcat.tail_3, logcat.tail_10,
logcat.tail_100, logcat.tail_1000 and logcat.tail_time tests inject
messages if we come up short should the background logging not be
sufficient to feed the test requirements.  Test frames run the
tests right after reboot requiring injection.  Will have radio
silence, so we also add kernel logs if available to help add to the
background logging activity level.

We also will inject a radio message for logcat.buckets so that test
can survive no radio content.

Test: set device to airplane mode (to stress this problem) then:
      adb logcat -b all -c && adb shell su root \
          /data/nativetest/logcat-unit-tests/logcat-unit-tests \
          --gtest_filter=logcat.tail_1000 (or others in this set)
Bug: 34454772
Change-Id: I5ec246552f3ab1fc9c5864ed69d63b851fdf538d
2017-01-23 13:33:02 -08:00
Mark Salyzyn
26a1facfbf logcat: do not report security buffer errors
Do not report security buffer errors if not specifically
named in the buffer list.

Test: gTest logcat-unit-test --gtest_filter=logcat.security
Bug: 34511645
Change-Id: I028d51abad0329fcf42e467b135d035b06c1d2e3
2017-01-20 15:30:34 -08:00
Mark Salyzyn
a46326a51c logcat: unit test produces log stutter
logd now counts multiple identical messages, causing messages to be
held back.  Stop doing that in the tests.  When that filter appeared,
the logcat-unit-tests went from 23 seconds to a couple of minutes of
runtime breakign the automated testing.

Test: gTest logcat-unit-tests total time less than 1 minute.
Bug: 33845198
Bug: 33535908
Change-Id: I6145bae89b6d5e5024ef4f8fe66440c9ae53f7c6
2016-12-27 19:13:00 +00:00
Oleksiy Avramchenko
8a96f5e4a7 Merge "logcat: Fix --last usage option typo"
am: 95a53b8b7a

Change-Id: Ic18c2cec4c72cd97353c22f9e41c926baac8085b
2016-11-30 17:01:37 +00:00
Oleksiy Avramchenko
39e2d22b93 logcat: Fix --last usage option typo
Test: mm
Change-Id: I0b7a1615857acd4cd467f1ff1752eeae86d84eca
2016-11-30 13:42:14 +01:00
Mark Salyzyn
10f4044341 Merge "system/core: replace EVENT_TAG_MAP_FILE with NULL"
am: 9bfd9f558b

Change-Id: Ief7fcc4f7dd8086186b38c091fed626560ca7215
2016-11-29 19:46:50 +00:00
Treehugger Robot
9bfd9f558b Merge "system/core: replace EVENT_TAG_MAP_FILE with NULL" 2016-11-29 19:37:48 +00:00
Mark Salyzyn
d96b925d9c Merge "liblog: move android_log_event_context class to log/log_event_list.h"
am: 418558f8af

Change-Id: I4f537d4010e60b86ad4f565135804cf92fa7bd37
2016-11-22 15:56:32 +00: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
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
c8124d1592 Merge "logcat: add hidden --debug flag and cleanup"
am: c097c79b77

Change-Id: I50d28c3fc5f7ffbf1186ece2748e944bfdcf8a9f
2016-11-17 15:33:19 +00: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
4a9419f627 Merge "liblog: logprint: report truncated event log contents if error"
am: 9258348219

Change-Id: I8b49452b92a65f5cf1cf92ec1d3b776d954243a6
2016-11-16 00:26:00 +00: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
cacd9dc244 liblog: logcat: logprint support -v descriptive
am: 4fd0507b20

Change-Id: Idd4379d83b1d2f708451e1f2dd21cd40bfa49811
2016-11-07 22:46:45 +00: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
6df6448930 Merge "fix regression from android_lookupEventTag_len()"
am: 9fa133cc28

Change-Id: I8aa5cddb87290eaf86536b567b34cb3119839911
2016-10-24 23:12:42 +00:00
Treehugger Robot
9fa133cc28 Merge "fix regression from android_lookupEventTag_len()" 2016-10-24 23:08:47 +00:00
Mark Salyzyn
28fcac705b liblog: logd: logcat: Split out log/logger.h into public and private.
am: aeaaf81c2c

Change-Id: I124c69673c30bb5f2259849792ed4ca99f4d6b60
2016-10-24 22:53:11 +00:00
Mark Salyzyn
9f53cac1b4 fix regression from android_lookupEventTag_len()
Commit 807e40ecc9 'liblog: logd: Add
android_lookupEventTag_len()' which addressed a Dirty Shared memory
leak resulted in a regression. Most notably logcat <tag> stopped
working for the events log buffer.

AndroidLogEntry::tag also requires callers to check out
AndroidLogEntry::tagLen as tag is no longer guaranteed to be
nul terminated.

Test: logcat-unit-tests --gtest_filter=logcat.event_tag_filter
Bug: 31456426
Change-Id: Ibe5236131b640eb5b7e3df0ab4b5f3e25b85ad45
2016-10-24 13:39:19 -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
Elliott Hughes
19340be9fe Merge "Rely on the platform -std default." am: 955648a915 am: 4594f50635
am: f1dffe0501

Change-Id: Ibbffb45d50ad038d55a4d435a250b59b64547227
2016-10-14 02:56:09 +00:00
Treehugger Robot
955648a915 Merge "Rely on the platform -std default." 2016-10-14 02:28:38 +00:00
Mark Salyzyn
70b9e8ece6 Merge "logcat: test: report system(command) details" am: 5980fe4aff am: 811696b1ce
am: 944194bf41

Change-Id: I223e42ae85280831d4665a8ab286c5fdc258ff41
2016-10-12 21:57:03 +00:00
Mark Salyzyn
56cddcd72e logcat: test: report system(command) details
Provide more details regarding test failures

Test: manual, forced a failure, reports actual command issued
Bug: 30566487
Change-Id: I2431dbd335685b5eaef54ba6bd688b8588018aa9
2016-10-12 12:10:08 -07: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
c0a92b4a94 logd: logcat: Replace log/log.h with android/log.h am: 0dd4431072 am: 0f76f04072
am: a8d0a46956

Change-Id: I7c43316eef4ae12e666ea6a0126a38ac571dd41e
2016-09-30 22:17:47 +00:00
Mark Salyzyn
ea3c6d1029 liblog: logcat: Replace log/logd.h with log/log.h am: a166708d15 am: 772ed1c63c
am: 2b42b87d8c

Change-Id: I4a977e248d0ea7e3b8ed31aed0643752aaab4e1c
2016-09-30 22:17:14 +00:00
Mark Salyzyn
a06a6509d9 liblog: logd: logcat: deprecate log/log_read.h am: 004cd3c55d am: 78a459a8c8
am: 13c68b09d9

Change-Id: Icaab3eedecad8f55d8d1291b3414da5c12cec287
2016-09-30 22:17:08 +00:00
Mark Salyzyn
0dd4431072 logd: logcat: Replace log/log.h with android/log.h
Should use android/log.h instead of log/log.h as a good example
to all others.

Test: Compile
Bug: 26552300
Bug: 31289077
Change-Id: If4c9711eb57267d4707b03d54a932af9de241b13
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
Mark Salyzyn
c91c4446a6 resolve merge conflicts of 5f6dbd9 to nyc-mr1-dev-plus-aosp
Change-Id: Ia85ca9ea4c38d270229af394c351b7b31ea2057e
2016-08-08 13:10:35 -07:00
Mark Salyzyn
8065220686 Merge "logcatd: logpersist.start more descriptive warning" am: dad158f3a1 am: 2c1322f751
am: dbfe0a1abe

Change-Id: I460f84979b743a341de4265f398b53cea8724e49
2016-08-08 18:36:12 +00:00
Mark Salyzyn
ad5e411608 logcat: -d, -t or -L, along with -f, do not background
Specifically logcatd with exec logcat -L needs to be foreground
process cgroup as it is spawned and can block init progress. Makes
sense generally to only set background cgroup when we are taking
continuous content, and we are pushing that content to a set of
logrotate files.

Rename setupOutput to setupOutputAndSchedulingPolicy to more
clearly indicate its purpose.

Bug: 30630936
Bug: 30612424
Bug: 28788401
Change-Id: I628d590a42a53a6b448ecd0af53d6d1edf7bbb0e
2016-08-08 10:20:22 -07:00
Mark Salyzyn
31961061d5 logcat: lastLogTime only two most recent files
Scaling issues if -f logrotation is specified and there are a lot of
log files to process in lastLogTime, focus on only the last two log
files. This will cover the situation where we have recently rotated
the logs and the last file is missing or empty.

This also alters monotonic processing as well as it used to focus on
only the last file; the danger being doubled now if the pair covers
more than one reboot when filling in missing content with logcat -L.
Problem was always there with one log file, but now we handle if
rotation happened recently. A fair tradeoff for KISS.

Bug: 30630936
Bug: 30612424
Bug: 28788401
Change-Id: I1c13b94e88f5edc08ecef52d407e296874ca5807
2016-08-08 10:20:22 -07:00
Mark Salyzyn
9b35df6517 logcatd: Add --id=${ro.build.id}
If a new build lands, this will automatically clear out old
logs in /data/misc/logd/ that may no longer be relevant.

Bug: 30591615
Change-Id: Iecf61bb2a4928ce4b2e8cc6a3b122b7ae598d268
2016-08-08 10:20:22 -07:00
Mark Salyzyn
2e5b71873c logcatd: fix up logpersist.cat to filter out signature file
Simple filter for no suffix, or a numerical suffix. toybox
grep did not handle a more robust regex, so we opted for
kiss in order to remove the .id suffix from consideration.

Bug: 30591615
Change-Id: I5b1c929d3e69c1ae39af95ae44a69f7b55e969ed
2016-08-08 10:20:22 -07:00
Mark Salyzyn
02687e75b0 logcat: add --id=<id> for -f option
Clear file rotate content if id signature changes. This allows
logcatd to detect change of property ro.build.id to reset the
recorded data. The id is stored in the the -f filespec as
<filespec>.id.

If the id file is missing or unreadable, do not clear. Allow an
API where chmod 0 to the id file blocks this feature. Does not
work for root.

Add logcat.logrotate_id gTest.

Bug: 30591615
Change-Id: I895749ca7c6d4af57ec57f058a29d8e3af2f8b27
2016-08-08 10:19:48 -07:00
Mark Salyzyn
5b1a538fc8 logcat: switch to android::base::StringPrintf
asprintf should be replaced with StringPrintf, solves
a memory leak issue because of exiting scope.

Bug: 30591615
Change-Id: I88644cc27946ba4f25d4539420199c6f40df1bfa
2016-08-08 10:03:14 -07:00
Mark Salyzyn
452eaf7d5b logcatd: logpersist.start more descriptive warning
"killing Settings" is meaningless without context, we are killing the
Settings application to pull in new values, so make this clearer!

Change-Id: Ice0b950040bd05dcd49b7315def4dac3dd93eb27
2016-08-08 10:03:05 -07:00
Ruchi Kandoi
dc4c1654b5 logd: logcat -L takes longer causing vold to timeout. am: 90a3f81c9e
am: 366513fc3f

Change-Id: Iab79f34aa6655295672fdd53dca7cef58b2574ee
2016-08-03 22:21:44 +00:00
Ruchi Kandoi
90a3f81c9e logd: logcat -L takes longer causing vold to timeout.
Temporary fix to prevent device from getting stuck at boot.

Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>
Bug: 28788401
Bug: 30041146
Bug: 30612424
Bug: 30630936
Change-Id: Ie4246fc3c9eb7a3af2cb909546811c85997515da
2016-08-03 20:27:02 +00:00
Mark Salyzyn
6a7bfd8749 logcatd: logpersist.start to enable logd service if disabled
Bug: 28936216
Change-Id: I2f2878f138be6675bf00bd638df2bdd690a1fae5
2016-07-21 14:19:39 -07:00
Mark Salyzyn
df5d12850a logcatd: trampoline persist.logd.logpersistd to logd.logpersistd
(cherry pick from 2591d483c8)

Best practices so that device can set logd.logpersistd properties.
Values can be overriden with trampolines for persist.logd.logpersistd
values except as designed for empty content to keep out of the way.

This allows us to set logd.logpersistd* for a non-persistent collection
that does not survive a reboot, and to use persist.logd.logpersistd*
for persistent collection that does survive a reboot.

Added logd.logpersistd.enable to gate when logpersist service can be
run allowing the properties to be adjusted safely prior to this state
as is the case for device property.

NB: /init will complain when trying to trampoline an empty property,
    this is acceptable for functionality, but may be considered
    annoying from the logging perspective.

Bug: 28788401
Bug: 28813587
Bug: 28936216
Bug: 29831823
Change-Id: I97317e8eedfae4daa8e3ef39e64e7c5c23d8b573
2016-07-19 11:13:14 -07:00
Mark Salyzyn
2d737011d6 logcatd: add stop and clear actions
(cherry pick from commit cd5118bf1e)

- add stop and clear (and stop) actions to logcatd.rc
- use stop and clear actions in logpersist script

Bug: 28788401
Bug: 28813587
Bug: 28936216
Change-Id: Id05118fb51e40609fd7b3a934cf9302f67ef6d1d
2016-07-19 11:13:14 -07:00
Mark Salyzyn
befa79d7e0 logcatd: Do not su for setprop
(cherry pick from commit 8d2a65572b)

sepolicy now permits setting persist.logd.logpersistd in shell

Bug: 28788401
Bug: 28813587
Bug: 28936216
Change-Id: Ieed50eae0f91afa5b0c0e4ade7a71922c4b7ef93
2016-07-19 11:13:14 -07:00
Mark Salyzyn
7545b471a2 logcat: allow comma-separate list of buffers
(cherry pick from commit 4517773296)

- Add parsing to support comma+ separated list of buffers.
- Move get_size test into a standalone get_groups function
- add some additional tests for this feature, leveraging
  get_groups to confirm buffer selection.

Bug: 28120456
Bug: 28788401
Bug: 28813587
Change-Id: I0b42736c08cf4b2a435cb74cda540dc163a26bd1
2016-07-19 11:13:14 -07:00
Mark Salyzyn
c869959d62 logcat: clear when specifying file output
(cherry pick from commit b7d059bb2f)

If -c and -f are both specified, clear the files rather
than notifying the logger to clear its data. The -f then
acts like a switch between clearing the in-memory log
data, or the on-disk logrotate data.

Bug: 28788401
Bug: 28813587
Bug: 28936216
Change-Id: Ib1d1fb46ea09f81a2fd9bebb6c8f0f9f2355f6e8
2016-07-19 11:13:14 -07:00
Mark Salyzyn
3f6777a3dd logcat: Adjust help to make it more meaningful
(cherry pick from commit 378f4745a2)

It is not clear about the long option aliases, list
them comma separate first for clarity. Squash lines
of help content if possible. Lock to 3 indents, one
for options, another for text on same line as options
and another for next line or continuation.

Bug: 28120456
Bug: 28788401
Bug: 28813587
Change-Id: I5331acde3ac0fd3b87f6699ba108f6cef46a1563
2016-07-19 11:13:10 -07:00