Skip to content

Commit 79434cb

Browse files
Narfingerjdm
andauthored
Add some more documentation for devtools and OHOS debugging. (#83)
* Add some more documentation for devtools and OHOS debugging. Signed-off-by: Narfinger <[email protected]> * Incorporate suggestions. Co-authored-by: Josh Matthews <[email protected]> Signed-off-by: Narfinger <[email protected]> --------- Signed-off-by: Narfinger <[email protected]> Co-authored-by: Josh Matthews <[email protected]>
1 parent cec2e23 commit 79434cb

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

src/hacking/debugging-on-openharmony.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@ When debugging, it can often be useful to start servo from the commandline inste
99

1010
```shell
1111
# Run this command to see which parameters can be passed to an ohos app
12-
hdc shell aa start --help
12+
hdc shell aa start --help
1313
# Start servo from the commandline
1414
hdc shell aa start -a EntryAbility -b org.servo.servo
1515
# --ps=<arg> <value> can be used to pass arguments with values to servoshell.
16-
# The space between arg and value is mandatory when using `--ps`.
16+
# The space between arg and value is mandatory when using `--ps`, meaning `--ps=--log-filter warn` is
17+
# correct while `--ps=--log-filter=warn` is not.
1718
# For pure flags without a value use `--psn <flag>`
1819
hdc shell aa start -a EntryAbility -b org.servo.servo --ps=--log-filter "warn"
1920
# Use `-U <url>` to let servo load a custom URL.
@@ -41,18 +42,18 @@ hdc shell hilog --domain=0xE0C3 --level=ERROR
4142

4243
### Log level
4344

44-
Whether log statements are visible depends on multiple conditions:
45+
Whether log statements are visible depends on multiple conditions:
4546

4647
1. The compile-time max log level of the `log` crate. See [log compile-time filters].
4748
Note: The `release_max_level_<level>` features of the log crate check if `debug_assertions = false` is set
48-
to determine the release filters should apply or not.
49+
to determine the release filters should apply or not.
4950
2. The runtime `log` global filter per module filters set in servoshell. Since environment variables aren't an
5051
option to customize the log level, `servoshell` has the `--log-filter` option on ohos targets, which allows
51-
customizing the log filter of the `log` crate.
52-
By default servoshell sets a log filter which hides log statements from many crates, so you likely will need to
52+
customizing the log filter of the `log` crate.
53+
By default servoshell sets a log filter which hides log statements from many crates, so you likely will need to
5354
set a custom log-filter if you aren't seeing the logs from the crate you are debugging.
5455
3. The `hilog` base log filter. `hdc shell hilog --base-level=<log_level>`. Can be combined with `--domain` and `--tag`
55-
options to customize **which logs are saved**.
56+
options to customize **which logs are saved**.
5657
4. The `hilog` log filter when displaying logs: `hdc shell hilog --level=<level>`
5758

5859
Most of the time option 2 and/or 4 should be used, since they allow quick changes with recompiling.
@@ -61,19 +62,27 @@ Most of the time option 2 and/or 4 should be used, since they allow quick change
6162

6263
### Hilog domains
6364

64-
`hilog` allows setting a custom integer called "domain" (between 0 and 0xFFFF) when logging, which allows developers to easily filter logs using the domain.
65-
For Rust code in servo logged via the `log` crate we set [`0xE0C3`] as the domain and for Spidermonkey C++ code we set [`0xE0C4`].
65+
`hilog` allows setting a custom integer called "domain" (between 0 and 0xFFFF) when logging, which allows developers to easily filter logs using the domain.
66+
For Rust code in servo logged via the `log` crate we set [`0xE0C3`] as the domain and for Spidermonkey C++ code we set [`0xE0C4`].
6667
These values are somewhat arbitrarily chosen.
6768

6869
[`0xE0C3`]: https://github.com/servo/servo/blob/384d8f1ff895f070397b7a5a384428b1678416c5/ports/servoshell/egl/ohos.rs#L420
6970
[`0xE0C4`]: <TODO - link pending SM PR being merged.>
7071

7172
### Hilog privacy feature
7273

73-
`hilog` has a privacy feature, which by default hides values in logs (e.g. from `%d` or `%s` substitutions).
74+
`hilog` has a privacy feature, which by default hides values in logs (e.g. from `%d` or `%s` substitutions).
7475
Log statements from Rust are generally unaffected by this, since the string formatting is done on the Rust side.
7576
If you encounter this issue when viewing C/C++ logs, you can temporarily turn off the privacy feature by running:
7677

7778
```shell
7879
hdc shell hilog -p off
7980
```
81+
82+
### Devtools and port forwards
83+
84+
You can enable the devtools and connect to them remotely with Firefox. It is easiest to do this with the command line via
85+
`hdc shell aa start -a EntryAbility -b org.servo.servo --psn=--devtools=1234`
86+
To connect to an instance of Servo you have to forward the port with
87+
`hdc fport tcp:1234 tcp:1234`. You should see a message that the forward succeeded. Now you can
88+
connect to the devtools using `localhost:1234`.

0 commit comments

Comments
 (0)