Commit graph

141 commits

Author SHA1 Message Date
Yifan Hong
24d0304ee9 lshal: Do not use lastError API.
Use the new API with error message pointer instead.

Test: lshal_test
Bug: 179270601
Change-Id: I19d1307c7b72b90d205f307a81edfb1efabb874e
2021-04-05 18:35:13 -07:00
Devin Moore
c03e3aa3cd Add libbinderdebug
Allows lshal and dumpsys to share the code to get Binder PID info.

Test: atest libbinderdebug_test lshal_test
Test: diff output of lshal before and after this CL
Bug: 140639610
Change-Id: I04dbe2509673502502ac849ef4ae74147404fc43
2020-12-15 14:16:39 -08:00
Yifan Hong
43101a4f34 lshal_test uses static libvintf.
Test: forrest on 64 bit cuttlefish x86
Fixes: 174494015
Change-Id: I33f98cd913dc5122babd0290e156ac394522bbca
2020-12-01 11:14:39 -08:00
Yifan Hong
3f21eafad7 Merge "lshal: resistent to metaversion updates." 2020-10-16 22:42:35 +00:00
Yifan Hong
29b35b6961 lshal: resistent to metaversion updates.
When metaversion of libvintf updates, --init-vintf option
always uses the highest metaversion, breaking tests. These
tests should work with any metaversion of libvintf. The HAL
sections should be focused on.

Test: lshal_test

Change-Id: Ie5471ddd6dea7b8098d0be3385cfd1cc6c29824d
2020-10-14 21:17:43 -07:00
Yifan Hong
c53cb4144d Merge "lshal: Add fqname to debug error messages" 2020-09-25 18:09:08 +00:00
Yifan Hong
8a662475ef lshal: Add fqname to debug error messages
If any error comes up when invoking debug, write fqname and the error
message to the error output stream.

Test: manual. Add addPostCommandTask to a HAL that keeps writing to the
fd after debug() finishes. lshal debug terminates with fqname and
the error message `timeout reading from pipe, output may be truncated.`

Fixes: 169247570

Change-Id: Idf8944e3cde08dc86766b144c4a3037cbcf6b3dc
2020-09-24 14:31:22 -07:00
Yifan Hong
30528a2d91 lshal: Add --all --types=all, and use in bugreport
Also clang-format.
When --all is specified, put "clients" at the end because it is usually
the longest.

Test: lshal --all
Test: lshal --all --cmdline
Test: lshal --types=all
Test: adb bugreport
Bug: 163060248
Change-Id: If95a18cff50d3b6ef3f70b300f16105b41ca28ed
2020-08-07 20:02:16 -07:00
Yifan Hong
6884b87a37 lshal: --debug omits info on parent objects.
Instead, print a short message that contains the information
on the row that it should look up.

Test: lshal --debug
Test: lshal debug -E android.hardware.health@2.0::IHealth/default
Test: lshal_test
Fixes: 160745145
Change-Id: I7d5ab9fba097c0fb0b080ec52682084c65ba9f50
2020-07-10 11:36:16 -07:00
Yifan Hong
5cceea8d0b lshal: Add test for debug -E
Test: lshal_test
Change-Id: Ib34d291fe94e7a0b0e21088b741d844c09f1a8a8
2020-07-10 11:14:59 -07:00
Steven Moreland
7a99e04990 lshal: avoid FQName globals.
These aren't really needed here, and they are costing 20Kib memory/user.

Bug: 148177595
Test: boot/lshal
Change-Id: Id0d311319c47553fac5d1d208409cef83073fddf
2020-02-26 13:16:34 -08:00
Hridya Valsaraju
b49b0b162f lshal: read binder stats from binderfs
If binderfs is mounted, lshal should read binder stats
from /dev/binderfs/binder_logs instead of debugfs.

Test: atest lshal_test, adb shell lshal
Change-Id: Id585cdcd71c0ab4346045a099c2e3d0ddffcecc0
2020-02-25 12:34:52 -08:00
Yifan Hong
c346a16e65 lshal: use new libvintf API
forEachInstanceOfVersion now requires a HalFormat arg now.
Right now, lshal only works on HIDL hals. We will re-visit
this code when we need lshal for staidl hals as well.

Bug: 140832836
Test: lshal_test
Change-Id: I721dff82ec6aeb4473236c5c78694d366893eb30
2019-09-11 12:21:05 -07:00
Steven Moreland
7a10a4f543 Remove libhwbinder/libhidltransport deps
Since these were combined into libhidlbase.

Bug: 135686713
Test: build only (libhwbinder/libhidltransport are empty)
Change-Id: Iec1802ce9226570d3a02cc5242f7ca72e1370635
2019-09-09 10:46:17 -07:00
Steven Moreland
c3ba3a0019 lshal: update test manifest to 2.0
Since libvintf is now at 2.0.

Fixes: 140733110
Test: lshal_test
Change-Id: Ib797c098be3c7f3a9adb47cb69e7994e88c063ce
2019-09-09 10:41:49 -07:00
Steven Moreland
d64ba89b2a lshal: explain VINTF 'X' value in help
Bug: N/A
Test: manual
Change-Id: I0ee79ad300d63842613e79773a581cfce67986a7
2019-07-12 16:00:35 -07:00
Steven Moreland
392c8417d9 Merge "lshal: add wait command" 2019-07-12 16:47:44 +00:00
Steven Moreland
552e407f8e lshal: add wait command
Waits for an interface to start (e.g. for scripting certain tests).

Fixes: 135956088
Test: the following
$ adb shell lshal wait android.hardware.nfc@1.0::INfc/foo
Service not found (missing permissions or not in VINTF manifest?).
$ echo $?
128
$ adb shell lshal wait android.hardware.nfc@1.0::INfc/default
$ echo $?
0
Test: lshal_test

Change-Id: I355fc33f9e46bac573a38425205e8db81f19a36e
2019-07-12 00:44:27 +00:00
Treehugger Robot
0ba6a437d5 Merge "Fix lshal_test after updated defaults." 2019-07-02 18:36:43 +00:00
Steven Moreland
eae1a0bd30 Fix lshal_test after updated defaults.
Also add TEST_MAPPING so that this doesn't happen again.

Bug: N/A
Test: N/A
Change-Id: Idd99b34e8e634b9f93652b756eabcf9f62256e7e
2019-06-26 18:20:28 -07:00
Steven Moreland
e416f70786 Merge changes I9b41e78f,Ia66e5da5
* changes:
  liblshal: make static
  lshal: use pragma once
2019-06-26 15:26:36 +00:00
Steven Moreland
b8745de570 liblshal: make static
- reduce number of files on device
- allow testing lshal w/o flashing
- no need for dynamic linking (static lib will be more compact)

Bug: N/A
Test: lshal, lshal_test
Change-Id: I9b41e78f7e6a469505cd530eb578df6855f45a1f
2019-06-25 11:40:37 -07:00
Steven Moreland
0b8e38764c lshal: use pragma once
For simplicity when adding new files.

Bug: N/A
Test: N/A
Change-Id: Ia66e5da5ff680b9287c4431799a935b58de02307
2019-06-25 08:54:34 -07:00
Felipe Leme
2382d319f2 Brace Yourselves, R is Coming.
Bug: none
Test: echo 'in TreeHugger we trust!'

Change-Id: I21d6b0dab95170093de5d725b170916ca7ca0a9c
2019-06-21 14:56:42 -07:00
Chih-Hung Hsieh
45e31c739f Fix/suppress cmds/lshal google-explicit-constructor warnings
* Add explicit to conversion constructors/operators
* Use NOLINT or NOLINTNEXTLINE to suppress warnings on intended converters

Bug: 28341362
Test: make with WITH_TIDY=1 DEFAULT_GLOBAL_TIDY_CHECKS=-*,google-explicit-constructor
Change-Id: I67a59b0051b5550ea135a91664bf03995e94eb75
2019-01-10 19:53:01 +00:00
Chih-Hung Hsieh
c7ba3e4f64 Add lshal owners
Bug: None
Test: uploader
Change-Id: Ib06540b288a321f6ebb858721a08975f6a0ffd93
2018-12-21 23:37:41 +00:00
Steven Moreland
8e0f539cc6 lshal: show VINTF column by default.
A HAL can't be retrieved unless it is in the VINTF manifest. This
design decision was made so that people add HALs to the manifest as
early as possible (this makes sure that the manifest is accurate on
a change by change basis).

A common problem people face is seeing a HAL in lshal, but because
of the above, it can't be retreived. Currently, in order to see
manifest information, you either have to dig into the lshal settings
or dig into the filesystem. Since one of the most common debugging
steps for a HAL is to check lshal for the HAL, having the information
right here will help. Even though it doesn't explicitly say what the
implications of 'FM' or 'DM' are, reading the lshal help gives a
reasonable idea of this, and when a snippet of lshal is shown (either
in a bugreport/email etc), it will contain the information required
to diagnose the issue.

This CL also fixes a couple bits of documentation in lshal and adjusts
the formatting of the output slightly to break up table descriptions
from the output.

Change-Id: I2bdc08a8b48b8b78a4b143cc4a7cfdfbef62622d
Fixes: 120871371
Test: lshal (manual)
2018-12-12 14:51:19 -08:00
Yifan Hong
b1db390e25 lshal: Allow read to timeout in debug()
Start timing when debug() has returned. When the specific
timeout has reached (currently 1s) and the relay thread
has not finish, tell the relay thread to stop.

Test: while true; do date; lshal debug android.hardware.health.storage@1.0::IStorage/default; done
Test: lshal_test

Bug: 111997867
Change-Id: Ib9235d3bd2fc3a54eb316da8d8b59d987988b134
2018-09-27 11:09:17 -07:00
Yifan Hong
a5ae7868e7 Revert "lshal: close fd before joining thread"
This reverts commit b9d19c87ab.

Reason of revert: will sometimes cause `lshal debug` to produce
no output at all.

Bug: 111997867
Test: while true; do date; lshal debug android.hardware.health.storage@1.0::IStorage/default; done

Change-Id: I31062b479ea8a9f1c5b94a1ad0969bc5e2e92cd3
2018-09-26 16:09:46 -07:00
Yifan Hong
8697168f9b lshal: SerializeFlag => SerializeFlags
Bug: 110711640
Test: lshal --init-vintf
Change-Id: If7770be64bff108e22d4fedfce0df991edb2b629
2018-08-08 10:11:08 -07:00
Yifan Hong
e13b6b62e6 Merge "lshal: close fd before joining thread"
am: 16b9f38d22

Change-Id: I7ab9f8e64e01dd5b1f2edba2e5db8404d8073b4c
2018-08-02 16:29:17 -07:00
Yi Kong
9ead54bed6 Merge "[cmds] Modernize codebase by replacing NULL with nullptr"
am: ad0f33eaf1

Change-Id: I7d55285b2e0ee1b949df253c5703be874fa21f63
2018-08-02 16:17:51 -07:00
Yifan Hong
16b9f38d22 Merge "lshal: close fd before joining thread" 2018-08-02 23:16:35 +00:00
Yifan Hong
b9d19c87ab lshal: close fd before joining thread
In ~PipeRelay, since the data is no longer needed,
just close the fd before joining the thread.

In previous code, 'lshal debug' can hang:
- lshal read() waiting for data in RelayThread
- lshal send fd to service in main thread
- service close the fd
- service returns in debug() call
- lshal calls ~PipeRelay
- lshal read() is still blocking because it does not
  receive the signal

But, since the service has already end the debug()
call, the fds can be closed to bail out from blocking read().

Test: 'while true; do lshal debug ...; done' does not hang
Fixes: 111997867
Change-Id: I90db486b0a6598bd9998ed904dc0c757dfa57e0e
2018-08-02 14:22:12 -07:00
Yi Kong
19d5c00350 [cmds] Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning.

Test: m
Bug: 68236239
Change-Id: I1635395d653ace5a11c75795f4a7d2bf2d9e0b1b
Merged-In: I73a0a82e3e32001f8ffb0880250c7023dd8290d3
2018-08-02 14:14:35 -07:00
Yifan Hong
7ed23273c2 Merge changes from topic "lshal_lazy_hals"
am: e3a52f01e4

Change-Id: I8261b7395f92c780efa487d2e015b62c72750a5a
2018-06-29 10:52:38 -07:00
Yifan Hong
3212f17721 lshal: add --types=lazy|z
Add a new section to lshal that shows HALs in the manifest
  - as hwbinder HALs but not registered
  - as passthrough HALs but no impl found

Fixes: 71555570
Test: lshal_test
Test: lshal --types=z

Change-Id: I6947d9e7e08991fa2497f40c81005f885d408931
2018-06-28 15:04:20 -07:00
Yifan Hong
13ba0a9751 lshal: add "Status" column and "Manifest HALs" section.
- Added "Status" column that has following values:
    - alive: running hwbinder service
    - registered;dead: registered, but service cannot accept calls
    - declared: only in VINTF, not in hwservicemanager
    - N/A: passthrough HALs

- Added a "Manifest HALs" section that lists all
  HALs (hwbinder or passthrough) in device / framework manifest

Test: lshal_test

Bug: 71555570

Change-Id: I202b562ee73bcd49506bb43cc9af27b86f32651c
2018-06-28 14:57:37 -07:00
Yifan Hong
b72f19ee9f lshal: --types works with --neat
Test: lshal_test
Change-Id: Ia2e6a2258b455605929a19da0c3213eae5f9d14f
2018-06-28 13:23:15 -07:00
Yifan Hong
db73053065 lshal: add ListCommand::tableForType
... to avoid duplicating switch/case logic.
Test: lshal_test

Change-Id: I9096534d607839ccc34dc115e76e890688a25c61
2018-06-28 13:23:15 -07:00
Yifan Hong
20f4ee8c46 lshal: Remove obsolete TableEntrySource type.
HalType is a better type.
Test: lshal_test

Change-Id: I2de08a6cce8413d93d3b7fb2367d0c1ad09d032a
2018-06-28 13:23:15 -07:00
Yifan Hong
c443091cbc lshal: test: make mocks more robust
Setup error stream for all tests in ListParseArgsTest.
Otherwise, if lshal writes to error stream, the test
immediately aborts.

Test: lshal_test

Change-Id: I085e764528534e9d2df8e0ccf3181366d20247bc
2018-06-28 13:23:15 -07:00
Yifan Hong
aa864577ff lshal: fix help message
Default options are incorrect. Should be `lshal list -liepc`.

Test: compare output of `lshal` and `lshal -liepc`

Change-Id: Ia5fa7452c5e770793ad89cdd9c29ef20af462887
2018-06-28 13:23:15 -07:00
Andreas Huber
2a9d939dde Merge "Use a pipe rather than a socketpair to collect debug information from" am: 14906cd8e9
am: 9129e86f04

Change-Id: I38f9e15e7ee0a9f071fcf5d208bd49b68ff26e69
2018-05-29 18:14:19 -07:00
Treehugger Robot
14906cd8e9 Merge "Use a pipe rather than a socketpair to collect debug information from" 2018-05-29 23:44:58 +00:00
Yifan Hong
e460f4122f Merge changes from topic "lshal_improve" am: 0639471d64
am: 3d76135f94

Change-Id: I2cb0588df3a90929535019c88ad9b9b71a70d763
2018-05-29 12:39:04 -07:00
Yifan Hong
9896fd5166 lshal: Add VINTF column am: bdf44f81d0
am: 5b2b7e9192

Change-Id: If7f574277681e61dd4786996f3fcbd10b7820919
2018-05-29 12:38:19 -07:00
Yifan Hong
fb86089fff lshal: refactor: Use vintf::Arch instead of enum Architecture am: 0ad64f522c
am: 2ce601a014

Change-Id: Icc1310252409aa03f518fac0c0cc4312a55bbb75
2018-05-29 12:37:43 -07:00
Yifan Hong
331c31bad7 lshal: refactor: Use vintf::Transport instead of string am: 8304e41694
am: 0dabfe452e

Change-Id: Icd7ff95b780c23d5902df2cb4b171165fa20da37
2018-05-29 12:37:09 -07:00
Yifan Hong
cfac7c52bf lshal: Released column is now Y/N/? am: d5ee11a531
am: 528dcc69d1

Change-Id: I5da1b623eade66f58dc5b457ce39dd363ee3e7d3
2018-05-29 12:36:34 -07:00