diff --git a/recipes-openharmony/openharmony/openharmony-standard-3.0/test-xts-acts-fix-faultloggertest.patch b/recipes-openharmony/openharmony/openharmony-standard-3.0/test-xts-acts-fix-faultloggertest.patch new file mode 100644 index 0000000000000000000000000000000000000000..7fadd71e0e2571e12e384267de3d3af18e36336e --- /dev/null +++ b/recipes-openharmony/openharmony/openharmony-standard-3.0/test-xts-acts-fix-faultloggertest.patch @@ -0,0 +1,86 @@ +# SPDX-FileCopyrightText: Huawei Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +Patch for //test/xts/acts repository of OpenHarmony 3.0 codebase. + +This fixes the ActsFaultLogger test-case. + +- Optimization needs to be disabled to avoid compiler optimizing out the null + pointer dereference. + +- In order for the faultloggerd process to actually generate the log files, + applications needs to install the needed signal handlers, as documented in + base/hiviewdfx/faultloggerd/README.md + +- Align the test with it's own name, so it actually matches on the generated + crash log. + +Signed-off-by: Esben Haabendal <esben@geanix.com> +Upstream-Status: Inappropritate [test-case was dropped in 3.0.2] + +diff --git a/hiviewdfx/faultloggertest/faultloggercpptest/BUILD.gn b/hiviewdfx/faultloggertest/faultloggercpptest/BUILD.gn +index 0eeb66084952..4ba249d8c4af 100755 +--- a/hiviewdfx/faultloggertest/faultloggercpptest/BUILD.gn ++++ b/hiviewdfx/faultloggertest/faultloggercpptest/BUILD.gn +@@ -23,6 +23,7 @@ config("faultloggertest_config") { + "//base/hiviewdfx/hilog/interfaces/native/innerkits/include", + "genfault.h", + ] ++ cflags = [ "-O0" ] + } + ohos_moduletest_suite("ActsFaultLoggerTest") { + module_out_path = module_output_path +@@ -33,6 +34,7 @@ ohos_moduletest_suite("ActsFaultLoggerTest") { + deps = [ + "../../utils/native:utilskit", + "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", ++ "//base/hiviewdfx/faultloggerd/interfaces/innerkits/signal_handler:dfx_signalhandler", + "//third_party/googletest:gtest_main", + "//utils/native/base:utils", + ] +diff --git a/hiviewdfx/faultloggertest/faultloggercpptest/faultloggertest.cpp b/hiviewdfx/faultloggertest/faultloggercpptest/faultloggertest.cpp +index 5870de2257c1..ff00cffddf9f 100755 +--- a/hiviewdfx/faultloggertest/faultloggercpptest/faultloggertest.cpp ++++ b/hiviewdfx/faultloggertest/faultloggercpptest/faultloggertest.cpp +@@ -22,6 +22,8 @@ + #include "hilog/log_c.h" + #include "hilog/log_cpp.h" + ++#include "dfx_signal_handler.h" ++ + #undef LOG_DOMAIN + #undef LOG_TAG + #define LOG_DOMAIN 0xD003200 +@@ -60,6 +62,7 @@ pid_t faultloggertest::DoTestProcess(int faulttype) + { + printf("DoTestProcess, param is %d\r\n", faulttype); + pid_t pid; ++ static int installed = 0; + pid = fork(); + printf("pid is %d\r\n", pid); + switch (pid) { +@@ -70,6 +73,11 @@ pid_t faultloggertest::DoTestProcess(int faulttype) + GenFault(faulttype); + break; + default: ++ if (installed == 0) { ++ DFX_InstallSignalHandler(); ++ std::cout << "DFX signal handler installed"<<std::endl; ++ installed = 1; ++ } + break; + } + wait(&status); +@@ -130,9 +138,9 @@ HWTEST_F(faultloggertest, Faultlogger_Faultdetect1, Function|MediumTest|Level1) + string fileinfo; + fileinfo = ReadFile("/data/log/faultlog/temp/" + faultloggerfile); + std::vector<std::string> para = {"Pid:" + to_string(pid), "Uid:0", +- "Process name:", "/data/local/tmp/faultloggertest", ++ "Process name:", "/data/local/tmp/ActsFaultLoggerTest", + "Reason:Signal:SIGILL", "Fault thread Info:", +- "Tid:" + to_string(pid), "Name:faultloggertest"}; ++ "Tid:" + to_string(pid), "Name:ActsFaultLoggerTest"}; + if (!fileinfo.empty()) { + result = CheckInfo(para, fileinfo); + } else { diff --git a/recipes-openharmony/openharmony/openharmony-standard-sources-3.0.inc b/recipes-openharmony/openharmony/openharmony-standard-sources-3.0.inc index 9c9259803c845c746430183040d6bf14f616eb7f..c33f1a8cc9da6e6cb51f0e6b8bb2c6b1cb4d214d 100644 --- a/recipes-openharmony/openharmony/openharmony-standard-sources-3.0.inc +++ b/recipes-openharmony/openharmony/openharmony-standard-sources-3.0.inc @@ -349,9 +349,6 @@ SRCREV_FORMAT .= "+third_party_libpng" SRC_URI += "${GITEE_URL}/third_party_libsnd.git;protocol=https;nobranch=1;branch=OpenHarmony-v3.0.1-LTS;name=third_party_libsnd;destsuffix=${OH_SRCDIR}/third_party/libsnd" SRCREV_third_party_libsnd = "11640c8570477dd9b3d741d3dfd9941b7325a98d" SRCREV_FORMAT .= "+third_party_libsnd" -SRC_URI += "${GITEE_URL}/third_party_libunwind.git;protocol=https;nobranch=1;branch=OpenHarmony-v3.0.1-LTS;name=third_party_libunwind;destsuffix=${OH_SRCDIR}/third_party/libunwind" -SRCREV_third_party_libunwind = "60ec73774087bdecd62072a1cfbd669580c35ca2" -SRCREV_FORMAT .= "+third_party_libunwind" SRC_URI += "${GITEE_URL}/third_party_libuv.git;protocol=https;nobranch=1;branch=OpenHarmony-v3.0.1-LTS;name=third_party_libuv;destsuffix=${OH_SRCDIR}/third_party/libuv;lfs=0" SRCREV_third_party_libuv = "96413c54af34a4a0c24631ac0c3cde26517f6d67" SRCREV_FORMAT .= "+third_party_libuv" diff --git a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb index 361d9bc7e50a4186acc84a7591304f1140d70c10..fc406749509efd62005e87e855e9cb1be85c720e 100644 --- a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb +++ b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb @@ -75,6 +75,7 @@ SRC_URI += "file://RenderText-PerformLayout-remove-sigsegv-code.patch;patchdir=$ SRC_URI += "file://test-xts-acts-timeout-increment.patch;patchdir=${S}/test/xts/acts" SRC_URI += "file://start-ability-timeout-increment.patch;patchdir=${S}/test/xts/acts" SRC_URI += "file://test-xts-acts-fix-Defpermission-typo.patch;patchdir=${S}/test/xts/acts" +SRC_URI += "file://test-xts-acts-fix-faultloggertest.patch;patchdir=${S}/test/xts/acts" inherit python3native gn_base ptest @@ -1580,7 +1581,7 @@ FILES:${PN}-faultlogger = " \ ${libdir}/libdfx_signalhandler*${SOLIBS} \ " RDEPENDS:${PN}-faultlogger += "musl libcxx" -RDEPENDS:${PN}-faultlogger += "${PN}-libutils ${PN}-hilog ${PN}-thirdparty-libunwind" +RDEPENDS:${PN}-faultlogger += "${PN}-libutils ${PN}-hilog" RDEPENDS:${PN} += "${PN}-faultlogger" # faultlogger-ptest @@ -1912,11 +1913,6 @@ FILES:${PN}-thirdparty-protobuf = "${libdir}/libprotobuf_standard*${SOLIBS}" RDEPENDS:${PN}-thirdparty-protobuf += "musl libcxx" RDEPENDS:${PN} += "${PN}-thirdparty-protobuf" -PACKAGES =+ "${PN}-thirdparty-libunwind" -FILES:${PN}-thirdparty-libunwind = "${libdir}/libunwind*${SOLIBS}" -RDEPENDS:${PN}-thirdparty-libunwind += "musl libcxx" -RDEPENDS:${PN} += "${PN}-thirdparty-libunwind" - PACKAGES =+ "${PN}-thirdparty-giflib" FILES:${PN}-thirdparty-giflib = "${libdir}/libgif*${SOLIBS}" RDEPENDS:${PN}-thirdparty-giflib += "musl libcxx" diff --git a/recipes-openharmony/sdk/oniro-openharmony-bundle.bb b/recipes-openharmony/sdk/oniro-openharmony-bundle.bb index 7c02da7809e562860873aa2e9431a57a6b5be799..d794eba174471eceb0dbf89edbc76f6300f68a82 100644 --- a/recipes-openharmony/sdk/oniro-openharmony-bundle.bb +++ b/recipes-openharmony/sdk/oniro-openharmony-bundle.bb @@ -18,3 +18,8 @@ TOOLCHAIN_TARGET_TASK += "openssl-dev" # OpenSSL for build host TOOLCHAIN_HOST_TASK += "nativesdk-openssl-dev" + +# libunwind for target +DEPENDS += "libunwind" +RDEPENDS:${PN} = "libunwind" +TOOLCHAIN_TARGET_TASK += "libcxx-dev" diff --git a/recipes-openharmony/sdk/oniro-openharmony-thirdparty-integration-3.0.inc b/recipes-openharmony/sdk/oniro-openharmony-thirdparty-integration-3.0.inc index a7f04d8facf670e04e447a6dc4067cda7cd97ce9..8463d7074f0d01e159582b40ec6f389596777d31 100644 --- a/recipes-openharmony/sdk/oniro-openharmony-thirdparty-integration-3.0.inc +++ b/recipes-openharmony/sdk/oniro-openharmony-thirdparty-integration-3.0.inc @@ -2,5 +2,6 @@ # # SPDX-License-Identifier: Apache-2.0 -# This file is intentionally left empty. -# It is needed so the 'require' statement in oniro-openharmony-thirdparty-integration.bb doesn't fail +SRC_URI += "file://third_party/libunwind/BUILD.gn;subdir=src/overlay" +SRC_URI += "file://patches/no-processdump.patch;apply=no;subdir=src" +SRC_URI += "file://patches/hiviewdfx_faultloggerd_local_unwind_unused_variables.patch;apply=no;subdir=src" diff --git a/recipes-openharmony/sdk/openharmony-3.0/BUILD.gn b/recipes-openharmony/sdk/openharmony-3.0/BUILD.gn index 636b13056ee4189e247a953ac8ea38d1a86e1560..9fddcb66f402bc7fc68fe35b5bfb5ea0b54a9204 100644 --- a/recipes-openharmony/sdk/openharmony-3.0/BUILD.gn +++ b/recipes-openharmony/sdk/openharmony-3.0/BUILD.gn @@ -9,6 +9,7 @@ group("third_party") { deps = [ "//third_party/openssl:libcrypto", "//third_party/openssl:libssl", + "//third_party/libunwind:libunwind", ] } } diff --git a/recipes-openharmony/sdk/openharmony-3.0/patches/hiviewdfx_faultloggerd_local_unwind_unused_variables.patch b/recipes-openharmony/sdk/openharmony-3.0/patches/hiviewdfx_faultloggerd_local_unwind_unused_variables.patch new file mode 100644 index 0000000000000000000000000000000000000000..027fabc3e5b74a6112c272598c0b5cf81c167fe9 --- /dev/null +++ b/recipes-openharmony/sdk/openharmony-3.0/patches/hiviewdfx_faultloggerd_local_unwind_unused_variables.patch @@ -0,0 +1,25 @@ +# SPDX-FileCopyrightText: Huawei Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +Patch for //base/hiviewdfx/faultloggerd git repository of OpenHarmony 3.0 codebase. + +This fixes warning about unused variables when using musl, which (depending on +compiler version) can be promoted to an error, and thus break compilation. + +Signed-off-by: Esben Haabendal <esben@geanix.com> +Upstream-Status: Pending + +--- a/base/hiviewdfx/faultloggerd/interfaces/innerkits/signal_handler/dfx_signal_handler.c 2023-02-20 10:19:50.406718524 +0100 ++++ b/base/hiviewdfx/faultloggerd/interfaces/innerkits/signal_handler/dfx_signal_handler.c 2023-02-20 10:20:41.980303697 +0100 +@@ -79,8 +79,10 @@ + static struct ProcessDumpRequest g_request; + static void *g_reservedChildStack; + static pthread_mutex_t g_signalHandlerMutex = PTHREAD_MUTEX_INITIALIZER; ++#ifndef DFX_LOCAL_UNWIND + static pthread_mutex_t g_dumpMutex = PTHREAD_MUTEX_INITIALIZER; + static int g_pipefd[2] = {-1, -1}; ++#endif + static BOOL g_hasInit = FALSE; + + enum DumpPreparationStage { diff --git a/recipes-openharmony/sdk/openharmony-3.0/patches/no-processdump.patch b/recipes-openharmony/sdk/openharmony-3.0/patches/no-processdump.patch new file mode 100644 index 0000000000000000000000000000000000000000..5e577395f40b63d9b258ef8c48ad3ec652f7e4bd --- /dev/null +++ b/recipes-openharmony/sdk/openharmony-3.0/patches/no-processdump.patch @@ -0,0 +1,25 @@ +# SPDX-FileCopyrightText: Huawei Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +Patch for //base/hiviewdfx/faultloggerd repository of OpenHarmony 3.0 codebase. + +The processdump tool relies on remote unwind feature of libunwind, which is not +supported by the LLVM libunwind version. The processdump tool is not a required +feature, so by dropping it, we can get rid of the libunwind fork, and avoid +having to convince meta-clang to use the non-LLVM libunwind library. + +Signed-off-by: Esben Haabendal <esben@geanix.com> +Upstream-Status: Inappropriate [configuration/integration] + +diff a/base/hiviewdfx/faultloggerd/ohos.build b/base/hiviewdfx/faultloggerd/ohos.build +--- a/base/hiviewdfx/faultloggerd/ohos.build 2023-02-14 18:40:25.662946940 +0100 ++++ b/base/hiviewdfx/faultloggerd/ohos.build 2023-02-14 16:07:18.840350031 +0100 +@@ -5,7 +5,6 @@ + "module_list": [ + "//base/hiviewdfx/faultloggerd/interfaces/innerkits/signal_handler:dfx_signalhandler", + "//base/hiviewdfx/faultloggerd/interfaces/innerkits/faultloggerd_client:libfaultloggerd", +- "//base/hiviewdfx/faultloggerd/tools/process_dump:processdump", + "//base/hiviewdfx/faultloggerd/services:faultloggerd" + ], + "test_list": [ diff --git a/recipes-openharmony/sdk/openharmony-3.0/third_party/libunwind/BUILD.gn b/recipes-openharmony/sdk/openharmony-3.0/third_party/libunwind/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..59186e0f7809cbae4f25ba4ccc00c504cb32a5d8 --- /dev/null +++ b/recipes-openharmony/sdk/openharmony-3.0/third_party/libunwind/BUILD.gn @@ -0,0 +1,14 @@ +# SPDX-FileCopyrightText: Huawei Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +import("//build/ohos.gni") +import("//oniro/third_party.gni") + +ohos_prebuilt_shared_library("libunwind") { + source = "//oniro/sysroots/target/usr/lib/libunwind.so.1.0" + subsystem_name = "hiviewdfx" + part_name = "faultloggerd" + install_enable = install_oniro_third_party + install_images = [ "system", "updater" ] +}