mirror of
https://gitee.com/openharmony/arkcompiler_toolchain
synced 2024-11-23 07:30:33 +00:00
Add E2E UT framework
1. add socket client test 2. add breakpoint test Issue: https://gitee.com/openharmony/arkcompiler_toolchain/issues/I89IL1 Signed-off-by: wengchangcheng <wengchangcheng@huawei.com> Change-Id: I5f2ebb6901222a50a45591d40834c5ed922b9858
This commit is contained in:
parent
b6da96ec72
commit
8079b487c7
5
BUILD.gn
5
BUILD.gn
@ -40,6 +40,11 @@ config("ark_platform_config") {
|
||||
"OHOS_PLATFORM",
|
||||
"UNIX_PLATFORM",
|
||||
]
|
||||
} else if (is_linux) {
|
||||
defines += [
|
||||
"LINUX_PLATFORM",
|
||||
"UNIX_PLATFORM",
|
||||
]
|
||||
} else if (is_mingw) {
|
||||
defines += [ "WINDOWS_PLATFORM" ]
|
||||
} else if (target_os == "android") {
|
||||
|
@ -22,4 +22,5 @@ if (QEMU_INSTALLATION_PATH == "") {
|
||||
" differently. Get set-up steps from" +
|
||||
" https://gitee.com/ark_standalone_build/docs if you need to run" +
|
||||
" executables of non-host type.")
|
||||
QEMU_INSTALLATION_PATH = "/"
|
||||
}
|
||||
|
@ -152,6 +152,7 @@ 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",
|
||||
]
|
||||
@ -414,6 +415,7 @@ musl_src_file = [
|
||||
"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",
|
||||
@ -2157,6 +2159,7 @@ musl_src_porting_file = [
|
||||
"include/unistd.h",
|
||||
"include/dlfcn.h",
|
||||
"include/dlfcn_ext.h",
|
||||
"src/fcntl/open.c",
|
||||
"src/hilog/hilog_common.h",
|
||||
"src/hilog/vsnprintf_s_p.h",
|
||||
"src/internal/hilog_adapter.h",
|
||||
@ -2169,6 +2172,9 @@ musl_src_porting_file = [
|
||||
"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",
|
||||
"ldso/namespace.h",
|
||||
"ldso/ns_config.h",
|
||||
"ldso/strops.h",
|
||||
@ -2190,6 +2196,7 @@ musl_src_porting_file = [
|
||||
"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",
|
||||
@ -2209,6 +2216,7 @@ musl_src_porting_file = [
|
||||
"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",
|
||||
@ -2298,12 +2306,15 @@ musl_src_porting_file = [
|
||||
"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",
|
||||
|
@ -13,8 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ARKCOMPILER_TOOLCHAIN_INSPECTOR_LOG_WRAPPER_H
|
||||
#define ARKCOMPILER_TOOLCHAIN_INSPECTOR_LOG_WRAPPER_H
|
||||
#ifndef ARKCOMPILER_TOOLCHAIN_COMMON_LOG_WRAPPER_H
|
||||
#define ARKCOMPILER_TOOLCHAIN_COMMON_LOG_WRAPPER_H
|
||||
|
||||
#include "common/macros.h"
|
||||
|
||||
#if defined(ENABLE_HILOG)
|
||||
#include "hilog/log.h"
|
||||
@ -48,7 +50,7 @@ enum class LogLevel {
|
||||
ERROR,
|
||||
FATAL
|
||||
};
|
||||
class StdLog {
|
||||
class TOOLCHAIN_EXPORT StdLog {
|
||||
public:
|
||||
StdLog() = default;
|
||||
~StdLog() = default;
|
||||
@ -80,4 +82,4 @@ static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {
|
||||
#endif
|
||||
#pragma clang diagnostic pop
|
||||
} // namespace OHOS::ArkCompiler::Toolchain
|
||||
#endif // ARKCOMPILER_TOOLCHAIN_INSPECTOR_LOG_WRAPPER_H
|
||||
#endif // ARKCOMPILER_TOOLCHAIN_COMMON_LOG_WRAPPER_H
|
||||
|
26
common/macros.h
Normal file
26
common/macros.h
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 2022 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.
|
||||
*/
|
||||
|
||||
#ifndef ARKCOMPILER_TOOLCHAIN_COMMON_MACROS_H
|
||||
#define ARKCOMPILER_TOOLCHAIN_COMMON_MACROS_H
|
||||
|
||||
#ifndef PANDA_TARGET_WINDOWS
|
||||
#define TOOLCHAIN_EXPORT __attribute__((visibility ("default")))
|
||||
#else
|
||||
#define TOOLCHAIN_EXPORT __declspec(dllexport)
|
||||
#endif
|
||||
|
||||
#endif // ARKCOMPILER_TOOLCHAIN_COMMON_MACROS_H
|
@ -47,6 +47,48 @@
|
||||
<option name="push" value="test/test/libark_ecma_debugger_test.so -> /data/test" src="out"/>
|
||||
</preparer>
|
||||
</target>
|
||||
<target name="DebuggerClientTest">
|
||||
<preparer>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/sample.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/exception.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/arrow_func.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/async_func.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/range_error.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/syntax_exception.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/throw_exception.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/step.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/dropframe.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/variable_first.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/variable_second.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/module_variable.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/export_variable_first.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/export_variable_second.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/container.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/local_variable_scope.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/closure_scope.abc -> /data/test" src="out"/>
|
||||
</preparer>
|
||||
</target>
|
||||
<target name="DebuggerCIntClientTest">
|
||||
<preparer>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/sample.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/exception.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/arrow_func.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/async_func.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/range_error.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/syntax_exception.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/throw_exception.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/step.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/dropframe.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/variable_first.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/variable_second.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/module_variable.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/export_variable_first.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/export_variable_second.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/container.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/local_variable_scope.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/toolchain/tooling/test/closure_scope.abc -> /data/test" src="out"/>
|
||||
</preparer>
|
||||
</target>
|
||||
<target name="DebuggerTest">
|
||||
<preparer>
|
||||
<option name="push" value="test/test/libark_jsruntime_test.so -> /data/test" src="out"/>
|
||||
|
@ -52,6 +52,7 @@ template("host_unittest_action") {
|
||||
"0",
|
||||
"--env-path",
|
||||
rebase_path(_root_out_dir_) + "/arkcompiler/ets_runtime:" +
|
||||
rebase_path(_root_out_dir_) + "/arkcompiler/toolchain:" +
|
||||
rebase_path(_root_out_dir_) + "/test/test:" +
|
||||
rebase_path(_root_out_dir_) + "/${_icu_path_}:" +
|
||||
rebase_path(_root_out_dir_) + "/thirdparty/cJSON:" +
|
||||
@ -102,8 +103,7 @@ template("host_unittest_action") {
|
||||
rebase_path("${clang_base_path}/lib/${musl_arch}-linux-ohos",
|
||||
root_build_dir),
|
||||
"--qemu-binary-path",
|
||||
rebase_path("${QEMU_INSTALLATION_PATH}/bin/qemu-${musl_arch}",
|
||||
root_build_dir),
|
||||
"${QEMU_INSTALLATION_PATH}/bin/qemu-${musl_arch}",
|
||||
"--qemu-ld-prefix",
|
||||
rebase_path(musl_linker_so_out_dir, root_build_dir),
|
||||
"--timeout-limit",
|
||||
|
@ -15,11 +15,11 @@
|
||||
|
||||
#include "agent/debugger_impl.h"
|
||||
|
||||
#include "base/pt_base64.h"
|
||||
#include "base/pt_events.h"
|
||||
#include "base/pt_params.h"
|
||||
#include "base/pt_returns.h"
|
||||
#include "base/pt_types.h"
|
||||
#include "tooling/base/pt_base64.h"
|
||||
#include "tooling/base/pt_events.h"
|
||||
#include "tooling/base/pt_params.h"
|
||||
#include "tooling/base/pt_returns.h"
|
||||
#include "tooling/base/pt_types.h"
|
||||
#include "backend/debugger_executor.h"
|
||||
#include "dispatcher.h"
|
||||
#include "protocol_handler.h"
|
||||
@ -63,7 +63,8 @@ DebuggerImpl::~DebuggerImpl()
|
||||
bool DebuggerImpl::NotifyScriptParsed(ScriptId scriptId, 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_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;
|
||||
@ -971,6 +972,7 @@ bool DebuggerImpl::ProcessSingleBreakpoint(const BreakpointInfo &breakpoint,
|
||||
};
|
||||
if (!extractor->MatchWithLocation(matchLocationCbFunc, lineNumber, columnNumber, url, GetRecordName(url))) {
|
||||
LOG_DEBUGGER(ERROR) << "failed to set breakpoint location number: " << lineNumber << ":" << columnNumber;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#include "agent/runtime_impl.h"
|
||||
#include "backend/js_pt_hooks.h"
|
||||
#include "base/pt_params.h"
|
||||
#include "tooling/base/pt_params.h"
|
||||
#include "backend/js_single_stepper.h"
|
||||
#include "dispatcher.h"
|
||||
|
||||
@ -117,7 +117,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<PtScript *> MatchAllScripts(const std::string url) const
|
||||
std::vector<PtScript *> MatchAllScripts(const std::string &url) const
|
||||
{
|
||||
std::vector<PtScript *> result;
|
||||
for (const auto &script : scripts_) {
|
||||
|
@ -18,9 +18,9 @@
|
||||
|
||||
#include <uv.h>
|
||||
|
||||
#include "base/pt_params.h"
|
||||
#include "base/pt_events.h"
|
||||
#include "base/pt_returns.h"
|
||||
#include "tooling/base/pt_params.h"
|
||||
#include "tooling/base/pt_events.h"
|
||||
#include "tooling/base/pt_returns.h"
|
||||
#include "dispatcher.h"
|
||||
#include "protocol_handler.h"
|
||||
#include "protocol_channel.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#include "agent/profiler_impl.h"
|
||||
|
||||
#include "base/pt_events.h"
|
||||
#include "tooling/base/pt_events.h"
|
||||
#include "protocol_channel.h"
|
||||
|
||||
#include "ecmascript/napi/include/dfx_jsnapi.h"
|
||||
|
@ -16,8 +16,8 @@
|
||||
#ifndef ECMASCRIPT_TOOLING_AGENT_PROFILER_IMPL_H
|
||||
#define ECMASCRIPT_TOOLING_AGENT_PROFILER_IMPL_H
|
||||
|
||||
#include "base/pt_params.h"
|
||||
#include "base/pt_returns.h"
|
||||
#include "tooling/base/pt_params.h"
|
||||
#include "tooling/base/pt_returns.h"
|
||||
#include "dispatcher.h"
|
||||
|
||||
#include "ecmascript/dfx/cpu_profiler/samples_record.h"
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
#include "base/pt_returns.h"
|
||||
#include "tooling/base/pt_returns.h"
|
||||
#include "protocol_channel.h"
|
||||
|
||||
#include "ecmascript/napi/include/dfx_jsnapi.h"
|
||||
|
@ -17,7 +17,7 @@
|
||||
#define ECMASCRIPT_TOOLING_AGENT_RUNTIME_IMPL_H
|
||||
|
||||
|
||||
#include "base/pt_params.h"
|
||||
#include "tooling/base/pt_params.h"
|
||||
#include "dispatcher.h"
|
||||
|
||||
#include "libpandabase/macros.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#include "agent/tracing_impl.h"
|
||||
|
||||
#include "base/pt_events.h"
|
||||
#include "tooling/base/pt_events.h"
|
||||
#include "protocol_channel.h"
|
||||
|
||||
#include "ecmascript/napi/include/dfx_jsnapi.h"
|
||||
|
@ -16,8 +16,8 @@
|
||||
#ifndef ECMASCRIPT_TOOLING_AGENT_TRACING_IMPL_H
|
||||
#define ECMASCRIPT_TOOLING_AGENT_TRACING_IMPL_H
|
||||
|
||||
#include "base/pt_params.h"
|
||||
#include "base/pt_returns.h"
|
||||
#include "tooling/base/pt_params.h"
|
||||
#include "tooling/base/pt_returns.h"
|
||||
#include "dispatcher.h"
|
||||
|
||||
#include "ecmascript/dfx/cpu_profiler/samples_record.h"
|
||||
|
@ -16,8 +16,8 @@
|
||||
#ifndef ECMASCRIPT_TOOLING_BACKEND_JS_PT_HOOKS_H
|
||||
#define ECMASCRIPT_TOOLING_BACKEND_JS_PT_HOOKS_H
|
||||
|
||||
#include "base/pt_events.h"
|
||||
#include "base/pt_script.h"
|
||||
#include "tooling/base/pt_events.h"
|
||||
#include "tooling/base/pt_script.h"
|
||||
|
||||
#include "ecmascript/debugger/js_debugger_interface.h"
|
||||
#include "libpandabase/macros.h"
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "base/pt_base64.h"
|
||||
#include "tooling/base/pt_base64.h"
|
||||
|
||||
namespace panda::ecmascript::tooling {
|
||||
static const unsigned char DECODE_TABLE[] = {
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "base/pt_events.h"
|
||||
#include "tooling/base/pt_events.h"
|
||||
|
||||
namespace panda::ecmascript::tooling {
|
||||
std::unique_ptr<PtJson> BreakpointResolved::ToJson() const
|
||||
|
@ -19,8 +19,8 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
#include "base/pt_script.h"
|
||||
#include "base/pt_types.h"
|
||||
#include "tooling/base/pt_script.h"
|
||||
#include "tooling/base/pt_types.h"
|
||||
#include "dispatcher.h"
|
||||
|
||||
#include "libpandabase/macros.h"
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "base/pt_json.h"
|
||||
#include "tooling/base/pt_json.h"
|
||||
|
||||
#include "libpandabase/macros.h"
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "cJSON.h"
|
||||
#include "common/macros.h"
|
||||
|
||||
namespace panda::ecmascript::tooling {
|
||||
enum class Result : uint8_t {
|
||||
@ -28,7 +29,7 @@ enum class Result : uint8_t {
|
||||
TYPE_ERROR,
|
||||
};
|
||||
|
||||
class PtJson {
|
||||
class TOOLCHAIN_EXPORT PtJson {
|
||||
public:
|
||||
PtJson() = default;
|
||||
explicit PtJson(cJSON *object) : object_(object) {}
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "base/pt_params.h"
|
||||
#include "tooling/base/pt_params.h"
|
||||
|
||||
namespace panda::ecmascript::tooling {
|
||||
std::unique_ptr<EnableParams> EnableParams::Create(const PtJson ¶ms)
|
||||
|
@ -16,7 +16,7 @@
|
||||
#ifndef ECMASCRIPT_TOOLING_BASE_PT_PARAMS_H
|
||||
#define ECMASCRIPT_TOOLING_BASE_PT_PARAMS_H
|
||||
|
||||
#include "base/pt_types.h"
|
||||
#include "tooling/base/pt_types.h"
|
||||
|
||||
namespace panda::ecmascript::tooling {
|
||||
class PtBaseParams : public PtBaseTypes {
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "base/pt_returns.h"
|
||||
#include "tooling/base/pt_returns.h"
|
||||
|
||||
namespace panda::ecmascript::tooling {
|
||||
std::unique_ptr<PtJson> EnableReturns::ToJson() const
|
||||
|
@ -16,7 +16,7 @@
|
||||
#ifndef ECMASCRIPT_TOOLING_BASE_PT_RETURNS_H
|
||||
#define ECMASCRIPT_TOOLING_BASE_PT_RETURNS_H
|
||||
|
||||
#include "base/pt_types.h"
|
||||
#include "tooling/base/pt_types.h"
|
||||
|
||||
namespace panda::ecmascript::tooling {
|
||||
class PtBaseReturns : public PtBaseTypes {
|
||||
@ -329,7 +329,7 @@ private:
|
||||
std::unique_ptr<Profile> profile_ {};
|
||||
};
|
||||
|
||||
class GetHeapUsageReturns : public PtBaseReturns {
|
||||
class TOOLCHAIN_EXPORT GetHeapUsageReturns : public PtBaseReturns {
|
||||
public:
|
||||
GetHeapUsageReturns() = default;
|
||||
explicit GetHeapUsageReturns(double usedSize, double totalSize)
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "base/pt_script.h"
|
||||
#include "tooling/base/pt_script.h"
|
||||
|
||||
#include "ecmascript/debugger/debugger_api.h"
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
#ifndef ECMASCRIPT_TOOLING_BASE_PT_SCRIPT_H
|
||||
#define ECMASCRIPT_TOOLING_BASE_PT_SCRIPT_H
|
||||
|
||||
#include "base/pt_types.h"
|
||||
#include "tooling/base/pt_types.h"
|
||||
|
||||
#include "libpandabase/macros.h"
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "pt_types.h"
|
||||
#include "tooling/base/pt_types.h"
|
||||
|
||||
namespace panda::ecmascript::tooling {
|
||||
using ObjectType = RemoteObject::TypeName;
|
||||
|
@ -19,7 +19,9 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
#include "base/pt_json.h"
|
||||
#include "common/macros.h"
|
||||
|
||||
#include "tooling/base/pt_json.h"
|
||||
|
||||
#include "ecmascript/debugger/debugger_api.h"
|
||||
#include "ecmascript/dfx/cpu_profiler/samples_record.h"
|
||||
@ -853,7 +855,7 @@ private:
|
||||
};
|
||||
|
||||
// Runtime.PropertyDescriptor
|
||||
class PropertyDescriptor final : public PtBaseTypes {
|
||||
class TOOLCHAIN_EXPORT PropertyDescriptor final : public PtBaseTypes {
|
||||
public:
|
||||
PropertyDescriptor() = default;
|
||||
~PropertyDescriptor() override = default;
|
||||
@ -1559,7 +1561,7 @@ private:
|
||||
};
|
||||
|
||||
// Debugger.CallFrame
|
||||
class CallFrame final : public PtBaseTypes {
|
||||
class TOOLCHAIN_EXPORT CallFrame final : public PtBaseTypes {
|
||||
public:
|
||||
CallFrame() = default;
|
||||
~CallFrame() override = default;
|
||||
|
@ -24,10 +24,7 @@ ohos_source_set("libark_client_set") {
|
||||
deps += hiviewdfx_deps
|
||||
|
||||
include_dirs = [
|
||||
"./",
|
||||
"../base",
|
||||
"../../inspector",
|
||||
"../../websocket",
|
||||
"..",
|
||||
"//third_party/cJSON",
|
||||
]
|
||||
|
||||
@ -36,10 +33,12 @@ ohos_source_set("libark_client_set") {
|
||||
"domain/heapprofiler_client.cpp",
|
||||
"domain/profiler_client.cpp",
|
||||
"domain/runtime_client.cpp",
|
||||
"domain/test_client.cpp",
|
||||
"manager/breakpoint_manager.cpp",
|
||||
"manager/domain_manager.cpp",
|
||||
"manager/stack_manager.cpp",
|
||||
"manager/variable_manager.cpp",
|
||||
"utils/cli_command.cpp",
|
||||
"utils/utils.cpp",
|
||||
"websocket/websocket_client.cpp",
|
||||
]
|
||||
@ -47,7 +46,7 @@ ohos_source_set("libark_client_set") {
|
||||
deps += [
|
||||
"$ark_third_party_root/libuv:uv",
|
||||
"$ark_third_party_root/openssl:libcrypto_shared",
|
||||
"..:libark_ecma_debugger_set",
|
||||
"..:libark_ecma_debugger",
|
||||
sdk_libc_secshared_dep,
|
||||
]
|
||||
|
||||
|
@ -14,10 +14,7 @@
|
||||
import("//arkcompiler/toolchain/toolchain.gni")
|
||||
|
||||
ohos_executable("arkdb") {
|
||||
sources = [
|
||||
"cli_command.cpp",
|
||||
"main.cpp",
|
||||
]
|
||||
sources = [ "main.cpp" ]
|
||||
|
||||
include_dirs = [
|
||||
"./",
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include <uv.h>
|
||||
#include <securec.h>
|
||||
|
||||
#include "cli_command.h"
|
||||
#include "tooling/client/utils/cli_command.h"
|
||||
|
||||
namespace OHOS::ArkCompiler::Toolchain {
|
||||
uint32_t g_messageId = 0;
|
||||
@ -30,6 +30,8 @@ uv_async_t* g_inputSignal;
|
||||
uv_async_t* g_releaseHandle;
|
||||
uv_loop_t* g_loop;
|
||||
|
||||
DomainManager g_domainManager;
|
||||
WebsocketClient g_cliSocket;
|
||||
|
||||
bool StrToUInt(const char *content, uint32_t *result)
|
||||
{
|
||||
@ -42,27 +44,6 @@ bool StrToUInt(const char *content, uint32_t *result)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<std::string> SplitString(const std::string &str, const std::string &delimiter)
|
||||
{
|
||||
std::size_t strIndex = 0;
|
||||
std::vector<std::string> value;
|
||||
std::size_t pos = str.find_first_of(delimiter, strIndex);
|
||||
while ((pos < str.size()) && (pos > strIndex)) {
|
||||
std::string subStr = str.substr(strIndex, pos - strIndex);
|
||||
value.push_back(std::move(subStr));
|
||||
strIndex = pos;
|
||||
strIndex = str.find_first_not_of(delimiter, strIndex);
|
||||
pos = str.find_first_of(delimiter, strIndex);
|
||||
}
|
||||
if (pos > strIndex) {
|
||||
std::string subStr = str.substr(strIndex, pos - strIndex);
|
||||
if (!subStr.empty()) {
|
||||
value.push_back(std::move(subStr));
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
void ReleaseHandle([[maybe_unused]] uv_async_t *releaseHandle)
|
||||
{
|
||||
uv_close(reinterpret_cast<uv_handle_t*>(g_inputSignal), [](uv_handle_t* handle) {
|
||||
@ -95,9 +76,9 @@ void InputOnMessage(uv_async_t *handle)
|
||||
{
|
||||
char* msg = static_cast<char*>(handle->data);
|
||||
std::string inputStr = std::string(msg);
|
||||
std::vector<std::string> cliCmdStr = SplitString(inputStr, " ");
|
||||
std::vector<std::string> cliCmdStr = Utils::SplitString(inputStr, " ");
|
||||
g_messageId += 1;
|
||||
CliCommand cmd(cliCmdStr, g_messageId);
|
||||
CliCommand cmd(cliCmdStr, g_messageId, g_domainManager, g_cliSocket);
|
||||
if (cmd.ExecCommand() == ErrCode::ERR_FAIL) {
|
||||
g_messageId -= 1;
|
||||
}
|
||||
|
@ -13,14 +13,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "domain/debugger_client.h"
|
||||
#include "tooling/client/domain/debugger_client.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "common/log_wrapper.h"
|
||||
#include "manager/breakpoint_manager.h"
|
||||
#include "manager/stack_manager.h"
|
||||
#include "pt_json.h"
|
||||
#include "tooling/client/manager/breakpoint_manager.h"
|
||||
#include "tooling/client/manager/stack_manager.h"
|
||||
#include "tooling/base/pt_json.h"
|
||||
|
||||
using PtJson = panda::ecmascript::tooling::PtJson;
|
||||
namespace OHOS::ArkCompiler::Toolchain {
|
||||
@ -29,7 +29,7 @@ bool DebuggerClient::DispatcherCmd(int id, const std::string &cmd, std::string*
|
||||
std::map<std::string, std::function<std::string()>> dispatcherTable {
|
||||
{ "break", std::bind(&DebuggerClient::BreakCommand, this, id)},
|
||||
{ "backtrack", std::bind(&DebuggerClient::BacktrackCommand, this, id)},
|
||||
{ "continue", std::bind(&DebuggerClient::ContinueCommand, this, id)},
|
||||
{ "continue", std::bind(&DebuggerClient::ResumeCommand, this, id)},
|
||||
{ "delete", std::bind(&DebuggerClient::DeleteCommand, this, id)},
|
||||
{ "jump", std::bind(&DebuggerClient::JumpCommand, this, id)},
|
||||
{ "disable", std::bind(&DebuggerClient::DisableCommand, this, id)},
|
||||
@ -57,12 +57,12 @@ bool DebuggerClient::DispatcherCmd(int id, const std::string &cmd, std::string*
|
||||
auto entry = dispatcherTable.find(cmd);
|
||||
if (entry != dispatcherTable.end()) {
|
||||
*reqStr = entry->second();
|
||||
LOGE("DebuggerClient DispatcherCmd reqStr1: %{public}s", reqStr->c_str());
|
||||
LOGI("DebuggerClient DispatcherCmd reqStr1: %{public}s", reqStr->c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
*reqStr = "Unknown commond: " + cmd;
|
||||
LOGE("DebuggerClient DispatcherCmd reqStr2: %{public}s", reqStr->c_str());
|
||||
LOGI("DebuggerClient DispatcherCmd reqStr2: %{public}s", reqStr->c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -85,11 +85,6 @@ std::string DebuggerClient::BacktrackCommand([[maybe_unused]] int id)
|
||||
return "backtrack";
|
||||
}
|
||||
|
||||
std::string DebuggerClient::ContinueCommand([[maybe_unused]] int id)
|
||||
{
|
||||
return "continue";
|
||||
}
|
||||
|
||||
std::string DebuggerClient::DeleteCommand(int id)
|
||||
{
|
||||
std::unique_ptr<PtJson> request = PtJson::CreateObject();
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "pt_json.h"
|
||||
#include "tooling/base/pt_json.h"
|
||||
|
||||
using PtJson = panda::ecmascript::tooling::PtJson;
|
||||
using Result = panda::ecmascript::tooling::Result;
|
||||
@ -37,7 +37,6 @@ public:
|
||||
bool DispatcherCmd(int id, const std::string &cmd, std::string* reqStr);
|
||||
std::string BreakCommand(int id);
|
||||
std::string BacktrackCommand(int id);
|
||||
std::string ContinueCommand(int id);
|
||||
std::string DeleteCommand(int id);
|
||||
std::string DisableCommand(int id);
|
||||
std::string DisplayCommand(int id);
|
||||
|
@ -13,9 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "domain/heapprofiler_client.h"
|
||||
#include "tooling/client/domain/heapprofiler_client.h"
|
||||
#include "common/log_wrapper.h"
|
||||
#include "utils/utils.h"
|
||||
#include "tooling/client/utils/utils.h"
|
||||
|
||||
#include <map>
|
||||
#include <functional>
|
||||
@ -45,12 +45,12 @@ bool HeapProfilerClient::DispatcherCmd(int id, const std::string &cmd, const std
|
||||
auto entry = dispatcherTable.find(cmd);
|
||||
if (entry != dispatcherTable.end() && entry->second != nullptr) {
|
||||
*reqStr = entry->second();
|
||||
LOGE("DispatcherCmd reqStr1: %{public}s", reqStr->c_str());
|
||||
LOGI("DispatcherCmd reqStr1: %{public}s", reqStr->c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
*reqStr = "Unknown commond: " + cmd;
|
||||
LOGE("DispatcherCmd reqStr2: %{public}s", reqStr->c_str());
|
||||
LOGI("DispatcherCmd reqStr2: %{public}s", reqStr->c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
|
||||
#include "pt_json.h"
|
||||
#include "tooling/base/pt_json.h"
|
||||
|
||||
using PtJson = panda::ecmascript::tooling::PtJson;
|
||||
|
||||
|
@ -13,10 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "domain/profiler_client.h"
|
||||
#include "pt_types.h"
|
||||
#include "tooling/client/domain/profiler_client.h"
|
||||
#include "tooling/base/pt_types.h"
|
||||
#include "common/log_wrapper.h"
|
||||
#include "utils/utils.h"
|
||||
#include "tooling/client/utils/utils.h"
|
||||
|
||||
#include <map>
|
||||
#include <functional>
|
||||
@ -40,11 +40,11 @@ bool ProfilerClient::DispatcherCmd(int id, const std::string &cmd, std::string*
|
||||
auto entry = dispatcherTable.find(cmd);
|
||||
if (entry == dispatcherTable.end()) {
|
||||
*reqStr = "Unknown commond: " + cmd;
|
||||
LOGE("DispatcherCmd reqStr2: %{public}s", reqStr->c_str());
|
||||
LOGI("DispatcherCmd reqStr2: %{public}s", reqStr->c_str());
|
||||
return false;
|
||||
}
|
||||
*reqStr = entry->second();
|
||||
LOGE("DispatcherCmd reqStr1: %{public}s", reqStr->c_str());
|
||||
LOGI("DispatcherCmd reqStr1: %{public}s", reqStr->c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "pt_json.h"
|
||||
#include "tooling/base/pt_json.h"
|
||||
|
||||
namespace OHOS::ArkCompiler::Toolchain {
|
||||
using PtJson = panda::ecmascript::tooling::PtJson;
|
||||
|
@ -13,19 +13,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "domain/runtime_client.h"
|
||||
#include "tooling/client/domain/runtime_client.h"
|
||||
|
||||
#include "common/log_wrapper.h"
|
||||
#include "manager/variable_manager.h"
|
||||
#include "pt_json.h"
|
||||
#include "tooling/client/manager/variable_manager.h"
|
||||
#include "tooling/base/pt_json.h"
|
||||
|
||||
using PtJson = panda::ecmascript::tooling::PtJson;
|
||||
namespace OHOS::ArkCompiler::Toolchain {
|
||||
RuntimeClient RuntimeClient::instance_;
|
||||
RuntimeClient& RuntimeClient::GetInstance()
|
||||
{
|
||||
return instance_;
|
||||
}
|
||||
bool RuntimeClient::DispatcherCmd(int id, const std::string &cmd, std::string* reqStr)
|
||||
{
|
||||
std::map<std::string, std::function<std::string()>> dispatcherTable {
|
||||
@ -40,11 +35,11 @@ bool RuntimeClient::DispatcherCmd(int id, const std::string &cmd, std::string* r
|
||||
auto entry = dispatcherTable.find(cmd);
|
||||
if (entry != dispatcherTable.end()) {
|
||||
*reqStr = entry->second();
|
||||
LOGE("RuntimeClient DispatcherCmd reqStr1: %{public}s", reqStr->c_str());
|
||||
LOGI("RuntimeClient DispatcherCmd reqStr1: %{public}s", reqStr->c_str());
|
||||
return true;
|
||||
} else {
|
||||
*reqStr = "Unknown commond: " + cmd;
|
||||
LOGE("RuntimeClient DispatcherCmd reqStr2: %{public}s", reqStr->c_str());
|
||||
LOGI("RuntimeClient DispatcherCmd reqStr2: %{public}s", reqStr->c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -19,14 +19,15 @@
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
#include "pt_types.h"
|
||||
#include "tooling/base/pt_types.h"
|
||||
|
||||
using PtJson = panda::ecmascript::tooling::PtJson;
|
||||
using Result = panda::ecmascript::tooling::Result;
|
||||
namespace OHOS::ArkCompiler::Toolchain {
|
||||
class RuntimeClient final {
|
||||
public:
|
||||
static RuntimeClient& GetInstance();
|
||||
RuntimeClient() = default;
|
||||
~RuntimeClient() = default;
|
||||
|
||||
bool DispatcherCmd(int id, const std::string &cmd, std::string *reqStr);
|
||||
std::string HeapusageCommand(int id);
|
||||
@ -57,13 +58,9 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
RuntimeClient() = default;
|
||||
static RuntimeClient instance_;
|
||||
std::map<int, std::tuple<std::string, std::string>> idMethodMap_ {};
|
||||
std::string objectId_ {"0"};
|
||||
bool isInitializeTree_ {true};
|
||||
RuntimeClient(const RuntimeClient&) = delete;
|
||||
RuntimeClient& operator=(const RuntimeClient&) = delete;
|
||||
};
|
||||
} // OHOS::ArkCompiler::Toolchain
|
||||
#endif
|
64
tooling/client/domain/test_client.cpp
Normal file
64
tooling/client/domain/test_client.cpp
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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 "tooling/client/domain/test_client.h"
|
||||
|
||||
#include "common/log_wrapper.h"
|
||||
#include "tooling/client/manager/variable_manager.h"
|
||||
#include "tooling/base/pt_json.h"
|
||||
|
||||
using PtJson = panda::ecmascript::tooling::PtJson;
|
||||
namespace OHOS::ArkCompiler::Toolchain {
|
||||
bool TestClient::DispatcherCmd(int id, const std::string &cmd, std::string* reqStr)
|
||||
{
|
||||
std::map<std::string, std::function<std::string()>> dispatcherTable {
|
||||
{ "success", std::bind(&TestClient::SuccessCommand, this, id)},
|
||||
{ "fail", std::bind(&TestClient::FailCommand, this, id)},
|
||||
};
|
||||
|
||||
auto entry = dispatcherTable.find(cmd);
|
||||
if (entry != dispatcherTable.end()) {
|
||||
*reqStr = entry->second();
|
||||
LOGI("TestClient DispatcherCmd reqStr1: %{public}s", reqStr->c_str());
|
||||
return true;
|
||||
} else {
|
||||
*reqStr = "Unknown commond: " + cmd;
|
||||
LOGI("TestClient DispatcherCmd reqStr2: %{public}s", reqStr->c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::string TestClient::SuccessCommand(int id)
|
||||
{
|
||||
std::unique_ptr<PtJson> request = PtJson::CreateObject();
|
||||
request->Add("id", id);
|
||||
request->Add("method", "Test.success");
|
||||
|
||||
std::unique_ptr<PtJson> params = PtJson::CreateObject();
|
||||
request->Add("params", params);
|
||||
return request->Stringify();
|
||||
}
|
||||
|
||||
std::string TestClient::FailCommand(int id)
|
||||
{
|
||||
std::unique_ptr<PtJson> request = PtJson::CreateObject();
|
||||
request->Add("id", id);
|
||||
request->Add("method", "Test.fail");
|
||||
|
||||
std::unique_ptr<PtJson> params = PtJson::CreateObject();
|
||||
request->Add("params", params);
|
||||
return request->Stringify();
|
||||
}
|
||||
} // OHOS::ArkCompiler::Toolchain
|
37
tooling/client/domain/test_client.h
Normal file
37
tooling/client/domain/test_client.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef ECMASCRIPT_TOOLING_CLIENT_DOMAIN_TEST_CLIENT_H
|
||||
#define ECMASCRIPT_TOOLING_CLIENT_DOMAIN_TEST_CLIENT_H
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
#include "tooling/base/pt_types.h"
|
||||
|
||||
using PtJson = panda::ecmascript::tooling::PtJson;
|
||||
using Result = panda::ecmascript::tooling::Result;
|
||||
namespace OHOS::ArkCompiler::Toolchain {
|
||||
class TestClient final {
|
||||
public:
|
||||
TestClient() = default;
|
||||
~TestClient() = default;
|
||||
|
||||
bool DispatcherCmd(int id, const std::string &cmd, std::string *reqStr);
|
||||
std::string SuccessCommand(int id);
|
||||
std::string FailCommand(int id);
|
||||
};
|
||||
} // OHOS::ArkCompiler::Toolchain
|
||||
#endif // ECMASCRIPT_TOOLING_CLIENT_DOMAIN_TEST_CLIENT_H
|
@ -13,9 +13,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "manager/breakpoint_manager.h"
|
||||
#include "ark_cli/cli_command.h"
|
||||
#include "tooling/client/manager/breakpoint_manager.h"
|
||||
|
||||
#include "common/log_wrapper.h"
|
||||
#include "tooling/client/utils/utils.h"
|
||||
|
||||
using PtJson = panda::ecmascript::tooling::PtJson;
|
||||
using Result = panda::ecmascript::tooling::Result;
|
||||
@ -51,7 +52,7 @@ void BreakPointManager::Createbreaklocation(const std::unique_ptr<PtJson> json)
|
||||
Breaklocation breaklocation;
|
||||
breaklocation.breakpointId = breakpointId;
|
||||
std::vector<std::string> breaksplitstring;
|
||||
breaksplitstring = SplitString(breakpointId, ':');
|
||||
breaksplitstring = Utils::SplitString(breakpointId, ":");
|
||||
breaklocation.lineNumber = breaksplitstring[1]; // 1: linenumber
|
||||
breaklocation.columnNumber = breaksplitstring[2]; // 2: columnnumber
|
||||
breaklocation.url = breaksplitstring[3]; // 3: url
|
||||
@ -62,23 +63,6 @@ void BreakPointManager::Createbreaklocation(const std::unique_ptr<PtJson> json)
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<std::string> BreakPointManager::SplitString(std::string &str, const char delimiter)
|
||||
{
|
||||
int size = str.size();
|
||||
std::vector<std::string> value;
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (str[i] == delimiter) {
|
||||
str[i] = ' ';
|
||||
}
|
||||
}
|
||||
std::istringstream out(str);
|
||||
std::string sstr;
|
||||
while (out >> sstr) {
|
||||
value.push_back(sstr);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
void BreakPointManager::Show()
|
||||
{
|
||||
int size = breaklist_.size();
|
||||
|
@ -22,8 +22,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "pt_json.h"
|
||||
#include "pt_types.h"
|
||||
#include "tooling/base/pt_json.h"
|
||||
#include "tooling/base/pt_types.h"
|
||||
|
||||
namespace OHOS::ArkCompiler::Toolchain {
|
||||
using PtJson = panda::ecmascript::tooling::PtJson;
|
||||
@ -38,7 +38,6 @@ class BreakPointManager {
|
||||
public:
|
||||
static BreakPointManager& GetInstance();
|
||||
|
||||
std::vector<std::string> SplitString(std::string &str, const char delimiter);
|
||||
void Createbreaklocation(const std::unique_ptr<PtJson> json);
|
||||
void Show();
|
||||
void Deletebreaklist(unsigned int num);
|
||||
|
@ -16,8 +16,8 @@
|
||||
#include "domain_manager.h"
|
||||
|
||||
#include "common/log_wrapper.h"
|
||||
#include "manager/breakpoint_manager.h"
|
||||
#include "pt_json.h"
|
||||
#include "tooling/client/manager/breakpoint_manager.h"
|
||||
#include "tooling/base/pt_json.h"
|
||||
|
||||
using PtJson = panda::ecmascript::tooling::PtJson;
|
||||
using Result = panda::ecmascript::tooling::Result;
|
||||
|
@ -18,10 +18,11 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "domain/debugger_client.h"
|
||||
#include "domain/heapprofiler_client.h"
|
||||
#include "domain/profiler_client.h"
|
||||
#include "domain/runtime_client.h"
|
||||
#include "tooling/client/domain/debugger_client.h"
|
||||
#include "tooling/client/domain/heapprofiler_client.h"
|
||||
#include "tooling/client/domain/profiler_client.h"
|
||||
#include "tooling/client/domain/runtime_client.h"
|
||||
#include "tooling/client/domain/test_client.h"
|
||||
|
||||
namespace OHOS::ArkCompiler::Toolchain {
|
||||
class DomainManager {
|
||||
@ -53,21 +54,37 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
HeapProfilerClient* GetHeapProfilerClient()
|
||||
HeapProfilerClient &GetHeapProfilerClient()
|
||||
{
|
||||
return &heapProfilerClient_;
|
||||
return heapProfilerClient_;
|
||||
}
|
||||
|
||||
ProfilerClient* GetProfilerClient()
|
||||
ProfilerClient &GetProfilerClient()
|
||||
{
|
||||
return &profilerClient_;
|
||||
return profilerClient_;
|
||||
}
|
||||
|
||||
DebuggerClient &GetDebuggerClient()
|
||||
{
|
||||
return debuggerClient_;
|
||||
}
|
||||
|
||||
RuntimeClient &GetRuntimeClient()
|
||||
{
|
||||
return runtimeClient_;
|
||||
}
|
||||
|
||||
TestClient &GetTestClient()
|
||||
{
|
||||
return testClient_;
|
||||
}
|
||||
|
||||
private:
|
||||
HeapProfilerClient heapProfilerClient_ {};
|
||||
ProfilerClient profilerClient_ {};
|
||||
DebuggerClient debuggerClient_ {};
|
||||
RuntimeClient &runtimeClient_ = RuntimeClient::GetInstance();
|
||||
RuntimeClient runtimeClient_ {};
|
||||
TestClient testClient_ {};
|
||||
std::map<uint32_t, std::string> idDomainMap_ {};
|
||||
};
|
||||
} // OHOS::ArkCompiler::Toolchain
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "manager/stack_manager.h"
|
||||
#include "tooling/client/manager/stack_manager.h"
|
||||
#include "common/log_wrapper.h"
|
||||
|
||||
namespace OHOS::ArkCompiler::Toolchain {
|
||||
|
@ -20,8 +20,8 @@
|
||||
#include <variant>
|
||||
|
||||
#include "common/log_wrapper.h"
|
||||
#include "pt_json.h"
|
||||
#include "pt_types.h"
|
||||
#include "tooling/base/pt_json.h"
|
||||
#include "tooling/base/pt_types.h"
|
||||
|
||||
using PtJson = panda::ecmascript::tooling::PtJson;
|
||||
using Result = panda::ecmascript::tooling::Result;
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "manager/variable_manager.h"
|
||||
#include "tooling/client/manager/variable_manager.h"
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
|
@ -19,10 +19,10 @@
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
#include "manager/stack_manager.h"
|
||||
#include "pt_json.h"
|
||||
#include "pt_returns.h"
|
||||
#include "pt_types.h"
|
||||
#include "tooling/client/manager/stack_manager.h"
|
||||
#include "tooling/base/pt_json.h"
|
||||
#include "tooling/base/pt_returns.h"
|
||||
#include "tooling/base/pt_types.h"
|
||||
|
||||
using PtJson = panda::ecmascript::tooling::PtJson;
|
||||
using Result = panda::ecmascript::tooling::Result;
|
||||
|
@ -13,25 +13,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "cli_command.h"
|
||||
#include "tooling/client/utils/cli_command.h"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <mutex>
|
||||
|
||||
#include "domain/debugger_client.h"
|
||||
#include "domain/runtime_client.h"
|
||||
#include "tooling/client/domain/debugger_client.h"
|
||||
#include "tooling/client/domain/runtime_client.h"
|
||||
#include "common/log_wrapper.h"
|
||||
#include "manager/breakpoint_manager.h"
|
||||
#include "manager/domain_manager.h"
|
||||
#include "manager/stack_manager.h"
|
||||
#include "manager/variable_manager.h"
|
||||
#include "tooling/client/manager/breakpoint_manager.h"
|
||||
#include "tooling/client/manager/domain_manager.h"
|
||||
#include "tooling/client/manager/stack_manager.h"
|
||||
#include "tooling/client/manager/variable_manager.h"
|
||||
|
||||
namespace OHOS::ArkCompiler::Toolchain {
|
||||
DomainManager g_domainManager;
|
||||
WebsocketClient g_cliSocket;
|
||||
const std::string HELP_MSG = "usage: <command> <options>\n"
|
||||
" These are common commands list:\n"
|
||||
" allocationtrack(at) allocation-track-start with options\n"
|
||||
@ -79,7 +74,9 @@ const std::string HELP_MSG = "usage: <command> <options>\n"
|
||||
" step-into(si) step-into\n"
|
||||
" step-out(so) step-out\n"
|
||||
" step-over(sov) step-over\n"
|
||||
" runtime-disable rt-disable\n";
|
||||
" runtime-disable rt-disable\n"
|
||||
" success test success\n"
|
||||
" fail test fail\n";
|
||||
|
||||
const std::vector<std::string> cmdList = {
|
||||
"allocationtrack",
|
||||
@ -125,8 +122,11 @@ const std::vector<std::string> cmdList = {
|
||||
"step-into",
|
||||
"step-out",
|
||||
"step-over",
|
||||
"runtime-disable"
|
||||
"runtime-disable",
|
||||
"success",
|
||||
"fail"
|
||||
};
|
||||
|
||||
ErrCode CliCommand::ExecCommand()
|
||||
{
|
||||
CreateCommandMap();
|
||||
@ -193,7 +193,11 @@ void CliCommand::CreateCommandMap()
|
||||
{std::make_pair("step-out", "so"), std::bind(&CliCommand::DebuggerCommand, this, "step-out")},
|
||||
{std::make_pair("step-over", "sov"), std::bind(&CliCommand::DebuggerCommand, this, "step-over")},
|
||||
{std::make_pair("runtime-disable", "rt-disable"),
|
||||
std::bind(&CliCommand::RuntimeCommand, this, "runtime-disable")}
|
||||
std::bind(&CliCommand::RuntimeCommand, this, "runtime-disable")},
|
||||
{std::make_pair("success", "success"),
|
||||
std::bind(&CliCommand::TestCommand, this, "success")},
|
||||
{std::make_pair("fail", "fail"),
|
||||
std::bind(&CliCommand::TestCommand, this, "fail")}
|
||||
};
|
||||
}
|
||||
|
||||
@ -202,16 +206,16 @@ ErrCode CliCommand::HeapProfilerCommand(const std::string &cmd)
|
||||
std::cout << "exe success, cmd is " << cmd << std::endl;
|
||||
std::string request;
|
||||
bool result = false;
|
||||
HeapProfilerClient* heapProfilerClient = g_domainManager.GetHeapProfilerClient();
|
||||
HeapProfilerClient &heapProfilerClient = domainManager_.GetHeapProfilerClient();
|
||||
VecStr argList = GetArgList();
|
||||
if (argList.empty()) {
|
||||
argList.push_back("/data/");
|
||||
}
|
||||
result = heapProfilerClient->DispatcherCmd(id_, cmd, argList[0], &request);
|
||||
result = heapProfilerClient.DispatcherCmd(id_, cmd, argList[0], &request);
|
||||
if (result) {
|
||||
g_cliSocket.ClientSendReq(request);
|
||||
if (g_domainManager.GetDomainById(id_).empty()) {
|
||||
g_domainManager.SetDomainById(id_, "HeapProfiler");
|
||||
cliSocket_.ClientSendReq(request);
|
||||
if (domainManager_.GetDomainById(id_).empty()) {
|
||||
domainManager_.SetDomainById(id_, "HeapProfiler");
|
||||
}
|
||||
} else {
|
||||
return ErrCode::ERR_FAIL;
|
||||
@ -224,23 +228,23 @@ ErrCode CliCommand::CpuProfileCommand(const std::string &cmd)
|
||||
std::cout << "exe success, cmd is " << cmd << std::endl;
|
||||
std::string request;
|
||||
bool result = false;
|
||||
ProfilerClient* profilerClient = g_domainManager.GetProfilerClient();
|
||||
ProfilerClient &profilerClient = domainManager_.GetProfilerClient();
|
||||
ProfilerSingleton& pro = ProfilerSingleton::GetInstance();
|
||||
if (cmd == "cpuprofile-show") {
|
||||
pro.ShowCpuFile();
|
||||
return ErrCode::ERR_OK;
|
||||
}
|
||||
if (cmd == "cpuprofile-setSamplingInterval") {
|
||||
profilerClient->SetSamplingInterval(std::atoi(GetArgList()[0].c_str()));
|
||||
profilerClient.SetSamplingInterval(std::atoi(GetArgList()[0].c_str()));
|
||||
}
|
||||
if (cmd == "cpuprofile-stop" && GetArgList().size() == 1) {
|
||||
pro.SetAddress(GetArgList()[0]);
|
||||
}
|
||||
result = profilerClient->DispatcherCmd(id_, cmd, &request);
|
||||
result = profilerClient.DispatcherCmd(id_, cmd, &request);
|
||||
if (result) {
|
||||
g_cliSocket.ClientSendReq(request);
|
||||
if (g_domainManager.GetDomainById(id_).empty()) {
|
||||
g_domainManager.SetDomainById(id_, "Profiler");
|
||||
cliSocket_.ClientSendReq(request);
|
||||
if (domainManager_.GetDomainById(id_).empty()) {
|
||||
domainManager_.SetDomainById(id_, "Profiler");
|
||||
}
|
||||
} else {
|
||||
return ErrCode::ERR_FAIL;
|
||||
@ -253,7 +257,7 @@ ErrCode CliCommand::DebuggerCommand(const std::string &cmd)
|
||||
std::cout << "exe success, cmd is " << cmd << std::endl;
|
||||
std::string request;
|
||||
bool result = false;
|
||||
DebuggerClient debuggerCli;
|
||||
DebuggerClient &debuggerCli = domainManager_.GetDebuggerClient();
|
||||
BreakPointManager &breakpoint = BreakPointManager::GetInstance();
|
||||
if (cmd == "display") {
|
||||
breakpoint.Show();
|
||||
@ -272,7 +276,7 @@ ErrCode CliCommand::DebuggerCommand(const std::string &cmd)
|
||||
}
|
||||
|
||||
if (cmd == "step-into" || cmd == "step-out" || cmd == "step-over") {
|
||||
RuntimeClient &runtimeClient = RuntimeClient::GetInstance();
|
||||
RuntimeClient &runtimeClient = domainManager_.GetRuntimeClient();
|
||||
runtimeClient.SetIsInitializeTree(true);
|
||||
}
|
||||
|
||||
@ -287,9 +291,9 @@ ErrCode CliCommand::DebuggerCommand(const std::string &cmd)
|
||||
|
||||
result = debuggerCli.DispatcherCmd(id_, cmd, &request);
|
||||
if (result) {
|
||||
g_cliSocket.ClientSendReq(request);
|
||||
if (g_domainManager.GetDomainById(id_).empty()) {
|
||||
g_domainManager.SetDomainById(id_, "Debugger");
|
||||
cliSocket_.ClientSendReq(request);
|
||||
if (domainManager_.GetDomainById(id_).empty()) {
|
||||
domainManager_.SetDomainById(id_, "Debugger");
|
||||
}
|
||||
} else {
|
||||
return ErrCode::ERR_FAIL;
|
||||
@ -302,7 +306,7 @@ ErrCode CliCommand::RuntimeCommand(const std::string &cmd)
|
||||
std::cout << "exe success, cmd is " << cmd << std::endl;
|
||||
std::string request;
|
||||
bool result = false;
|
||||
RuntimeClient &runtimeClient = RuntimeClient::GetInstance();
|
||||
RuntimeClient &runtimeClient = domainManager_.GetRuntimeClient();
|
||||
|
||||
if (cmd == "print" && GetArgList().size() == 1) {
|
||||
runtimeClient.SetIsInitializeTree(false);
|
||||
@ -313,10 +317,29 @@ ErrCode CliCommand::RuntimeCommand(const std::string &cmd)
|
||||
|
||||
result = runtimeClient.DispatcherCmd(id_, cmd, &request);
|
||||
if (result) {
|
||||
g_cliSocket.ClientSendReq(request);
|
||||
cliSocket_.ClientSendReq(request);
|
||||
runtimeClient.SetObjectId("0");
|
||||
if (g_domainManager.GetDomainById(id_).empty()) {
|
||||
g_domainManager.SetDomainById(id_, "Runtime");
|
||||
if (domainManager_.GetDomainById(id_).empty()) {
|
||||
domainManager_.SetDomainById(id_, "Runtime");
|
||||
}
|
||||
} else {
|
||||
return ErrCode::ERR_FAIL;
|
||||
}
|
||||
return ErrCode::ERR_OK;
|
||||
}
|
||||
|
||||
ErrCode CliCommand::TestCommand(const std::string &cmd)
|
||||
{
|
||||
std::string request;
|
||||
bool result = false;
|
||||
if (cmd == "success" || cmd == "fail") {
|
||||
TestClient &testClient = domainManager_.GetTestClient();
|
||||
result = testClient.DispatcherCmd(id_, cmd, &request);
|
||||
if (result) {
|
||||
cliSocket_.ClientSendReq(request);
|
||||
if (domainManager_.GetDomainById(id_).empty()) {
|
||||
domainManager_.SetDomainById(id_, "Test");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return ErrCode::ERR_FAIL;
|
@ -21,17 +21,16 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "domain/heapprofiler_client.h"
|
||||
#include "domain/profiler_client.h"
|
||||
#include "common/log_wrapper.h"
|
||||
#include "manager/domain_manager.h"
|
||||
#include "websocket/websocket_client.h"
|
||||
#include "tooling/client/domain/heapprofiler_client.h"
|
||||
#include "tooling/client/domain/profiler_client.h"
|
||||
#include "tooling/client/manager/domain_manager.h"
|
||||
#include "tooling/client/utils/utils.h"
|
||||
#include "tooling/client/websocket/websocket_client.h"
|
||||
|
||||
namespace OHOS::ArkCompiler::Toolchain {
|
||||
using StrPair = std::pair<std::string, std::string>;
|
||||
using VecStr = std::vector<std::string>;
|
||||
extern DomainManager g_domainManager;
|
||||
extern WebsocketClient g_cliSocket;
|
||||
|
||||
enum class ErrCode : uint8_t {
|
||||
ERR_OK = 0,
|
||||
@ -40,11 +39,10 @@ enum class ErrCode : uint8_t {
|
||||
|
||||
class CliCommand {
|
||||
public:
|
||||
CliCommand(std::vector<std::string> cliCmdStr, int cmdId)
|
||||
CliCommand(std::vector<std::string> cliCmdStr, int cmdId, DomainManager &domainManager, WebsocketClient &cliSocket)
|
||||
: cmd_(cliCmdStr[0]), id_(cmdId), domainManager_(domainManager), cliSocket_(cliSocket)
|
||||
{
|
||||
id_ = cmdId;
|
||||
cmd_ = cliCmdStr[0];
|
||||
for (unsigned int i = 1; i < cliCmdStr.size(); i++) {
|
||||
for (size_t i = 1; i < cliCmdStr.size(); i++) {
|
||||
argList_.push_back(cliCmdStr[i]);
|
||||
}
|
||||
}
|
||||
@ -58,6 +56,7 @@ public:
|
||||
ErrCode DebuggerCommand(const std::string &cmd);
|
||||
ErrCode CpuProfileCommand(const std::string &cmd);
|
||||
ErrCode RuntimeCommand(const std::string &cmd);
|
||||
ErrCode TestCommand(const std::string &cmd);
|
||||
ErrCode ExecHelpCommand();
|
||||
|
||||
uint32_t GetId() const
|
||||
@ -76,6 +75,8 @@ private:
|
||||
std::map<StrPair, std::function<ErrCode()>> commandMap_;
|
||||
std::string resultReceiver_ = "";
|
||||
uint32_t id_ = 0;
|
||||
DomainManager &domainManager_;
|
||||
WebsocketClient &cliSocket_;
|
||||
};
|
||||
} // namespace OHOS::ArkCompiler::Toolchain
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "utils/utils.h"
|
||||
#include "tooling/client/utils/utils.h"
|
||||
#include "common/log_wrapper.h"
|
||||
#include <ctime>
|
||||
|
||||
@ -52,4 +52,25 @@ bool Utils::GetCurrentTime(char *date, char *tim, size_t size)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::vector<std::string> Utils::SplitString(const std::string &str, const std::string &delimiter)
|
||||
{
|
||||
std::size_t strIndex = 0;
|
||||
std::vector<std::string> value;
|
||||
std::size_t pos = str.find_first_of(delimiter, strIndex);
|
||||
while ((pos < str.size()) && (pos > strIndex)) {
|
||||
std::string subStr = str.substr(strIndex, pos - strIndex);
|
||||
value.push_back(std::move(subStr));
|
||||
strIndex = pos;
|
||||
strIndex = str.find_first_not_of(delimiter, strIndex);
|
||||
pos = str.find_first_of(delimiter, strIndex);
|
||||
}
|
||||
if (pos > strIndex) {
|
||||
std::string subStr = str.substr(strIndex, pos - strIndex);
|
||||
if (!subStr.empty()) {
|
||||
value.push_back(std::move(subStr));
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
} // OHOS::ArkCompiler::Toolchain
|
@ -16,12 +16,14 @@
|
||||
#ifndef ECMASCRIPT_TOOLING_CLIENT_UTILS_UTILS_H
|
||||
#define ECMASCRIPT_TOOLING_CLIENT_UTILS_UTILS_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace OHOS::ArkCompiler::Toolchain {
|
||||
class Utils {
|
||||
public:
|
||||
static bool GetCurrentTime(char *date, char *tim, size_t size);
|
||||
static std::vector<std::string> SplitString(const std::string &str, const std::string &delimiter);
|
||||
};
|
||||
} // OHOS::ArkCompiler::Toolchain
|
||||
#endif
|
@ -21,7 +21,8 @@
|
||||
#include <memory>
|
||||
#include <map>
|
||||
|
||||
#include "websocket.h"
|
||||
#include "ecmascript/log_wrapper.h"
|
||||
#include "websocket/websocket.h"
|
||||
|
||||
namespace OHOS::ArkCompiler::Toolchain {
|
||||
struct ToolchainWebSocketFrame {
|
||||
|
@ -19,11 +19,7 @@
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
#ifndef PANDA_TARGET_WINDOWS
|
||||
#define TOOLCHAIN_EXPORT __attribute__((visibility ("default")))
|
||||
#else
|
||||
#define TOOLCHAIN_EXPORT __declspec(dllexport)
|
||||
#endif
|
||||
#include "common/macros.h"
|
||||
|
||||
namespace panda::ecmascript {
|
||||
class EcmaVM;
|
||||
|
@ -166,7 +166,15 @@ void Dispatcher::Dispatch(const DispatchRequest &request)
|
||||
if (dispatcher != dispatchers_.end()) {
|
||||
dispatcher->second->Dispatch(request);
|
||||
} else {
|
||||
LOG_DEBUGGER(ERROR) << "unknown domain: " << domain;
|
||||
if (domain == "Test") {
|
||||
if (request.GetMethod() == "fail") {
|
||||
LOG_DEBUGGER(FATAL) << "Test fail";
|
||||
UNREACHABLE();
|
||||
}
|
||||
LOG_DEBUGGER(INFO) << "Test success";
|
||||
} else {
|
||||
LOG_DEBUGGER(ERROR) << "unknown domain: " << domain;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace panda::ecmascript::tooling
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
#include "base/pt_returns.h"
|
||||
#include "tooling/base/pt_returns.h"
|
||||
|
||||
#include "ecmascript/debugger/js_debugger_interface.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
|
@ -16,8 +16,8 @@
|
||||
#ifndef ECMASCRIPT_TOOLING_PROTOCOL_CHANNEL_H
|
||||
#define ECMASCRIPT_TOOLING_PROTOCOL_CHANNEL_H
|
||||
|
||||
#include "base/pt_events.h"
|
||||
#include "base/pt_returns.h"
|
||||
#include "tooling/base/pt_events.h"
|
||||
#include "tooling/base/pt_returns.h"
|
||||
#include "dispatcher.h"
|
||||
|
||||
#include "libpandabase/macros.h"
|
||||
|
@ -26,7 +26,8 @@ config("debug_api_test") {
|
||||
|
||||
include_dirs = [
|
||||
"//arkcompiler/ets_runtime",
|
||||
"//arkcompiler/toolchain/tooling",
|
||||
"../..",
|
||||
"//third_party/cJSON",
|
||||
]
|
||||
}
|
||||
|
||||
@ -108,9 +109,9 @@ ohos_shared_library("jsdebugtest") {
|
||||
]
|
||||
|
||||
test_abc_dir = "/data/test/"
|
||||
target_label = get_label_info(":${target_name}", "label_with_toolchain")
|
||||
target_toolchain = get_label_info(target_label, "toolchain")
|
||||
if (target_toolchain == host_toolchain || ark_standalone_build) {
|
||||
test_label = get_label_info(":${target_name}", "label_with_toolchain")
|
||||
test_toolchain = get_label_info(test_label, "toolchain")
|
||||
if (test_toolchain == host_toolchain || ark_standalone_build) {
|
||||
test_abc_dir = rebase_path(target_out_dir)
|
||||
}
|
||||
test_js_dir = rebase_path(test_js_path)
|
||||
@ -236,10 +237,106 @@ host_unittest_action("DebuggerCInterpTest") {
|
||||
external_deps += [ "ets_runtime:libark_jsruntime_test" ]
|
||||
}
|
||||
|
||||
host_unittest_action("DebuggerClientTest") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
sources = [
|
||||
# test file
|
||||
"client_utils/test_list.cpp",
|
||||
"client_utils/test_util.cpp",
|
||||
"debugger_client_test.cpp",
|
||||
]
|
||||
|
||||
test_abc_dir = "/data/test/"
|
||||
test_label = get_label_info(":${target_name}", "label_with_toolchain")
|
||||
test_toolchain = get_label_info(test_label, "toolchain")
|
||||
if (test_toolchain == host_toolchain || ark_standalone_build) {
|
||||
test_abc_dir = rebase_path(target_out_dir)
|
||||
}
|
||||
test_js_dir = rebase_path(test_js_path)
|
||||
|
||||
defines = [
|
||||
"DEBUGGER_ABC_DIR=\"${test_abc_dir}/\"",
|
||||
"DEBUGGER_JS_DIR=\"${test_js_dir}\"",
|
||||
]
|
||||
|
||||
cflags_cc = [ "-Wno-gnu-zero-variadic-macro-arguments" ]
|
||||
|
||||
configs = [ ":debug_api_test" ]
|
||||
|
||||
deps = [
|
||||
":debugger_client_resource",
|
||||
"$ark_third_party_root/icu/icu4c:shared_icui18n",
|
||||
"$ark_third_party_root/icu/icu4c:shared_icuuc",
|
||||
"$toolchain_root/tooling:libark_ecma_debugger",
|
||||
"../client:libark_client",
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
|
||||
external_deps += [ "ets_runtime:libark_jsruntime" ]
|
||||
}
|
||||
|
||||
host_unittest_action("DebuggerCIntClientTest") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
sources = [
|
||||
# test file
|
||||
"client_utils/test_list.cpp",
|
||||
"client_utils/test_util.cpp",
|
||||
"debugger_cint_client_test.cpp",
|
||||
]
|
||||
|
||||
cflags_cc = [ "-Wno-gnu-zero-variadic-macro-arguments" ]
|
||||
|
||||
test_abc_dir = "/data/test/"
|
||||
test_label = get_label_info(":${target_name}", "label_with_toolchain")
|
||||
test_toolchain = get_label_info(test_label, "toolchain")
|
||||
if (test_toolchain == host_toolchain || ark_standalone_build) {
|
||||
test_abc_dir = rebase_path(target_out_dir)
|
||||
}
|
||||
test_js_dir = rebase_path(test_js_path)
|
||||
|
||||
defines = [
|
||||
"DEBUGGER_ABC_DIR=\"${test_abc_dir}/\"",
|
||||
"DEBUGGER_JS_DIR=\"${test_js_dir}\"",
|
||||
]
|
||||
|
||||
configs = [ ":debug_api_test" ]
|
||||
|
||||
deps = [
|
||||
":debugger_client_resource",
|
||||
"$ark_third_party_root/icu/icu4c:shared_icui18n",
|
||||
"$ark_third_party_root/icu/icu4c:shared_icuuc",
|
||||
"$toolchain_root/tooling:libark_ecma_debugger",
|
||||
"../client:libark_client",
|
||||
]
|
||||
|
||||
# hiviewdfx libraries
|
||||
external_deps = hiviewdfx_ext_deps
|
||||
deps += hiviewdfx_deps
|
||||
|
||||
external_deps += [ "ets_runtime:libark_jsruntime" ]
|
||||
}
|
||||
|
||||
group("debugger_entry_resource") {
|
||||
testonly = true
|
||||
|
||||
deps = [ ":debugger_entry" ]
|
||||
foreach(file, test_js_files) {
|
||||
deps += [ ":gen_${file}_abc" ]
|
||||
}
|
||||
}
|
||||
|
||||
group("debugger_client_resource") {
|
||||
testonly = true
|
||||
|
||||
deps = [ "../../inspector:ark_debugger" ]
|
||||
foreach(file, test_js_files) {
|
||||
deps += [ ":gen_${file}_abc" ]
|
||||
}
|
||||
}
|
||||
|
||||
group("unittest") {
|
||||
@ -247,7 +344,9 @@ group("unittest") {
|
||||
|
||||
# deps file
|
||||
deps = [
|
||||
":DebuggerCIntClientTest",
|
||||
":DebuggerCInterpTest",
|
||||
":DebuggerClientTest",
|
||||
":DebuggerEntryTest",
|
||||
":DebuggerTest",
|
||||
]
|
||||
@ -258,7 +357,9 @@ group("host_unittest") {
|
||||
|
||||
# deps file
|
||||
deps = [
|
||||
":DebuggerCIntClientTestAction",
|
||||
":DebuggerCInterpTestAction",
|
||||
":DebuggerClientTestAction",
|
||||
":DebuggerEntryTestAction",
|
||||
":DebuggerTestAction",
|
||||
]
|
||||
|
85
tooling/test/client_utils/test_actions.h
Normal file
85
tooling/test/client_utils/test_actions.h
Normal file
@ -0,0 +1,85 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef ECMASCRIPT_TOOLING_TEST_UTILS_TEST_ACTIONS_H
|
||||
#define ECMASCRIPT_TOOLING_TEST_UTILS_TEST_ACTIONS_H
|
||||
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace panda::ecmascript::tooling::test {
|
||||
/*
|
||||
* Socket action.
|
||||
* {SEND} Send a message to server.
|
||||
* {RECV} Should recv a message from server.
|
||||
*/
|
||||
enum class SocketAction {
|
||||
SEND = 0U,
|
||||
RECV = 1U,
|
||||
};
|
||||
|
||||
/*
|
||||
* Action matching rules.
|
||||
* {STRING_EQUAL} Expect string should equal recv string.
|
||||
* {STRING_CONTAIN} Expect string should a substring of recv string.
|
||||
* {CUSTOM_RULE} Recv string should match custom rule.
|
||||
*/
|
||||
enum class ActionRule {
|
||||
STRING_EQUAL,
|
||||
STRING_CONTAIN,
|
||||
CUSTOM_RULE,
|
||||
};
|
||||
std::ostream &operator<<(std::ostream &out, ActionRule value);
|
||||
|
||||
using MatchFunc = std::function<bool(const std::string&, const std::string&)>;
|
||||
|
||||
/*
|
||||
* Add some common match func here
|
||||
*/
|
||||
struct MatchRule {
|
||||
static MatchFunc replySuccess;
|
||||
};
|
||||
|
||||
/*
|
||||
* Action information.
|
||||
* @param action Socket action.
|
||||
* @param rule Action matching rules.
|
||||
* @param message Expect message or send message
|
||||
* @param matchFunc Custom matching rule
|
||||
*/
|
||||
struct ActionInfo {
|
||||
SocketAction action;
|
||||
std::string message;
|
||||
ActionRule rule = ActionRule::STRING_CONTAIN;
|
||||
MatchFunc matchFunc = [] (auto, auto) -> auto {
|
||||
return true;
|
||||
};
|
||||
|
||||
ActionInfo(const ActionInfo&) = default;
|
||||
ActionInfo& operator=(const ActionInfo&) = default;
|
||||
};
|
||||
|
||||
struct TestActions {
|
||||
std::vector<ActionInfo> testAction;
|
||||
|
||||
TestActions() = default;
|
||||
virtual ~TestActions() = default;
|
||||
|
||||
virtual std::pair<std::string, std::string> GetEntryPoint() = 0;
|
||||
};
|
||||
} // namespace panda::ecmascript::tooling::test
|
||||
|
||||
#endif // ECMASCRIPT_TOOLING_TEST_UTILS_TEST_ACTIONS_H
|
58
tooling/test/client_utils/test_list.cpp
Normal file
58
tooling/test/client_utils/test_list.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "tooling/test/client_utils/test_list.h"
|
||||
|
||||
#include "tooling/test/client_utils/test_util.h"
|
||||
|
||||
// testcase list
|
||||
#include "tooling/test/testcases/js_breakpoint_test.h"
|
||||
|
||||
namespace panda::ecmascript::tooling::test {
|
||||
static std::string g_currentTestName = "";
|
||||
|
||||
static void RegisterTests()
|
||||
{
|
||||
// Register testcases
|
||||
TestUtil::RegisterTest("JsBreakpointTest", GetJsBreakpointTest());
|
||||
}
|
||||
|
||||
std::vector<const char *> GetTestList()
|
||||
{
|
||||
RegisterTests();
|
||||
std::vector<const char *> res;
|
||||
|
||||
auto &tests = TestUtil::GetTests();
|
||||
for (const auto &entry : tests) {
|
||||
res.push_back(entry.first.c_str());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void SetCurrentTestName(const std::string &testName)
|
||||
{
|
||||
g_currentTestName = testName;
|
||||
}
|
||||
|
||||
std::string GetCurrentTestName()
|
||||
{
|
||||
return g_currentTestName;
|
||||
}
|
||||
|
||||
std::pair<std::string, std::string> GetTestEntryPoint(const std::string &testName)
|
||||
{
|
||||
return TestUtil::GetTest(testName)->GetEntryPoint();
|
||||
}
|
||||
} // namespace panda::ecmascript::tooling::test
|
32
tooling/test/client_utils/test_list.h
Normal file
32
tooling/test/client_utils/test_list.h
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef ECMASCRIPT_TOOLING_TEST_UTILS_TEST_LIST_H
|
||||
#define ECMASCRIPT_TOOLING_TEST_UTILS_TEST_LIST_H
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
namespace panda::ecmascript::tooling::test {
|
||||
std::vector<const char *> GetTestList();
|
||||
|
||||
void SetCurrentTestName(const std::string &testName);
|
||||
std::string GetCurrentTestName();
|
||||
|
||||
std::pair<std::string, std::string> GetTestEntryPoint(const std::string &testName);
|
||||
} // namespace panda::ecmascript::tooling::test
|
||||
|
||||
#endif // ECMASCRIPT_TOOLING_TEST_UTILS_TEST_LIST_H
|
158
tooling/test/client_utils/test_util.cpp
Normal file
158
tooling/test/client_utils/test_util.cpp
Normal file
@ -0,0 +1,158 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "tooling/test/client_utils/test_util.h"
|
||||
|
||||
#include "tooling/client/domain/debugger_client.h"
|
||||
#include "tooling/client/domain/runtime_client.h"
|
||||
#include "tooling/client/utils/cli_command.h"
|
||||
|
||||
namespace panda::ecmascript::tooling::test {
|
||||
TestMap TestUtil::testMap_;
|
||||
|
||||
MatchFunc MatchRule::replySuccess = [] (auto recv, auto) -> bool {
|
||||
std::unique_ptr<PtJson> json = PtJson::Parse(recv);
|
||||
Result ret;
|
||||
int32_t id = 0;
|
||||
ret = json->GetInt("id", &id);
|
||||
if (ret != Result::SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::unique_ptr<PtJson> result = nullptr;
|
||||
ret = json->GetObject("result", &result);
|
||||
if (ret != Result::SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t code = 0;
|
||||
ret = result->GetInt("code", &code);
|
||||
if (ret != Result::NOT_EXIST) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, ActionRule value)
|
||||
{
|
||||
const char *s = nullptr;
|
||||
|
||||
#define ADD_CASE(entry) \
|
||||
case (entry): \
|
||||
s = #entry; \
|
||||
break
|
||||
|
||||
switch (value) {
|
||||
ADD_CASE(ActionRule::STRING_EQUAL);
|
||||
ADD_CASE(ActionRule::STRING_CONTAIN);
|
||||
ADD_CASE(ActionRule::CUSTOM_RULE);
|
||||
default: {
|
||||
ASSERT(false && "Unknown ActionRule");
|
||||
}
|
||||
}
|
||||
#undef ADD_CASE
|
||||
|
||||
return out << s;
|
||||
}
|
||||
|
||||
void TestUtil::NotifySuccess(int cmdId, DomainManager &domainManager, WebsocketClient &client)
|
||||
{
|
||||
std::vector<std::string> cliCmdStr = { "success" };
|
||||
CliCommand cmd(cliCmdStr, cmdId, domainManager, client);
|
||||
if (cmd.ExecCommand() == ErrCode::ERR_FAIL) {
|
||||
LOG_DEBUGGER(ERROR) << "ExecCommand Test.success fail";
|
||||
}
|
||||
}
|
||||
|
||||
void TestUtil::NotifyFail(int cmdId, DomainManager &domainManager, WebsocketClient &client)
|
||||
{
|
||||
std::vector<std::string> cliCmdStr = { "fail" };
|
||||
CliCommand cmd(cliCmdStr, cmdId, domainManager, client);
|
||||
if (cmd.ExecCommand() == ErrCode::ERR_FAIL) {
|
||||
LOG_DEBUGGER(ERROR) << "ExecCommand Test.fail fail";
|
||||
}
|
||||
}
|
||||
|
||||
void TestUtil::ForkSocketClient([[maybe_unused]] int port, const std::string &name)
|
||||
{
|
||||
int cmdId = 0;
|
||||
#ifdef OHOS_PLATFORM
|
||||
auto correntPid = getpid();
|
||||
#endif
|
||||
pid_t pid = fork();
|
||||
if (pid < 0) {
|
||||
LOG_DEBUGGER(FATAL) << "fork error";
|
||||
UNREACHABLE();
|
||||
} else if (pid == 0) {
|
||||
LOG_DEBUGGER(INFO) << "fork son pid: " << getpid();
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(500000)); // 500000: 500ms for wait debugger
|
||||
DomainManager domainManager;
|
||||
WebsocketClient client;
|
||||
#ifdef OHOS_PLATFORM
|
||||
std::string pidStr = std::to_string(correntPid);
|
||||
std::string sockName = pidStr + "PandaDebugger";
|
||||
bool ret = client.InitToolchainWebSocketForSockName(sockName, 120);
|
||||
#else
|
||||
bool ret = client.InitToolchainWebSocketForPort(port, 120);
|
||||
#endif
|
||||
LOG_ECMA_IF(!ret, FATAL) << "InitToolchainWebSocketForPort fail";
|
||||
ret = client.ClientSendWSUpgradeReq();
|
||||
LOG_ECMA_IF(!ret, FATAL) << "ClientSendWSUpgradeReq fail";
|
||||
ret = client.ClientRecvWSUpgradeRsp();
|
||||
LOG_ECMA_IF(!ret, FATAL) << "ClientRecvWSUpgradeRsp fail";
|
||||
|
||||
auto &testAction = TestUtil::GetTest(name)->testAction;
|
||||
for (const auto &action: testAction) {
|
||||
LOG_DEBUGGER(INFO) << "message: " << action.message;
|
||||
bool success = true;
|
||||
if (action.action == SocketAction::SEND) {
|
||||
std::vector<std::string> cliCmdStr = Utils::SplitString(action.message, " ");
|
||||
CliCommand cmd(cliCmdStr, cmdId++, domainManager, client);
|
||||
success = (cmd.ExecCommand() == ErrCode::ERR_OK);
|
||||
} else {
|
||||
ASSERT(action.action == SocketAction::RECV);
|
||||
std::string recv = client.Decode();
|
||||
switch (action.rule) {
|
||||
case ActionRule::STRING_EQUAL: {
|
||||
success = (recv == action.message);
|
||||
break;
|
||||
}
|
||||
case ActionRule::STRING_CONTAIN: {
|
||||
success = (recv.find(action.message) != std::string::npos);
|
||||
break;
|
||||
}
|
||||
case ActionRule::CUSTOM_RULE: {
|
||||
success = action.matchFunc(recv, action.message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
LOG_DEBUGGER(INFO) << "recv: " << recv;
|
||||
LOG_DEBUGGER(INFO) << "rule: " << action.rule;
|
||||
}
|
||||
if (!success) {
|
||||
LOG_DEBUGGER(ERROR) << "Notify fail";
|
||||
NotifyFail(cmdId++, domainManager, client);
|
||||
client.Close();
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
NotifySuccess(cmdId++, domainManager, client);
|
||||
client.Close();
|
||||
exit(0);
|
||||
}
|
||||
LOG_DEBUGGER(INFO) << "ForkSocketClient end";
|
||||
}
|
||||
} // namespace panda::ecmascript::tooling::test
|
73
tooling/test/client_utils/test_util.h
Normal file
73
tooling/test/client_utils/test_util.h
Normal file
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef ECMASCRIPT_TOOLING_TEST_UTILS_TEST_UTIL_H
|
||||
#define ECMASCRIPT_TOOLING_TEST_UTILS_TEST_UTIL_H
|
||||
|
||||
#include "tooling/test/client_utils/test_actions.h"
|
||||
|
||||
#include "tooling/client/manager/domain_manager.h"
|
||||
#include "tooling/client/websocket/websocket_client.h"
|
||||
#include "ecmascript/jspandafile/js_pandafile_manager.h"
|
||||
#include "ecmascript/debugger/js_debugger.h"
|
||||
#include "os/mutex.h"
|
||||
|
||||
namespace panda::ecmascript::tooling::test {
|
||||
template<class Key, class T, class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>>
|
||||
using CUnorderedMap = panda::ecmascript::CUnorderedMap<Key, T, Hash, KeyEqual>;
|
||||
using TestMap = CUnorderedMap<std::string, std::unique_ptr<TestActions>>;
|
||||
using namespace OHOS::ArkCompiler::Toolchain;
|
||||
|
||||
#ifdef OHOS_PLATFORM
|
||||
#define DEBUGGER_LIBRARY "libark_debugger.z.so"
|
||||
#else
|
||||
#define DEBUGGER_LIBRARY "libark_debugger.so"
|
||||
#endif
|
||||
|
||||
class TestUtil {
|
||||
public:
|
||||
static void RegisterTest(const std::string &testName, std::unique_ptr<TestActions> test)
|
||||
{
|
||||
testMap_.insert({testName, std::move(test)});
|
||||
}
|
||||
|
||||
static TestActions *GetTest(const std::string &name)
|
||||
{
|
||||
auto iter = std::find_if(testMap_.begin(), testMap_.end(), [&name](auto &it) {
|
||||
return it.first == name;
|
||||
});
|
||||
if (iter != testMap_.end()) {
|
||||
return iter->second.get();
|
||||
}
|
||||
LOG_DEBUGGER(FATAL) << "Test " << name << " not found";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static TestMap &GetTests()
|
||||
{
|
||||
return testMap_;
|
||||
}
|
||||
|
||||
static void ForkSocketClient(int port, const std::string &name);
|
||||
|
||||
private:
|
||||
static void NotifyFail(int cmdId, DomainManager &domainManager, WebsocketClient &client);
|
||||
static void NotifySuccess(int cmdId, DomainManager &domainManager, WebsocketClient &client);
|
||||
|
||||
static TestMap testMap_;
|
||||
};
|
||||
} // namespace panda::ecmascript::tooling::test
|
||||
|
||||
#endif // ECMASCRIPT_TOOLING_TEST_UTILS_TEST_UTIL_H
|
69
tooling/test/debugger_cint_client_test.cpp
Normal file
69
tooling/test/debugger_cint_client_test.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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 "ecmascript/ecma_vm.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
#include "ecmascript/tests/test_helper.h"
|
||||
#include "tooling/test/client_utils/test_list.h"
|
||||
#include "tooling/test/client_utils/test_util.h"
|
||||
|
||||
namespace panda::ecmascript::tooling::test {
|
||||
using panda::test::TestHelper;
|
||||
|
||||
class DebuggerCIntClientTest : public testing::TestWithParam<const char *> {
|
||||
public:
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
GTEST_LOG_(INFO) << "SetUpTestCase";
|
||||
}
|
||||
|
||||
static void TearDownTestCase()
|
||||
{
|
||||
GTEST_LOG_(INFO) << "TearDownCase";
|
||||
}
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
static int port = 9003; // 9003: socket port
|
||||
SetCurrentTestName(GetParam());
|
||||
TestHelper::CreateEcmaVMWithScope(instance, thread, scope, false, true);
|
||||
TestUtil::ForkSocketClient(port, GetParam());
|
||||
JSNApi::DebugOption debugOption = {DEBUGGER_LIBRARY, true, port};
|
||||
JSNApi::StartDebugger(instance, debugOption);
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
JSNApi::StopDebugger(instance);
|
||||
TestHelper::DestroyEcmaVMWithScope(instance, scope);
|
||||
}
|
||||
|
||||
EcmaVM *instance {nullptr};
|
||||
EcmaHandleScope *scope {nullptr};
|
||||
JSThread *thread {nullptr};
|
||||
};
|
||||
|
||||
HWTEST_P_L0(DebuggerCIntClientTest, DebuggerSuite)
|
||||
{
|
||||
std::string testName = GetCurrentTestName();
|
||||
std::cout << "Running " << testName << std::endl;
|
||||
ASSERT_NE(instance, nullptr);
|
||||
auto [pandaFile, entryPoint] = GetTestEntryPoint(testName);
|
||||
auto res = JSNApi::Execute(instance, pandaFile.c_str(), entryPoint.c_str());
|
||||
ASSERT_TRUE(res);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(DebuggerCIntClientAbcTest, DebuggerCIntClientTest, testing::ValuesIn(GetTestList()));
|
||||
} // namespace panda::ecmascript::tooling::test
|
@ -16,7 +16,7 @@
|
||||
#include "ecmascript/ecma_vm.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
#include "ecmascript/tests/test_helper.h"
|
||||
#include "test/utils/test_list.h"
|
||||
#include "tooling/test/utils/test_list.h"
|
||||
|
||||
namespace panda::ecmascript::tooling::test {
|
||||
using panda::test::TestHelper;
|
||||
@ -62,5 +62,5 @@ HWTEST_P_L0(DebuggerCInterpTest, DebuggerSuite)
|
||||
ASSERT_TRUE(res);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(DebugAbcTest, DebuggerCInterpTest, testing::ValuesIn(GetCInterpTestList()));
|
||||
INSTANTIATE_TEST_SUITE_P(DebugAbcTest, DebuggerCInterpTest, testing::ValuesIn(GetTestList()));
|
||||
} // namespace panda::ecmascript::tooling::test
|
||||
|
69
tooling/test/debugger_client_test.cpp
Normal file
69
tooling/test/debugger_client_test.cpp
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "ecmascript/ecma_vm.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
#include "ecmascript/tests/test_helper.h"
|
||||
#include "tooling/test/client_utils/test_list.h"
|
||||
#include "tooling/test/client_utils/test_util.h"
|
||||
|
||||
namespace panda::ecmascript::tooling::test {
|
||||
using panda::test::TestHelper;
|
||||
|
||||
class DebuggerClientTest : public testing::TestWithParam<const char *> {
|
||||
public:
|
||||
static void SetUpTestCase()
|
||||
{
|
||||
GTEST_LOG_(INFO) << "SetUpTestCase";
|
||||
}
|
||||
|
||||
static void TearDownTestCase()
|
||||
{
|
||||
GTEST_LOG_(INFO) << "TearDownCase";
|
||||
}
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
static int port = 9002; // 9002: socket port
|
||||
SetCurrentTestName(GetParam());
|
||||
TestHelper::CreateEcmaVMWithScope(instance, thread, scope);
|
||||
TestUtil::ForkSocketClient(port, GetParam());
|
||||
JSNApi::DebugOption debugOption = {DEBUGGER_LIBRARY, true, port};
|
||||
JSNApi::StartDebugger(instance, debugOption);
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
JSNApi::StopDebugger(instance);
|
||||
TestHelper::DestroyEcmaVMWithScope(instance, scope);
|
||||
}
|
||||
|
||||
EcmaVM *instance {nullptr};
|
||||
EcmaHandleScope *scope {nullptr};
|
||||
JSThread *thread {nullptr};
|
||||
};
|
||||
|
||||
HWTEST_P_L0(DebuggerClientTest, DebuggerSuite)
|
||||
{
|
||||
std::string testName = GetCurrentTestName();
|
||||
std::cout << "Running " << testName << std::endl;
|
||||
ASSERT_NE(instance, nullptr);
|
||||
auto [pandaFile, entryPoint] = GetTestEntryPoint(testName);
|
||||
auto res = JSNApi::Execute(instance, pandaFile.c_str(), entryPoint.c_str());
|
||||
ASSERT_TRUE(res);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(DebugClientAbcTest, DebuggerClientTest, testing::ValuesIn(GetTestList()));
|
||||
} // namespace panda::ecmascript::tooling::test
|
@ -19,8 +19,8 @@
|
||||
#include "ecmascript/debugger/js_debugger.h"
|
||||
#include "ecmascript/tests/test_helper.h"
|
||||
|
||||
#include "base/pt_params.h"
|
||||
#include "base/pt_returns.h"
|
||||
#include "tooling/base/pt_params.h"
|
||||
#include "tooling/base/pt_returns.h"
|
||||
#include "debugger_service.h"
|
||||
#include "dispatcher.h"
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "ecmascript/ecma_vm.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
#include "ecmascript/tests/test_helper.h"
|
||||
#include "test/utils/test_list.h"
|
||||
#include "tooling/test/utils/test_list.h"
|
||||
|
||||
namespace panda::ecmascript::tooling::test {
|
||||
using panda::test::TestHelper;
|
||||
|
@ -17,8 +17,8 @@
|
||||
#include "ecmascript/js_tagged_value-inl.h"
|
||||
#include "ecmascript/object_factory.h"
|
||||
#include "ecmascript/tests/test_helper.h"
|
||||
#include "base/pt_events.h"
|
||||
#include "base/pt_types.h"
|
||||
#include "tooling/base/pt_events.h"
|
||||
#include "tooling/base/pt_types.h"
|
||||
#include "dispatcher.h"
|
||||
|
||||
using namespace panda::ecmascript;
|
||||
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "base/pt_types.h"
|
||||
#include "base/pt_params.h"
|
||||
#include "tooling/base/pt_types.h"
|
||||
#include "tooling/base/pt_params.h"
|
||||
#include "dispatcher.h"
|
||||
|
||||
#include "ecmascript/js_array.h"
|
||||
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "base/pt_types.h"
|
||||
#include "base/pt_returns.h"
|
||||
#include "tooling/base/pt_types.h"
|
||||
#include "tooling/base/pt_returns.h"
|
||||
#include "dispatcher.h"
|
||||
|
||||
#include "ecmascript/js_array.h"
|
||||
|
@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "base/pt_params.h"
|
||||
#include "base/pt_returns.h"
|
||||
#include "base/pt_script.h"
|
||||
#include "tooling/base/pt_params.h"
|
||||
#include "tooling/base/pt_returns.h"
|
||||
#include "tooling/base/pt_script.h"
|
||||
#include "debugger_service.h"
|
||||
#include "dispatcher.h"
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "base/pt_types.h"
|
||||
#include "tooling/base/pt_types.h"
|
||||
#include "dispatcher.h"
|
||||
|
||||
#include "ecmascript/js_array.h"
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "test/utils/test_entry.h"
|
||||
#include "tooling/test/utils/test_entry.h"
|
||||
|
||||
namespace panda::ecmascript::tooling::test {
|
||||
extern "C" bool StartDebug(const std::string &name, EcmaVM *vm, bool isDebugMode)
|
||||
|
@ -15,8 +15,8 @@
|
||||
|
||||
#include "agent/debugger_impl.h"
|
||||
#include "backend/js_pt_hooks.h"
|
||||
#include "base/pt_types.h"
|
||||
#include "base/pt_events.h"
|
||||
#include "tooling/base/pt_types.h"
|
||||
#include "tooling/base/pt_events.h"
|
||||
#include "dispatcher.h"
|
||||
|
||||
#include "ecmascript/debugger/js_debugger.h"
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "ecmascript/tests/test_helper.h"
|
||||
#include "base/pt_base64.h"
|
||||
#include "tooling/base/pt_base64.h"
|
||||
|
||||
using namespace panda::ecmascript::tooling;
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "ecmascript/tests/test_helper.h"
|
||||
#include "base/pt_json.h"
|
||||
#include "tooling/base/pt_json.h"
|
||||
|
||||
using namespace panda::ecmascript::tooling;
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "base/pt_params.h"
|
||||
#include "tooling/base/pt_params.h"
|
||||
#include "ecmascript/tests/test_helper.h"
|
||||
#include "protocol_handler.h"
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "base/pt_returns.h"
|
||||
#include "tooling/base/pt_returns.h"
|
||||
#include "ecmascript/tests/test_helper.h"
|
||||
#include "tooling/protocol_handler.h"
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "base/pt_types.h"
|
||||
#include "tooling/base/pt_types.h"
|
||||
#include "ecmascript/tests/test_helper.h"
|
||||
#include "protocol_handler.h"
|
||||
|
||||
|
@ -13,54 +13,73 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ECMASCRIPT_TOOLING_TEST_UTILS_TESTCASES_JS_BREAKPOINT_TEST_H
|
||||
#define ECMASCRIPT_TOOLING_TEST_UTILS_TESTCASES_JS_BREAKPOINT_TEST_H
|
||||
#ifndef ECMASCRIPT_TOOLING_TEST_TESTCASES_JS_BREAKPOINT_TEST_H
|
||||
#define ECMASCRIPT_TOOLING_TEST_TESTCASES_JS_BREAKPOINT_TEST_H
|
||||
|
||||
#include "test/utils/test_util.h"
|
||||
#include "tooling/test/client_utils/test_util.h"
|
||||
|
||||
namespace panda::ecmascript::tooling::test {
|
||||
class JsBreakpointTest : public TestEvents {
|
||||
class JsBreakpointTest : public TestActions {
|
||||
public:
|
||||
JsBreakpointTest()
|
||||
{
|
||||
breakpoint = [this](const JSPtLocation &location) {
|
||||
ASSERT_TRUE(location.GetMethodId().IsValid());
|
||||
ASSERT_LOCATION_EQ(location, location_);
|
||||
++breakpointCounter_;
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::BREAKPOINT, location);
|
||||
return true;
|
||||
};
|
||||
testAction = {
|
||||
{SocketAction::SEND, "enable"},
|
||||
{SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess},
|
||||
{SocketAction::SEND, "runtime-enable"},
|
||||
{SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess},
|
||||
{SocketAction::SEND, "run"},
|
||||
{SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess},
|
||||
// load sample.js
|
||||
{SocketAction::RECV, "Debugger.scriptParsed", ActionRule::STRING_CONTAIN},
|
||||
// break on start
|
||||
{SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN},
|
||||
// set breakpoint
|
||||
{SocketAction::SEND, "b " DEBUGGER_JS_DIR "sample.js 21"},
|
||||
{SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess},
|
||||
// hit breakpoint after resume first time
|
||||
{SocketAction::SEND, "resume"},
|
||||
{SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN},
|
||||
{SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess},
|
||||
{SocketAction::RECV, "Debugger.paused", ActionRule::STRING_CONTAIN},
|
||||
// hit breakpoint after resume second time
|
||||
{SocketAction::SEND, "resume"},
|
||||
{SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN},
|
||||
{SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess},
|
||||
{SocketAction::RECV, "Debugger.paused", ActionRule::CUSTOM_RULE, [this] (auto recv, auto) -> bool {
|
||||
std::unique_ptr<PtJson> json = PtJson::Parse(recv);
|
||||
Result ret;
|
||||
std::string method;
|
||||
ret = json->GetString("method", &method);
|
||||
if (ret != Result::SUCCESS || method != "Debugger.paused") {
|
||||
return false;
|
||||
}
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
runtime_->Enable();
|
||||
// 22: breakpointer line
|
||||
location_ = TestUtil::GetLocation(sourceFile_.c_str(), 22, 0, pandaFile_.c_str());
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
ASSERT_TRUE(debugger_->NotifyScriptParsed(0, pandaFile_));
|
||||
auto condFuncRef = FunctionRef::Undefined(vm_);
|
||||
auto ret = debugInterface_->SetBreakpoint(location_, condFuncRef);
|
||||
ASSERT_TRUE(ret);
|
||||
return true;
|
||||
};
|
||||
std::unique_ptr<PtJson> params = nullptr;
|
||||
ret = json->GetObject("params", ¶ms);
|
||||
if (ret != Result::SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
scenario = [this]() {
|
||||
TestUtil::WaitForLoadModule();
|
||||
TestUtil::Continue();
|
||||
TestUtil::WaitForBreakpoint(location_);
|
||||
TestUtil::Continue();
|
||||
TestUtil::WaitForBreakpoint(location_);
|
||||
TestUtil::Continue();
|
||||
auto ret = debugInterface_->RemoveBreakpoint(location_);
|
||||
ASSERT_TRUE(ret);
|
||||
ASSERT_EXITED();
|
||||
return true;
|
||||
};
|
||||
std::unique_ptr<PtJson> hitBreakpoints = nullptr;
|
||||
ret = params->GetArray("hitBreakpoints", &hitBreakpoints);
|
||||
if (ret != Result::SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
vmDeath = [this]() {
|
||||
ASSERT_EQ(breakpointCounter_, 2U); // 2: break point counter
|
||||
return true;
|
||||
std::string breakpoint;
|
||||
breakpoint = hitBreakpoints->Get(0)->GetString();
|
||||
if (ret != Result::SUCCESS || breakpoint.find(sourceFile_) == std::string::npos ||
|
||||
breakpoint.find("21") == std::string::npos) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}},
|
||||
// reply success and run
|
||||
{SocketAction::SEND, "success"},
|
||||
{SocketAction::SEND, "resume"},
|
||||
{SocketAction::RECV, "Debugger.resumed", ActionRule::STRING_CONTAIN},
|
||||
{SocketAction::RECV, "", ActionRule::CUSTOM_RULE, MatchRule::replySuccess},
|
||||
};
|
||||
}
|
||||
|
||||
@ -74,14 +93,12 @@ private:
|
||||
std::string pandaFile_ = DEBUGGER_ABC_DIR "sample.abc";
|
||||
std::string sourceFile_ = DEBUGGER_JS_DIR "sample.js";
|
||||
std::string entryPoint_ = "_GLOBAL::func_main_0";
|
||||
JSPtLocation location_ {nullptr, JSPtLocation::EntityId(0), 0};
|
||||
size_t breakpointCounter_ = 0;
|
||||
};
|
||||
|
||||
std::unique_ptr<TestEvents> GetJsBreakpointTest()
|
||||
std::unique_ptr<TestActions> GetJsBreakpointTest()
|
||||
{
|
||||
return std::make_unique<JsBreakpointTest>();
|
||||
}
|
||||
} // namespace panda::ecmascript::tooling::test
|
||||
|
||||
#endif // ECMASCRIPT_TOOLING_TEST_UTILS_TESTCASES_JS_BREAKPOINT_TEST_H
|
||||
#endif // ECMASCRIPT_TOOLING_TEST_TESTCASES_JS_BREAKPOINT_TEST_H
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "test/utils/test_util.h"
|
||||
|
||||
// testcase list
|
||||
#include "test/testcases/js_breakpoint_test.h"
|
||||
#include "test/testcases/js_breakpoint_arrow_test.h"
|
||||
#include "test/testcases/js_breakpoint_async_test.h"
|
||||
#include "test/testcases/js_exception_test.h"
|
||||
@ -45,7 +44,6 @@ static void RegisterTests()
|
||||
// Register testcases
|
||||
TestUtil::RegisterTest("JsExceptionTest", GetJsExceptionTest());
|
||||
TestUtil::RegisterTest("JsSingleStepTest", GetJsSingleStepTest());
|
||||
TestUtil::RegisterTest("JsBreakpointTest", GetJsBreakpointTest());
|
||||
TestUtil::RegisterTest("JsBreakpointAsyncTest", GetJsBreakpointAsyncTest());
|
||||
TestUtil::RegisterTest("JsBreakpointArrowTest", GetJsBreakpointArrowTest());
|
||||
TestUtil::RegisterTest("JsRangeErrorTest", GetJsRangeErrorTest());
|
||||
@ -63,11 +61,6 @@ static void RegisterTests()
|
||||
TestUtil::RegisterTest("JsClosureScopeTest", GetJsClosureScopeTest());
|
||||
}
|
||||
|
||||
static void RegisterCInterpTests()
|
||||
{
|
||||
TestUtil::RegisterTest("JSDropFrameTest", GetJsDropFrameTest());
|
||||
}
|
||||
|
||||
std::vector<const char *> GetTestList()
|
||||
{
|
||||
RegisterTests();
|
||||
@ -80,18 +73,6 @@ std::vector<const char *> GetTestList()
|
||||
return res;
|
||||
}
|
||||
|
||||
std::vector<const char *> GetCInterpTestList()
|
||||
{
|
||||
RegisterCInterpTests();
|
||||
std::vector<const char *> res;
|
||||
|
||||
auto &tests = TestUtil::GetTests();
|
||||
for (const auto &entry : tests) {
|
||||
res.push_back(entry.first.c_str());
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
void SetCurrentTestName(const std::string &testName)
|
||||
{
|
||||
g_currentTestName = testName;
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
namespace panda::ecmascript::tooling::test {
|
||||
std::vector<const char *> GetTestList();
|
||||
std::vector<const char *> GetCInterpTestList();
|
||||
|
||||
void SetCurrentTestName(const std::string &testName);
|
||||
std::string GetCurrentTestName();
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include <sys/un.h>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "websocket.h"
|
||||
#include "websocket/websocket.h"
|
||||
#include "securec.h"
|
||||
|
||||
using namespace OHOS::ArkCompiler::Toolchain;
|
||||
|
@ -13,7 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "websocket.h"
|
||||
#include "websocket/websocket.h"
|
||||
|
||||
#include "define.h"
|
||||
#include "common/log_wrapper.h"
|
||||
@ -308,7 +308,7 @@ bool WebSocket::HttpHandShake()
|
||||
return false;
|
||||
} else if (req.connection.find("Upgrade") != std::string::npos &&
|
||||
req.upgrade.find("websocket") != std::string::npos && req.version.compare("HTTP/1.1") == 0) {
|
||||
ProtocolUpgrade(req);
|
||||
return ProtocolUpgrade(req);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user