From 3427393a9b551c525fdc8c395f555c3005180848 Mon Sep 17 00:00:00 2001 From: fangting Date: Mon, 19 Aug 2024 21:27:46 +0800 Subject: [PATCH 01/25] update tag update tag Issue:#IAL2EO Signed-off-by: fangting --- build/third_party_gn/googletest/BUILD.gn | 175 +++-- build/third_party_gn/icu/icu4c/BUILD.gn | 16 +- build/third_party_gn/libuv/BUILD.gn | 35 +- build/third_party_gn/libuv/src/log_ohos.c | 20 + build/third_party_gn/libuv/src/trace_ohos.c | 19 + build/third_party_gn/musl/BUILD.gn | 69 +- build/third_party_gn/musl/musl_src.gni | 720 +++++++++++++------- build/third_party_gn/musl/musl_template.gni | 105 +-- build/third_party_gn/openssl/BUILD.gn | 4 + 9 files changed, 732 insertions(+), 431 deletions(-) create mode 100644 build/third_party_gn/libuv/src/log_ohos.c create mode 100644 build/third_party_gn/libuv/src/trace_ohos.c diff --git a/build/third_party_gn/googletest/BUILD.gn b/build/third_party_gn/googletest/BUILD.gn index 05146504..04449d71 100644 --- a/build/third_party_gn/googletest/BUILD.gn +++ b/build/third_party_gn/googletest/BUILD.gn @@ -19,8 +19,22 @@ config("gtest_private_config") { include_dirs = [ "$googletest_dir" ] } +config("gtest_private_config_rtti") { + visibility = [ ":*" ] + include_dirs = [ "googletest" ] + cflags = [ "-frtti" ] + cflags_objcc = [ "-frtti" ] + cflags_cc = [ "-frtti" ] +} + config("gtest_config") { include_dirs = [ "$googletest_dir/include" ] + cflags_cc = [ + "-std=c++17", + "-Wno-float-equal", + "-Wno-sign-compare", + "-Wno-reorder-init-list", + ] if (is_mingw) { cflags_cc = [ "-Wno-unused-const-variable", @@ -29,57 +43,74 @@ config("gtest_config") { } } +sources_files = [ + "$googletest_dir/include/gtest/gtest-death-test.h", + "$googletest_dir/include/gtest/gtest-matchers.h", + "$googletest_dir/include/gtest/gtest-message.h", + "$googletest_dir/include/gtest/gtest-param-test.h", + "$googletest_dir/include/gtest/gtest-printers.h", + "$googletest_dir/include/gtest/gtest-test-part.h", + "$googletest_dir/include/gtest/gtest-typed-test.h", + "$googletest_dir/include/gtest/gtest_pred_impl.h", + "$googletest_dir/include/gtest/gtest_prod.h", + "$googletest_dir/include/gtest/hwext/gtest-ext.h", + "$googletest_dir/include/gtest/hwext/gtest-filter.h", + "$googletest_dir/include/gtest/hwext/gtest-multithread.h", + "$googletest_dir/include/gtest/hwext/gtest-tag.h", + "$googletest_dir/include/gtest/hwext/utils.h", + "$googletest_dir/include/gtest/internal/custom/gtest-port.h", + "$googletest_dir/include/gtest/internal/custom/gtest-printers.h", + "$googletest_dir/include/gtest/internal/custom/gtest.h", + "$googletest_dir/include/gtest/internal/gtest-death-test-internal.h", + "$googletest_dir/include/gtest/internal/gtest-filepath.h", + "$googletest_dir/include/gtest/internal/gtest-internal.h", + "$googletest_dir/include/gtest/internal/gtest-param-util.h", + "$googletest_dir/include/gtest/internal/gtest-port-arch.h", + "$googletest_dir/include/gtest/internal/gtest-port.h", + "$googletest_dir/include/gtest/internal/gtest-string.h", + "$googletest_dir/include/gtest/internal/gtest-type-util.h", + "$googletest_dir/src/gtest-all.cc", + "$googletest_dir/src/gtest-assertion-result.cc", + "$googletest_dir/src/gtest-death-test.cc", + "$googletest_dir/src/gtest-filepath.cc", + "$googletest_dir/src/gtest-internal-inl.h", + "$googletest_dir/src/gtest-matchers.cc", + "$googletest_dir/src/gtest-port.cc", + "$googletest_dir/src/gtest-printers.cc", + "$googletest_dir/src/gtest-test-part.cc", + "$googletest_dir/src/gtest-typed-test.cc", + "$googletest_dir/src/gtest.cc", + "$googletest_dir/src/hwext/gtest-ext.cc", + "$googletest_dir/src/hwext/gtest-filter.cc", + "$googletest_dir/src/hwext/gtest-multithread.cpp", + "$googletest_dir/src/hwext/gtest-tag.cc", + "$googletest_dir/src/hwext/gtest-utils.cc", +] + static_library("gtest") { testonly = true public = [ "$googletest_dir/include/gtest/gtest-spi.h", "$googletest_dir/include/gtest/gtest.h", ] - sources = [ - "$googletest_dir/include/gtest/gtest-death-test.h", - "$googletest_dir/include/gtest/gtest-matchers.h", - "$googletest_dir/include/gtest/gtest-message.h", - "$googletest_dir/include/gtest/gtest-param-test.h", - "$googletest_dir/include/gtest/gtest-printers.h", - "$googletest_dir/include/gtest/gtest-test-part.h", - "$googletest_dir/include/gtest/gtest-typed-test.h", - "$googletest_dir/include/gtest/gtest_pred_impl.h", - "$googletest_dir/include/gtest/gtest_prod.h", - "$googletest_dir/include/gtest/hwext/gtest-ext.h", - "$googletest_dir/include/gtest/hwext/gtest-filter.h", - "$googletest_dir/include/gtest/hwext/gtest-tag.h", - "$googletest_dir/include/gtest/hwext/utils.h", - "$googletest_dir/include/gtest/internal/custom/gtest-port.h", - "$googletest_dir/include/gtest/internal/custom/gtest-printers.h", - "$googletest_dir/include/gtest/internal/custom/gtest.h", - "$googletest_dir/include/gtest/internal/gtest-death-test-internal.h", - "$googletest_dir/include/gtest/internal/gtest-filepath.h", - "$googletest_dir/include/gtest/internal/gtest-internal.h", - "$googletest_dir/include/gtest/internal/gtest-param-util.h", - "$googletest_dir/include/gtest/internal/gtest-port-arch.h", - "$googletest_dir/include/gtest/internal/gtest-port.h", - "$googletest_dir/include/gtest/internal/gtest-string.h", - "$googletest_dir/include/gtest/internal/gtest-type-util.h", - "$googletest_dir/src/gtest-all.cc", - "$googletest_dir/src/gtest-death-test.cc", - "$googletest_dir/src/gtest-filepath.cc", - "$googletest_dir/src/gtest-internal-inl.h", - "$googletest_dir/src/gtest-matchers.cc", - "$googletest_dir/src/gtest-port.cc", - "$googletest_dir/src/gtest-printers.cc", - "$googletest_dir/src/gtest-test-part.cc", - "$googletest_dir/src/gtest-typed-test.cc", - "$googletest_dir/src/gtest.cc", - "$googletest_dir/src/hwext/gtest-ext.cc", - "$googletest_dir/src/hwext/gtest-filter.cc", - "$googletest_dir/src/hwext/gtest-tag.cc", - "$googletest_dir/src/hwext/gtest-utils.cc", - ] + sources = sources_files sources -= [ "$googletest_dir/src/gtest-all.cc" ] public_configs = [ ":gtest_config" ] configs += [ ":gtest_private_config" ] } +static_library("gtest_rtti") { + testonly = true + public = [ + "$googletest_dir/include/gtest/gtest-spi.h", + "$googletest_dir/include/gtest/gtest.h", + ] + sources = sources_files + sources -= [ "$googletest_dir/src/gtest-all.cc" ] + public_configs = [ ":gtest_config" ] + configs += [ ":gtest_private_config_rtti" ] +} + static_library("gtest_main") { testonly = true sources = [ "$googletest_dir/src/gtest_main.cc" ] @@ -91,6 +122,14 @@ config("gmock_private_config") { include_dirs = [ "$googlemock_dir" ] } +config("gmock_private_config_rtti") { + visibility = [ ":*" ] + include_dirs = [ "googlemock_dir/include" ] + cflags = [ "-frtti" ] + cflags_objcc = [ "-frtti" ] + cflags_cc = [ "-frtti" ] +} + config("gmock_config") { include_dirs = [ "$googlemock_dir/include" ] @@ -104,37 +143,49 @@ config("gmock_config") { ] } +gmock_sources_files = [ + "$googlemock_dir/include/gmock/gmock-actions.h", + "$googlemock_dir/include/gmock/gmock-cardinalities.h", + "$googlemock_dir/include/gmock/gmock-function-mocker.h", + "$googlemock_dir/include/gmock/gmock-matchers.h", + "$googlemock_dir/include/gmock/gmock-more-actions.h", + "$googlemock_dir/include/gmock/gmock-more-matchers.h", + "$googlemock_dir/include/gmock/gmock-nice-strict.h", + "$googlemock_dir/include/gmock/gmock-spec-builders.h", + "$googlemock_dir/include/gmock/internal/custom/gmock-generated-actions.h", + "$googlemock_dir/include/gmock/internal/custom/gmock-matchers.h", + "$googlemock_dir/include/gmock/internal/custom/gmock-port.h", + "$googlemock_dir/include/gmock/internal/gmock-internal-utils.h", + "$googlemock_dir/include/gmock/internal/gmock-port.h", + "$googlemock_dir/include/gmock/internal/gmock-pp.h", + "$googlemock_dir/src/gmock-all.cc", + "$googlemock_dir/src/gmock-cardinalities.cc", + "$googlemock_dir/src/gmock-internal-utils.cc", + "$googlemock_dir/src/gmock-matchers.cc", + "$googlemock_dir/src/gmock-spec-builders.cc", + "$googlemock_dir/src/gmock.cc", +] + static_library("gmock") { testonly = true public = [ "$googlemock_dir/include/gmock/gmock.h" ] - sources = [ - "$googlemock_dir/include/gmock/gmock-actions.h", - "$googlemock_dir/include/gmock/gmock-cardinalities.h", - "$googlemock_dir/include/gmock/gmock-function-mocker.h", - "$googlemock_dir/include/gmock/gmock-matchers.h", - "$googlemock_dir/include/gmock/gmock-more-actions.h", - "$googlemock_dir/include/gmock/gmock-more-matchers.h", - "$googlemock_dir/include/gmock/gmock-nice-strict.h", - "$googlemock_dir/include/gmock/gmock-spec-builders.h", - "$googlemock_dir/include/gmock/internal/custom/gmock-generated-actions.h", - "$googlemock_dir/include/gmock/internal/custom/gmock-matchers.h", - "$googlemock_dir/include/gmock/internal/custom/gmock-port.h", - "$googlemock_dir/include/gmock/internal/gmock-internal-utils.h", - "$googlemock_dir/include/gmock/internal/gmock-port.h", - "$googlemock_dir/include/gmock/internal/gmock-pp.h", - "$googlemock_dir/src/gmock-all.cc", - "$googlemock_dir/src/gmock-cardinalities.cc", - "$googlemock_dir/src/gmock-internal-utils.cc", - "$googlemock_dir/src/gmock-matchers.cc", - "$googlemock_dir/src/gmock-spec-builders.cc", - "$googlemock_dir/src/gmock.cc", - ] + sources = gmock_sources_files sources -= [ "$googlemock_dir/src/gmock-all.cc" ] public_configs = [ ":gmock_config" ] configs += [ ":gmock_private_config" ] deps = [ ":gtest" ] } +static_library("gmock_rtti") { + testonly = true + public = [ "$googlemock_dir/include/gmock/gmock.h" ] + sources = gmock_sources_files + sources -= [ "$googlemock_dir/src/gmock-all.cc" ] + public_configs = [ ":gmock_config" ] + configs += [ ":gmock_private_config_rtti" ] + deps = [ ":gtest_rtti" ] +} + static_library("gmock_main") { testonly = true sources = [ "$googlemock_dir/src/gmock_main.cc" ] diff --git a/build/third_party_gn/icu/icu4c/BUILD.gn b/build/third_party_gn/icu/icu4c/BUILD.gn index 082ce8bc..cafe6465 100644 --- a/build/third_party_gn/icu/icu4c/BUILD.gn +++ b/build/third_party_gn/icu/icu4c/BUILD.gn @@ -499,13 +499,7 @@ ohos_shared_library("shared_icuuc") { "-shared", "-lm", ] - if (current_os == "ios") { - ldflags += [ - "-Wl", - "-install_name", - "@rpath/libhmicuuc.framework/libhmicuuc", - ] - } + configs = [ ":icu_config", "$build_root/config/compiler:rtti", @@ -552,14 +546,6 @@ ohos_shared_library("shared_icuuc") { install_enable = true } -if (current_os == "ios") { - ohos_combine_darwin_framework("libhmicuuc") { - deps = [ ":shared_icuuc" ] - subsystem_name = "thirdparty" - part_name = "icu" - } -} - ohos_shared_library("shared_icui18n") { ldflags = [ "-shared", diff --git a/build/third_party_gn/libuv/BUILD.gn b/build/third_party_gn/libuv/BUILD.gn index b7276c26..5bb82bb0 100644 --- a/build/third_party_gn/libuv/BUILD.gn +++ b/build/third_party_gn/libuv/BUILD.gn @@ -20,6 +20,7 @@ common_source = [ "//third_party/libuv/src/random.c", "//third_party/libuv/src/strscpy.c", "//third_party/libuv/src/threadpool.c", + "//third_party/libuv/src/thread-common.c", "//third_party/libuv/src/timer.c", "//third_party/libuv/src/uv-common.c", "//third_party/libuv/src/uv-data-getter-setters.c", @@ -28,7 +29,6 @@ common_source = [ ] if (!is_mingw && !is_win) { nonwin_srcs = [ - "//third_party/libuv/src/unix/epoll.c", "//third_party/libuv/src/unix/async.c", "//third_party/libuv/src/unix/core.c", "//third_party/libuv/src/unix/dl.c", @@ -57,6 +57,7 @@ config("libuv_config") { "//third_party/libuv/src", "//third_party/libuv/src/unix", ] + defines = [] cflags = [ "-Wno-unused-parameter" ] if (is_linux || is_ohos) { cflags += [ @@ -68,7 +69,7 @@ config("libuv_config") { # Adding NDEBUG macro manually to avoid compilation # error in debug version, FIX ME # https://gitee.com/openharmony/build/pulls/1206/files - defines = [ "NDEBUG" ] + defines += [ "NDEBUG" ] } else if (is_mingw || is_win) { cflags += [ "-Wno-missing-braces", @@ -79,7 +80,7 @@ config("libuv_config") { "-Wno-error=unknown-pragmas", "-Wno-unused-variable", ] - defines = [ + defines += [ "WIN32_LEAN_AND_MEAN", "_WIN32_WINNT=0x0600", ] @@ -98,7 +99,7 @@ config("libuv_config") { "ws2_32", ] } else if (is_android) { - defines = [ "_GNU_SOURCE" ] + defines += [ "_GNU_SOURCE" ] } } @@ -122,7 +123,7 @@ ohos_source_set("libuv_source") { stack_protector_ret = false configs = [ ":libuv_config" ] sources = common_source - + external_deps = [] if (is_mac || (defined(is_ios) && is_ios)) { sources += nonwin_srcs + [ "//third_party/libuv/src/unix/bsd-ifaddrs.c", @@ -132,8 +133,9 @@ ohos_source_set("libuv_source") { "//third_party/libuv/src/unix/darwin.c", "//third_party/libuv/src/unix/fsevents.c", "//third_party/libuv/src/unix/os390-proctitle.c", + "//third_party/libuv/src/unix/log_unix.c", + "//third_party/libuv/src/unix/trace_unix.c", ] - sources -= [ "//third_party/libuv/src/unix/epoll.c" ] } else if (is_mingw || is_win) { sources += [ "//third_party/libuv/src/win/async.c", @@ -146,6 +148,7 @@ ohos_source_set("libuv_source") { "//third_party/libuv/src/win/getaddrinfo.c", "//third_party/libuv/src/win/getnameinfo.c", "//third_party/libuv/src/win/handle.c", + "//third_party/libuv/src/win/log_win.c", "//third_party/libuv/src/win/loop-watcher.c", "//third_party/libuv/src/win/pipe.c", "//third_party/libuv/src/win/poll.c", @@ -156,6 +159,7 @@ ohos_source_set("libuv_source") { "//third_party/libuv/src/win/stream.c", "//third_party/libuv/src/win/tcp.c", "//third_party/libuv/src/win/thread.c", + "//third_party/libuv/src/win/trace_win.c", "//third_party/libuv/src/win/tty.c", "//third_party/libuv/src/win/udp.c", "//third_party/libuv/src/win/util.c", @@ -164,31 +168,30 @@ ohos_source_set("libuv_source") { ] } else if (is_ohos || (defined(is_android) && is_android)) { sources += nonwin_srcs + [ - "//third_party/libuv/src/unix/linux-core.c", - "//third_party/libuv/src/unix/linux-inotify.c", - "//third_party/libuv/src/unix/linux-syscalls.c", + "//third_party/libuv/src/unix/linux.c", "//third_party/libuv/src/unix/procfs-exepath.c", - "//third_party/libuv/src/unix/pthread-fixes.c", "//third_party/libuv/src/unix/random-getentropy.c", "//third_party/libuv/src/unix/random-getrandom.c", "//third_party/libuv/src/unix/random-sysctl-linux.c", "//third_party/libuv/src/unix/proctitle.c", ] + sources += [ + "src/log_ohos.c", + "src/trace_ohos.c", + ] } else if (is_linux) { sources += nonwin_srcs + [ - "//third_party/libuv/src/unix/linux-core.c", - "//third_party/libuv/src/unix/linux-inotify.c", - "//third_party/libuv/src/unix/linux-syscalls.c", + "//third_party/libuv/src/unix/linux.c", "//third_party/libuv/src/unix/procfs-exepath.c", "//third_party/libuv/src/unix/random-getrandom.c", "//third_party/libuv/src/unix/random-sysctl-linux.c", "//third_party/libuv/src/unix/proctitle.c", + "//third_party/libuv/src/unix/log_unix.c", + "//third_party/libuv/src/unix/trace_unix.c", ] } else { sources += nonwin_srcs + [ - "//third_party/libuv/src/unix/linux-core.c", - "//third_party/libuv/src/unix/linux-inotify.c", - "//third_party/libuv/src/unix/linux-syscalls.c", + "//third_party/libuv/src/unix/linux.c", "//third_party/libuv/src/unix/procfs-exepath.c", "//third_party/libuv/src/unix/random-getrandom.c", "//third_party/libuv/src/unix/random-sysctl-linux.c", diff --git a/build/third_party_gn/libuv/src/log_ohos.c b/build/third_party_gn/libuv/src/log_ohos.c new file mode 100644 index 00000000..adca6ab0 --- /dev/null +++ b/build/third_party_gn/libuv/src/log_ohos.c @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "uv_log.h" + +int uv__log_impl(enum uv__log_level level, const char* fmt, ...) +{ + return 0; +} \ No newline at end of file diff --git a/build/third_party_gn/libuv/src/trace_ohos.c b/build/third_party_gn/libuv/src/trace_ohos.c new file mode 100644 index 00000000..d288639d --- /dev/null +++ b/build/third_party_gn/libuv/src/trace_ohos.c @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include +#define UV_TRACE_TAG (1ULL << 30) + +void uv_start_trace(uint64_t tag, const char* name) {} +void uv_end_trace(uint64_t tag) {} \ No newline at end of file diff --git a/build/third_party_gn/musl/BUILD.gn b/build/third_party_gn/musl/BUILD.gn index 2b827ba2..8cbfe3ec 100644 --- a/build/third_party_gn/musl/BUILD.gn +++ b/build/third_party_gn/musl/BUILD.gn @@ -39,41 +39,46 @@ action("create_porting_src") { outdir = [ "${target_out_dir}/${musl_ported_dir}" ] src_files = musl_src_arch_file - src_files += musl_inc_root_files - src_files += musl_inc_fortify_files - src_files += musl_inc_sys_files - src_files += musl_inc_scsi_files - src_files += musl_inc_netpacket_files - src_files += musl_inc_netinet_files - src_files += musl_inc_net_files - src_files += musl_inc_arpa_files - src_files += musl_inc_bits_files - src_files += musl_src_ldso src_files += musl_src_file + src_files += musl_src_ldso + src_files += musl_inc_bits_files + src_files += musl_inc_arpa_files + src_files += musl_inc_net_files + src_files += musl_inc_netinet_files + src_files += musl_inc_netpacket_files + src_files += musl_inc_scsi_files + src_files += musl_inc_sys_files + src_files += musl_inc_fortify_files + src_files += musl_inc_root_files + src_files += musl_inc_info_files + src_files += musl_inc_trace_files src_files += [ - "scripts/create_syscall.sh", - "scripts/create_vesion.sh", - "scripts/create_alltypes.sh", - "scripts/install.py", - "tools/install.sh", - "tools/version.sh", - "VERSION", - "include/alltypes.h.in", - "arch/${musl_arch}/bits/syscall.h.in", - "arch/${musl_arch}/bits/alltypes.h.in", - "tools/mkalltypes.sed", - "crt/rcrt1.c", - "crt/crt1.c", "crt/Scrt1.c", - "crt/${musl_arch}/crtn.s", + "crt/crt1.c", + "crt/rcrt1.c", + "tools/mkalltypes.sed", + "arch/${musl_arch}/bits/alltypes.h.in", + "arch/${musl_arch}/bits/syscall.h.in", + "include/alltypes.h.in", + "VERSION", + "tools/version.sh", + "tools/install.sh", + "scripts/install.py", + "scripts/create_alltypes.sh", + "scripts/create_vesion.sh", + "scripts/create_syscall.sh", + ] + src_files += [ "crt/${musl_arch}/crti.s", + "crt/${musl_arch}/crtn.s", ] + args = [ "-i" ] + rebase_path(sources_dir) args += [ "-o" ] + rebase_path(outdir) args += [ "-p" ] + [ "${musl_target_os}" ] foreach(i, src_files) { - foreach(s, musl_src_porting_file) { + foreach(s, musl_src_files_ext) { if (i == s) { src_files -= [ "${s}" ] } @@ -85,16 +90,24 @@ action("create_porting_src") { outputs += [ "${target_out_dir}/${musl_ported_dir}/${s}" ] } - foreach(s, musl_src_porting_file) { + foreach(s, musl_src_files_ext) { outputs += [ "${target_out_dir}/${musl_ported_dir}/${s}" ] } + inputs = [] + foreach(i, src_files) { + foreach(s, musl_src_linux_files) { + if (i == s) { + src_files -= [ "${s}" ] + } + } + } foreach(s, src_files) { inputs += [ "${musl_dir}/${s}" ] } - foreach(s, musl_src_porting_file) { - inputs += [ "${musl_porting_dir}/${s}" ] + foreach(s, musl_src_files_ext) { + inputs += [ "${musl_dir}/${s}" ] } } diff --git a/build/third_party_gn/musl/musl_src.gni b/build/third_party_gn/musl/musl_src.gni index eeb0267d..aa32f5cc 100644 --- a/build/third_party_gn/musl/musl_src.gni +++ b/build/third_party_gn/musl/musl_src.gni @@ -14,6 +14,7 @@ import("//third_party/FreeBSD/FreeBSD.gni") import("$build_root/third_party_gn/musl/musl_config.gni") +OPTRTDIR = "//third_party/optimized-routines/" if (musl_arch == "arm") { musl_src_arch_file = [ "src/exit/arm/__aeabi_atexit.c", @@ -21,7 +22,6 @@ if (musl_arch == "arm") { "src/fenv/arm/fenv.c", "src/ldso/arm/dlsym.s", "src/ldso/arm/dlsym_time64.S", - "src/ldso/arm/dlvsym.s", "src/ldso/arm/find_exidx.c", "src/ldso/arm/tlsdesc.S", "src/math/arm/fabs.c", @@ -44,6 +44,7 @@ if (musl_arch == "arm") { "src/thread/arm/atomics.s", "src/thread/arm/clone.s", "src/thread/arm/syscall_cp.s", + "src/linux/arm/flock.s", "compat/time32/adjtime32.c", "compat/time32/adjtimex_time32.c", "compat/time32/aio_suspend_time32.c", @@ -113,7 +114,6 @@ if (musl_arch == "arm") { musl_src_arch_file = [ "src/fenv/aarch64/fenv.s", "src/ldso/aarch64/dlsym.s", - "src/ldso/aarch64/dlvsym.s", "src/ldso/aarch64/tlsdesc.s", "src/math/aarch64/ceil.c", "src/math/aarch64/ceilf.c", @@ -152,15 +152,58 @@ if (musl_arch == "arm") { "src/thread/aarch64/__set_thread_area.s", "src/thread/aarch64/__unmapself.s", "src/thread/aarch64/clone.s", - "src/misc/aarch64/fstat.s", "src/thread/aarch64/syscall_cp.s", - "src/misc/aarch64/syscall.s", + "src/linux/aarch64/flock.s", + ] +} else if (musl_arch == "mips") { + musl_src_arch_file = [ + "src/fenv/mips/fenv-sf.c", + "src/fenv/mips/fenv.S", + "src/ldso/mips/dlsym_time64.S", + "src/ldso/mips/dlsym.s", + "src/math/mips/fabs.c", + "src/math/mips/fabsf.c", + "src/math/mips/sqrt.c", + "src/math/mips/sqrtf.c", + "src/setjmp/mips/longjmp.S", + "src/setjmp/mips/setjmp.S", + "src/signal/mips/sigsetjmp.s", + "src/thread/mips/__unmapself.s", + "src/thread/mips/clone.s", + "src/thread/mips/syscall_cp.s", + "src/unistd/mips/pipe.s", + ] +} else if (musl_arch == "riscv64") { + musl_src_arch_file = [ + "src/fenv/riscv64/fenv-sf.c", + "src/fenv/riscv64/fenv.S", + "src/ldso/riscv64/dlsym.s", + "src/ldso/riscv64/tlsdesc.s", + "src/math/riscv64/copysign.c", + "src/math/riscv64/copysignf.c", + "src/math/riscv64/fabs.c", + "src/math/riscv64/fabsf.c", + "src/math/riscv64/fma.c", + "src/math/riscv64/fmaf.c", + "src/math/riscv64/fmax.c", + "src/math/riscv64/fmaxf.c", + "src/math/riscv64/fmin.c", + "src/math/riscv64/fminf.c", + "src/math/riscv64/sqrt.c", + "src/math/riscv64/sqrtf.c", + "src/setjmp/riscv64/longjmp.S", + "src/setjmp/riscv64/setjmp.S", + "src/signal/riscv64/restore.s", + "src/signal/riscv64/sigsetjmp.s", + "src/thread/riscv64/__set_thread_area.s", + "src/thread/riscv64/__unmapself.s", + "src/thread/riscv64/clone.s", + "src/thread/riscv64/syscall_cp.s", ] } else if (musl_arch == "x86_64") { musl_src_arch_file = [ "src/fenv/x86_64/fenv.s", "src/ldso/x86_64/dlsym.s", - "src/ldso/x86_64/dlvsym.s", "src/ldso/x86_64/tlsdesc.s", "src/math/x86_64/__invtrigl.s", "src/math/x86_64/acosl.s", @@ -205,38 +248,32 @@ if (musl_arch == "arm") { "src/thread/x86_64/__unmapself.s", "src/thread/x86_64/clone.s", "src/thread/x86_64/syscall_cp.s", + "src/linux/x86_64/flock.s", ] -} else if (musl_arch == "mips") { +} else if (musl_arch == "loongarch64") { musl_src_arch_file = [ - "src/fenv/mips/fenv.S", - "src/fenv/mips/fenv-sf.c", - "src/ldso/mips/dlsym.s", - "src/ldso/mips/dlsym_time64.S", - "src/math/mips/fabs.c", - "src/math/mips/fabsf.c", - "src/math/mips/sqrt.c", - "src/math/mips/sqrtf.c", - "src/setjmp/mips/longjmp.S", - "src/setjmp/mips/setjmp.S", - "src/signal/mips/restore.s", - "src/signal/mips/sigsetjmp.s", - "src/thread/mips/__unmapself.s", - "src/thread/mips/clone.s", - "src/thread/mips/syscall_cp.s", + "src/fenv/loongarch64/fenv.S", + "src/ldso/loongarch64/dlsym.s", + "src/ldso/loongarch64/tlsdesc.s", + "src/setjmp/loongarch64/longjmp.S", + "src/setjmp/loongarch64/setjmp.S", + "src/signal/loongarch64/restore.s", + "src/signal/loongarch64/sigsetjmp.s", + "src/thread/loongarch64/__set_thread_area.s", + "src/thread/loongarch64/__unmapself.s", + "src/thread/loongarch64/clone.s", + "src/thread/loongarch64/syscall_cp.s", ] } musl_src_file = [ - "src/thread/pthread_cond_clockwait.c", - "src/thread/pthread_cond_timedwait_monotonic_np.c", - "src/thread/pthread_cond_timeout_np.c", "src/internal/pthread_impl.h", "src/internal/locale_impl.h", - "src/thread/pthread_rwlock_clockrdlock.c", + "src/internal/locale_impl.c", + "src/internal/stdio_impl.h", + "src/internal/unsupported_api.h", + "src/internal/syscall_hooks.h", "src/thread/pthread_rwlock_timedrdlock.c", - "src/thread/pthread_rwlock_timedrdlock_monotonic_np.c", - "src/thread/pthread_rwlock_clockwrlock.c", - "src/thread/pthread_rwlock_timedwrlock_monotonic_np.c", "src/thread/pthread_rwlock_timedwrlock.c", "src/aio/aio.c", "src/aio/aio_suspend.c", @@ -391,6 +428,7 @@ musl_src_file = [ "src/exit/at_quick_exit.c", "src/exit/atexit.c", "src/exit/exit.c", + "src/exit/cxa_thread_atexit_impl.c", "src/exit/quick_exit.c", "src/fcntl/creat.c", "src/fcntl/fcntl.c", @@ -398,6 +436,7 @@ musl_src_file = [ "src/fcntl/openat.c", "src/fcntl/posix_fadvise.c", "src/fcntl/posix_fallocate.c", + "src/fdsan/fdsan.c", "src/fenv/__flt_rounds.c", "src/fenv/fegetexceptflag.c", "src/fenv/feholdexcept.c", @@ -406,6 +445,8 @@ musl_src_file = [ "src/fenv/fesetround.c", "src/fenv/feupdateenv.c", "src/fortify/fortify.c", + "src/gwp_asan/gwp_asan.c", + "src/gwp_asan/gwp_asan.h", "src/internal/defsysinfo.c", "src/internal/floatscan.c", "src/internal/intscan.c", @@ -413,9 +454,7 @@ musl_src_file = [ "src/internal/procfdname.c", "src/internal/shgetc.c", "src/internal/syscall_ret.c", - "src/internal/vdso.c", "src/internal/version.c", - "src/internal/network_conf_function.c", "src/hilog/hilog_adapter.c", "src/hilog/vsnprintf_s_p.c", "src/ipc/ftok.c", @@ -488,15 +527,14 @@ musl_src_file = [ "src/linux/open_by_handle_at.c", "src/linux/personality.c", "src/linux/pivot_root.c", - "src/linux/ppoll.c", "src/linux/prctl.c", + "src/linux/preadv2.c", "src/linux/prlimit.c", "src/linux/process_vm.c", "src/linux/ptrace.c", "src/linux/quotactl.c", "src/linux/readahead.c", "src/linux/reboot.c", - "src/linux/tgkill.c", "src/linux/remap_file_pages.c", "src/linux/sbrk.c", "src/linux/sendfile.c", @@ -508,6 +546,7 @@ musl_src_file = [ "src/linux/settimeofday.c", "src/linux/signalfd.c", "src/linux/splice.c", + "src/linux/statx.c", "src/linux/stime.c", "src/linux/swap.c", "src/linux/sync_file_range.c", @@ -521,6 +560,7 @@ musl_src_file = [ "src/linux/vmsplice.c", "src/linux/wait3.c", "src/linux/wait4.c", + "src/linux/pwritev2.c", "src/linux/xattr.c", "src/locale/__lctrans.c", "src/locale/__mo_lookup.c", @@ -542,6 +582,7 @@ musl_src_file = [ "src/locale/setlocale.c", "src/locale/strcoll.c", "src/locale/strtod_l.c", + "src/locale/wcstod_l.c", "src/locale/strfmon.c", "src/locale/strxfrm.c", "src/locale/textdomain.c", @@ -556,8 +597,6 @@ musl_src_file = [ "src/malloc/mallocng/malloc.c", "src/malloc/mallocng/meta.h", "src/malloc/mallocng/realloc.c", - "src/malloc/stats.c", - "src/malloc/calloc.c", "src/malloc/free.c", "src/malloc/libc_calloc.c", "src/malloc/lite_malloc.c", @@ -1029,6 +1068,7 @@ musl_src_file = [ "src/regex/regerror.c", "src/regex/regexec.c", "src/regex/tre-mem.c", + "src/syscall_hooks/syscall_hooks.c", "src/sched/sched_cpualloc.c", "src/sched/affinity.c", "src/sched/sched_cpucount.c", @@ -1049,6 +1089,7 @@ musl_src_file = [ "src/search/tsearch.c", "src/search/twalk.c", "src/select/poll.c", + "src/select/ppoll.c", "src/select/pselect.c", "src/select/select.c", "src/setjmp/longjmp.c", @@ -1091,7 +1132,6 @@ musl_src_file = [ "src/signal/sigtimedwait.c", "src/signal/sigwait.c", "src/signal/sigwaitinfo.c", - "src/sigchain/sigchain.c", "src/stat/__xstat.c", "src/stat/chmod.c", "src/stat/fchmod.c", @@ -1250,6 +1290,7 @@ musl_src_file = [ "src/stdlib/strtol.c", "src/stdlib/wcstod.c", "src/stdlib/wcstol.c", + "src/string/strcspn.c", "src/string/bcmp.c", "src/string/bcopy.c", "src/string/bzero.c", @@ -1268,13 +1309,11 @@ musl_src_file = [ "src/string/stpcpy.c", "src/string/stpncpy.c", "src/string/strcasecmp.c", - "src/string/strcasestr.c", "src/string/strcat.c", "src/string/strchr.c", "src/string/strchrnul.c", "src/string/strcmp.c", "src/string/strcpy.c", - "src/string/strcspn.c", "src/string/strdup.c", "src/string/strerror_r.c", "src/string/strlcat.c", @@ -1415,9 +1454,6 @@ musl_src_file = [ "src/thread/pthread_mutex_lock.c", "src/thread/pthread_mutex_setprioceiling.c", "src/thread/pthread_mutex_timedlock.c", - "src/thread/pthread_mutex_clocklock.c", - "src/thread/pthread_mutex_timedlock_monotonic_np.c", - "src/thread/pthread_mutex_lock_timeout_np.c", "src/thread/pthread_mutex_trylock.c", "src/thread/pthread_mutex_unlock.c", "src/thread/pthread_mutexattr_destroy.c", @@ -1596,6 +1632,39 @@ musl_src_file = [ "src/info/application_target_sdk_version.c", "src/info/device_api_version.c", "src/info/fatal_message.c", + "arch/generic/crtbrand.s", + "crt/crtplus.c", + "ldso/namespace.h", + "ldso/ns_config.h", + "ldso/strops.h", + "ldso/cfi.h", + "ldso/ld_log.h", + "ldso/dynlink_rand.h", + "src/internal/vdso.c", + "src/internal/emulate_wait4.c", + "src/internal/malloc_config.h", + "src/internal/malloc_random.h", + "src/internal/hilog_adapter.h", + "src/internal/musl_log.h", + "src/internal/musl_log.c", + "src/internal/network_conf_function.c", + "src/internal/network_conf_function.h", + "src/internal/services.h", + "src/internal/proc_xid_impl.h", + "src/linux/tgkill.c", + "src/malloc/calloc.c", + "src/malloc/stats.c", + "src/sigchain/sigchain.c", + "src/thread/pthread_cond_clockwait.c", + "src/thread/pthread_cond_timedwait_monotonic_np.c", + "src/thread/pthread_cond_timeout_np.c", + "src/thread/pthread_mutex_clocklock.c", + "src/thread/pthread_mutex_timedlock_monotonic_np.c", + "src/thread/pthread_mutex_lock_timeout_np.c", + "src/thread/pthread_rwlock_clockrdlock.c", + "src/thread/pthread_rwlock_timedrdlock_monotonic_np.c", + "src/thread/pthread_rwlock_clockwrlock.c", + "src/thread/pthread_rwlock_timedwrlock_monotonic_np.c", ] if (musl_arch == "arm") { @@ -1718,13 +1787,54 @@ if (musl_arch == "arm") { musl_src_filterout = [ "src/fenv/fenv.c", "src/ldso/dlsym.c", + "src/ldso/tlsdesc.c", + "src/math/fabs.c", + "src/math/fabsf.c", + "src/math/sqrt.c", + "src/math/sqrtf.c", + "src/setjmp/longjmp.c", + "src/setjmp/setjmp.c", + "src/signal/restore.c", + "src/signal/sigsetjmp.c", + "src/thread/__unmapself.c", + "src/thread/clone.c", + "src/thread/syscall_cp.c", + "src/unistd/pipe.c", + ] +} else if (musl_arch == "riscv64") { + musl_src_filterout = [ + "src/fenv/fenv.c", + "src/ldso/dlsym.c", + "src/ldso/tlsdesc.c", "src/math/fabs.c", "src/math/fabsf.c", + "src/math/fma.c", "src/math/fmaf.c", + "src/math/fmax.c", + "src/math/fmaxf.c", + "src/math/fmin.c", + "src/math/fminf.c", "src/math/sqrt.c", "src/math/sqrtf.c", + "src/setjmp/longjmp.c", "src/setjmp/setjmp.c", "src/signal/restore.c", + "src/signal/sigsetjmp.c", + "src/thread/__set_thread_area.c", + "src/thread/__unmapself.c", + "src/thread/clone.c", + "src/thread/syscall_cp.c", + ] +} else if (musl_arch == "loongarch64") { + musl_src_filterout = [ + "src/fenv/fenv.c", + "src/ldso/dlsym.c", + "src/ldso/tlsdesc.c", + "src/setjmp/longjmp.c", + "src/setjmp/setjmp.c", + "src/signal/restore.c", + "src/signal/sigsetjmp.c", + "src/thread/__set_thread_area.c", "src/thread/__unmapself.c", "src/thread/clone.c", "src/thread/syscall_cp.c", @@ -1828,7 +1938,6 @@ if (musl_arch == "arm") { "arch/x86_64/bits/stat.h", "arch/x86_64/bits/stdint.h", "arch/x86_64/bits/user.h", - "arch/generic/bits/dirent.h", "arch/generic/bits/errno.h", "arch/generic/bits/hwcap.h", @@ -1855,40 +1964,115 @@ if (musl_arch == "arm") { ] } else if (musl_arch == "mips") { musl_inc_bits_files = [ - "arch/mips/bits/errno.h", - "arch/mips/bits/fcntl.h", + "arch/generic/bits/fcntl.h", "arch/mips/bits/fenv.h", "arch/mips/bits/float.h", - "arch/mips/bits/hwcap.h", - "arch/mips/bits/ioctl.h", - "arch/mips/bits/ipcstat.h", - "arch/mips/bits/mman.h", - "arch/mips/bits/msg.h", - "arch/mips/bits/poll.h", "arch/mips/bits/posix.h", - "arch/mips/bits/ptrace.h", "arch/mips/bits/reg.h", - "arch/mips/bits/resource.h", - "arch/mips/bits/sem.h", "arch/mips/bits/setjmp.h", - "arch/mips/bits/shm.h", "arch/mips/bits/signal.h", - "arch/mips/bits/socket.h", "arch/mips/bits/stat.h", - "arch/mips/bits/statfs.h", "arch/mips/bits/stdint.h", - "arch/mips/bits/termios.h", "arch/mips/bits/user.h", + "arch/generic/bits/dirent.h", + "arch/generic/bits/errno.h", + "arch/generic/bits/hwcap.h", "arch/generic/bits/ioctl_fix.h", + "arch/generic/bits/ioctl.h", "arch/generic/bits/io.h", "arch/generic/bits/ipc.h", + "arch/generic/bits/ipcstat.h", "arch/generic/bits/kd.h", "arch/generic/bits/limits.h", "arch/generic/bits/link.h", + "arch/generic/bits/mman.h", + "arch/generic/bits/msg.h", + "arch/generic/bits/poll.h", + "arch/generic/bits/ptrace.h", + "arch/generic/bits/resource.h", + "arch/generic/bits/sem.h", + "arch/generic/bits/shm.h", + "arch/generic/bits/socket.h", "arch/generic/bits/soundcard.h", + "arch/generic/bits/statfs.h", + "arch/generic/bits/termios.h", "arch/generic/bits/vt.h", ] +} else if (musl_arch == "riscv64") { + musl_inc_bits_files = [ + "arch/generic/bits/fcntl.h", + "arch/riscv64/bits/fenv.h", + "arch/riscv64/bits/float.h", + "arch/riscv64/bits/posix.h", + "arch/riscv64/bits/reg.h", + "arch/riscv64/bits/setjmp.h", + "arch/riscv64/bits/signal.h", + "arch/riscv64/bits/stat.h", + "arch/riscv64/bits/stdint.h", + "arch/riscv64/bits/user.h", + + "arch/generic/bits/dirent.h", + "arch/generic/bits/errno.h", + "arch/generic/bits/hwcap.h", + "arch/generic/bits/ioctl_fix.h", + "arch/generic/bits/ioctl.h", + "arch/generic/bits/io.h", + "arch/generic/bits/ipc.h", + "arch/generic/bits/ipcstat.h", + "arch/generic/bits/kd.h", + "arch/generic/bits/limits.h", + "arch/generic/bits/link.h", + "arch/generic/bits/mman.h", + "arch/generic/bits/msg.h", + "arch/generic/bits/poll.h", + "arch/generic/bits/ptrace.h", + "arch/generic/bits/resource.h", + "arch/generic/bits/sem.h", + "arch/generic/bits/shm.h", + "arch/generic/bits/socket.h", + "arch/generic/bits/soundcard.h", + "arch/generic/bits/statfs.h", + "arch/generic/bits/termios.h", + "arch/generic/bits/vt.h", + ] +} else if (musl_arch == "loongarch64") { + musl_inc_bits_files = [ + "arch/loongarch64/bits/fenv.h", + "arch/loongarch64/bits/float.h", + "arch/loongarch64/bits/posix.h", + "arch/loongarch64/bits/reg.h", + "arch/loongarch64/bits/setjmp.h", + "arch/loongarch64/bits/signal.h", + "arch/loongarch64/bits/stat.h", + "arch/loongarch64/bits/stdint.h", + "arch/loongarch64/bits/user.h", + + "arch/generic/bits/dirent.h", + "arch/generic/bits/errno.h", + "arch/generic/bits/hwcap.h", + "arch/generic/bits/ioctl_fix.h", + "arch/generic/bits/ioctl.h", + "arch/generic/bits/io.h", + "arch/generic/bits/ipc.h", + "arch/generic/bits/ipcstat.h", + "arch/generic/bits/kd.h", + "arch/generic/bits/link.h", + "arch/generic/bits/mman.h", + "arch/generic/bits/msg.h", + "arch/generic/bits/poll.h", + "arch/generic/bits/sem.h", + "arch/generic/bits/shm.h", + "arch/generic/bits/socket.h", + "arch/generic/bits/soundcard.h", + "arch/generic/bits/termios.h", + "arch/generic/bits/vt.h", + "arch/generic/bits/statfs.h", + "arch/generic/bits/ptrace.h", + "arch/generic/bits/resource.h", + "arch/generic/bits/fcntl.h", + "arch/generic/bits/limits.h", + ] } musl_inc_arpa_files = [ @@ -2117,239 +2301,245 @@ musl_inc_root_files = [ "include/wchar.h", "include/wctype.h", "include/wordexp.h", + "include/syscall_hooks.h", + "include/pthread_ffrt.h", ] -musl_src_porting_file = [ - "arch/aarch64/syscall_arch.h", - "arch/arm/bits/fenv.h", - "arch/generic/bits/shm.h", - "arch/generic/crtbrand.s", - "arch/x86_64/bits/float.h", - "include/ctype.h", - "include/info/application_target_sdk_version.h", - "include/info/device_api_version.h", - "include/info/fatal_message.h", - "include/malloc.h", - "include/pthread.h", - "include/fcntl.h", - "include/poll.h", - "include/stdio.h", - "include/stdlib.h", - "include/string.h", - "include/sys/stat.h", - "include/sys/sspret.h", - "include/sys/cdefs.h", - "include/fortify/fcntl.h", - "include/fortify/fortify.h", - "include/fortify/poll.h", - "include/fortify/socket.h", - "include/fortify/stat.h", - "include/fortify/stdlib.h", - "include/fortify/string.h", - "include/fortify/unistd.h", - "include/fortify/stdio.h", +musl_src_files_ext = [ + "src/internal/linux/musl_log.c", + "src/internal/linux/vdso.c", + "src/hook/linux/malloc_common.c", + "src/hook/linux/musl_preinit.c", + "src/hook/linux/musl_socket_preinit.c", + "src/hook/linux/socket_common.c", + "src/hook/linux/memory_trace.c", + "src/hook/linux/musl_fdtrack.c", + "src/hook/linux/musl_fdtrack_load.c", + "src/hook/linux/musl_preinit_common.c", + "src/hook/linux/musl_socket_preinit_common.c", + "crt/linux/crtplus.c", + "src/linux/arm/linux/flock.s", + "src/linux/aarch64/linux/flock.s", + "src/linux/x86_64/linux/flock.s", + "src/exit/linux/assert.c", + "src/exit/linux/atexit.c", + "src/fdsan/linux/fdsan.c", + "src/fortify/linux/fortify.c", + "src/gwp_asan/linux/gwp_asan.c", + "src/gwp_asan/linux/gwp_asan.h", + "src/hilog/linux/hilog_adapter.c", + "src/hilog/linux/hilog_common.h", + "src/hilog/linux/output_p.inl", + "src/hilog/linux/vsnprintf_s_p.c", + "src/hilog/linux/vsnprintf_s_p.h", + "src/linux/linux/clone.c", + "src/linux/linux/getprocpid.c", + "src/network/linux/getaddrinfo.c", + "src/syscall_hooks/linux/syscall_hooks.c", + "src/signal/linux/sigaction.c", + "src/thread/linux/pthread_create.c", + "src/trace/linux/trace_marker.c", + "include/trace/linux/trace_marker.h", + "src/info/linux/application_target_sdk_version.c", + "src/info/linux/device_api_version.c", + "src/info/linux/fatal_message.c", + "ldso/linux/cfi.c", + "ldso/linux/dynlink.c", + "ldso/linux/dynlink_rand.h", + "ldso/linux/ld_log.h", + "ldso/linux/namespace.h", + "ldso/linux/ns_config.h", + "ldso/linux/strops.c", + "ldso/linux/zip_archive.h", + "ldso/linux/cfi.h", + "ldso/linux/dynlink_rand.c", + "ldso/linux/ld_log.c", + "ldso/linux/namespace.c", + "ldso/linux/ns_config.c", + "ldso/linux/strops.h", + "include/sys/linux/capability.h", + "include/sys/linux/cdefs.h", + "include/sys/linux/sspret.h", + "include/info/linux/application_target_sdk_version.h", + "include/info/linux/device_api_version.h", + "include/info/linux/fatal_message.h", + "include/fortify/linux/fcntl.h", + "include/fortify/linux/poll.h", + "include/fortify/linux/stat.h", + "include/fortify/linux/stdlib.h", + "include/fortify/linux/unistd.h", + "include/fortify/linux/fortify.h", + "include/fortify/linux/socket.h", + "include/fortify/linux/stdio.h", + "include/fortify/linux/string.h", + "include/linux/dlfcn_ext.h", + "include/linux/sigchain.h", + "include/linux/syscall_hooks.h", + "src/ldso/arm/linux/dlvsym.s", + "src/ldso/aarch64/linux/dlvsym.s", + "src/ldso/x86_64/linux/dlvsym.s", + "src/misc/aarch64/linux/fstat.s", + "src/misc/aarch64/linux/syscall.s", + "src/malloc/linux/calloc.c", + "src/malloc/linux/stats.c", + "src/sigchain/linux/sigchain.c", + "src/internal/linux/malloc_config.h", + "src/internal/linux/proc_xid_impl.h", + "src/internal/linux/malloc_random.h", + "src/internal/linux/musl_log.h", + "src/internal/linux/syscall_hooks.h", + "src/hook/linux/common_def.h", + "src/hook/linux/musl_fdtrack.h", + "src/hook/linux/musl_fdtrack_hook.h", + "src/hook/linux/musl_malloc_dispatch.h", + "src/hook/linux/musl_malloc_dispatch_table.h", + "src/hook/linux/musl_preinit_common.h", + "src/hook/linux/musl_malloc.h", + "src/hook/linux/musl_socket_dispatch.h", + "src/hook/linux/musl_socket_preinit_common.h", + "src/hook/linux/memory_trace.h", + "src/hook/linux/musl_socket.h", +] + +musl_src_linux_files = [ + "src/internal/malloc_config.h", + "src/internal/proc_xid_impl.h", + "src/internal/malloc_random.h", + "src/internal/musl_log.h", + "src/internal/syscall_hooks.h", + "src/hook/common_def.h", + "src/hook/musl_fdtrack.h", + "src/hook/musl_fdtrack_hook.h", + "src/hook/musl_malloc_dispatch.h", + "src/hook/musl_malloc_dispatch_table.h", + "src/hook/musl_preinit_common.h", + "src/hook/musl_malloc.h", + "src/hook/musl_socket_dispatch.h", + "src/hook/musl_socket_preinit_common.h", + "src/hook/memory_trace.h", + "src/hook/musl_socket.h", + "src/internal/musl_log.c", + "src/internal/vdso.c", + "src/hook/malloc_common.c", + "src/hook/musl_preinit.c", + "src/hook/musl_socket_preinit.c", + "src/hook/socket_common.c", + "src/hook/memory_trace.c", + "src/hook/musl_fdtrack.c", + "src/hook/musl_fdtrack_load.c", + "src/hook/musl_preinit_common.c", + "src/hook/musl_socket_preinit_common.c", + "crt/crtplus.c", + "src/linux/arm/flock.s", + "src/linux/aarch64/flock.s", + "src/linux/x86_64/flock.s", + "src/exit/assert.c", + "src/exit/atexit.c", + "src/fdsan/fdsan.c", "src/fortify/fortify.c", - "include/sys/capability.h", - "include/sys/reboot.h", - "include/sys/socket.h", - "include/sys/sysinfo.h", - "include/signal.h", - "include/sigchain.h", - "include/sched.h", - "src/internal/dynlink.h", - "include/sys/tgkill.h", - "include/trace/trace_marker.h", - "include/unistd.h", - "include/dlfcn.h", - "include/dlfcn_ext.h", - "src/fcntl/open.c", + "src/gwp_asan/gwp_asan.c", + "src/gwp_asan/gwp_asan.h", + "src/hilog/hilog_adapter.c", "src/hilog/hilog_common.h", + "src/hilog/output_p.inl", + "src/hilog/vsnprintf_s_p.c", "src/hilog/vsnprintf_s_p.h", - "src/internal/hilog_adapter.h", - "src/internal/musl_log.h", - "src/info/application_target_sdk_version.c", - "src/info/device_api_version.c", - "src/info/fatal_message.c", - "src/env/__init_tls.c", - "src/env/__libc_start_main.c", - "src/internal/pthread_impl.h", - "src/internal/locale_impl.h", - "src/internal/syscall.h", - "src/internal/services.h", - "src/internal/network_conf_function.h", - "src/internal/network_conf_function.c", - "src/internal/proc_xid_impl.h", - "ldso/namespace.h", - "ldso/ns_config.h", - "ldso/strops.h", - "src/legacy/ulimit.c", "src/linux/clone.c", "src/linux/getprocpid.c", - "src/linux/reboot.c", - "src/linux/tgkill.c", - "src/malloc/mallocng/malloc_usable_size.c", - "src/malloc/mallocng/malloc.c", - "src/malloc/mallocng/meta.h", - "src/malloc/mallocng/donate.c", - "src/malloc/mallocng/aligned_alloc.c", - "src/malloc/lite_malloc.c", - "src/malloc/stats.c", - "src/malloc/calloc.c", - "src/malloc/free.c", - "src/network/getnameinfo.c", - "src/malloc/libc_calloc.c", - "src/malloc/realloc.c", - "src/network/inet_legacy.c", - "src/network/lookup_name.c", - "src/network/lookup_serv.c", - "src/network/resolvconf.c", - "src/network/socket.c", - "src/passwd/getspnam_r.c", - "src/sched/sched_setparam.c", - "src/sched/sched_getparam.c", - "src/sched/sched_setscheduler.c", - "src/sched/sched_getscheduler.c", - "src/thread/arm/clone.s", - "src/thread/arm/syscall_cp.s", - "src/thread/pthread_mutex_clocklock.c", - "src/thread/pthread_mutex_timedlock.c", - "src/thread/pthread_mutex_lock.c", - "src/thread/pthread_mutex_timedlock_monotonic_np.c", - "src/thread/pthread_mutex_lock_timeout_np.c", - "src/thread/pthread_mutex_init.c", - "src/thread/pthread_rwlock_clockrdlock.c", - "src/thread/pthread_rwlock_timedrdlock.c", - "src/thread/pthread_rwlock_timedrdlock_monotonic_np.c", - "src/thread/pthread_rwlock_init.c", - "src/thread/pthread_cond_timedwait.c", - "src/thread/pthread_cond_timedwait_monotonic_np.c", - "src/thread/pthread_cond_timeout_np.c", - "src/thread/pthread_cond_clockwait.c", - "src/thread/pthread_cond_init.c", + "src/network/getaddrinfo.c", + "src/syscall_hooks/syscall_hooks.c", + "src/signal/sigaction.c", "src/thread/pthread_create.c", - "src/thread/pthread_rwlock_clockwrlock.c", - "src/thread/pthread_rwlock_timedwrlock_monotonic_np.c", - "src/thread/pthread_rwlock_timedwrlock.c", - "src/thread/pthread_sigmask.c", "src/trace/trace_marker.c", - "src/ldso/dlclose.c", - "src/ldso/dlerror.c", + "include/trace/trace_marker.h", + "src/info/application_target_sdk_version.c", + "src/info/device_api_version.c", + "src/info/fatal_message.c", + "ldso/cfi.c", "ldso/dynlink.c", - "src/exit/atexit.c", - "crt/arm/crti.s", - "crt/aarch64/crti.s", - "crt/crtplus.c", - "ldso/cfi.h", + "ldso/dynlink_rand.h", "ldso/ld_log.h", + "ldso/namespace.h", + "ldso/ns_config.h", + "ldso/strops.c", + "ldso/zip_archive.h", + "ldso/cfi.h", + "ldso/dynlink_rand.c", "ldso/ld_log.c", "ldso/namespace.c", "ldso/ns_config.c", - "ldso/strops.c", - "ldso/cfi.c", - "ldso/dynlink_rand.c", - "ldso/dynlink_rand.h", - "src/sched/sched_cpualloc.c", - "src/signal/signal.c", - "src/signal/sigaction.c", - "src/signal/siginterrupt.c", - "include/langinfo.h", - "include/locale.h", - "src/hilog/hilog_adapter.c", - "src/hilog/vsnprintf_s_p.c", - "src/internal/libc.h", - "src/locale/dcngettext.c", - "src/locale/locale_map.c", - "src/locale/langinfo.c", - "src/locale/newlocale.c", - "src/time/__tz.c", - "src/time/gmtime_r.c", - "src/time/strftime.c", - "src/time/strptime.c", - "src/time/time_impl.h", - "src/ldso/aarch64/dlvsym.s", + "ldso/strops.h", + "include/sys/capability.h", + "include/sys/cdefs.h", + "include/sys/sspret.h", + "include/info/application_target_sdk_version.h", + "include/info/device_api_version.h", + "include/info/fatal_message.h", + "include/fortify/fcntl.h", + "include/fortify/poll.h", + "include/fortify/stat.h", + "include/fortify/stdlib.h", + "include/fortify/unistd.h", + "include/fortify/fortify.h", + "include/fortify/socket.h", + "include/fortify/stdio.h", + "include/fortify/string.h", + "include/dlfcn_ext.h", + "include/sigchain.h", + "include/syscall_hooks.h", "src/ldso/arm/dlvsym.s", - "src/ldso/riscv64/dlvsym.s", + "src/ldso/aarch64/dlvsym.s", "src/ldso/x86_64/dlvsym.s", - "src/stdio/__fdopen.c", - "src/stdio/vfprintf.c", - "src/stdio/__stdio_read.c", - "src/stdio/__stdio_write.c", - "src/stdio/__stdout_write.c", - "src/stdio/fread.c", - "src/stdio/fmemopen.c", - "src/stdio/freopen.c", - "src/stdio/stdin.c", - "src/stdio/__fmodeflags.c", - "src/stdio/fopen.c", - "src/stdio/ofl.c", - "src/stdio/fclose.c", - "src/stdio/__toread.c", - "src/stdio/__towrite.c", - "src/stdio/stderr.c", - "src/stdio/fgets.c", - "src/stdio/vsnprintf.c", - "src/stdio/vsscanf.c", - "src/internal/stdio_impl.h", - "src/internal/vdso.c", - "src/time/clock_gettime.c", - "src/time/clock_getres.c", - "src/time/gettimeofday.c", - "src/time/time.c", - "src/unistd/getpid.c", - "src/process/_Fork.c", - "src/process/vfork.c", - "src/process/arm/__vfork.s", - "src/process/x86_64/__vfork.s", - "src/linux/cache.c", - "src/sched/sched_getcpu.c", - "src/sigchain/sigchain.c", - "src/conf/legacy.c", - "src/conf/sysconf.c", - "src/env/getenv.c", - "src/string/strcasecmp.c", - "src/string/strncasecmp.c", - "src/string/strncat.c", - "src/string/stpncpy.c", - "src/string/strncpy.c", - "src/stat/fstat.c", - "src/string/strcspn.c", - "src/thread/pthread_once.c", - "src/thread/pthread_cancel.c", - "src/mq/mq_notify.c", - "src/aio/aio.c", "src/misc/aarch64/fstat.s", "src/misc/aarch64/syscall.s", - "src/stdlib/strtol.c", - "src/stdlib/strtod.c", - "src/thread/sem_timedwait.c", - "src/stdio/vfscanf.c", - "src/stdio/fileno.c", + "src/malloc/calloc.c", + "src/malloc/stats.c", + "src/sigchain/sigchain.c", ] +if (musl_arch == "arm") { + musl_src_file += [ + "src/process/arm/__vfork.s", + "src/ldso/arm/dlvsym.s", + ] +} else if (musl_arch == "aarch64") { + musl_src_file += [ + "arch/aarch64/syscall_arch.h", + "src/misc/aarch64/fstat.s", + "src/misc/aarch64/syscall.s", + "src/ldso/aarch64/dlvsym.s", + ] +} else if (musl_arch == "loongarch64") { + musl_src_file += [ "arch/loongarch64/syscall_arch.h" ] +} else if (musl_arch == "x86_64") { + musl_src_file += [ + "src/process/x86_64/__vfork.s", + "src/ldso/x86_64/dlvsym.s", + ] +} + musl_inc_hook_files = [ - "//third_party/musl/porting/linux/user/src/internal/hilog_adapter.h", - "//third_party/musl/porting/linux/user/src/internal/musl_log.h", - "//third_party/musl/porting/linux/user/src/hook/memory_trace.h", - "//third_party/musl/porting/linux/user/src/hook/musl_malloc_dispatch_table.h", - "//third_party/musl/porting/linux/user/src/hook/musl_malloc_dispatch.h", - "//third_party/musl/porting/linux/user/src/hook/musl_preinit_common.h", + "//third_party/musl/src/internal/hilog_adapter.h", + "//third_party/musl/src/internal/linux/musl_log.h", + "//third_party/musl/src/hook/linux/memory_trace.h", + "//third_party/musl/src/hook/linux/musl_fdtrack.h", + "//third_party/musl/src/hook/linux/musl_fdtrack_hook.h", + "//third_party/musl/src/hook/linux/musl_malloc_dispatch_table.h", + "//third_party/musl/src/hook/linux/musl_malloc_dispatch.h", + "//third_party/musl/src/hook/linux/musl_preinit_common.h", + "//third_party/musl/src/hook/linux/musl_socket_dispatch.h", ] added_freebsd_files = [ - "$FREEBSD_DIR/contrib/gdtoa/strtod.c", - "$FREEBSD_DIR/contrib/gdtoa/gethex.c", - "$FREEBSD_DIR/contrib/gdtoa/smisc.c", - "$FREEBSD_DIR/contrib/gdtoa/misc.c", - "$FREEBSD_DIR/contrib/gdtoa/strtord.c", - "$FREEBSD_DIR/contrib/gdtoa/hexnan.c", - "$FREEBSD_DIR/contrib/gdtoa/gmisc.c", - "$FREEBSD_DIR/contrib/gdtoa/hd_init.c", - "$FREEBSD_DIR/contrib/gdtoa/strtodg.c", - "$FREEBSD_DIR/contrib/gdtoa/ulp.c", - "$FREEBSD_DIR/contrib/gdtoa/strtof.c", - "$FREEBSD_DIR/contrib/gdtoa/sum.c", - "$FREEBSD_DIR/lib/libc/gdtoa/glue.c", - "$FREEBSD_DIR/lib/libc/stdio/parsefloat.c", + "$FREEBSD_DIR/contrib/tcp_wrappers/strcasecmp.c", + "$FREEBSD_DIR/lib/libc/gen/arc4random.c", + "$FREEBSD_DIR/lib/libc/gen/arc4random_uniform.c", + "$FREEBSD_DIR/lib/libc/stdlib/qsort.c", + "$FREEBSD_DIR/lib/libc/stdlib/strtoimax.c", + "$FREEBSD_DIR/lib/libc/stdlib/strtoul.c", + "$FREEBSD_DIR/lib/libc/stdlib/strtoumax.c", ] +freebsd_headers = [ "$FREEBSD_DIR/contrib/libexecinfo/execinfo.h" ] + freebsd_sys_headers = [ "$FREEBSD_DIR/sys/sys/queue.h" ] diff --git a/build/third_party_gn/musl/musl_template.gni b/build/third_party_gn/musl/musl_template.gni index 84c653b5..c62f882f 100644 --- a/build/third_party_gn/musl/musl_template.gni +++ b/build/third_party_gn/musl/musl_template.gni @@ -302,6 +302,7 @@ template("musl_libs") { "//third_party/jemalloc/include/", "//third_party/jemalloc/include/jemalloc/internal", "//third_party/jemalloc/include/jemalloc", + "//third_party/FreeBSD/contrib/libexecinfo", ] } @@ -333,25 +334,43 @@ template("musl_libs") { source_set("soft_musl_src") { sources_orig = [] sources = [] - + include_dirs = [] sources_orig = musl_src_arch_file + musl_src_file + sources_orig -= musl_src_filterout sources_orig -= [ - "src/env/__stack_chk_fail.c", - "src/env/__libc_start_main.c", - "src/env/__init_tls.c", - "src/string/memset.c", "src/string/mempcpy.c", + "src/string/memset.c", + "src/env/__init_tls.c", + "src/env/__libc_start_main.c", + "src/env/__stack_chk_fail.c", "src/stdlib/qsort.c", "src/stdlib/qsort_nr.c", - ] - if (musl_arch == "mips") { - sources_orig += [ "src/string/memset.c" ] - } - sources_orig -= musl_src_filterout - - sources += [ - "$FREEBSD_DIR/contrib/tcp_wrappers/strcasecmp.c", - "$FREEBSD_DIR/lib/libc/stdlib/qsort.c", + "src/string/strncpy.c", + ] + + freebsd_files = [ + "//third_party/FreeBSD/contrib/gdtoa/strtod.c", + "//third_party/FreeBSD/contrib/gdtoa/gethex.c", + "//third_party/FreeBSD/contrib/gdtoa/smisc.c", + "//third_party/FreeBSD/contrib/gdtoa/misc.c", + "//third_party/FreeBSD/contrib/gdtoa/strtord.c", + "//third_party/FreeBSD/contrib/gdtoa/hexnan.c", + "//third_party/FreeBSD/contrib/gdtoa/gmisc.c", + "//third_party/FreeBSD/contrib/gdtoa/hd_init.c", + "//third_party/FreeBSD/contrib/gdtoa/strtodg.c", + "//third_party/FreeBSD/contrib/gdtoa/ulp.c", + "//third_party/FreeBSD/contrib/gdtoa/strtof.c", + "//third_party/FreeBSD/contrib/gdtoa/sum.c", + "//third_party/FreeBSD/lib/libc/gdtoa/glue.c", + "//third_party/FreeBSD/lib/libc/stdio/parsefloat.c", + "//third_party/FreeBSD/contrib/tcp_wrappers/strcasecmp.c", + "//third_party/FreeBSD/lib/libc/gen/arc4random.c", + "//third_party/FreeBSD/lib/libc/gen/arc4random_uniform.c", + "//third_party/FreeBSD/lib/libc/stdlib/qsort.c", + "//third_party/FreeBSD/lib/libc/stdlib/strtoimax.c", + "//third_party/FreeBSD/lib/libc/stdlib/strtoul.c", + "//third_party/FreeBSD/lib/libc/stdlib/strtoumax.c", + "//third_party/musl/third_party/openbsd/lib/libc/string/strncpy.c", ] if (musl_arch == "arm") { @@ -382,6 +401,7 @@ template("musl_libs") { "src/math/powl.c", "src/math/sinf.c", "src/math/cosf.c", + "src/linux/flock.c", ] } else if (musl_arch == "aarch64") { sources_orig -= [ @@ -416,12 +436,23 @@ template("musl_libs") { "src/math/sincos.c", "src/math/pow.c", "src/math/powf.c", + "src/linux/flock.c", ] } else if (musl_arch == "x86_64") { - sources_orig -= [ "src/thread/${musl_arch}/__set_thread_area.s" ] + sources_orig -= [ + "src/thread/${musl_arch}/__set_thread_area.s", + "src/linux/flock.c", + ] } defines = [] + defines += [ "FEATURE_ICU_LOCALE" ] + + # There are two ways to implement cxa_thread_atexit_impl: + # - CXA_THREAD_USE_TSD(default): use pthread_key_xxx to implement cxa_thread_atexit_impl. + # - CXA_THREAD_USE_TLS: put dtors in pthread to implement cxa_thread_atexit_impl. + defines += [ "CXA_THREAD_USE_TSD" ] + if (musl_arch == "arm") { defines += [ "MUSL_ARM_ARCH" ] } @@ -477,8 +508,7 @@ template("musl_libs") { "$OPTRTDIR/string/arm/strcmp.S", "$OPTRTDIR/string/arm/strlen-armv6t2.S", ] - - sources += added_freebsd_files + sources += freebsd_files asmflags = [ "-D__memcpy_arm = memcpy", "-D__memchr_arm = memchr", @@ -487,6 +517,7 @@ template("musl_libs") { "-D__strlen_armv6t2 = strlen", ] } else if (musl_arch == "aarch64") { + sources += freebsd_files if (defined(ARM_FEATURE_SVE)) { sources += [ "$OPTRTDIR/string/aarch64/memchr-sve.S", @@ -565,7 +596,6 @@ template("musl_libs") { "$OPTRTDIR/string/aarch64/strnlen.S", "$OPTRTDIR/string/aarch64/strrchr.S", ] - sources += added_freebsd_files asmflags = [ "-D__memmove_aarch64 = memmove", "-D__memcpy_aarch64 = memcpy", @@ -588,37 +618,19 @@ template("musl_libs") { cflags = [ "-O3", "-fPIC", - "-ffreestanding", "-fstack-protector-strong", - "-flto", ] - if (use_jemalloc) { - defines += [ "USE_JEMALLOC" ] - if (use_jemalloc_dfx_intf) { - defines += [ "USE_JEMALLOC_DFX_INTF" ] - } - include_dirs = [ "//third_party/jemalloc/include/jemalloc" ] - } - - if (!defined(include_dirs)) { - if (musl_arch == "aarch64") { - include_dirs = [ "//third_party/FreeBSD/lib/libc/aarch64" ] - } - if (musl_arch == "arm") { - include_dirs = [ "//third_party/FreeBSD/lib/libc/arm" ] - } - } else { - if (musl_arch == "aarch64") { - include_dirs += [ "//third_party/FreeBSD/lib/libc/aarch64" ] - } - if (musl_arch == "arm") { - include_dirs += [ "//third_party/FreeBSD/lib/libc/arm" ] - } - } - configs -= musl_inherited_configs configs += [ ":soft_musl_config" ] + if (musl_arch == "aarch64") { + include_dirs += [ "//third_party/FreeBSD/lib/libc/aarch64" ] + } else if (musl_arch == "arm") { + include_dirs += [ "//third_party/FreeBSD/lib/libc/arm" ] + } + include_dirs += [ "//third_party/FreeBSD/lib/libc/include" ] + include_dirs += [ "//third_party/FreeBSD/contrib/libexecinfo" ] + include_dirs += [ "//third_party/FreeBSD/crypto/openssh/openbsd-compat" ] if (!defined(defines)) { defines = [] @@ -633,7 +645,8 @@ template("musl_libs") { defines += [ "TARGET_GUARD_SIZE=${_product_config.device_guard_size}" ] } } - + external_deps = [] + external_deps += [ "FreeBSD:libc_static" ] deps = porting_deps } @@ -827,6 +840,8 @@ template("musl_libs") { ":soft_musl_src_nossp", ":soft_musl_src_optimize", ] + external_deps = [] + external_deps = [ "FreeBSD:libc_static" ] output_name = "libc" complete_static_lib = true } diff --git a/build/third_party_gn/openssl/BUILD.gn b/build/third_party_gn/openssl/BUILD.gn index 0b311628..cae0e8ea 100644 --- a/build/third_party_gn/openssl/BUILD.gn +++ b/build/third_party_gn/openssl/BUILD.gn @@ -636,6 +636,10 @@ libdefault_common_sources = [ "//third_party/openssl/providers/implementations/ciphers/cipher_cts.c", "//third_party/openssl/providers/implementations/ciphers/cipher_null.c", "//third_party/openssl/providers/implementations/ciphers/cipher_sm4.c", + "//third_party/openssl/providers/implementations/ciphers/cipher_sm4_ccm.c", + "//third_party/openssl/providers/implementations/ciphers/cipher_sm4_ccm_hw.c", + "//third_party/openssl/providers/implementations/ciphers/cipher_sm4_gcm.c", + "//third_party/openssl/providers/implementations/ciphers/cipher_sm4_gcm_hw.c", "//third_party/openssl/providers/implementations/ciphers/cipher_sm4_hw.c", "//third_party/openssl/providers/implementations/ciphers/cipher_tdes.c", "//third_party/openssl/providers/implementations/ciphers/cipher_tdes_common.c", -- Gitee From 993819cbde1f9ffeeeabaa6c2ef23af9a28001ee Mon Sep 17 00:00:00 2001 From: xwx1135370 Date: Fri, 9 Aug 2024 16:50:48 +0800 Subject: [PATCH 02/25] =?UTF-8?q?[Bug]:=20Fix=20the=20musl=20feature=20con?= =?UTF-8?q?figured=20in=20part=5Fconfig=20=EF=BC=88cherry=20picked=20commi?= =?UTF-8?q?t=20from=20=20Signed-off-by:?= =?UTF-8?q?=20xwx1135370=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/third_party_gn/musl/BUILD.gn | 12 ++++++------ build/third_party_gn/musl/musl_config.gni | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/build/third_party_gn/musl/BUILD.gn b/build/third_party_gn/musl/BUILD.gn index 2b827ba2..93edf01c 100644 --- a/build/third_party_gn/musl/BUILD.gn +++ b/build/third_party_gn/musl/BUILD.gn @@ -149,7 +149,7 @@ action("create_syscall_h_file") { } uapi_from = "local" -uapi_full_path = rebase_path(uapi_dir) +uapi_full_path = rebase_path(musl_uapi_dir) arguments_uapi = [ "-c" ] # exclude these files because they need special treatment @@ -166,7 +166,7 @@ uspi_files = exec_script("/bin/sh", arguments_uapi, "list lines") # Generate a copy target for each file foreach(file, uspi_files) { copy("copy_uapi_${file}") { - sources = [ "${uapi_dir}/${file}" ] + sources = [ "${musl_uapi_dir}/${file}" ] outputs = [ "${target_out_dir}/${musl_inc_out_dir}/${file}" ] } } @@ -175,7 +175,7 @@ group("copy_uapi_scsi") { deps = [] sources = [] outputs = [] - uapi_scsi_dir = rebase_path("${uapi_dir}/scsi") + uapi_scsi_dir = rebase_path("${musl_uapi_dir}/scsi") arguments_scsi = [ "-c" ] arguments_scsi += [ "ls ${uapi_scsi_dir}" ] uapi_scsi_files = exec_script("/bin/sh", arguments_scsi, "list lines") @@ -183,7 +183,7 @@ group("copy_uapi_scsi") { # Generate a copy target for each file in scsi dir to avoid being influenced by musl_copy_inc_scsi output foreach(file, uapi_scsi_files) { copy("copy_uapi_scsi_${file}") { - sources += [ "${uapi_dir}/scsi/${file}" ] + sources += [ "${musl_uapi_dir}/scsi/${file}" ] outputs += [ "${target_out_dir}/${musl_inc_out_dir}/scsi/${file}" ] } deps += [ ":copy_uapi_scsi_${file}" ] @@ -197,9 +197,9 @@ copy("copy_uapi_asm") { } else { # aarch64 and x86_64 use same file file_name = "asm-arm64" } - sources = [ "${uapi_dir}/${file_name}/asm" ] + sources = [ "${musl_uapi_dir}/${file_name}/asm" ] } else { - sources = [ "${uapi_dir}/asm" ] + sources = [ "${musl_uapi_dir}/asm" ] } outputs = [ "${target_out_dir}/${musl_inc_out_dir}/asm" ] } diff --git a/build/third_party_gn/musl/musl_config.gni b/build/third_party_gn/musl/musl_config.gni index ceff6198..52814f23 100644 --- a/build/third_party_gn/musl/musl_config.gni +++ b/build/third_party_gn/musl/musl_config.gni @@ -45,10 +45,10 @@ declare_args() { declare_args() { runtime_lib_path = "//prebuilts/clang/ohos/linux-x86_64/llvm/lib/clang/15.0.4/lib" - use_jemalloc = false + musl_use_jemalloc = false musl_ported_dir = "intermidiates/${musl_target_os}/musl_src_ported" musl_inc_out_dir = "usr/include/${musl_target_triple}" - uapi_dir = "//kernel/linux/patches/linux-5.10/prebuilts/usr/include" + musl_uapi_dir = "//kernel/linux/patches/linux-5.10/prebuilts/usr/include" musl_dir = "//third_party/musl" musl_porting_dir = "//third_party/musl/porting/linux/user" } -- Gitee From 1921f7bd4b368e752f93c0239a27d8ad236f3e74 Mon Sep 17 00:00:00 2001 From: bigtea Date: Tue, 13 Aug 2024 15:28:45 +0800 Subject: [PATCH 03/25] Fix static variable multithreading issue Issue: IALMO9 Signed-off-by: bigtea --- tooling/backend/js_pt_hooks.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tooling/backend/js_pt_hooks.cpp b/tooling/backend/js_pt_hooks.cpp index c46f608b..2a8a06ec 100644 --- a/tooling/backend/js_pt_hooks.cpp +++ b/tooling/backend/js_pt_hooks.cpp @@ -19,6 +19,9 @@ #include "ecmascript/jspandafile/js_pandafile_manager.h" namespace panda::ecmascript::tooling { + +static std::atomic g_scriptId {0}; + void JSPtHooks::DebuggerStmt([[maybe_unused]] const JSPtLocation &location) { LOG_DEBUGGER(VERBOSE) << "JSPHooks: Debugger Statement"; @@ -87,8 +90,7 @@ void JSPtHooks::LoadModule(std::string_view pandaFileName, std::string_view entr [[maybe_unused]] LocalScope scope(debugger_->vm_); - static uint32_t scriptId = 0; - if (!debugger_->NotifyScriptParsed(scriptId++, pandaFileName.data(), entryPoint)) { + if (!debugger_->NotifyScriptParsed(g_scriptId++, pandaFileName.data(), entryPoint)) { LOG_DEBUGGER(DEBUG) << "JSPtHooks: LoadModule: " << pandaFileName << " NotifyParsed fail"; } } -- Gitee From 920db42fc2e0cce39f95be4722271fbe4e887aae Mon Sep 17 00:00:00 2001 From: yangxiaoshuai2022 Date: Sat, 10 Aug 2024 15:10:43 +0800 Subject: [PATCH 04/25] fix the non-standard naming of DLL Issue:https://gitee.com/openharmony/arkcompiler_toolchain/issues/IALS40 Signed-off-by: yangxiaoshuai2022 --- inspector/BUILD.gn | 2 ++ inspector/inspector.cpp | 6 +++--- tooling/BUILD.gn | 1 + tooling/test/client_utils/test_util.h | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/inspector/BUILD.gn b/inspector/BUILD.gn index 48d5efab..ed217326 100644 --- a/inspector/BUILD.gn +++ b/inspector/BUILD.gn @@ -69,6 +69,7 @@ ohos_shared_library("ark_debugger") { innerapi_tags = [ "platformsdk" ] subsystem_name = "arkcompiler" part_name = "toolchain" + output_name = "ark_inspector" } ohos_source_set("connectserver_debugger_static") { @@ -118,4 +119,5 @@ ohos_shared_library("connectserver_debugger") { innerapi_tags = [ "platformsdk" ] subsystem_name = "arkcompiler" part_name = "toolchain" + output_name = "ark_connect_inspector" } diff --git a/inspector/inspector.cpp b/inspector/inspector.cpp index 3292a9d6..265e1a1d 100644 --- a/inspector/inspector.cpp +++ b/inspector/inspector.cpp @@ -71,11 +71,11 @@ thread_local void* g_vm = nullptr; #if !defined(IOS_PLATFORM) #if defined(WINDOWS_PLATFORM) -constexpr char ARK_DEBUGGER_SHARED_LIB[] = "libark_ecma_debugger.dll"; +constexpr char ARK_DEBUGGER_SHARED_LIB[] = "libark_tooling.dll"; #elif defined(MAC_PLATFORM) -constexpr char ARK_DEBUGGER_SHARED_LIB[] = "libark_ecma_debugger.dylib"; +constexpr char ARK_DEBUGGER_SHARED_LIB[] = "libark_tooling.dylib"; #else -constexpr char ARK_DEBUGGER_SHARED_LIB[] = "libark_ecma_debugger.so"; +constexpr char ARK_DEBUGGER_SHARED_LIB[] = "libark_tooling.so"; #endif #endif diff --git a/tooling/BUILD.gn b/tooling/BUILD.gn index 2000fa87..9221adcb 100644 --- a/tooling/BUILD.gn +++ b/tooling/BUILD.gn @@ -127,6 +127,7 @@ ohos_shared_library("libark_ecma_debugger") { innerapi_tags = [ "platformsdk" ] subsystem_name = "arkcompiler" part_name = "toolchain" + output_name = "libark_tooling" } ohos_shared_library("libark_ecma_debugger_test") { diff --git a/tooling/test/client_utils/test_util.h b/tooling/test/client_utils/test_util.h index 81375f99..5fe22bbe 100644 --- a/tooling/test/client_utils/test_util.h +++ b/tooling/test/client_utils/test_util.h @@ -36,9 +36,9 @@ using TestMap = CUnorderedMap>; using namespace OHOS::ArkCompiler::Toolchain; #ifdef OHOS_PLATFORM -#define DEBUGGER_LIBRARY "libark_debugger.z.so" +#define DEBUGGER_LIBRARY "libark_inspector.z.so" #else -#define DEBUGGER_LIBRARY "libark_debugger.so" +#define DEBUGGER_LIBRARY "libark_inspector.so" #endif class TestUtil { -- Gitee From c1a13e8743d277960fc4ee63d77e0baebe8a0c5b Mon Sep 17 00:00:00 2001 From: yang-19970325 Date: Wed, 21 Aug 2024 17:25:48 +0800 Subject: [PATCH 05/25] Revert "sendable features" Issue: #IAMMZ3 Signed-off-by: yang-19970325 --- tooling/agent/debugger_impl.cpp | 159 +++++++-------------- tooling/agent/debugger_impl.h | 7 +- tooling/base/pt_types.h | 1 - tooling/test/debugger_cint_client_test.cpp | 1 - tooling/test/debugger_client_test.cpp | 1 - tooling/test/debugger_impl_test.cpp | 10 +- tooling/test/utils/test_extractor.cpp | 3 +- 7 files changed, 59 insertions(+), 123 deletions(-) diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index c2ee0ba6..f7d4974c 100755 --- a/tooling/agent/debugger_impl.cpp +++ b/tooling/agent/debugger_impl.cpp @@ -254,23 +254,8 @@ void DebuggerImpl::NotifyPaused(std::optional location, PauseReaso if (!MatchScripts(scriptFunc, location->GetSourceFile(), ScriptMatchType::URL) || extractor == nullptr || !extractor->MatchLineWithOffset(callbackLineFunc, methodId, offset) || !extractor->MatchColumnWithOffset(callbackColumnFunc, methodId, offset)) { - LOG_DEBUGGER(WARN) << "NotifyPaused: unknown file " << location->GetSourceFile(); - auto jsPandaFile = location->GetJsPandaFile(); - if (jsPandaFile == nullptr) { - LOG_DEBUGGER(WARN) << "NotifyPaused: jsPandaFile is nullptr"; - return; - } - CString moduleName = jsPandaFile->GetJSPandaFileDesc(); - CString recordName = location->GetRecordName(); - if (moduleName.empty() || recordName.empty()) { - LOG_DEBUGGER(WARN) << "NotifyPaused: try to reload module after paused failed"; - return; - } - hooks_->LoadModule(moduleName, recordName); - detail.url_ = location->GetSourceFile(); - detail.line_ = location->GetLine(); - detail.column_ = location->GetColumn(); - detail.needResetBreakpoint_ = location->GetNeedResetBreakpoint(); + LOG_DEBUGGER(ERROR) << "NotifyPaused: unknown file " << location->GetSourceFile(); + return; } hitBreakpoints.emplace_back(BreakpointDetails::ToString(detail)); } @@ -1075,8 +1060,7 @@ DispatchResponse DebuggerImpl::GetPossibleBreakpoints(const GetPossibleBreakpoin auto callbackFunc = [](const JSPtLocation &) -> bool { return true; }; - Global funcRef = Global(vm_, FunctionRef::Undefined(vm_)); - if (extractor->MatchWithLocation(callbackFunc, line, column, url, GetRecordName(url), funcRef)) { + if (extractor->MatchWithLocation(callbackFunc, line, column, url, GetRecordName(url))) { std::unique_ptr location = std::make_unique(); location->SetScriptId(start->GetScriptId()).SetLine(line).SetColumn(column); locations->emplace_back(std::move(location)); @@ -1121,13 +1105,8 @@ DispatchResponse DebuggerImpl::RemoveBreakpoint(const RemoveBreakpointParams &pa return true; }; if (!MatchScripts(scriptFunc, metaData.url_, ScriptMatchType::URL)) { - LOG_DEBUGGER(WARN) << "RemoveBreakpoint: Unknown url: " << metaData.url_; - JSPtLocation location{metaData.url_, metaData.line_, metaData.column_}; - bool res = DebuggerApi::RemoveBreakpointWithNoMatchUrl(jsDebugger_, location); - if (!res) { - return DispatchResponse::Fail("RemoveBreakpointWithNoMatchUrl failed"); - } - return DispatchResponse::Ok(); + LOG_DEBUGGER(ERROR) << "RemoveBreakpoint: Unknown url: " << metaData.url_; + return DispatchResponse::Fail("Unknown file name."); } std::vector extractors = GetExtractors(metaData.url_); @@ -1141,9 +1120,8 @@ DispatchResponse DebuggerImpl::RemoveBreakpoint(const RemoveBreakpointParams &pa LOG_DEBUGGER(INFO) << "remove breakpoint location: " << location.ToString(); return DebuggerApi::RemoveBreakpoint(jsDebugger_, location); }; - Global funcRef = Global(vm_, FunctionRef::Undefined(vm_)); if (!extractor->MatchWithLocation(callbackFunc, metaData.line_, metaData.column_, - metaData.url_, GetRecordName(metaData.url_), funcRef)) { + metaData.url_, GetRecordName(metaData.url_))) { LOG_DEBUGGER(ERROR) << "failed to remove breakpoint location number: " << metaData.line_ << ":" << metaData.column_; } @@ -1160,14 +1138,13 @@ DispatchResponse DebuggerImpl::RemoveBreakpointsByUrl(const RemoveBreakpointsByU return true; }; if (!MatchScripts(scriptMatchCallback, url, ScriptMatchType::URL)) { - if (!DebuggerApi::RemoveAllBreakpointsByUrl(jsDebugger_, url, true)) { - return DispatchResponse::Fail("RemoveBreakpointsByUrl failed"); - } - } else { - if (!DebuggerApi::RemoveAllBreakpointsByUrl(jsDebugger_, url, false)) { - return DispatchResponse::Fail("RemoveBreakpointsByUrl failed"); - } + LOG_DEBUGGER(ERROR) << "RemoveBreakpointByUrl: Unknown url: " << url; + return DispatchResponse::Fail("Unknown url"); + } + if (!DebuggerApi::RemoveBreakpointsByUrl(jsDebugger_, url)) { + return DispatchResponse::Fail("RemoveBreakpointByUrl failed"); } + LOG_DEBUGGER(INFO) << "All breakpoints on " << url << " are removed"; return DispatchResponse::Ok(); } @@ -1190,27 +1167,20 @@ DispatchResponse DebuggerImpl::SetAsyncCallStackDepth() void DebuggerImpl::AddBreakpointDetail(const std::string &url, int32_t lineNumber, std::string *outId, - std::vector> *outLocations, - bool hasScriptId) + std::vector> *outLocations) { - if (!hasScriptId) { - ScriptId invalidId = -1; + std::vector ptScripts = MatchAllScripts(url); + for (auto ptScript : ptScripts) { + ScriptId scriptId = ptScript->GetScriptId(); std::unique_ptr location = std::make_unique(); - location->SetScriptId(invalidId).SetLine(lineNumber).SetColumn(0); + location->SetScriptId(scriptId).SetLine(lineNumber).SetColumn(0); outLocations->emplace_back(std::move(location)); - } else { - std::vector ptScripts = MatchAllScripts(url); - for (auto ptScript : ptScripts) { - ScriptId scriptId = ptScript->GetScriptId(); - std::unique_ptr location = std::make_unique(); - location->SetScriptId(scriptId).SetLine(lineNumber).SetColumn(0); - outLocations->emplace_back(std::move(location)); - } } BreakpointDetails metaData{lineNumber, 0, url}; *outId = BreakpointDetails::ToString(metaData); } + DispatchResponse DebuggerImpl::SetBreakpointByUrl(const SetBreakpointByUrlParams ¶ms, std::string *outId, std::vector> *outLocations, @@ -1230,14 +1200,8 @@ DispatchResponse DebuggerImpl::SetBreakpointByUrl(const SetBreakpointByUrlParams return true; }; if (!MatchScripts(scriptFunc, url, ScriptMatchType::URL)) { - LOG_DEBUGGER(WARN) << "SetBreakpointByUrl: Unknown url: " << url; - JSPtLocation location{url, lineNumber, columnNumber}; - bool res = DebuggerApi::SetBreakpointWithNoMatchUrl(jsDebugger_, location); - if (!res) { - return DispatchResponse::Fail("DebuggerImpl SetBreakpointWithNoMatchUrl failed"); - } - AddBreakpointDetail(url, lineNumber, outId, outLocations, false); - return DispatchResponse::Ok(); + LOG_DEBUGGER(ERROR) << "SetBreakpointByUrl: Unknown url: " << url; + return DispatchResponse::Fail("Unknown file name."); } std::vector extractors = GetExtractors(url); @@ -1259,14 +1223,13 @@ DispatchResponse DebuggerImpl::SetBreakpointByUrl(const SetBreakpointByUrlParams } return DebuggerApi::SetBreakpoint(jsDebugger_, location, condFuncRef, isSmartBreakpoint); }; - Global funcRef = Global(vm_, FunctionRef::Undefined(vm_)); - if (!extractor->MatchWithLocation(callbackFunc, lineNumber, columnNumber, url, GetRecordName(url), funcRef)) { + if (!extractor->MatchWithLocation(callbackFunc, lineNumber, columnNumber, url, GetRecordName(url))) { LOG_DEBUGGER(ERROR) << "failed to set breakpoint location number: " << lineNumber << ":" << columnNumber; return DispatchResponse::Fail("Breakpoint not found."); } } - AddBreakpointDetail(url, lineNumber, outId, outLocations, true); + AddBreakpointDetail(url, lineNumber, outId, outLocations); return DispatchResponse::Ok(); } @@ -1286,31 +1249,26 @@ DispatchResponse DebuggerImpl::GetPossibleAndSetBreakpointByUrl(const GetPossibl return DispatchResponse::Fail("GetPossibleAndSetBreakpointByUrl: no pennding breakpoint exists"); } auto breakpointList = params.GetBreakpointsList(); - std::vector processedList; - CUnorderedMap scriptIdList; - int32_t index = 0; - for (const auto &breakpoint : *breakpointList) { - ScriptId id = PreProcessBreakpoint(*breakpoint, processedList); - scriptIdList[index++] = id; - } - auto resultList = DebuggerApi::SetBreakpointByList(jsDebugger_, processedList); - index = 0; - ASSERT(resultList.size() == scriptIdList.size()); - for (auto const &res : resultList) { - auto breakpoint = processedList.at(index); - GenerateBreakpointOutLocation(scriptIdList[index++], breakpoint.GetSourceFile(), - breakpoint.GetLine(), res, outLocations); + if (!ProcessSingleBreakpoint(*breakpoint, outLocations)) { + std::string invalidBpId = "invalid"; + std::unique_ptr bpInfo = std::make_unique(); + bpInfo->SetId(invalidBpId) + .SetLineNumber(breakpoint->GetLineNumber()) + .SetColumnNumber(breakpoint->GetColumnNumber()); + outLocations.emplace_back(std::move(bpInfo)); + } } return DispatchResponse::Ok(); } -ScriptId DebuggerImpl::PreProcessBreakpoint(const BreakpointInfo &breakpoint, std::vector &list) +bool DebuggerImpl::ProcessSingleBreakpoint(const BreakpointInfo &breakpoint, + std::vector> &outLocations) { const std::string &url = breakpoint.GetUrl(); int32_t lineNumber = breakpoint.GetLineNumber(); + // it is not support column breakpoint now, so columnNumber is not useful int32_t columnNumber = -1; - ScriptId noMatchedId = -1; auto condition = breakpoint.HasCondition() ? breakpoint.GetCondition() : std::optional {}; ScriptId scriptId; @@ -1319,14 +1277,14 @@ ScriptId DebuggerImpl::PreProcessBreakpoint(const BreakpointInfo &breakpoint, st return true; }; if (!MatchScripts(scriptFunc, url, ScriptMatchType::URL)) { - LOG_DEBUGGER(INFO) << "DebuggerImpl::PreProcessBreakpoint SUCCESS: URL-NO-MATCH Breakpoint"; - JSPtLocation location{url, lineNumber, columnNumber}; - list.emplace_back(location); - return noMatchedId; + LOG_DEBUGGER(ERROR) << "GetPossibleAndSetBreakpointByUrl: Unknown url: " << url; + return false; } + std::vector extractors = GetExtractors(url); for (auto extractor : extractors) { if (extractor == nullptr) { + LOG_DEBUGGER(DEBUG) << "GetPossibleAndSetBreakpointByUrl: extractor is null"; continue; } // decode and convert condition to function before doing matchWithLocation @@ -1334,43 +1292,26 @@ ScriptId DebuggerImpl::PreProcessBreakpoint(const BreakpointInfo &breakpoint, st if (condition.has_value() && !condition.value().empty()) { funcRef = CheckAndGenerateCondFunc(condition); if (funcRef->IsUndefined()) { - JSPtLocation location{"invalid", lineNumber, columnNumber}; - list.emplace_back(location); - return noMatchedId; + LOG_DEBUGGER(ERROR) << "GetPossibleAndSetBreakpointByUrl: generate function failed"; + return false; } } - auto matchLocationCbFunc = [&list](const JSPtLocation &location) -> bool { - list.emplace_back(location); - return true; + auto matchLocationCbFunc = [this, &funcRef](const JSPtLocation &location) -> bool { + return DebuggerApi::SetBreakpoint(jsDebugger_, location, funcRef); }; - Global globalFuncRef = Global(vm_, funcRef); - if (!extractor->MatchWithLocation(matchLocationCbFunc, lineNumber, - columnNumber, url, GetRecordName(url), globalFuncRef)) { - JSPtLocation location{"invalid", lineNumber, columnNumber}; - list.emplace_back(location); - return noMatchedId; - } else { - return scriptId; + if (!extractor->MatchWithLocation(matchLocationCbFunc, lineNumber, columnNumber, url, GetRecordName(url))) { + LOG_DEBUGGER(ERROR) << "failed to set breakpoint location number: " << lineNumber << ":" << columnNumber; + return false; } } - JSPtLocation location{"invalid", lineNumber, columnNumber}; - list.emplace_back(location); - return noMatchedId; -} - -void DebuggerImpl::GenerateBreakpointOutLocation(ScriptId scriptId, const std::string &url, int32_t line, - bool res, std::vector> &outLocations) -{ - BreakpointDetails bpMetaData {line, 0, url}; + + BreakpointDetails bpMetaData {lineNumber, 0, url}; + std::string outId = BreakpointDetails::ToString(bpMetaData); std::unique_ptr bpInfo = std::make_unique(); - if (res) { - std::string outId = BreakpointDetails::ToString(bpMetaData); - bpInfo->SetScriptId(scriptId).SetLineNumber(line).SetColumnNumber(0).SetId(outId); - } else { - std::string invalidBpId = "invalid"; - bpInfo->SetScriptId(scriptId).SetLineNumber(line).SetColumnNumber(0).SetId(invalidBpId); - } + bpInfo->SetScriptId(scriptId).SetLineNumber(lineNumber).SetColumnNumber(0).SetId(outId); outLocations.emplace_back(std::move(bpInfo)); + + return true; } DispatchResponse DebuggerImpl::SetNativeRange(const SetNativeRangeParams ¶ms) diff --git a/tooling/agent/debugger_impl.h b/tooling/agent/debugger_impl.h index 9c842173..81e99a2e 100644 --- a/tooling/agent/debugger_impl.h +++ b/tooling/agent/debugger_impl.h @@ -54,7 +54,7 @@ public: void SetDebuggerState(DebuggerState debuggerState); void SetNativeOutPause(bool nativeOutPause); void AddBreakpointDetail(const std::string &url, int32_t lineNumber, - std::string *outId, std::vector> *outLocations, bool hasScriptId); + std::string *outId, std::vector> *outLocations); DispatchResponse ContinueToLocation(const ContinueToLocationParams ¶ms); DispatchResponse Enable(const EnableParams ¶ms, UniqueDebuggerId *id); @@ -256,12 +256,11 @@ private: bool IsSkipLine(const JSPtLocation &location); bool CheckPauseOnException(); bool IsWithinVariableScope(const LocalVariableInfo &localVariableInfo, uint32_t bcOffset); + bool ProcessSingleBreakpoint(const BreakpointInfo &breakpoint, + std::vector> &outLocations); bool IsVariableSkipped(const std::string &varName); Local CheckAndGenerateCondFunc(const std::optional &condition); void InitializeExtendedProtocolsList(); - void GenerateBreakpointOutLocation(ScriptId scriptId, const std::string &url, int32_t line, - bool res, std::vector> &outLocations); - ScriptId PreProcessBreakpoint(const BreakpointInfo &breakpoint, std::vector &list); const std::unordered_set &GetRecordName(const std::string &url) { diff --git a/tooling/base/pt_types.h b/tooling/base/pt_types.h index c3122276..483a5c67 100644 --- a/tooling/base/pt_types.h +++ b/tooling/base/pt_types.h @@ -81,7 +81,6 @@ struct BreakpointDetails { int32_t line_ {0}; int32_t column_ {0}; std::string url_ {}; - bool needResetBreakpoint_ {false}; }; // Debugger.CallFrameId diff --git a/tooling/test/debugger_cint_client_test.cpp b/tooling/test/debugger_cint_client_test.cpp index 09809e99..5d125a13 100644 --- a/tooling/test/debugger_cint_client_test.cpp +++ b/tooling/test/debugger_cint_client_test.cpp @@ -49,7 +49,6 @@ public: JSNApi::StartDebugger(instance, debugOption); if (instance->GetJsDebuggerManager() != nullptr) { instance->GetJsDebuggerManager()->DisableObjectHashDisplay(); - instance->GetJsDebuggerManager()->DisableBreakpointSync(); } } diff --git a/tooling/test/debugger_client_test.cpp b/tooling/test/debugger_client_test.cpp index 2f54ce54..ba9df5f6 100644 --- a/tooling/test/debugger_client_test.cpp +++ b/tooling/test/debugger_client_test.cpp @@ -49,7 +49,6 @@ public: JSNApi::StartDebugger(instance, debugOption); if (instance->GetJsDebuggerManager() != nullptr) { instance->GetJsDebuggerManager()->DisableObjectHashDisplay(); - instance->GetJsDebuggerManager()->DisableBreakpointSync(); } } diff --git a/tooling/test/debugger_impl_test.cpp b/tooling/test/debugger_impl_test.cpp index 4aaa0338..5be5f405 100644 --- a/tooling/test/debugger_impl_test.cpp +++ b/tooling/test/debugger_impl_test.cpp @@ -494,7 +494,8 @@ HWTEST_F_L0(DebuggerImplTest, Dispatcher_Dispatch_RemoveBreakpoint__003) DispatchRequest request(msg); dispatcherImpl->Dispatch(request); - EXPECT_STREQ(outStrForCallbackCheck.c_str(), R"({"id":0,"result":{}})"); + EXPECT_STREQ(outStrForCallbackCheck.c_str(), + R"({"id":0,"result":{"code":1,"message":"Unknown file name."}})"); if (protocolChannel) { delete protocolChannel; protocolChannel = nullptr; @@ -550,7 +551,7 @@ HWTEST_F_L0(DebuggerImplTest, Dispatcher_Dispatch_RemoveBreakpointsByUrl__002) DispatchRequest request(msg); dispatcherImpl->Dispatch(request); - EXPECT_STREQ(outStrForCallbackCheck.c_str(), R"({"id":0,"result":{}})"); + EXPECT_STREQ(outStrForCallbackCheck.c_str(), R"({"id":0,"result":{"code":1,"message":"Unknown url"}})"); if (protocolChannel) { delete protocolChannel; protocolChannel = nullptr; @@ -702,8 +703,7 @@ HWTEST_F_L0(DebuggerImplTest, Dispatcher_Dispatch_SetBreakpointByUrl__002) DispatchRequest request(msg); dispatcherImpl->Dispatch(request); - EXPECT_STREQ(outStrForCallbackCheck.c_str(), - R"({"id":0,"result":{"code":1,"message":"DebuggerImpl SetBreakpointWithNoMatchUrl failed"}})"); + EXPECT_STREQ(outStrForCallbackCheck.c_str(), R"({"id":0,"result":{"code":1,"message":"Unknown file name."}})"); if (protocolChannel) { delete protocolChannel; protocolChannel = nullptr; @@ -1176,7 +1176,7 @@ HWTEST_F_L0(DebuggerImplTest, Dispatcher_Dispatch_GetPossibleAndSetBreakpoint__0 dispatcherImpl->Dispatch(request); EXPECT_STREQ(outStrForCallbackCheck.c_str(), - R"({"id":0,"result":{"locations":[{"lineNumber":3,"columnNumber":0,"id":"invalid","scriptId":-1}]}})"); + R"({"id":0,"result":{"locations":[{"lineNumber":3,"columnNumber":20,"id":"invalid","scriptId":0}]}})"); if (protocolChannel) { delete protocolChannel; protocolChannel = nullptr; diff --git a/tooling/test/utils/test_extractor.cpp b/tooling/test/utils/test_extractor.cpp index 48e291e9..5a57694e 100644 --- a/tooling/test/utils/test_extractor.cpp +++ b/tooling/test/utils/test_extractor.cpp @@ -36,8 +36,7 @@ std::pair TestExtractor::GetBreakpointAddress(const SourceLo return true; }; std::unordered_set recordName {}; - Global funcRef; - MatchWithLocation(callbackFunc, sourceLocation.line, sourceLocation.column, "", recordName, funcRef); + MatchWithLocation(callbackFunc, sourceLocation.line, sourceLocation.column, "", recordName); return {retId, retOffset}; } -- Gitee From 0857bf09377373efccc647f9474e1f43782de5ce Mon Sep 17 00:00:00 2001 From: bigtea Date: Thu, 22 Aug 2024 16:40:22 +0800 Subject: [PATCH 06/25] Fix arkdb tool leak of memory alert Issue: IAN2G3 Signed-off-by: bigtea --- tooling/base/pt_types.cpp | 7 +++-- tooling/client/ark_cli/main.cpp | 19 +++++------ tooling/client/tcpServer/tcp_server.cpp | 17 +++++----- tooling/test/pt_types_test.cpp | 42 +++++++++++++++++-------- 4 files changed, 53 insertions(+), 32 deletions(-) diff --git a/tooling/base/pt_types.cpp b/tooling/base/pt_types.cpp index b138d947..c000ff3f 100644 --- a/tooling/base/pt_types.cpp +++ b/tooling/base/pt_types.cpp @@ -3086,7 +3086,7 @@ std::unique_ptr ScriptTypeProfile::Create(const PtJson ¶m std::string error; auto scriptTypeProfile = std::make_unique(); Result ret; - + std::string scriptId; ret = params.GetString("scriptId", &scriptId); if (ret == Result::SUCCESS) { @@ -3193,6 +3193,7 @@ std::unique_ptr TraceConfig::Create(const PtJson ¶ms) ret = params.GetArray("includedCategories", &includedCategories); if (ret == Result::SUCCESS) { int32_t includedCategoriesLen = includedCategories->GetSize(); + traceConfig->includedCategories_= std::vector(); for (int32_t i = 0; i < includedCategoriesLen; ++i) { std::string pIncludedCategories = includedCategories->Get(i)->GetString(); traceConfig->includedCategories_.value().emplace_back(pIncludedCategories); @@ -3205,6 +3206,7 @@ std::unique_ptr TraceConfig::Create(const PtJson ¶ms) ret = params.GetArray("excludedCategories", &excludedCategories); if (ret == Result::SUCCESS) { int32_t excludedCategoriesLen = excludedCategories->GetSize(); + traceConfig->excludedCategories_ = std::vector(); for (int32_t i = 0; i < excludedCategoriesLen; ++i) { std::string pExcludedCategories = excludedCategories->Get(i)->GetString(); traceConfig->excludedCategories_.value().emplace_back(pExcludedCategories); @@ -3216,7 +3218,8 @@ std::unique_ptr TraceConfig::Create(const PtJson ¶ms) std::unique_ptr syntheticDelays; ret = params.GetArray("syntheticDelays", &syntheticDelays); if (ret == Result::SUCCESS) { - int32_t syntheticDelaysLen = includedCategories->GetSize(); + int32_t syntheticDelaysLen = syntheticDelays->GetSize(); + traceConfig->syntheticDelays_ = std::vector(); for (int32_t i = 0; i < syntheticDelaysLen; ++i) { std::string pSyntheticDelays = syntheticDelays->Get(i)->GetString(); traceConfig->syntheticDelays_.value().emplace_back(pSyntheticDelays); diff --git a/tooling/client/ark_cli/main.cpp b/tooling/client/ark_cli/main.cpp index 25cbcf75..5b82d80b 100644 --- a/tooling/client/ark_cli/main.cpp +++ b/tooling/client/ark_cli/main.cpp @@ -121,17 +121,18 @@ void GetInputCommand([[maybe_unused]] void *arg) if (uv_is_active(reinterpret_cast(g_inputSignal))) { uint32_t len = inputStr.length(); char* msg = (char*)malloc(len + 1); - if ((msg != nullptr) && uv_is_active(reinterpret_cast(g_inputSignal))) { - if (strncpy_s(msg, len + 1, inputStr.c_str(), len) != 0) { - if (uv_is_active(reinterpret_cast(g_releaseHandle))) { - uv_async_send(g_releaseHandle); - } - free(msg); - break; + if (msg == nullptr) { + continue; + } + if (strncpy_s(msg, len + 1, inputStr.c_str(), len) != 0) { + if (uv_is_active(reinterpret_cast(g_releaseHandle))) { + uv_async_send(g_releaseHandle); } - g_inputSignal->data = std::move(msg); - uv_async_send(g_inputSignal); + free(msg); + break; } + g_inputSignal->data = std::move(msg); + uv_async_send(g_inputSignal); } } } diff --git a/tooling/client/tcpServer/tcp_server.cpp b/tooling/client/tcpServer/tcp_server.cpp index e17f07ce..e3a0155a 100644 --- a/tooling/client/tcpServer/tcp_server.cpp +++ b/tooling/client/tcpServer/tcp_server.cpp @@ -102,15 +102,16 @@ void TcpServer::SendCommand(std::string inputStr) return; } char* msg = (char*)malloc(len + 1); - if ((msg != nullptr) && uv_is_active(reinterpret_cast(g_inputSignal))) { - if (strncpy_s(msg, len + 1, inputStr.c_str(), len) != 0) { - CloseServer(); - return; - } - - g_inputSignal->data = std::move(msg); - uv_async_send(g_inputSignal); + if (msg == nullptr) { + return; + } + if (strncpy_s(msg, len + 1, inputStr.c_str(), len) != 0) { + free(msg); + CloseServer(); + return; } + g_inputSignal->data = std::move(msg); + uv_async_send(g_inputSignal); } return; } diff --git a/tooling/test/pt_types_test.cpp b/tooling/test/pt_types_test.cpp index 02c2e543..0421c447 100644 --- a/tooling/test/pt_types_test.cpp +++ b/tooling/test/pt_types_test.cpp @@ -309,12 +309,9 @@ HWTEST_F_L0(PtTypesTest, TraceConfigToJsonTest) std::unique_ptr result = treceConfig.ToJson(); ASSERT_TRUE(result); } + HWTEST_F_L0(PtTypesTest, TraceConfigCreateTest) { - std::unique_ptr includedCategoriesArray = PtJson::CreateArray(); - std::unique_ptr excludedCategoriesArray = PtJson::CreateArray(); - std::unique_ptr syntheticDelaysArray = PtJson::CreateArray(); - std::unique_ptr object = PtJson::CreateObject(); std::string attribute = "test"; std::unique_ptr ptJson = PtJson::CreateObject(); ptJson->Add("recordMode", 0); @@ -327,23 +324,42 @@ HWTEST_F_L0(PtTypesTest, TraceConfigCreateTest) ptJson->Add("memoryDumpConfig", attribute.c_str()); std::unique_ptr traceConfig = TraceConfig::Create(*ptJson); ASSERT_TRUE(!traceConfig); - object->Add("test", 0); + std::unique_ptr ptJson1 = PtJson::CreateObject(); - ptJson1->Add("includedCategories", includedCategoriesArray); - ptJson1->Add("recordMode", attribute.c_str()); - ptJson1->Add("excludedCategories", excludedCategoriesArray); - ptJson1->Add("syntheticDelays", syntheticDelaysArray); - ptJson1->Add("memoryDumpConfig", object); + ptJson1->Add("recordMode", "test"); std::unique_ptr traceConfig1 = TraceConfig::Create(*ptJson1); ASSERT_TRUE(!traceConfig1); + std::unique_ptr ptJson2 = PtJson::CreateObject(); std::unique_ptr traceConfig2 = TraceConfig::Create(*ptJson2); ASSERT_TRUE(traceConfig2); + + std::unique_ptr includedCategoriesArray = PtJson::CreateArray(); + includedCategoriesArray->Push("includedCategory"); + std::unique_ptr excludedCategoriesArray = PtJson::CreateArray(); + excludedCategoriesArray->Push("excludedCategory1"); + excludedCategoriesArray->Push("excludedCategory2"); + std::unique_ptr syntheticDelaysArray = PtJson::CreateArray(); + syntheticDelaysArray->Push("syntheticDelay1"); + syntheticDelaysArray->Push("syntheticDelay2"); + syntheticDelaysArray->Push("syntheticDelay3"); std::unique_ptr ptJson3 = PtJson::CreateObject(); - std::unique_ptr memoryDumpConfig = PtJson::CreateArray(); - ptJson3->Add("memoryDumpConfig", std::move(memoryDumpConfig)); + ptJson3->Add("recordMode", "recordUntilFull"); + ptJson3->Add("enableSampling", true); + ptJson3->Add("enableSystrace", true); + ptJson3->Add("enableArgumentFilter", true); + ptJson3->Add("includedCategories", includedCategoriesArray); + ptJson3->Add("excludedCategories", excludedCategoriesArray); + ptJson3->Add("syntheticDelays", syntheticDelaysArray); + ptJson3->Add("memoryDumpConfig", PtJson::CreateObject()); std::unique_ptr traceConfig3 = TraceConfig::Create(*ptJson3); - ASSERT_TRUE(!traceConfig3); + ASSERT_TRUE(traceConfig3); + ASSERT_TRUE(traceConfig3->GetEnableSampling()); + ASSERT_TRUE(traceConfig3->GetEnableSystrace()); + ASSERT_TRUE(traceConfig3->GetEnableArgumentFilter()); + ASSERT_EQ(traceConfig3->GetIncludedCategories()->size(), 1); + ASSERT_EQ(traceConfig3->GetExcludedCategories()->size(), 2); + ASSERT_EQ(traceConfig3->GetSyntheticDelays()->size(), 3); } HWTEST_F_L0(PtTypesTest, ScriptTypeProfileCreateTest) -- Gitee From ce9c17aad3222dbb19d08ceebf8713300a4af77b Mon Sep 17 00:00:00 2001 From: hanweiqi Date: Wed, 28 Aug 2024 18:08:16 +0800 Subject: [PATCH 07/25] cherry pick 210bbe1 from https://gitee.com/hanweiqi3/arkcompiler_toolchain/pulls/843 Optimize cold patch performance Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IAN60V Signed-off-by: hanweiqi --- tooling/agent/debugger_impl.cpp | 10 +++++++--- tooling/agent/debugger_impl.h | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index c2ee0ba6..c5589d35 100755 --- a/tooling/agent/debugger_impl.cpp +++ b/tooling/agent/debugger_impl.cpp @@ -112,10 +112,14 @@ bool DebuggerImpl::NotifyScriptParsed(ScriptId scriptId, const std::string &file // if load module, it needs to check whether clear singlestepper_ ClearSingleStepper(); - if (MatchUrlAndFileName(url, fileName)) { - LOG_DEBUGGER(WARN) << "NotifyScriptParsed: already loaded: " << url; - return false; + auto urlFileNameIter = urlFileNameMap_.find(url); + if (urlFileNameIter != urlFileNameMap_.end()) { + if (urlFileNameIter->second.find(fileName) != urlFileNameIter->second.end()) { + LOG_DEBUGGER(WARN) << "NotifyScriptParsed: already loaded: " << url; + return false; + } } + urlFileNameMap_[url].insert(fileName); // Notify script parsed event std::unique_ptr script = std::make_unique(scriptId, fileName, url, source); diff --git a/tooling/agent/debugger_impl.h b/tooling/agent/debugger_impl.h index 9c842173..bee97a7f 100644 --- a/tooling/agent/debugger_impl.h +++ b/tooling/agent/debugger_impl.h @@ -312,6 +312,7 @@ private: JSDebugger *jsDebugger_ {nullptr}; std::unordered_map> recordNames_ {}; + std::unordered_map> urlFileNameMap_ {}; std::unordered_map> scripts_ {}; PauseOnExceptionsState pauseOnException_ {PauseOnExceptionsState::NONE}; DebuggerState debuggerState_ {DebuggerState::ENABLED}; -- Gitee From 1cd03e43183961610e342a710f9eb6194bd45b7d Mon Sep 17 00:00:00 2001 From: liu-zelin Date: Sat, 24 Aug 2024 09:57:22 +0800 Subject: [PATCH 08/25] cherry pick 7b4d6fa from https://gitee.com/diartyz/arkcompiler_toolchain/pulls/833 Add SendableSet debug support Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IAM61I?from=project-issue Signed-off-by: liu-zelin Change-Id: Ic6ce64b7413e2cda245671ea820ac16bb18f236c --- tooling/agent/runtime_impl.cpp | 33 ++++++++++++++++++++-- tooling/agent/runtime_impl.h | 4 ++- tooling/test/testcases/js/container.js | 19 +++++++++++++ tooling/test/testcases/js_container_test.h | 16 +++++++++-- 4 files changed, 67 insertions(+), 5 deletions(-) diff --git a/tooling/agent/runtime_impl.cpp b/tooling/agent/runtime_impl.cpp index 2cd0c683..470380f6 100644 --- a/tooling/agent/runtime_impl.cpp +++ b/tooling/agent/runtime_impl.cpp @@ -236,6 +236,8 @@ DispatchResponse RuntimeImpl::GetProperties(const GetPropertiesParams ¶ms, GetWeakMapValue(value, outPropertyDesc); } else if (value->IsRegExp(vm_)) { GetRegExpValue(value, outPropertyDesc); + } else if (value->IsSharedSet(vm_)) { + GetSendableSetValue(value, outPropertyDesc); } else if (value->IsSet(vm_)) { GetSetValue(value, outPropertyDesc); } else if (value->IsWeakSet(vm_)) { @@ -256,7 +258,7 @@ DispatchResponse RuntimeImpl::GetProperties(const GetPropertiesParams ¶ms, GetListValue(value, outPropertyDesc); } else if (value->IsPlainArray(vm_)) { GetPlainArrayValue(value, outPropertyDesc); - } else if (value->IsTreeMap(vm_)) { + } else if (value->IsTreeMap(vm_)) { GetTreeMapValue(value, outPropertyDesc); } else if (value->IsTreeSet(vm_)) { GetTreeSetValue(value, outPropertyDesc); @@ -671,6 +673,33 @@ void RuntimeImpl::GetWeakMapValue(Local value, SetKeyValue(jsValueRef, outPropertyDesc, "[[Entries]]"); } +void RuntimeImpl::GetSendableSetValue(Local value, + std::vector> *outPropertyDesc) +{ + Local setRef = value->ToObject(vm_); + int32_t size = setRef->GetSize(vm_); + int32_t len = setRef->GetTotalElements(vm_); + int32_t index = 0; + Local jsValueRef = NumberRef::New(vm_, size); + SetKeyValue(jsValueRef, outPropertyDesc, "size"); + jsValueRef = ArrayRef::New(vm_, size); + for (int32_t i = 0; i < len; ++i) { + Local elementRef = setRef->GetValue(vm_, i); + if (elementRef->IsHole()) { + continue; + } else if (elementRef->IsObject(vm_)) { + Local objRef = ObjectRef::New(vm_); + objRef->Set(vm_, StringRef::NewFromUtf8(vm_, "value"), elementRef); + DebuggerApi::AddInternalProperties(vm_, objRef, ArkInternalValueType::Entry, internalObjects_); + ArrayRef::SetValueAt(vm_, jsValueRef, index++, objRef); + } else { + ArrayRef::SetValueAt(vm_, jsValueRef, index++, elementRef); + } + } + DebuggerApi::AddInternalProperties(vm_, jsValueRef, ArkInternalValueType::Entry, internalObjects_); + SetKeyValue(jsValueRef, outPropertyDesc, "[[Entries]]"); +} + void RuntimeImpl::GetSetValue(Local value, std::vector> *outPropertyDesc) { @@ -912,4 +941,4 @@ void RuntimeImpl::GetPromiseValue(Local value, Local promiseResult = promiseRef->GetPromiseResult(vm_); SetKeyValue(promiseResult, outPropertyDesc, "[[PromiseResult]]"); } -} // namespace panda::ecmascript::tooling \ No newline at end of file +} // namespace panda::ecmascript::tooling diff --git a/tooling/agent/runtime_impl.h b/tooling/agent/runtime_impl.h index d7e6a1d7..0c40beb6 100644 --- a/tooling/agent/runtime_impl.h +++ b/tooling/agent/runtime_impl.h @@ -116,6 +116,8 @@ private: std::vector> *outPropertyDesc); void GetWeakMapValue(Local value, std::vector> *outPropertyDesc); + void GetSendableSetValue(Local value, + std::vector> *outPropertyDesc); void GetSetValue(Local value, std::vector> *outPropertyDesc); void GetWeakSetValue(Local value, @@ -182,4 +184,4 @@ private: friend class DebuggerImpl; }; } // namespace panda::ecmascript::tooling -#endif \ No newline at end of file +#endif diff --git a/tooling/test/testcases/js/container.js b/tooling/test/testcases/js/container.js index fe61bd45..9ad75c01 100644 --- a/tooling/test/testcases/js/container.js +++ b/tooling/test/testcases/js/container.js @@ -346,6 +346,25 @@ var o = { var number26 = vector.getIndexOf(857); var number27 = vector.getFirstElement(); + // sendable + let sendableArray = new SendableArray(1, 2); + let sendableArray0 = sendableArray[0]; + let sendableArray1 = sendableArray[1]; + let sendableArraySize = sendableArray.length; + let sendableMap = new SendableMap([ + [0, 1], + [1, 2], + ]); + let sendableMap0 = sendableMap.get(0); + let sendableMap1 = sendableMap.get(1); + let sendableMapSize = sendableMap.size; + let sendableSet = new SendableSet(); + sendableSet.add(1); + sendableSet.add(2); + let sendableSet0 = sendableSet.has(1) + let sendableSet1 = sendableSet.has(2) + let sendableSetSize = sendableSet.size; + var nop = undefined; } } diff --git a/tooling/test/testcases/js_container_test.h b/tooling/test/testcases/js_container_test.h index 81309a1c..9b521de4 100644 --- a/tooling/test/testcases/js_container_test.h +++ b/tooling/test/testcases/js_container_test.h @@ -35,7 +35,7 @@ public: // break on start {SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN}, // set breakpoint - {SocketAction::SEND, "b " DEBUGGER_JS_DIR "container.js 349"}, + {SocketAction::SEND, "b " DEBUGGER_JS_DIR "container.js 368"}, {SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess}, // hit breakpoint after resume first time {SocketAction::SEND, "resume"}, @@ -65,7 +65,7 @@ public: std::string breakpoint; breakpoint = hitBreakpoints->Get(0)->GetString(); if (ret != Result::SUCCESS || breakpoint.find(sourceFile_) == std::string::npos || - breakpoint.find("348") == std::string::npos) { + breakpoint.find("367") == std::string::npos) { return false; } @@ -246,6 +246,18 @@ private: { "string3", { "string", "array", "array" } }, { "string4", { "string", "male", "male" } }, { "string5", { "string", "one", "one" } }, + { "sendableArray", { "object", "Object", "SendableArray [Sendable]", "SendableArray [Sendable]" } }, + { "sendableArray0", { "number", "1", "1" } }, + { "sendableArray1", { "number", "2", "2" } }, + { "sendableArraySize", { "number", "2", "2" } }, + { "sendableMap", { "object", "Object", "SendableMap [Sendable]", "SendableMap [Sendable]" } }, + { "sendableMap0", { "number", "1", "1" } }, + { "sendableMap1", { "number", "2", "2" } }, + { "sendableMapSize", { "number", "2", "2" } }, + { "sendableSet", { "object", "Object", "SendableSet [Sendable]", "SendableSet [Sendable]" } }, + { "sendableSet0", { "boolean", "true", "true" } }, + { "sendableSet1", { "boolean", "true", "true" } }, + { "sendableSetSize", { "number", "2", "2" } }, }; }; -- Gitee From f4add7fa4d8a9bbda58e2de66f89029395a49276 Mon Sep 17 00:00:00 2001 From: daiweihao Date: Tue, 3 Sep 2024 10:44:47 +0800 Subject: [PATCH 09/25] Sync Code Eliminate the difference between open source code and commercial code Issue:https://gitee.com/openharmony/arkcompiler_toolchain/issues/IAODEB Signed-off-by: daiweihao Change-Id: Ia5721cf54166c96dd6ab649c9ac5e880a03a6b72 --- tooling/client/ark_multi/main.cpp | 7 +++++-- tooling/test/debugger_cint_client_test.cpp | 2 +- tooling/test/debugger_client_test.cpp | 3 +-- websocket/server/websocket_server.cpp | 2 +- websocket/test/websocket_test.cpp | 8 ++++---- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/tooling/client/ark_multi/main.cpp b/tooling/client/ark_multi/main.cpp index 7e94fb9a..d574206d 100644 --- a/tooling/client/ark_multi/main.cpp +++ b/tooling/client/ark_multi/main.cpp @@ -112,6 +112,7 @@ bool StartThread(uv_loop_t *loop) } auto [fileName, entry] = GetNextPara(); g_mutex.Unlock(); + panda::ecmascript::EcmaVM *vm = panda::JSNApi::CreateEcmaVM(g_runtimeOptions); if (vm == nullptr) { std::cerr << "Cannot create vm." << std::endl; @@ -119,15 +120,17 @@ bool StartThread(uv_loop_t *loop) } panda::JSNApi::SetBundle(vm, !g_runtimeOptions.GetMergeAbc()); bool ret = ExecutePandaFile(vm, g_runtimeOptions, fileName, entry); + panda::JSNApi::DestroyJSVM(vm); auto loop = static_cast(arg); auto work = new uv_work_t; std::string msg = GetMsg(ret, msg, fileName); work->data = new char[msg.size() + 1]; if (strncpy_s(static_cast(work->data), msg.size() + 1, msg.data(), msg.size()) != EOK) { + std::cerr << "strncpy_s fail." << std::endl; delete[] static_cast(work->data); delete work; - std::abort(); + return; } uv_queue_work(loop, work, [] (uv_work_t*) {}, [] (uv_work_t* work, int) { std::cerr << static_cast(work->data) << std::endl; @@ -167,7 +170,7 @@ int Main(const int argc, const char **argv) while (std::getline(in, line)) { if (line.find_last_of(".abc") == std::string::npos) { // endwith std::cerr << "Not endwith .abc" << line << std::endl; - std::abort(); + return -1; } g_files.emplace_back(line); } diff --git a/tooling/test/debugger_cint_client_test.cpp b/tooling/test/debugger_cint_client_test.cpp index 09809e99..b03f609b 100644 --- a/tooling/test/debugger_cint_client_test.cpp +++ b/tooling/test/debugger_cint_client_test.cpp @@ -65,7 +65,7 @@ public: JSThread *thread {nullptr}; }; -HWTEST_P_L0(DebuggerCIntClientTest, DISABLED_DebuggerSuite) +HWTEST_P_L0(DebuggerCIntClientTest, DebuggerSuite) { std::string testName = GetCurrentTestName(); std::cout << "Running " << testName << std::endl; diff --git a/tooling/test/debugger_client_test.cpp b/tooling/test/debugger_client_test.cpp index 2f54ce54..1486a143 100644 --- a/tooling/test/debugger_client_test.cpp +++ b/tooling/test/debugger_client_test.cpp @@ -65,8 +65,7 @@ public: JSThread *thread {nullptr}; }; -//NOTE: enable (issue 18042) -HWTEST_P_L0(DebuggerClientTest, DISABLED_DebuggerSuite) +HWTEST_P_L0(DebuggerClientTest, DebuggerSuite) { std::string testName = GetCurrentTestName(); std::cout << "Running " << testName << std::endl; diff --git a/websocket/server/websocket_server.cpp b/websocket/server/websocket_server.cpp index f06201a9..cb59a7ce 100644 --- a/websocket/server/websocket_server.cpp +++ b/websocket/server/websocket_server.cpp @@ -331,7 +331,7 @@ bool WebSocketServer::InitUnixWebSocket(int socketfd) SetConnectionSocket(socketfd); const int flag = fcntl(socketfd, F_GETFL, 0); if (flag == -1) { - LOGE("InitUnixWebSocket get client state is failed"); + LOGE("InitUnixWebSocket get client state is failed, error is %s", strerror(errno)); return false; } fcntl(socketfd, F_SETFL, static_cast(flag) & ~O_NONBLOCK); diff --git a/websocket/test/websocket_test.cpp b/websocket/test/websocket_test.cpp index 1c942286..0523f2a6 100644 --- a/websocket/test/websocket_test.cpp +++ b/websocket/test/websocket_test.cpp @@ -65,7 +65,7 @@ public: const std::string WebSocketTest::LONG_MSG = std::string(1000, 'f'); const std::string WebSocketTest::LONG_LONG_MSG = std::string(0xfffff, 'f'); -HWTEST_F(WebSocketTest, DISABLED_ConnectWebSocketTest, testing::ext::TestSize.Level0) +HWTEST_F(WebSocketTest, ConnectWebSocketTest, testing::ext::TestSize.Level0) { WebSocketServer serverSocket; bool ret = false; @@ -162,7 +162,7 @@ HWTEST_F(WebSocketTest, DISABLED_ConnectWebSocketTest, testing::ext::TestSize.Le } } -HWTEST_F(WebSocketTest, DISABLED_ReConnectWebSocketTest, testing::ext::TestSize.Level0) +HWTEST_F(WebSocketTest, ReConnectWebSocketTest, testing::ext::TestSize.Level0) { WebSocketServer serverSocket; bool ret = false; @@ -222,7 +222,7 @@ HWTEST_F(WebSocketTest, DISABLED_ReConnectWebSocketTest, testing::ext::TestSize. sleep(3); } -HWTEST_F(WebSocketTest, DISABLED_ClientAbnormalTest, testing::ext::TestSize.Level0) +HWTEST_F(WebSocketTest, ClientAbnormalTest, testing::ext::TestSize.Level0) { WebSocketClient clientSocket; ASSERT_STREQ(clientSocket.GetSocketStateString().c_str(), "closed"); @@ -231,7 +231,7 @@ HWTEST_F(WebSocketTest, DISABLED_ClientAbnormalTest, testing::ext::TestSize.Leve ASSERT_FALSE(clientSocket.SendReply(HELLO_SERVER)); } -HWTEST_F(WebSocketTest, DISABLED_ServerAbnormalTest, testing::ext::TestSize.Level0) +HWTEST_F(WebSocketTest, ServerAbnormalTest, testing::ext::TestSize.Level0) { WebSocketServer serverSocket; // No connection established, the function returns directly. -- Gitee From 2b32a3beaf9deb77ae8784421dc601d2ff022e8c Mon Sep 17 00:00:00 2001 From: daiweihao Date: Wed, 4 Sep 2024 19:44:21 +0800 Subject: [PATCH 10/25] Revert PR 682 This reverts commit 6bb8d597704f9194bf9791d5f1ce465696662ab1. Issue:https://gitee.com/openharmony/arkcompiler_toolchain/issues/IAOWMD Signed-off-by: daiweihao Change-Id: Ibc2d7ff91656bc1738249cd73cb6018efdd3a8b8 --- tooling/agent/debugger_impl.cpp | 7 ++----- tooling/agent/debugger_impl.h | 11 ----------- tooling/backend/js_pt_hooks.cpp | 20 ++++++++------------ tooling/backend/js_pt_hooks.h | 1 + 4 files changed, 11 insertions(+), 28 deletions(-) diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index c2ee0ba6..fcd48504 100755 --- a/tooling/agent/debugger_impl.cpp +++ b/tooling/agent/debugger_impl.cpp @@ -124,10 +124,6 @@ bool DebuggerImpl::NotifyScriptParsed(ScriptId scriptId, const std::string &file // Store parsed script in map scripts_[script->GetScriptId()] = std::move(script); - - // Store parsed file url, used by hook to determine - // whether a Break_on_start pause is needed - parsedFileNames_.emplace(url); return true; } @@ -404,7 +400,8 @@ void DebuggerImpl::InitializeExtendedProtocolsList() "setNativeRange", "resetSingleStepper", "callFunctionOn", - "smartStepInto" + "smartStepInto", + "callFunctionOn" }; debuggerExtendedProtocols_ = std::move(debuggerProtocolList); } diff --git a/tooling/agent/debugger_impl.h b/tooling/agent/debugger_impl.h index 9c842173..153f5d8f 100644 --- a/tooling/agent/debugger_impl.h +++ b/tooling/agent/debugger_impl.h @@ -273,16 +273,6 @@ private: return recordName; } - void RemoveUrlFromParsedSet(std::string &url) - { - parsedFileNames_.erase(url); - } - - bool IsUrlFoundInParsedSet(std::string &url) - { - return parsedFileNames_.find(url) != parsedFileNames_.end(); - } - class Frontend { public: explicit Frontend(ProtocolChannel *channel) : channel_(channel) {} @@ -334,7 +324,6 @@ private: JsDebuggerManager::SingleStepperFunc stepperFunc_ {nullptr}; JsDebuggerManager::ReturnNativeFunc returnNative_ {nullptr}; std::vector debuggerExtendedProtocols_ {}; - CUnorderedSet parsedFileNames_ {}; friend class JSPtHooks; friend class test::TestHooks; diff --git a/tooling/backend/js_pt_hooks.cpp b/tooling/backend/js_pt_hooks.cpp index 2a8a06ec..3905adbb 100644 --- a/tooling/backend/js_pt_hooks.cpp +++ b/tooling/backend/js_pt_hooks.cpp @@ -16,7 +16,6 @@ #include "backend/js_pt_hooks.h" #include "agent/debugger_impl.h" -#include "ecmascript/jspandafile/js_pandafile_manager.h" namespace panda::ecmascript::tooling { @@ -51,16 +50,13 @@ bool JSPtHooks::SingleStep(const JSPtLocation &location) LOG_DEBUGGER(VERBOSE) << "JSPtHooks: SingleStep => " << location.GetBytecodeOffset(); [[maybe_unused]] LocalScope scope(debugger_->vm_); - if (!debugger_->parsedFileNames_.empty()) { - auto jsPandaFile = location.GetJsPandaFile(); - DebugInfoExtractor *extractor = JSPandaFileManager::GetInstance()->GetJSPtExtractor(jsPandaFile); - std::string url = extractor->GetSourceFile(location.GetMethodId()); - if (debugger_->IsUrlFoundInParsedSet(url)) { - debugger_->RemoveUrlFromParsedSet(url); - debugger_->NotifyPaused({}, BREAK_ON_START); - return false; - } + if (UNLIKELY(firstTime_)) { + firstTime_ = false; + + debugger_->NotifyPaused({}, BREAK_ON_START); + return false; } + // pause or step complete if (debugger_->NotifySingleStep(location)) { debugger_->NotifyPaused({}, OTHER); @@ -90,8 +86,8 @@ void JSPtHooks::LoadModule(std::string_view pandaFileName, std::string_view entr [[maybe_unused]] LocalScope scope(debugger_->vm_); - if (!debugger_->NotifyScriptParsed(g_scriptId++, pandaFileName.data(), entryPoint)) { - LOG_DEBUGGER(DEBUG) << "JSPtHooks: LoadModule: " << pandaFileName << " NotifyParsed fail"; + if (debugger_->NotifyScriptParsed(g_scriptId++, pandaFileName.data(), entryPoint)) { + firstTime_ = true; } } diff --git a/tooling/backend/js_pt_hooks.h b/tooling/backend/js_pt_hooks.h index 085c6fdf..cb5f7726 100644 --- a/tooling/backend/js_pt_hooks.h +++ b/tooling/backend/js_pt_hooks.h @@ -46,6 +46,7 @@ private: NO_MOVE_SEMANTIC(JSPtHooks); DebuggerImpl *debugger_ {nullptr}; + bool firstTime_ {true}; }; } // namespace panda::ecmascript::tooling #endif // ECMASCRIPT_TOOLING_BACKEND_JS_PT_HOOKS_H \ No newline at end of file -- Gitee From 7313d17fa887d6b42d6b10e34805533421de09ff Mon Sep 17 00:00:00 2001 From: daiweihao Date: Thu, 5 Sep 2024 16:11:53 +0800 Subject: [PATCH 11/25] Revert "es2abc change" This reverts commit 716da4612d8907dc59436e0a58000759f55228ea. Issue:https://gitee.com/openharmony/arkcompiler_toolchain/issues/IAP56M Signed-off-by: daiweihao --- .../components/ets_frontend/es2abc_config.gni | 104 ------------------ .../ets_frontend/ets_frontend_config.gni | 36 ------ build/core/gn/BUILD.gn | 4 +- build/scripts/generate_js_bytecode.py | 96 ---------------- test/test_helper.gni | 4 +- tooling/test/BUILD.gn | 3 +- 6 files changed, 6 insertions(+), 241 deletions(-) delete mode 100644 build/config/components/ets_frontend/es2abc_config.gni delete mode 100644 build/config/components/ets_frontend/ets_frontend_config.gni delete mode 100755 build/scripts/generate_js_bytecode.py diff --git a/build/config/components/ets_frontend/es2abc_config.gni b/build/config/components/ets_frontend/es2abc_config.gni deleted file mode 100644 index a805c564..00000000 --- a/build/config/components/ets_frontend/es2abc_config.gni +++ /dev/null @@ -1,104 +0,0 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("$build_root/config/components/ets_frontend/ets_frontend_config.gni") - -es2abc_root = "//arkcompiler/ets_frontend/es2panda" -es2abc_build_path = "" -es2abc_build_deps = "" -es2abc_out_root = "" - -if (host_toolchain == toolchain_mac) { - es2abc_out_root = - get_label_info("$es2abc_root:es2panda($toolchain_mac)", "root_out_dir") - es2abc_build_deps = [ "$es2abc_root:es2panda($toolchain_mac)" ] -} else if (host_toolchain == toolchain_win) { - es2abc_out_root = - get_label_info("$es2abc_root:es2panda($toolchain_win)", "root_out_dir") - es2abc_build_deps = [ "$es2abc_root:es2panda($toolchain_win)" ] -} else { - es2abc_out_root = - get_label_info("$es2abc_root:es2panda($toolchain_linux)", "root_out_dir") - es2abc_build_deps = [ "$es2abc_root:es2panda($toolchain_linux)" ] -} -es2abc_build_path = es2abc_out_root + "/arkcompiler/ets_frontend" - -# Generate abc. -# -# Mandatory arguments: -# plugin_path -- plugin js file path -# plugin_name -- name of js file, ex: BatteryPlugin.js -# generat_file -- name of generated file -# package_name -- name of generated file's package -# extra_dependencies -- a list of files that should be considered as dependencies, must be label -# out_puts -template("es2abc_gen_abc") { - assert(defined(invoker.src_js), "src_js is required!") - assert(defined(invoker.dst_file), "dst_file is required!") - assert(defined(invoker.out_puts), "out_puts is required!") - - extra_dependencies = [] - if (defined(invoker.extra_dependencies)) { - extra_dependencies += invoker.extra_dependencies - } - - action("$target_name") { - if (defined(invoker.extra_visibility)) { - visibility = invoker.extra_visibility - } - - script = "$build_root/scripts/generate_js_bytecode.py" - - deps = extra_dependencies - deps += es2abc_build_deps - - args = [ - "--src-js", - invoker.src_js, - "--dst-file", - invoker.dst_file, - "--frontend-tool-path", - rebase_path("${es2abc_build_path}"), - ] - - if (defined(invoker.extension)) { - args += [ - "--extension", - invoker.extension, - ] - } - - if (defined(invoker.dump_symbol_table)) { - args += [ - "--dump-symbol-table", - invoker.dump_symbol_table, - ] - } - if (defined(invoker.input_symbol_table)) { - args += [ - "--input-symbol-table", - invoker.input_symbol_table, - ] - } - - if (defined(invoker.extra_args)) { - args += invoker.extra_args - } - - if (defined(invoker.in_puts)) { - inputs = invoker.in_puts - } - - outputs = invoker.out_puts - } -} diff --git a/build/config/components/ets_frontend/ets_frontend_config.gni b/build/config/components/ets_frontend/ets_frontend_config.gni deleted file mode 100644 index 2aebf108..00000000 --- a/build/config/components/ets_frontend/ets_frontend_config.gni +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (c) 2021-2024 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -if (!defined(ark_standalone_build)) { - ark_standalone_build = false -} - -if (!ark_standalone_build) { - build_root = "//build" - ark_third_party_root = "//third_party" - import("$build_root/ohos.gni") -} else { - ark_third_party_root = "//arkcompiler/toolchain/build/third_party_gn" - import("$build_root/ark.gni") -} -import("$build_root/test.gni") - -ets_frontend_root = "//arkcompiler/ets_frontend" - -toolchain_linux = "$build_root/toolchain/linux:clang_x64" -if (host_cpu == "arm64") { - toolchain_mac = "$build_root/toolchain/mac:clang_arm64" -} else { - toolchain_mac = "$build_root/toolchain/mac:clang_x64" -} -toolchain_win = "$build_root/toolchain/mingw:mingw_x86_64" diff --git a/build/core/gn/BUILD.gn b/build/core/gn/BUILD.gn index c9ff832c..2dc69e0b 100644 --- a/build/core/gn/BUILD.gn +++ b/build/core/gn/BUILD.gn @@ -11,8 +11,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//arkcompiler/toolchain/toolchain.gni") -import("$build_root/config/components/ets_frontend/ets_frontend_config.gni") +import("//arkcompiler/ets_frontend/ets_frontend_config.gni") +import("../../../toolchain.gni") print("root_out_dir=$root_out_dir") print("root_build_dir=$root_build_dir") diff --git a/build/scripts/generate_js_bytecode.py b/build/scripts/generate_js_bytecode.py deleted file mode 100755 index f978b33d..00000000 --- a/build/scripts/generate_js_bytecode.py +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env python3 -# coding: utf-8 - -""" -Copyright (c) 2021 Huawei Device Co., Ltd. -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -Description: Generate javascript byte code using es2abc -""" - -import os -import subprocess -import platform -import argparse - - -def parse_args(): - parser = argparse.ArgumentParser() - parser.add_argument('--src-js', - help='js source file') - parser.add_argument('--dst-file', - help='the converted target file') - parser.add_argument('--frontend-tool-path', - help='path of the frontend conversion tool') - parser.add_argument('--extension', - help='source file extension') - parser.add_argument("--debug", action='store_true', - help='whether add debuginfo') - parser.add_argument("--module", action='store_true', - help='whether is module') - parser.add_argument("--commonjs", action='store_true', - help='whether is commonjs') - parser.add_argument("--merge-abc", action='store_true', - help='whether is merge abc') - parser.add_argument("--generate-patch", action='store_true', - help='generate patch abc') - parser.add_argument("--dump-symbol-table", - help='dump symbol table of base abc') - parser.add_argument("--input-symbol-table", - help='input symbol table for patch abc') - arguments = parser.parse_args() - return arguments - - -def run_command(cmd, execution_path): - print(" ".join(cmd) + " | execution_path: " + execution_path) - proc = subprocess.Popen(cmd, cwd=execution_path) - proc.wait() - - -def gen_abc_info(input_arguments): - frontend_tool_path = input_arguments.frontend_tool_path - - (path, name) = os.path.split(frontend_tool_path) - - cmd = [os.path.join("./", name, "es2abc"), - '--output', input_arguments.dst_file, - input_arguments.src_js] - - if input_arguments.extension: - cmd += ['--extension', input_arguments.extension] - if input_arguments.dump_symbol_table: - cmd += ['--dump-symbol-table', input_arguments.dump_symbol_table] - if input_arguments.input_symbol_table: - cmd += ['--input-symbol-table', input_arguments.input_symbol_table] - if input_arguments.debug: - src_index = cmd.index(input_arguments.src_js) - cmd.insert(src_index, '--debug-info') - if input_arguments.module: - src_index = cmd.index(input_arguments.src_js) - cmd.insert(src_index, '--module') - if input_arguments.commonjs: - src_index = cmd.index(input_arguments.src_js) - cmd.insert(src_index, '--commonjs') - if input_arguments.merge_abc: - src_index = cmd.index(input_arguments.src_js) - cmd.insert(src_index, '--merge-abc') - if input_arguments.generate_patch: - src_index = cmd.index(input_arguments.src_js) - cmd.insert(src_index, '--generate-patch') - # insert d.ts option to cmd later - run_command(cmd, path) - - -if __name__ == '__main__': - gen_abc_info(parse_args()) \ No newline at end of file diff --git a/test/test_helper.gni b/test/test_helper.gni index 65c55916..f1f98843 100644 --- a/test/test_helper.gni +++ b/test/test_helper.gni @@ -11,9 +11,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//arkcompiler/toolchain/toolchain.gni") -import("$build_root/config/components/ets_frontend/es2abc_config.gni") +import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") import("$build_root/test.gni") +import("../toolchain.gni") if (is_standard_system || ark_standalone_build) { _icu_path_ = "thirdparty/icu" diff --git a/tooling/test/BUILD.gn b/tooling/test/BUILD.gn index 86cee6a2..7d941caf 100644 --- a/tooling/test/BUILD.gn +++ b/tooling/test/BUILD.gn @@ -11,8 +11,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//arkcompiler/ets_frontend/es2panda/es2abc_config.gni") import("//arkcompiler/toolchain/test/test_helper.gni") -import("$build_root/config/components/ets_frontend/es2abc_config.gni") +import("../../toolchain.gni") module_output_path = "arkcompiler/toolchain" -- Gitee From 3a29b311b1f5646857711d1c2bf98b98cd60d919 Mon Sep 17 00:00:00 2001 From: yang-19970325 Date: Thu, 15 Aug 2024 23:18:00 +0800 Subject: [PATCH 12/25] Fix debugger stuck Issue: #IAKDO8 Signed-off-by: yang-19970325 --- tooling/agent/debugger_impl.cpp | 106 ++++++++++++++++++++++------ tooling/agent/debugger_impl.h | 17 ++--- tooling/backend/js_pt_hooks.cpp | 16 +++-- tooling/backend/js_pt_hooks.h | 1 + tooling/test/debugger_impl_test.cpp | 4 +- tooling/test/utils/test_hooks.h | 2 + 6 files changed, 107 insertions(+), 39 deletions(-) diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index eca8c4ec..cee3f417 100755 --- a/tooling/agent/debugger_impl.cpp +++ b/tooling/agent/debugger_impl.cpp @@ -42,6 +42,8 @@ const std::string DATA_APP_PATH = "/"; const std::string DATA_APP_PATH = "/data/"; #endif +static std::atomic g_scriptId {0}; + DebuggerImpl::DebuggerImpl(const EcmaVM *vm, ProtocolChannel *channel, RuntimeImpl *runtime) : vm_(vm), frontend_(channel), runtime_(runtime) { @@ -68,22 +70,9 @@ DebuggerImpl::~DebuggerImpl() DebuggerApi::DestroyJSDebugger(jsDebugger_); } -bool DebuggerImpl::NotifyScriptParsed(ScriptId scriptId, const std::string &fileName, std::string_view entryPoint) +bool DebuggerImpl::NotifyScriptParsed(const std::string &fileName, std::string_view entryPoint) { -#if !defined(PANDA_TARGET_WINDOWS) && !defined(PANDA_TARGET_MACOS) \ - && !defined(PANDA_TARGET_ANDROID) && !defined(PANDA_TARGET_IOS) \ - && !defined(PANDA_TARGET_LINUX) - if (fileName.substr(0, DATA_APP_PATH.length()) != DATA_APP_PATH) { - LOG_DEBUGGER(DEBUG) << "NotifyScriptParsed: unsupport file: " << fileName; - return false; - } -#endif - - // The release application does not require scriptParsed - if (!vm_->GetJsDebuggerManager()->IsDebugApp()) { - return false; - } - if (!vm_->GetJsDebuggerManager()->IsDebugMode()) { + if (!CheckScriptParsed(fileName)) { return false; } @@ -112,17 +101,13 @@ bool DebuggerImpl::NotifyScriptParsed(ScriptId scriptId, const std::string &file // if load module, it needs to check whether clear singlestepper_ ClearSingleStepper(); - auto urlFileNameIter = urlFileNameMap_.find(url); - if (urlFileNameIter != urlFileNameMap_.end()) { - if (urlFileNameIter->second.find(fileName) != urlFileNameIter->second.end()) { - LOG_DEBUGGER(WARN) << "NotifyScriptParsed: already loaded: " << url; - return false; - } + if (MatchUrlAndFileName(url, fileName)) { + return false; } urlFileNameMap_[url].insert(fileName); // Notify script parsed event - std::unique_ptr script = std::make_unique(scriptId, fileName, url, source); + std::unique_ptr script = std::make_unique(g_scriptId++, fileName, url, source); frontend_.ScriptParsed(vm_, *script); @@ -131,6 +116,83 @@ bool DebuggerImpl::NotifyScriptParsed(ScriptId scriptId, const std::string &file return true; } +bool DebuggerImpl::SendableScriptParsed(const std::string &fileName, const std::string &url, + const std::string &source, const std::string &recordName) +{ + if (!CheckScriptParsed(fileName)) { + return false; + } + + recordNames_[url].insert(recordName); + + // if load module, it needs to check whether clear singlestepper_ + ClearSingleStepper(); + // Notify script parsed event + std::unique_ptr script = std::make_unique(g_scriptId++, fileName, url, source); + + frontend_.ScriptParsed(vm_, *script); + + // Store parsed script in map + scripts_[script->GetScriptId()] = std::move(script); + return true; +} + +bool DebuggerImpl::CheckScriptParsed([[maybe_unused]] const std::string &fileName) +{ +#if !defined(PANDA_TARGET_WINDOWS) && !defined(PANDA_TARGET_MACOS) \ + && !defined(PANDA_TARGET_ANDROID) && !defined(PANDA_TARGET_IOS) \ + && !defined(PANDA_TARGET_LINUX) + if (fileName.substr(0, DATA_APP_PATH.length()) != DATA_APP_PATH) { + LOG_DEBUGGER(DEBUG) << "SendableScriptParsed: unsupport file: " << fileName; + return false; + } +#endif + + // The release application does not require scriptParsed + if (!vm_->GetJsDebuggerManager()->IsDebugApp()) { + return false; + } + + return true; +} + +bool DebuggerImpl::SendableMethodEntry(JSHandle method) +{ + const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + if (jsPandaFile == nullptr) { + LOG_DEBUGGER(ERROR) << "JSPandaFile is nullptr"; + return false; + } + DebugInfoExtractor *extractor = JSPandaFileManager::GetInstance()->GetJSPtExtractor(jsPandaFile); + if (extractor == nullptr) { + LOG_DEBUGGER(ERROR) << "extractor is nullptr"; + return false; + } + auto methodId = method->GetMethodId(); + const std::string &url = extractor->GetSourceFile(methodId); + const std::string &fileName = std::string(jsPandaFile->GetJSPandaFileDesc()); + if (!MatchUrlAndFileName(url, fileName)) { + // scriptParsed + const std::string &source = extractor->GetSourceCode(methodId); + const std::string &recordName = std::string(method->GetRecordNameStr()); + SendableScriptParsed(fileName, url, source, recordName); + return true; + } + return false; +} + +bool DebuggerImpl::MatchUrlAndFileName(const std::string &url, const std::string &fileName) +{ + auto urlFileNameIter = urlFileNameMap_.find(url); + if (urlFileNameIter != urlFileNameMap_.end()) { + if (urlFileNameIter->second.find(fileName) != urlFileNameIter->second.end()) { + LOG_DEBUGGER(WARN) << "MatchUrlAndFileName: already loaded: " << url; + return true; + } + } + return false; +} + bool DebuggerImpl::NotifyNativeOut() { if (nativeOutPause_) { diff --git a/tooling/agent/debugger_impl.h b/tooling/agent/debugger_impl.h index 9130e613..98baa21d 100644 --- a/tooling/agent/debugger_impl.h +++ b/tooling/agent/debugger_impl.h @@ -38,8 +38,13 @@ public: ~DebuggerImpl(); // event - bool NotifyScriptParsed(ScriptId scriptId, const std::string &fileName, + bool NotifyScriptParsed(const std::string &fileName, std::string_view entryPoint = "func_main_0"); + bool SendableScriptParsed(const std::string &fileName, const std::string &url, + const std::string &source, const std::string &recordName); + bool CheckScriptParsed(const std::string &fileName); + bool SendableMethodEntry(JSHandle method); + bool MatchUrlAndFileName(const std::string &url, const std::string &fileName); bool NotifySingleStep(const JSPtLocation &location); void NotifyPaused(std::optional location, PauseReason reason); void GeneratePausedInfo(PauseReason reason, @@ -127,16 +132,6 @@ public: return false; } - bool MatchUrlAndFileName(const std::string &url, const std::string &fileName) const - { - for (const auto &script : scripts_) { - if (url == script.second->GetUrl() && fileName == script.second->GetFileName()) { - return true; - } - } - return false; - } - std::vector MatchAllScripts(const std::string &url) const { std::vector result; diff --git a/tooling/backend/js_pt_hooks.cpp b/tooling/backend/js_pt_hooks.cpp index 3905adbb..b704d8b6 100644 --- a/tooling/backend/js_pt_hooks.cpp +++ b/tooling/backend/js_pt_hooks.cpp @@ -18,9 +18,6 @@ #include "agent/debugger_impl.h" namespace panda::ecmascript::tooling { - -static std::atomic g_scriptId {0}; - void JSPtHooks::DebuggerStmt([[maybe_unused]] const JSPtLocation &location) { LOG_DEBUGGER(VERBOSE) << "JSPHooks: Debugger Statement"; @@ -86,7 +83,7 @@ void JSPtHooks::LoadModule(std::string_view pandaFileName, std::string_view entr [[maybe_unused]] LocalScope scope(debugger_->vm_); - if (debugger_->NotifyScriptParsed(g_scriptId++, pandaFileName.data(), entryPoint)) { + if (debugger_->NotifyScriptParsed(pandaFileName.data(), entryPoint)) { firstTime_ = true; } } @@ -106,4 +103,15 @@ void JSPtHooks::NativeReturn(const void *nativeAddress) debugger_->NotifyNativeReturn(nativeAddress); } + +void JSPtHooks::SendableMethodEntry(JSHandle method) +{ + LOG_DEBUGGER(VERBOSE) << "JSPtHooks: MethodEntry"; + + [[maybe_unused]] LocalScope scope(debugger_->vm_); + + if (debugger_->SendableMethodEntry(method)) { + firstTime_ = true; + }; +} } // namespace panda::ecmascript::tooling diff --git a/tooling/backend/js_pt_hooks.h b/tooling/backend/js_pt_hooks.h index cb5f7726..a8429053 100644 --- a/tooling/backend/js_pt_hooks.h +++ b/tooling/backend/js_pt_hooks.h @@ -40,6 +40,7 @@ public: void NativeReturn(const void *nativeAddress) override; void VmStart() override {} void VmDeath() override {} + void SendableMethodEntry(JSHandle method) override; private: NO_COPY_SEMANTIC(JSPtHooks); diff --git a/tooling/test/debugger_impl_test.cpp b/tooling/test/debugger_impl_test.cpp index 5be5f405..79e9903a 100644 --- a/tooling/test/debugger_impl_test.cpp +++ b/tooling/test/debugger_impl_test.cpp @@ -62,11 +62,11 @@ HWTEST_F_L0(DebuggerImplTest, NotifyScriptParsed__001) // DebuggerImpl::NotifyScriptParsed -- fileName.substr(0, DATA_APP_PATH.length()) != DATA_APP_PATH std::string strFilename = "filename"; - EXPECT_FALSE(debuggerImpl->NotifyScriptParsed(0, strFilename, "")); + EXPECT_FALSE(debuggerImpl->NotifyScriptParsed(strFilename, "")); // DebuggerImpl::NotifyScriptParsed -- fileName.substr(0, DATA_APP_PATH.length()) != DATA_APP_PATH strFilename = "/filename"; - EXPECT_FALSE(debuggerImpl->NotifyScriptParsed(0, strFilename, "")); + EXPECT_FALSE(debuggerImpl->NotifyScriptParsed(strFilename, "")); if (protocolChannel) { delete protocolChannel; diff --git a/tooling/test/utils/test_hooks.h b/tooling/test/utils/test_hooks.h index b1fd969a..88cda04a 100644 --- a/tooling/test/utils/test_hooks.h +++ b/tooling/test/utils/test_hooks.h @@ -116,6 +116,8 @@ public: void NativeReturn([[maybe_unused]] const void *nativeAddress) override {} + void SendableMethodEntry([[maybe_unused]] JSHandle method) override {} + void TerminateTest() { debugInterface_->UnregisterHooks(); -- Gitee From e074300c51146d959ec16d07b42c65beca80b034 Mon Sep 17 00:00:00 2001 From: daiweihao Date: Mon, 9 Sep 2024 10:43:39 +0800 Subject: [PATCH 13/25] Sync Code Sync Code Issue:https://gitee.com/openharmony/arkcompiler_toolchain/issues/IAPBOO Signed-off-by: daiweihao Change-Id: If50019622bcf326f1cd07919410b70a0642508f5 --- inspector/BUILD.gn | 2 -- tooling/BUILD.gn | 1 - tooling/agent/debugger_impl.cpp | 3 --- tooling/agent/runtime_impl.cpp | 6 +++--- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/inspector/BUILD.gn b/inspector/BUILD.gn index ed217326..2ab3234d 100644 --- a/inspector/BUILD.gn +++ b/inspector/BUILD.gn @@ -66,7 +66,6 @@ ohos_shared_library("ark_debugger") { if (enable_hilog) { external_deps = [ "hilog:libhilog" ] } - innerapi_tags = [ "platformsdk" ] subsystem_name = "arkcompiler" part_name = "toolchain" output_name = "ark_inspector" @@ -116,7 +115,6 @@ ohos_shared_library("connectserver_debugger") { if (enable_hilog) { external_deps = [ "hilog:libhilog" ] } - innerapi_tags = [ "platformsdk" ] subsystem_name = "arkcompiler" part_name = "toolchain" output_name = "ark_connect_inspector" diff --git a/tooling/BUILD.gn b/tooling/BUILD.gn index 9221adcb..81dd10b9 100644 --- a/tooling/BUILD.gn +++ b/tooling/BUILD.gn @@ -124,7 +124,6 @@ ohos_shared_library("libark_ecma_debugger") { if (!is_standard_system) { relative_install_dir = "ark" } - innerapi_tags = [ "platformsdk" ] subsystem_name = "arkcompiler" part_name = "toolchain" output_name = "libark_tooling" diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index cee3f417..88dabb61 100755 --- a/tooling/agent/debugger_impl.cpp +++ b/tooling/agent/debugger_impl.cpp @@ -26,8 +26,6 @@ #include "ecmascript/jspandafile/js_pandafile_manager.h" #include "ecmascript/napi/jsnapi_helper.h" -#include "ecmascript/tagged_array-inl.h" - namespace panda::ecmascript::tooling { using namespace std::placeholders; @@ -1243,7 +1241,6 @@ void DebuggerImpl::AddBreakpointDetail(const std::string &url, *outId = BreakpointDetails::ToString(metaData); } - DispatchResponse DebuggerImpl::SetBreakpointByUrl(const SetBreakpointByUrlParams ¶ms, std::string *outId, std::vector> *outLocations, diff --git a/tooling/agent/runtime_impl.cpp b/tooling/agent/runtime_impl.cpp index 470380f6..1e3d1d22 100644 --- a/tooling/agent/runtime_impl.cpp +++ b/tooling/agent/runtime_impl.cpp @@ -627,13 +627,13 @@ void RuntimeImpl::GetMapValue(Local value, std::vector> *outPropertyDesc) { Local mapRef = value->ToObject(vm_); - int32_t size = mapRef->GetSize(vm_); - int32_t len = mapRef->GetTotalElements(vm_); + uint32_t size = mapRef->GetSize(vm_); + uint32_t len = mapRef->GetTotalElements(vm_); int32_t index = 0; Local jsValueRef = NumberRef::New(vm_, size); SetKeyValue(jsValueRef, outPropertyDesc, "size"); jsValueRef = ArrayRef::New(vm_, size); - for (int32_t i = 0; i < len; ++i) { + for (uint32_t i = 0; i < len; ++i) { Local jsKey = mapRef->GetKey(vm_, i); if (jsKey->IsHole()) { continue; -- Gitee From 0996feaef919dc13b2c458b407b59e8fdd56ebdb Mon Sep 17 00:00:00 2001 From: daiweihao Date: Tue, 10 Sep 2024 19:24:08 +0800 Subject: [PATCH 14/25] Sync code Sync code. Issue:https://gitee.com/openharmony/arkcompiler_toolchain/issues/IAQCKL Signed-off-by: daiweihao Change-Id: I6bbcae760cbbfd3f6d7e51524add8e7103e0fefe --- tooling/agent/runtime_impl.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tooling/agent/runtime_impl.cpp b/tooling/agent/runtime_impl.cpp index 1e3d1d22..4d58d1e2 100644 --- a/tooling/agent/runtime_impl.cpp +++ b/tooling/agent/runtime_impl.cpp @@ -627,13 +627,13 @@ void RuntimeImpl::GetMapValue(Local value, std::vector> *outPropertyDesc) { Local mapRef = value->ToObject(vm_); - uint32_t size = mapRef->GetSize(vm_); - uint32_t len = mapRef->GetTotalElements(vm_); + int32_t size = mapRef->GetSize(vm_); + int32_t len = mapRef->GetTotalElements(vm_); int32_t index = 0; Local jsValueRef = NumberRef::New(vm_, size); SetKeyValue(jsValueRef, outPropertyDesc, "size"); jsValueRef = ArrayRef::New(vm_, size); - for (uint32_t i = 0; i < len; ++i) { + for (int32_t i = 0; i < len; ++i) { Local jsKey = mapRef->GetKey(vm_, i); if (jsKey->IsHole()) { continue; @@ -677,13 +677,13 @@ void RuntimeImpl::GetSendableSetValue(Local value, std::vector> *outPropertyDesc) { Local setRef = value->ToObject(vm_); - int32_t size = setRef->GetSize(vm_); - int32_t len = setRef->GetTotalElements(vm_); + uint32_t size = setRef->GetSize(vm_); + uint32_t len = setRef->GetTotalElements(vm_); int32_t index = 0; Local jsValueRef = NumberRef::New(vm_, size); SetKeyValue(jsValueRef, outPropertyDesc, "size"); jsValueRef = ArrayRef::New(vm_, size); - for (int32_t i = 0; i < len; ++i) { + for (uint32_t i = 0; i < len; ++i) { Local elementRef = setRef->GetValue(vm_, i); if (elementRef->IsHole()) { continue; -- Gitee From a418d23a0b9912d61734359c2b4e17f3ca4d03b0 Mon Sep 17 00:00:00 2001 From: hanweiqi Date: Wed, 21 Aug 2024 18:54:28 +0800 Subject: [PATCH 15/25] cherry pick 791c884 from https://gitee.com/hanweiqi3/arkcompiler_toolchain/pulls/826 Avoid Sendable's DropFrame Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IALL34 Signed-off-by: hanweiqi --- tooling/agent/debugger_impl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index 88dabb61..58a8d872 100755 --- a/tooling/agent/debugger_impl.cpp +++ b/tooling/agent/debugger_impl.cpp @@ -1504,6 +1504,9 @@ DispatchResponse DebuggerImpl::DropFrame(const DropFrameParams ¶ms) if (droppedDepth >= stackDepthOverBuiltin) { return DispatchResponse::Fail("Frames to be dropped contain builtin frame"); } + if (DebuggerApi::CheckIsSendableMethod(vm_)) { + return DispatchResponse::Fail("Not yet support sendable method"); + } if (!DebuggerApi::CheckPromiseQueueSize(vm_)) { return DispatchResponse::Fail("Detect promise enqueued in current frame"); } -- Gitee From 86ffff7377672633914ae219b522d51a0c74de69 Mon Sep 17 00:00:00 2001 From: bigtea Date: Sat, 21 Sep 2024 14:42:00 +0800 Subject: [PATCH 16/25] Disable cpuprofile and heapsampling testcases Issue: IASOSK Signed-off-by: bigtea --- tooling/test/client_utils/test_list.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tooling/test/client_utils/test_list.cpp b/tooling/test/client_utils/test_list.cpp index f3acefb5..cdd96ac0 100644 --- a/tooling/test/client_utils/test_list.cpp +++ b/tooling/test/client_utils/test_list.cpp @@ -24,8 +24,6 @@ #include "tooling/test/testcases/js_closure_scope_test.h" #include "tooling/test/testcases/js_container_test.h" #include "tooling/test/testcases/js_exception_test.h" -#include "tooling/test/testcases/js_heapsampling_loop_test.h" -#include "tooling/test/testcases/js_heapsampling_test.h" #include "tooling/test/testcases/js_local_variable_scope_test.h" #include "tooling/test/testcases/js_module_variable_test.h" #include "tooling/test/testcases/js_source_test.h" @@ -51,9 +49,6 @@ #include "tooling/test/testcases/js_stepinto_async_test.h" #include "tooling/test/testcases/js_stepout_arrow_test.h" #include "tooling/test/testcases/js_stepout_async_test.h" -#include "tooling/test/testcases/js_cpuprofile_test.h" -#include "tooling/test/testcases/js_cpuprofile_async_test.h" -#include "tooling/test/testcases/js_cpuprofile_step_test.h" #include "tooling/test/testcases/js_heapusage_test.h" #include "tooling/test/testcases/js_heapusage_async_test.h" #include "tooling/test/testcases/js_heapusage_step_test.h" @@ -72,8 +67,6 @@ #include "tooling/test/testcases/js_breakpoint_loop_test.h" #include "tooling/test/testcases/js_breakpoint_recursion_test.h" #include "tooling/test/testcases/js_breakpoint_switch_test.h" -#include "tooling/test/testcases/js_cpuprofile_loop_test.h" -#include "tooling/test/testcases/js_cpuprofile_recursion_test.h" #include "tooling/test/testcases/js_heapusage_loop_test.h" #include "tooling/test/testcases/js_heapusage_recursion_test.h" #include "tooling/test/testcases/js_smart_stepInto_test.h" @@ -94,7 +87,6 @@ static void RegisterTests() TestUtil::RegisterTest("JsModuleVariableTest", GetJsModuleVariableTest()); TestUtil::RegisterTest("JsSourceTest", GetJsSourceTest()); TestUtil::RegisterTest("JsTracingTest", GetJsTracingTest()); - TestUtil::RegisterTest("JsHeapsamplingTest", GetJsHeapsamplingTest()); TestUtil::RegisterTest("JsWatchTest", GetJsWatchTest()); TestUtil::RegisterTest("JsHeapdumpTest", GetJsHeapdumpTest()); TestUtil::RegisterTest("JsAllocationtrackTest", GetJsAllocationtrackTest()); @@ -113,16 +105,12 @@ static void RegisterTests() TestUtil::RegisterTest("JsStepintoAsyncTest", GetJsStepintoAsyncTest()); TestUtil::RegisterTest("JsStepoutArrowTest", GetJsStepoutArrowTest()); TestUtil::RegisterTest("JsStepoutAsyncTest", GetJsStepoutAsyncTest()); - TestUtil::RegisterTest("JsCpuprofileTest", GetJsCpuprofileTest()); - TestUtil::RegisterTest("JsCpuprofileAsyncTest", GetJsCpuprofileAsyncTest()); - TestUtil::RegisterTest("JsCpuprofileStepTest", GetJsCpuprofileStepTest()); TestUtil::RegisterTest("JsHeapusageTest", GetJsHeapusageTest()); TestUtil::RegisterTest("JsHeapusageAsyncTest", GetJsHeapusageAsyncTest()); TestUtil::RegisterTest("JsHeapusageStepTest", GetJsHeapusageStepTest()); TestUtil::RegisterTest("JsHeapdumpLoopTest", GetJsHeapdumpLoopTest()); TestUtil::RegisterTest("JsAllocationTrackLoopTest", GetJsAllocationTrackLoopTest()); TestUtil::RegisterTest("JsAllocationTrackRecursionTest", GetJsAllocationTrackRecursionTest()); - TestUtil::RegisterTest("JsHeapSamplingLoopTest", GetJsHeapSamplingLoopTest()); TestUtil::RegisterTest("JsJsWatchBasicTypeTest", GetJsWatchBasicTypeTest()); TestUtil::RegisterTest("JsJsWatchSetTypeTest", GetJsWatchSetTypeTest()); TestUtil::RegisterTest("JsJsWatchOtherTypeTest", GetJsWatchOtherTypeTest()); @@ -138,7 +126,6 @@ static void RegisterTests() TestUtil::RegisterTest("JsBreakpointLoopTest", GetJsBreakpointLoopTest()); TestUtil::RegisterTest("JsBreakpointRecursionTest", GetJsBreakpointRecursionTest()); TestUtil::RegisterTest("JsBreakpointSwitchTest", GetJsBreakpointSwitchTest()); - TestUtil::RegisterTest("JsCpuprofileLoopTest", GetJsCpuprofileLoopTest()); TestUtil::RegisterTest("JsHeapusageLoopTest", GetJsHeapusageLoopTest()); TestUtil::RegisterTest("JsHeapusageRecursionTest", GetJsHeapusageRecursionTest()); TestUtil::RegisterTest("JsSmartStepoutTest", GetJsSmartStepoutTest()); -- Gitee From bff224f33a7eccfba8f17ca76633c3e7041677bc Mon Sep 17 00:00:00 2001 From: daiweihao Date: Mon, 5 Aug 2024 21:22:08 +0800 Subject: [PATCH 17/25] Sync PR 798 Sync PR 798. Issue:https://gitee.com/openharmony/arkcompiler_toolchain/issues/IATVCE Signed-off-by: daiweihao Change-Id: I263cfc9369c1143b5acc7dee6cc3007c537ae280 --- BUILD.gn | 3 + inspector/test/BUILD.gn | 69 +++++++++++ inspector/test/connect_server_test.cpp | 155 +++++++++++++++++++++++++ test/resource/tooling/ohos_test.xml | 5 + websocket/test/websocket_test.cpp | 18 +-- 5 files changed, 242 insertions(+), 8 deletions(-) create mode 100644 inspector/test/BUILD.gn create mode 100644 inspector/test/connect_server_test.cpp diff --git a/BUILD.gn b/BUILD.gn index 5d98ae83..6dce3edb 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -215,6 +215,7 @@ config("ark_toolchain_public_config") { # ecmascript unit testcase config config("toolchain_test_config") { visibility = [ + "./inspector/test/*", "./test/fuzztest/*", "./tooling/test/*", "./websocket/test/*", @@ -243,6 +244,7 @@ group("ark_toolchain_unittest") { testonly = true deps = [] deps += [ + "./inspector/test:unittest", "./tooling/test:unittest", "./websocket/test:unittest", ] @@ -257,6 +259,7 @@ group("ark_toolchain_host_unittest") { # js unittest deps += [ + "./inspector/test:host_unittest", "./tooling/test:host_unittest", "./websocket/test:host_unittest", ] diff --git a/inspector/test/BUILD.gn b/inspector/test/BUILD.gn new file mode 100644 index 00000000..4153eb43 --- /dev/null +++ b/inspector/test/BUILD.gn @@ -0,0 +1,69 @@ +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//arkcompiler/toolchain/test/test_helper.gni") +import("//arkcompiler/toolchain/toolchain.gni") + +module_output_path = "arkcompiler/toolchain" + +host_unittest_action("InspectorConnectTest") { + module_out_path = module_output_path + + include_dirs = [ "$toolchain_root/inspector" ] + + sources = [ + # test file + "connect_server_test.cpp", + ] + + configs = [ "$toolchain_root:toolchain_test_config" ] + + deps = [ + "$toolchain_root/inspector:connectserver_debugger", + "$toolchain_root/websocket:websocket_client", + "$toolchain_root/websocket:websocket_server", + ] + + # hiviewdfx libraries + external_deps = hiviewdfx_ext_deps + if (is_arkui_x && target_os == "ios") { + external_deps += [ "openssl:libcrypto_static" ] + } else { + external_deps += [ "openssl:libcrypto_shared" ] + } + + external_deps += [ "bounds_checking_function:libsec_shared" ] + deps += hiviewdfx_deps +} + +group("unittest") { + testonly = true + + # deps file + deps = [ ":InspectorConnectTest" ] + + if (is_mac) { + deps -= [ ":InspectorConnectTest" ] + } +} + +group("host_unittest") { + testonly = true + + # deps file + deps = [ ":InspectorConnectTestAction" ] + + if (is_mac) { + deps -= [ ":InspectorConnectTestAction" ] + } +} diff --git a/inspector/test/connect_server_test.cpp b/inspector/test/connect_server_test.cpp new file mode 100644 index 00000000..1eeeba1a --- /dev/null +++ b/inspector/test/connect_server_test.cpp @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gtest/gtest.h" +#include "inspector/connect_inspector.h" +#include "inspector/connect_server.h" +#include "websocket/client/websocket_client.h" +#include "websocket/server/websocket_server.h" + +using namespace OHOS::ArkCompiler::Toolchain; + +namespace panda::test { +class ConnectServerTest : public testing::Test { +public: + static void SetUpTestCase() + { + GTEST_LOG_(INFO) << "ConnectServerTest::SetUpTestCase"; + } + + static void TearDownTestCase() + { + GTEST_LOG_(INFO) << "ConnectServerTest::TearDownTestCase"; + } + + void SetUp() override {} + + void TearDown() override {} +#if defined(OHOS_PLATFORM) + static constexpr char CONNECTED_MESSAGE_TEST[] = "connected"; + static constexpr char OPEN_MESSAGE_TEST[] = "layoutOpen"; + static constexpr char CLOSE_MESSAGE_TEST[] = "layoutClose"; + static constexpr char REQUEST_MESSAGE_TEST[] = "tree"; + static constexpr char STOPDEBUGGER_MESSAGE_TEST[] = "stopDebugger"; + static constexpr char OPEN_ARKUI_STATE_PROFILER_TEST[] = "ArkUIStateProfilerOpen"; + static constexpr char CLOSE_ARKUI_STATE_PROFILER_TEST[] = "ArkUIStateProfilerClose"; + + static constexpr char HELLO_INSPECTOR_CLIENT[] = "hello inspector client"; + static constexpr char INSPECTOR_SERVER_OK[] = "inspector server ok"; + static constexpr char INSPECTOR_RUN[] = "inspector run"; + static constexpr char INSPECTOR_QUIT[] = "inspector quit"; +#endif +}; + +bool g_profilerFlag = false; +bool g_connectFlag = false; +bool g_switchStatus = false; +int32_t g_createInfoId = 0; +int32_t g_instanceId = 1; + +void CallbackInit() +{ + auto profilerCb = [](bool flag) -> void { + g_profilerFlag = flag; + }; + SetProfilerCallback(profilerCb); + + auto connectCb = [](bool flag) -> void { + g_connectFlag = flag; + }; + SetConnectCallback(connectCb); + + auto debugModeCb = []() -> void { + GTEST_LOG_(INFO) << "Execute DebugModeCallBack."; + }; + SetDebugModeCallBack(debugModeCb); + + auto switchStatusCb = [](bool flag) -> void { + g_switchStatus = flag; + }; + auto createInfoCb = [](int32_t id) -> void { + g_createInfoId = id; + }; + SetSwitchCallBack(switchStatusCb, createInfoCb, g_instanceId); + GTEST_LOG_(INFO) << "ConnectServerTest::CallbackInit finished"; +} + +HWTEST_F(ConnectServerTest, InspectorBasicTest, testing::ext::TestSize.Level0) +{ + ASSERT_TRUE(WaitForConnection()); +} + +HWTEST_F(ConnectServerTest, InspectorConnectTest, testing::ext::TestSize.Level0) +{ + CallbackInit(); +#if defined(OHOS_PLATFORM) + int appPid = getprocpid(); + int oldProcessfd = -2; + StartServerForSocketPair(oldProcessfd); + StoreMessage(g_instanceId, HELLO_INSPECTOR_CLIENT); + pid_t pid = fork(); + if (pid == 0) { + WebSocketClient clientSocket; + ASSERT_TRUE(clientSocket.InitToolchainWebSocketForSockName(std::to_string(appPid))); + ASSERT_TRUE(clientSocket.ClientSendWSUpgradeReq()); + ASSERT_TRUE(clientSocket.ClientRecvWSUpgradeRsp()); + EXPECT_TRUE(clientSocket.SendReply(OPEN_ARKUI_STATE_PROFILER_TEST)); + EXPECT_TRUE(clientSocket.SendReply(REQUEST_MESSAGE_TEST)); + EXPECT_TRUE(clientSocket.SendReply(OPEN_MESSAGE_TEST)); + EXPECT_TRUE(clientSocket.SendReply(CONNECTED_MESSAGE_TEST)); + + EXPECT_STREQ(clientSocket.Decode().c_str(), HELLO_INSPECTOR_CLIENT); + + std::string recv = clientSocket.Decode(); + EXPECT_STREQ(recv.c_str(), INSPECTOR_SERVER_OK); + if (strcmp(recv.c_str(), INSPECTOR_SERVER_OK) == 0) { + EXPECT_TRUE(clientSocket.SendReply(CLOSE_MESSAGE_TEST)); + EXPECT_TRUE(clientSocket.SendReply(STOPDEBUGGER_MESSAGE_TEST)); + EXPECT_TRUE(clientSocket.SendReply(CLOSE_ARKUI_STATE_PROFILER_TEST)); + } + + EXPECT_STREQ(clientSocket.Decode().c_str(), INSPECTOR_RUN); + EXPECT_STREQ(clientSocket.Decode().c_str(), INSPECTOR_QUIT); + clientSocket.Close(); + exit(0); + } else if (pid > 0) { + // Waiting for executing the message instruction sent by the client + sleep(2); + ASSERT_TRUE(g_profilerFlag); + ASSERT_EQ(g_createInfoId, g_instanceId); + ASSERT_TRUE(g_switchStatus); + ASSERT_TRUE(g_connectFlag); + ASSERT_FALSE(WaitForConnection()); + + SendMessage(INSPECTOR_SERVER_OK); + SendLayoutMessage(INSPECTOR_RUN); + + // Waiting for executing the message instruction sent by the client + sleep(2); + ASSERT_FALSE(g_profilerFlag); + ASSERT_FALSE(g_switchStatus); + ASSERT_FALSE(g_connectFlag); + + SendProfilerMessage(INSPECTOR_QUIT); + + StopServer("InspectorConnectTest"); + } else { + std::cerr << "InspectorConnectTest::fork failed" << std::endl; + } + RemoveMessage(g_instanceId); +#endif +} + +} // namespace panda::test \ No newline at end of file diff --git a/test/resource/tooling/ohos_test.xml b/test/resource/tooling/ohos_test.xml index a733d13e..5b9dc623 100755 --- a/test/resource/tooling/ohos_test.xml +++ b/test/resource/tooling/ohos_test.xml @@ -275,4 +275,9 @@