Skip to content

Commit 8af55cb

Browse files
committed
ohos: Use custom domain when logging with hilog
This modifies the existing patch to redirect log messages to hilog to use a non-zero domain, which allows us to filter logs via the domain on ohos devices. We set 0xE0C3 for Rust code in servo, using a different number allows us to seperate spidermonkey from servo logs if wanted. Signed-off-by: Jonathan Schwender <[email protected]>
1 parent 728acdf commit 8af55cb

File tree

8 files changed

+36
-17
lines changed

8 files changed

+36
-17
lines changed

mozjs-sys/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "mozjs_sys"
33
description = "System crate for the Mozilla SpiderMonkey JavaScript engine."
44
repository.workspace = true
5-
version = "0.128.9-2"
5+
version = "0.128.9-3"
66
authors = ["Mozilla"]
77
links = "mozjs"
88
build = "build.rs"

mozjs-sys/etc/patches/0036-Redirect_errors_to_hilog_on_OpenHarmony.patch

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ index e0e14bf60..179de2592 100644
1010

1111

1212
@depends(target)
13+
@@ -1019,6 +1019,12 @@
14+
15+
set_config("ANDROID_CPU_ARCH", android_cpu_arch)
16+
17+
+@depends(target, when=target_is_ohos)
18+
+def ohos_hilog_domain(target):
19+
+ return "0xE0C4"
20+
+
21+
+set_define("OHOS_LOG_DOMAIN", ohos_hilog_domain)
22+
+
23+
24+
@depends("--enable-project", build_environment, "--help")
25+
@imports(_from="os.path", _import="exists")
1326
diff --git a/config/system-headers.mozbuild b/config/system-headers.mozbuild
1427
index 471599f17..a89f0ca7a 100644
1528
--- a/config/system-headers.mozbuild
@@ -47,7 +60,7 @@ index 3cfc92533..9c487ac45 100644
4760
+#ifdef ANDROID
4861
+ __android_log_print(ANDROID_LOG_ERROR, "Gecko", "mozalloc_abort: %s", msg);
4962
+#elif defined(OHOS)
50-
+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "Gecko",
63+
+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, OHOS_LOG_DOMAIN, "Gecko",
5164
+ "mozalloc_abort: %{public}s\n", msg);
5265
+#else
5366
fputs(msg, stderr);
@@ -75,7 +88,7 @@ index 0b7395177..e84d76aba 100644
7588
/* aMaxFrames */ 0);
7689
# endif
7790
+#elif defined(OHOS)
78-
+ (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_Assert",
91+
+ (void) OH_LOG_Print(LOG_APP, LOG_FATAL, OHOS_LOG_DOMAIN, "MOZ_Assert",
7992
+ "Assertion failure: %{public}s, at %{public}s:%{public}d\n",
8093
+ aStr, aFilename, aLine);
8194
#else
@@ -86,7 +99,7 @@ index 0b7395177..e84d76aba 100644
8699
"[%d] Hit MOZ_CRASH(%s) at %s:%d\n", MOZ_GET_PID(), aStr,
87100
aFilename, aLine);
88101
+#elif defined(OHOS)
89-
+ (void) OH_LOG_Print(LOG_APP, LOG_FATAL, 0, "MOZ_CRASH",
102+
+ (void) OH_LOG_Print(LOG_APP, LOG_FATAL, OHOS_LOG_DOMAIN, "MOZ_CRASH",
90103
+ "Hit MOZ_CRASH(%{public}s), at %{public}s:%{public}d\n",
91104
+ aStr, aFilename, aLine);
92105
#else
@@ -116,7 +129,7 @@ index 3247b993c..c7039d5f8 100644
116129
+#if defined(ANDROID)
117130
__android_log_print(ANDROID_LOG_INFO, "Gecko", "%s", s.str().c_str());
118131
+#elif defined(OHOS)
119-
+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", "%{public}s\n", s.str().c_str());
132+
+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, OHOS_LOG_DOMAIN, "Gecko", "%{public}s\n", s.str().c_str());
120133
#else
121134
fputs(s.str().c_str(), stderr);
122135
#endif
@@ -143,7 +156,7 @@ index c3a2ca89e..3fea33f4b 100644
143156
}
144157
+#elif defined(OHOS)
145158
+MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) {
146-
+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "Gecko", aFmt, aArgs);
159+
+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, OHOS_LOG_DOMAIN, "Gecko", aFmt, aArgs);
147160
+}
148161
#elif defined(FUZZING_SNAPSHOT)
149162
MFBT_API void vprintf_stderr(const char* aFmt, va_list aArgs) {
@@ -194,7 +207,7 @@ index 52bd6abc5..781402d56 100644
194207
+ if (fd == _pr_stderr) { \
195208
+ char savebyte = buf[nb]; \
196209
+ buf[nb] = '\0'; \
197-
+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, 0, "PRLog", \
210+
+ (void) OH_LOG_Print(LOG_APP, LOG_INFO, OHOS_LOG_DOMAIN, "PRLog", \
198211
+ "%{public}s\n", buf); \
199212
+ buf[nb] = savebyte; \
200213
+ } else { \
@@ -209,7 +222,7 @@ index 52bd6abc5..781402d56 100644
209222
#ifdef ANDROID
210223
__android_log_write(ANDROID_LOG_ERROR, "PRLog", "Aborting");
211224
+#elif defined(OHOS)
212-
+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog", "Aborting\n");
225+
+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, OHOS_LOG_DOMAIN, "PRLog", "Aborting\n");
213226
#endif
214227
abort();
215228
}
@@ -218,7 +231,7 @@ index 52bd6abc5..781402d56 100644
218231
__android_log_assert(NULL, "PRLog", "Assertion failure: %s, at %s:%d\n",
219232
s, file, ln);
220233
+#elif defined(OHOS)
221-
+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, 0, "PRLog",
234+
+ (void) OH_LOG_Print(LOG_APP, LOG_ERROR, OHOS_LOG_DOMAIN, "PRLog",
222235
+ "Assertion failure: %{public}s, at %{public}s:%{public}d\n",s, file, ln);
223236
#endif
224237
abort();

mozjs-sys/mozjs/build/moz.configure/init.configure

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mozjs-sys/mozjs/memory/mozalloc/mozalloc_abort.cpp

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mozjs-sys/mozjs/mfbt/Assertions.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mozjs-sys/mozjs/mfbt/DbgMacro.h

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mozjs-sys/mozjs/mozglue/misc/Debug.cpp

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mozjs-sys/mozjs/nsprpub/pr/src/io/prlog.c

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)