mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 16:13:49 +00:00
!2355 [debugger] fix some testcase and memory leak
Merge pull request !2355 from weng-changcheng/fix_testcase
This commit is contained in:
commit
f830e261ab
@ -30,11 +30,17 @@ namespace panda::ecmascript::tooling {
|
||||
DispatchRequest::DispatchRequest(const std::string &message)
|
||||
{
|
||||
std::unique_ptr<PtJson> json = PtJson::Parse(message);
|
||||
if (json == nullptr || !json->IsObject()) {
|
||||
if (json == nullptr) {
|
||||
code_ = RequestCode::JSON_PARSE_ERROR;
|
||||
LOG_DEBUGGER(ERROR) << "json parse error";
|
||||
return;
|
||||
}
|
||||
if (!json->IsObject()) {
|
||||
code_ = RequestCode::PARAMS_FORMAT_ERROR;
|
||||
LOG_DEBUGGER(ERROR) << "json parse format error";
|
||||
json->ReleaseRoot();
|
||||
return;
|
||||
}
|
||||
|
||||
Result ret;
|
||||
int32_t callId;
|
||||
|
@ -95,12 +95,15 @@ void ProtocolHandler::SendResponse(const DispatchRequest &request, const Dispatc
|
||||
}
|
||||
reply->Add("result", resultObj);
|
||||
SendReply(*reply);
|
||||
reply->ReleaseRoot();
|
||||
}
|
||||
|
||||
void ProtocolHandler::SendNotification(const PtBaseEvents &events)
|
||||
{
|
||||
LOG_DEBUGGER(DEBUG) << "ProtocolHandler::SendNotification: " << events.GetName();
|
||||
SendReply(*events.ToJson());
|
||||
std::unique_ptr<PtJson> reply = events.ToJson();
|
||||
SendReply(*reply);
|
||||
reply->ReleaseRoot();
|
||||
}
|
||||
|
||||
void ProtocolHandler::SendReply(const PtJson &reply)
|
||||
|
@ -32,108 +32,32 @@ config("debug_api_test") {
|
||||
]
|
||||
}
|
||||
|
||||
ts2abc_gen_abc("ark_sample_abc") {
|
||||
test_js_path =
|
||||
"//arkcompiler/ets_runtime/ecmascript/tooling/test/js/Sample.js"
|
||||
test_abc_path = "$target_out_dir/Sample.abc"
|
||||
extra_visibility = [ ":*" ] # Only targets in this file can depend on this.
|
||||
src_js = rebase_path(test_js_path)
|
||||
dst_file = rebase_path(test_abc_path)
|
||||
extra_args = [ "--debug" ]
|
||||
test_js_path = "//arkcompiler/ets_runtime/ecmascript/tooling/test/testcases/js/"
|
||||
|
||||
in_puts = [ test_js_path ]
|
||||
out_puts = [ test_abc_path ]
|
||||
}
|
||||
# add new js test file here and modify test/resource/js_runtime/ohos_test.xml
|
||||
test_js_files = [
|
||||
"arrow_func",
|
||||
"async_func",
|
||||
"exception",
|
||||
"range_error",
|
||||
"sample",
|
||||
"step_into",
|
||||
"syntax_exception",
|
||||
"throw_exception",
|
||||
]
|
||||
|
||||
ts2abc_gen_abc("ark_asyncfunc_abc") {
|
||||
test_js_path =
|
||||
"//arkcompiler/ets_runtime/ecmascript/tooling/test/js/AsyncFunc.js"
|
||||
test_abc_path = "$target_out_dir/AsyncFunc.abc"
|
||||
extra_visibility = [ ":*" ] # Only targets in this file can depend on this.
|
||||
src_js = rebase_path(test_js_path)
|
||||
dst_file = rebase_path(test_abc_path)
|
||||
extra_args = [ "--debug" ]
|
||||
foreach(file, test_js_files) {
|
||||
ts2abc_gen_abc("gen_${file}_abc") {
|
||||
test_js = "${test_js_path}${file}.js"
|
||||
test_abc = "$target_out_dir/${file}.abc"
|
||||
extra_visibility = [ ":*" ] # Only targets in this file can depend on this.
|
||||
src_js = rebase_path(test_js)
|
||||
dst_file = rebase_path(test_abc)
|
||||
extra_args = [ "--debug" ]
|
||||
|
||||
in_puts = [ test_js_path ]
|
||||
out_puts = [ test_abc_path ]
|
||||
}
|
||||
|
||||
ts2abc_gen_abc("ark_arrowfunc_abc") {
|
||||
test_js_path =
|
||||
"//arkcompiler/ets_runtime/ecmascript/tooling/test/js/ArrowFunc.js"
|
||||
test_abc_path = "$target_out_dir/ArrowFunc.abc"
|
||||
extra_visibility = [ ":*" ] # Only targets in this file can depend on this.
|
||||
src_js = rebase_path(test_js_path)
|
||||
dst_file = rebase_path(test_abc_path)
|
||||
extra_args = [ "--debug" ]
|
||||
|
||||
in_puts = [ test_js_path ]
|
||||
out_puts = [ test_abc_path ]
|
||||
}
|
||||
|
||||
ts2abc_gen_abc("ark_exception_abc") {
|
||||
test_js_path =
|
||||
"//arkcompiler/ets_runtime/ecmascript/tooling/test/js/exception.js"
|
||||
test_abc_path = "$target_out_dir/exception.abc"
|
||||
extra_visibility = [ ":*" ] # Only targets in this file can depend on this.
|
||||
src_js = rebase_path(test_js_path)
|
||||
dst_file = rebase_path(test_abc_path)
|
||||
extra_args = [ "--debug" ]
|
||||
|
||||
in_puts = [ test_js_path ]
|
||||
out_puts = [ test_abc_path ]
|
||||
}
|
||||
|
||||
ts2abc_gen_abc("ark_range_error_abc") {
|
||||
test_js_path =
|
||||
"//arkcompiler/ets_runtime/ecmascript/tooling/test/js/RangeError.js"
|
||||
test_abc_path = "$target_out_dir/RangeError.abc"
|
||||
extra_visibility = [ ":*" ] # Only targets in this file can depend on this.
|
||||
src_js = rebase_path(test_js_path)
|
||||
dst_file = rebase_path(test_abc_path)
|
||||
extra_args = [ "--debug" ]
|
||||
|
||||
in_puts = [ test_js_path ]
|
||||
out_puts = [ test_abc_path ]
|
||||
}
|
||||
|
||||
ts2abc_gen_abc("ark_syntaxException_abc") {
|
||||
test_js_path =
|
||||
"//arkcompiler/ets_runtime/ecmascript/tooling/test/js/syntaxException.js"
|
||||
test_abc_path = "$target_out_dir/syntaxException.abc"
|
||||
extra_visibility = [ ":*" ] # Only targets in this file can depend on this.
|
||||
src_js = rebase_path(test_js_path)
|
||||
dst_file = rebase_path(test_abc_path)
|
||||
extra_args = [ "--debug" ]
|
||||
|
||||
in_puts = [ test_js_path ]
|
||||
out_puts = [ test_abc_path ]
|
||||
}
|
||||
|
||||
ts2abc_gen_abc("ark_throwException_abc") {
|
||||
test_js_path =
|
||||
"//arkcompiler/ets_runtime/ecmascript/tooling/test/js/throwException.js"
|
||||
test_abc_path = "$target_out_dir/throwException.abc"
|
||||
extra_visibility = [ ":*" ] # Only targets in this file can depend on this.
|
||||
src_js = rebase_path(test_js_path)
|
||||
dst_file = rebase_path(test_abc_path)
|
||||
extra_args = [ "--debug" ]
|
||||
|
||||
in_puts = [ test_js_path ]
|
||||
out_puts = [ test_abc_path ]
|
||||
}
|
||||
|
||||
ts2abc_gen_abc("ark_stepInto_abc") {
|
||||
test_js_path =
|
||||
"//arkcompiler/ets_runtime/ecmascript/tooling/test/js/StepInto.js"
|
||||
test_abc_path = "$target_out_dir/StepInto.abc"
|
||||
extra_visibility = [ ":*" ] # Only targets in this file can depend on this.
|
||||
src_js = rebase_path(test_js_path)
|
||||
dst_file = rebase_path(test_abc_path)
|
||||
extra_args = [ "--debug" ]
|
||||
|
||||
in_puts = [ test_js_path ]
|
||||
out_puts = [ test_abc_path ]
|
||||
in_puts = [ test_js ]
|
||||
out_puts = [ test_abc ]
|
||||
}
|
||||
}
|
||||
|
||||
source_set("debugger_entry_set") {
|
||||
@ -141,17 +65,11 @@ source_set("debugger_entry_set") {
|
||||
|
||||
public_configs = [ ":debug_api_test" ]
|
||||
|
||||
deps = [
|
||||
":ark_arrowfunc_abc",
|
||||
":ark_asyncfunc_abc",
|
||||
":ark_exception_abc",
|
||||
":ark_range_error_abc",
|
||||
":ark_sample_abc",
|
||||
":ark_stepInto_abc",
|
||||
":ark_syntaxException_abc",
|
||||
":ark_throwException_abc",
|
||||
":jsdebugtest",
|
||||
]
|
||||
deps = [ ":jsdebugtest" ]
|
||||
|
||||
foreach(file, test_js_files) {
|
||||
deps += [ ":gen_${file}_abc" ]
|
||||
}
|
||||
}
|
||||
|
||||
ohos_shared_library("debugger_entry") {
|
||||
@ -167,8 +85,8 @@ source_set("jsdebugtest_set") {
|
||||
sources = [
|
||||
"utils/test_entry.cpp",
|
||||
"utils/test_extractor.cpp",
|
||||
"utils/test_list.cpp",
|
||||
"utils/test_util.cpp",
|
||||
"utils/testcases/test_list.cpp",
|
||||
]
|
||||
|
||||
public_configs = [
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "ecmascript/ecma_vm.h"
|
||||
#include "ecmascript/napi/include/jsnapi.h"
|
||||
#include "ecmascript/tests/test_helper.h"
|
||||
#include "ecmascript/tooling/test/utils/testcases/test_list.h"
|
||||
#include "ecmascript/tooling/test/utils/test_list.h"
|
||||
|
||||
namespace panda::ecmascript::tooling::test {
|
||||
using panda::test::TestHelper;
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
JsBreakpointArrowTest()
|
||||
{
|
||||
vmStart = [this] {
|
||||
location_ = TestUtil::GetLocation("ArrowFunc.js", 18, 0, pandaFile_.c_str()); // 18: breakpointer line
|
||||
location_ = TestUtil::GetLocation(18, 0, pandaFile_.c_str()); // 18: breakpointer line
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
return true;
|
||||
};
|
||||
@ -38,6 +38,7 @@ public:
|
||||
};
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
ASSERT_TRUE(debugger_->NotifyScriptParsed(0, pandaFile_));
|
||||
auto condFuncRef = FunctionRef::Undefined(vm_);
|
||||
@ -47,7 +48,9 @@ public:
|
||||
};
|
||||
|
||||
scenario = [this]() {
|
||||
ASSERT_BREAKPOINT_SUCCESS(location_);
|
||||
TestUtil::WaitForLoadModule();
|
||||
TestUtil::Continue();
|
||||
TestUtil::WaitForBreakpoint(location_);
|
||||
TestUtil::Continue();
|
||||
auto ret = debugInterface_->RemoveBreakpoint(location_);
|
||||
ASSERT_TRUE(ret);
|
||||
@ -68,7 +71,7 @@ public:
|
||||
~JsBreakpointArrowTest() = default;
|
||||
|
||||
private:
|
||||
std::string pandaFile_ = DEBUGGER_ABC_DIR "ArrowFunc.abc";
|
||||
std::string pandaFile_ = DEBUGGER_ABC_DIR "arrow_func.abc";
|
||||
std::string entryPoint_ = "_GLOBAL::func_main_0";
|
||||
JSPtLocation location_ {nullptr, JSPtLocation::EntityId(0), 0};
|
||||
size_t breakpointCounter_ = 0;
|
@ -24,7 +24,7 @@ public:
|
||||
JsBreakpointAsyncTest()
|
||||
{
|
||||
vmStart = [this] {
|
||||
location_ = TestUtil::GetLocation("AsyncFunc.js", 18, 0, pandaFile_.c_str()); // 18: breakpointer line
|
||||
location_ = TestUtil::GetLocation(18, 0, pandaFile_.c_str()); // 18: breakpointer line
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
return true;
|
||||
};
|
||||
@ -38,6 +38,7 @@ public:
|
||||
};
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
ASSERT_TRUE(debugger_->NotifyScriptParsed(0, pandaFile_));
|
||||
auto condFuncRef = FunctionRef::Undefined(vm_);
|
||||
@ -47,9 +48,11 @@ public:
|
||||
};
|
||||
|
||||
scenario = [this]() {
|
||||
ASSERT_BREAKPOINT_SUCCESS(location_);
|
||||
TestUtil::WaitForLoadModule();
|
||||
TestUtil::Continue();
|
||||
ASSERT_BREAKPOINT_SUCCESS(location_);
|
||||
TestUtil::WaitForBreakpoint(location_);
|
||||
TestUtil::Continue();
|
||||
TestUtil::WaitForBreakpoint(location_);
|
||||
TestUtil::Continue();
|
||||
auto ret = debugInterface_->RemoveBreakpoint(location_);
|
||||
ASSERT_TRUE(ret);
|
||||
@ -70,7 +73,7 @@ public:
|
||||
~JsBreakpointAsyncTest() = default;
|
||||
|
||||
private:
|
||||
std::string pandaFile_ = DEBUGGER_ABC_DIR "AsyncFunc.abc";
|
||||
std::string pandaFile_ = DEBUGGER_ABC_DIR "async_func.abc";
|
||||
std::string entryPoint_ = "_GLOBAL::func_main_0";
|
||||
JSPtLocation location_ {nullptr, JSPtLocation::EntityId(0), 0};
|
||||
size_t breakpointCounter_ = 0;
|
@ -24,7 +24,7 @@ public:
|
||||
JsBreakpointTest()
|
||||
{
|
||||
vmStart = [this] {
|
||||
location_ = TestUtil::GetLocation("Sample.js", 22, 0, pandaFile_.c_str()); // 22: breakpointer line
|
||||
location_ = TestUtil::GetLocation(22, 0, pandaFile_.c_str()); // 22: breakpointer line
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
return true;
|
||||
};
|
||||
@ -38,6 +38,7 @@ public:
|
||||
};
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
ASSERT_TRUE(debugger_->NotifyScriptParsed(0, pandaFile_));
|
||||
auto condFuncRef = FunctionRef::Undefined(vm_);
|
||||
@ -47,9 +48,11 @@ public:
|
||||
};
|
||||
|
||||
scenario = [this]() {
|
||||
ASSERT_BREAKPOINT_SUCCESS(location_);
|
||||
TestUtil::WaitForLoadModule();
|
||||
TestUtil::Continue();
|
||||
ASSERT_BREAKPOINT_SUCCESS(location_);
|
||||
TestUtil::WaitForBreakpoint(location_);
|
||||
TestUtil::Continue();
|
||||
TestUtil::WaitForBreakpoint(location_);
|
||||
TestUtil::Continue();
|
||||
auto ret = debugInterface_->RemoveBreakpoint(location_);
|
||||
ASSERT_TRUE(ret);
|
||||
@ -70,7 +73,7 @@ public:
|
||||
~JsBreakpointTest() = default;
|
||||
|
||||
private:
|
||||
std::string pandaFile_ = DEBUGGER_ABC_DIR "Sample.abc";
|
||||
std::string pandaFile_ = DEBUGGER_ABC_DIR "sample.abc";
|
||||
std::string entryPoint_ = "_GLOBAL::func_main_0";
|
||||
JSPtLocation location_ {nullptr, JSPtLocation::EntityId(0), 0};
|
||||
size_t breakpointCounter_ = 0;
|
@ -24,7 +24,7 @@ public:
|
||||
JsExceptionTest()
|
||||
{
|
||||
vmStart = [this] {
|
||||
location_ = TestUtil::GetLocation("exception.js", 22, 0, pandaFile_.c_str()); // 22:breakpointer line
|
||||
location_ = TestUtil::GetLocation(22, 0, pandaFile_.c_str()); // 22:breakpointer line
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
return true;
|
||||
};
|
||||
@ -61,6 +61,7 @@ public:
|
||||
};
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
ASSERT_TRUE(debugger_->NotifyScriptParsed(0, pandaFile_));
|
||||
auto condFuncRef = FunctionRef::Undefined(vm_);
|
||||
@ -70,7 +71,9 @@ public:
|
||||
};
|
||||
|
||||
scenario = [this]() {
|
||||
ASSERT_BREAKPOINT_SUCCESS(location_);
|
||||
TestUtil::WaitForLoadModule();
|
||||
TestUtil::Continue();
|
||||
TestUtil::WaitForBreakpoint(location_);
|
||||
TestUtil::Continue();
|
||||
TestUtil::WaitForException();
|
||||
TestUtil::Continue();
|
@ -24,7 +24,7 @@ public:
|
||||
JsRangeErrorTest()
|
||||
{
|
||||
vmStart = [this] {
|
||||
location_ = TestUtil::GetLocation("RangeError.js", 20, 0, pandaFile_.c_str()); // 20: breakpointer line
|
||||
location_ = TestUtil::GetLocation(20, 0, pandaFile_.c_str()); // 20: breakpointer line
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
return true;
|
||||
};
|
||||
@ -61,6 +61,7 @@ public:
|
||||
};
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
ASSERT_TRUE(debugger_->NotifyScriptParsed(0, pandaFile_));
|
||||
auto condFuncRef = FunctionRef::Undefined(vm_);
|
||||
@ -70,7 +71,9 @@ public:
|
||||
};
|
||||
|
||||
scenario = [this]() {
|
||||
ASSERT_BREAKPOINT_SUCCESS(location_);
|
||||
TestUtil::WaitForLoadModule();
|
||||
TestUtil::Continue();
|
||||
TestUtil::WaitForBreakpoint(location_);
|
||||
TestUtil::Continue();
|
||||
TestUtil::WaitForException();
|
||||
TestUtil::Continue();
|
||||
@ -94,7 +97,7 @@ public:
|
||||
~JsRangeErrorTest() = default;
|
||||
|
||||
private:
|
||||
std::string pandaFile_ = DEBUGGER_ABC_DIR "RangeError.abc";
|
||||
std::string pandaFile_ = DEBUGGER_ABC_DIR "range_error.abc";
|
||||
std::string entryPoint_ = "_GLOBAL::func_main_0";
|
||||
JSPtLocation location_ {nullptr, JSPtLocation::EntityId(0), 0};
|
||||
size_t breakpointCounter_ = 0;
|
@ -24,8 +24,8 @@ public:
|
||||
JsSingleStepTest()
|
||||
{
|
||||
vmStart = [this] {
|
||||
locationStart_ = TestUtil::GetLocation("Sample.js", 19, 0, pandaFile_.c_str()); // 19: line number
|
||||
locationEnd_ = TestUtil::GetLocation("Sample.js", 22, 0, pandaFile_.c_str()); // 22: line number
|
||||
locationStart_ = TestUtil::GetLocation(19, 0, pandaFile_.c_str()); // 19: line number
|
||||
locationEnd_ = TestUtil::GetLocation(22, 0, pandaFile_.c_str()); // 22: line number
|
||||
return true;
|
||||
};
|
||||
|
||||
@ -36,6 +36,7 @@ public:
|
||||
};
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
auto condFuncRef = FunctionRef::Undefined(vm_);
|
||||
auto ret = debugInterface_->SetBreakpoint(locationEnd_, condFuncRef);
|
||||
@ -70,6 +71,12 @@ public:
|
||||
bytecodeOffset_ = location.GetBytecodeOffset();
|
||||
return false;
|
||||
};
|
||||
|
||||
scenario = []() {
|
||||
TestUtil::WaitForLoadModule();
|
||||
TestUtil::Continue();
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
std::pair<std::string, std::string> GetEntryPoint() override
|
||||
@ -78,7 +85,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
std::string pandaFile_ = DEBUGGER_ABC_DIR "Sample.abc";
|
||||
std::string pandaFile_ = DEBUGGER_ABC_DIR "sample.abc";
|
||||
std::string entryPoint_ = "_GLOBAL::func_main_0";
|
||||
JSPtLocation locationStart_ {nullptr, JSPtLocation::EntityId(0), 0};
|
||||
JSPtLocation locationEnd_ {nullptr, JSPtLocation::EntityId(0), 0};
|
@ -24,24 +24,23 @@ public:
|
||||
JsStepIntoTest()
|
||||
{
|
||||
vmStart = [this] {
|
||||
// 45、20: line number for breakpoint array
|
||||
int32_t breakpoint[6][2] = {{45, 0}, {20, 0}, {25, 0}, {31, 0}, {33, 0}, {48, 0}};
|
||||
// 16、21: line number for stepinto array
|
||||
int32_t stepInto[5][2] = {{16, 0}, {21, 0}, {30, 0}, {32, 0}, {38, 0}};
|
||||
// 6、2: breakpoint array for total index
|
||||
SetJSPtLocation("StepInto.js", breakpoint[0], 6, 2, pointerLocations_);
|
||||
// 5、2:stepinto array for total index
|
||||
SetJSPtLocation("StepInto.js", stepInto[0], 5, 2, stepLocations_);
|
||||
// line number for breakpoint array
|
||||
size_t breakpoint[POINTER_SIZE][LINE_COLUMN] = {{45, 0}, {20, 0}, {25, 0}, {31, 0}, {33, 0}, {41, 0}, {48, 0}};
|
||||
// line number for stepinto array
|
||||
size_t stepInto[STEP_SIZE][LINE_COLUMN] = {{16, 0}, {21, 0}, {30, 0}, {32, 0}, {38, 0}, {34, 0}};
|
||||
SetJSPtLocation(breakpoint[0], POINTER_SIZE, pointerLocations_);
|
||||
SetJSPtLocation(stepInto[0], STEP_SIZE, stepLocations_);
|
||||
return true;
|
||||
};
|
||||
|
||||
vmDeath = [this]() {
|
||||
ASSERT_EQ(breakpointCounter_, pointerLocations_.size()); // size: break point counter
|
||||
ASSERT_EQ(stepCompleteCounter_, stepLocations_.size()); // size: step complete counter
|
||||
ASSERT_EQ(breakpointCounter_, pointerLocations_.size());
|
||||
ASSERT_EQ(stepCompleteCounter_, stepLocations_.size());
|
||||
return true;
|
||||
};
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
debugger_->NotifyScriptParsed(0, moduleName.data());
|
||||
auto condFuncRef = FunctionRef::Undefined(vm_);
|
||||
@ -66,24 +65,24 @@ public:
|
||||
ASSERT_TRUE(location.GetMethodId().IsValid());
|
||||
ASSERT_LOCATION_EQ(location, stepLocations_.at(stepCompleteCounter_));
|
||||
stepCompleteCounter_++;
|
||||
if (stepCompleteCounter_ == (int32_t)stepLocations_.size()) {
|
||||
TestUtil::Event(DebugEvent::STEP_COMPLETE);
|
||||
}
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::STEP_COMPLETE, location);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
scenario = [this]() {
|
||||
while (true) {
|
||||
if (breakpointCounter_ >= (int32_t)pointerLocations_.size()) {
|
||||
TestUtil::WaitForStepComplete();
|
||||
break;
|
||||
}
|
||||
ASSERT_BREAKPOINT_SUCCESS(pointerLocations_.at(breakpointCounter_));
|
||||
TestUtil::WaitForLoadModule();
|
||||
TestUtil::Continue();
|
||||
size_t index = 0;
|
||||
while (index < POINTER_SIZE) {
|
||||
TestUtil::WaitForBreakpoint(pointerLocations_.at(index));
|
||||
TestUtil::Continue();
|
||||
auto ret = debugInterface_->RemoveBreakpoint(pointerLocations_.at(breakpointCounter_-1));
|
||||
ASSERT_TRUE(ret);
|
||||
if (index < STEP_SIZE) {
|
||||
TestUtil::WaitForStepComplete(stepLocations_.at(index));
|
||||
TestUtil::Continue();
|
||||
}
|
||||
++index;
|
||||
}
|
||||
ASSERT_EXITED();
|
||||
return true;
|
||||
@ -96,20 +95,23 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
std::string pandaFile_ = DEBUGGER_ABC_DIR "StepInto.abc";
|
||||
static constexpr size_t LINE_COLUMN = 2;
|
||||
static constexpr size_t POINTER_SIZE = 7;
|
||||
static constexpr size_t STEP_SIZE = 6;
|
||||
|
||||
std::string pandaFile_ = DEBUGGER_ABC_DIR "step_into.abc";
|
||||
std::string entryPoint_ = "_GLOBAL::func_main_0";
|
||||
JSPtLocation location1_ {nullptr, JSPtLocation::EntityId(0), 0};
|
||||
JSPtLocation location2_ {nullptr, JSPtLocation::EntityId(0), 0};
|
||||
int32_t breakpointCounter_ = 0;
|
||||
int32_t stepCompleteCounter_ = 0;
|
||||
size_t breakpointCounter_ = 0;
|
||||
size_t stepCompleteCounter_ = 0;
|
||||
std::vector<JSPtLocation> pointerLocations_;
|
||||
std::vector<JSPtLocation> stepLocations_;
|
||||
|
||||
void SetJSPtLocation(const char *sFile, int32_t *arr, int32_t m, int32_t n, std::vector<JSPtLocation> &vct_)
|
||||
void SetJSPtLocation(size_t *arr, size_t number, std::vector<JSPtLocation> &locations)
|
||||
{
|
||||
for (int32_t i = 0; i < m; i++) {
|
||||
JSPtLocation location_ = TestUtil::GetLocation(sFile, arr[i*n], arr[i*n + 1], pandaFile_.c_str());
|
||||
vct_.push_back(location_);
|
||||
for (size_t i = 0; i < number; i++) {
|
||||
JSPtLocation location =
|
||||
TestUtil::GetLocation(arr[i * LINE_COLUMN], arr[i * LINE_COLUMN + 1], pandaFile_.c_str());
|
||||
locations.push_back(location);
|
||||
}
|
||||
};
|
||||
};
|
@ -24,7 +24,7 @@ public:
|
||||
JsSyntaxExceptionTest()
|
||||
{
|
||||
vmStart = [this] {
|
||||
location_ = TestUtil::GetLocation("syntaxException.js", 27, 0, pandaFile_.c_str()); // 27: breakpointer line
|
||||
location_ = TestUtil::GetLocation(27, 0, pandaFile_.c_str()); // 27: breakpointer line
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
return true;
|
||||
};
|
||||
@ -61,6 +61,7 @@ public:
|
||||
};
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
ASSERT_TRUE(debugger_->NotifyScriptParsed(0, pandaFile_));
|
||||
auto condFuncRef = FunctionRef::Undefined(vm_);
|
||||
@ -70,7 +71,9 @@ public:
|
||||
};
|
||||
|
||||
scenario = [this]() {
|
||||
ASSERT_BREAKPOINT_SUCCESS(location_);
|
||||
TestUtil::WaitForLoadModule();
|
||||
TestUtil::Continue();
|
||||
TestUtil::WaitForBreakpoint(location_);
|
||||
TestUtil::Continue();
|
||||
TestUtil::WaitForException();
|
||||
TestUtil::Continue();
|
||||
@ -94,7 +97,7 @@ public:
|
||||
~JsSyntaxExceptionTest() = default;
|
||||
|
||||
private:
|
||||
std::string pandaFile_ = DEBUGGER_ABC_DIR "syntaxException.abc";
|
||||
std::string pandaFile_ = DEBUGGER_ABC_DIR "syntax_exception.abc";
|
||||
std::string entryPoint_ = "_GLOBAL::func_main_0";
|
||||
JSPtLocation location_ {nullptr, JSPtLocation::EntityId(0), 0};
|
||||
size_t breakpointCounter_ = 0;
|
@ -24,7 +24,7 @@ public:
|
||||
JsThrowExceptionTest()
|
||||
{
|
||||
vmStart = [this] {
|
||||
location_ = TestUtil::GetLocation("throwException.js", 28, 0, pandaFile_.c_str()); // 28: breakpointer line
|
||||
location_ = TestUtil::GetLocation(28, 0, pandaFile_.c_str()); // 28: breakpointer line
|
||||
std::cout<<"vmStart1"<<std::endl;
|
||||
ASSERT_TRUE(location_.GetMethodId().IsValid());
|
||||
std::cout<<"vmStart2"<<std::endl;
|
||||
@ -64,6 +64,7 @@ public:
|
||||
};
|
||||
|
||||
loadModule = [this](std::string_view moduleName) {
|
||||
TestUtil::SuspendUntilContinue(DebugEvent::LOAD_MODULE);
|
||||
ASSERT_EQ(moduleName, pandaFile_);
|
||||
ASSERT_TRUE(debugger_->NotifyScriptParsed(0, pandaFile_));
|
||||
auto condFuncRef = FunctionRef::Undefined(vm_);
|
||||
@ -73,7 +74,9 @@ public:
|
||||
};
|
||||
|
||||
scenario = [this]() {
|
||||
ASSERT_BREAKPOINT_SUCCESS(location_);
|
||||
TestUtil::WaitForLoadModule();
|
||||
TestUtil::Continue();
|
||||
TestUtil::WaitForBreakpoint(location_);
|
||||
TestUtil::Continue();
|
||||
TestUtil::WaitForException();
|
||||
TestUtil::Continue();
|
||||
@ -97,7 +100,7 @@ public:
|
||||
~JsThrowExceptionTest() = default;
|
||||
|
||||
private:
|
||||
std::string pandaFile_ = DEBUGGER_ABC_DIR "throwException.abc";
|
||||
std::string pandaFile_ = DEBUGGER_ABC_DIR "throw_exception.abc";
|
||||
std::string entryPoint_ = "_GLOBAL::func_main_0";
|
||||
JSPtLocation location_ {nullptr, JSPtLocation::EntityId(0), 0};
|
||||
size_t breakpointCounter_ = 0;
|
@ -17,8 +17,8 @@
|
||||
|
||||
#include <thread>
|
||||
|
||||
#include "ecmascript/tooling/test/utils/testcases/test_list.h"
|
||||
#include "ecmascript/tooling/test/utils/test_hooks.h"
|
||||
#include "ecmascript/tooling/test/utils/test_list.h"
|
||||
|
||||
namespace panda::ecmascript::tooling::test {
|
||||
static std::thread g_debuggerThread;
|
||||
|
@ -13,20 +13,20 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "ecmascript/tooling/test/utils/testcases/test_list.h"
|
||||
#include "ecmascript/tooling/test/utils/test_list.h"
|
||||
|
||||
#include "ecmascript/tooling/test/utils/test_util.h"
|
||||
|
||||
// testcase list
|
||||
#include "js_breakpoint_test.h"
|
||||
#include "js_breakpoint_arrow_test.h"
|
||||
#include "js_breakpoint_async_test.h"
|
||||
#include "js_exception_test.h"
|
||||
#include "js_range_error_test.h"
|
||||
#include "js_single_step_test.h"
|
||||
#include "js_step_into_test.h"
|
||||
#include "js_syntaxException_test.h"
|
||||
#include "js_throwException_test.h"
|
||||
#include "ecmascript/tooling/test/testcases/js_breakpoint_test.h"
|
||||
#include "ecmascript/tooling/test/testcases/js_breakpoint_arrow_test.h"
|
||||
#include "ecmascript/tooling/test/testcases/js_breakpoint_async_test.h"
|
||||
#include "ecmascript/tooling/test/testcases/js_exception_test.h"
|
||||
#include "ecmascript/tooling/test/testcases/js_range_error_test.h"
|
||||
#include "ecmascript/tooling/test/testcases/js_single_step_test.h"
|
||||
#include "ecmascript/tooling/test/testcases/js_step_into_test.h"
|
||||
#include "ecmascript/tooling/test/testcases/js_syntax_exception_test.h"
|
||||
#include "ecmascript/tooling/test/testcases/js_throw_exception_test.h"
|
||||
|
||||
namespace panda::ecmascript::tooling::test {
|
||||
static std::string g_currentTestName = "";
|
@ -13,8 +13,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ECMASCRIPT_TOOLING_TEST_UTILS_TESTCASES_TEST_LIST_H
|
||||
#define ECMASCRIPT_TOOLING_TEST_UTILS_TESTCASES_TEST_LIST_H
|
||||
#ifndef ECMASCRIPT_TOOLING_TEST_UTILS_TEST_LIST_H
|
||||
#define ECMASCRIPT_TOOLING_TEST_UTILS_TEST_LIST_H
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
@ -31,4 +31,4 @@ std::string GetCurrentTestName();
|
||||
std::pair<std::string, std::string> GetTestEntryPoint(const std::string &testName);
|
||||
} // namespace panda::ecmascript::tooling::test
|
||||
|
||||
#endif // ECMASCRIPT_TOOLING_TEST_UTILS_TESTCASES_TEST_LIST_H
|
||||
#endif // ECMASCRIPT_TOOLING_TEST_UTILS_TEST_LIST_H
|
@ -40,11 +40,13 @@ std::ostream &operator<<(std::ostream &out, DebugEvent value)
|
||||
ADD_CASE(DebugEvent::LOAD_MODULE);
|
||||
ADD_CASE(DebugEvent::PAUSED);
|
||||
ADD_CASE(DebugEvent::EXCEPTION);
|
||||
ADD_CASE(DebugEvent::STEP_COMPLETE);
|
||||
ADD_CASE(DebugEvent::METHOD_ENTRY);
|
||||
ADD_CASE(DebugEvent::SINGLE_STEP);
|
||||
ADD_CASE(DebugEvent::VM_START);
|
||||
ADD_CASE(DebugEvent::VM_INITIALIZATION);
|
||||
ADD_CASE(DebugEvent::VM_DEATH);
|
||||
ADD_CASE(DebugEvent::UNINITIALIZED);
|
||||
default: {
|
||||
ASSERT(false && "Unknown DebugEvent"); // NOLINT
|
||||
}
|
||||
|
@ -67,10 +67,15 @@ public:
|
||||
}, [] {});
|
||||
}
|
||||
|
||||
static bool WaitForStepComplete()
|
||||
static void WaitForStepComplete(JSPtLocation location)
|
||||
{
|
||||
auto predicate = []() REQUIRES(eventMutex_) { return lastEvent_ == DebugEvent::STEP_COMPLETE; };
|
||||
return WaitForEvent(DebugEvent::STEP_COMPLETE, predicate, [] {});
|
||||
auto predicate = [&location]() REQUIRES(eventMutex_) { return lastEventLocation_ == location; };
|
||||
auto onSuccess = []() REQUIRES(eventMutex_) {
|
||||
// Need to reset location, because we might want to stop at the same point
|
||||
lastEventLocation_ = JSPtLocation("", EntityId(0), 0);
|
||||
};
|
||||
|
||||
WaitForEvent(DebugEvent::STEP_COMPLETE, predicate, onSuccess);
|
||||
}
|
||||
|
||||
static bool WaitForException()
|
||||
@ -87,6 +92,12 @@ public:
|
||||
}, [] {});
|
||||
}
|
||||
|
||||
static bool WaitForLoadModule()
|
||||
{
|
||||
auto predicate = []() REQUIRES(eventMutex_) { return lastEvent_ == DebugEvent::LOAD_MODULE; };
|
||||
return WaitForEvent(DebugEvent::LOAD_MODULE, predicate, [] {});
|
||||
}
|
||||
|
||||
static void Event(DebugEvent event, JSPtLocation location = JSPtLocation("", EntityId(0), 0))
|
||||
{
|
||||
LOG_DEBUGGER(DEBUG) << "Occurred event " << event;
|
||||
@ -117,14 +128,14 @@ public:
|
||||
return lastEvent_ == DebugEvent::VM_DEATH;
|
||||
}
|
||||
|
||||
static JSPtLocation GetLocation(const char *sourceFile, int32_t line, int32_t column, const char *pandaFile)
|
||||
static JSPtLocation GetLocation(int32_t line, int32_t column, const char *pandaFile)
|
||||
{
|
||||
auto jsPandaFile = ::panda::ecmascript::JSPandaFileManager::GetInstance()->OpenJSPandaFile(pandaFile);
|
||||
if (jsPandaFile == nullptr) {
|
||||
return JSPtLocation("", EntityId(0), 0);
|
||||
}
|
||||
TestExtractor extractor(jsPandaFile);
|
||||
auto [id, offset] = extractor.GetBreakpointAddress({sourceFile, line, column});
|
||||
auto [id, offset] = extractor.GetBreakpointAddress({"", line, column});
|
||||
return JSPtLocation(pandaFile, id, offset);
|
||||
}
|
||||
|
||||
@ -138,7 +149,7 @@ public:
|
||||
return extractor.GetSourceLocation(location.GetMethodId(), location.GetBytecodeOffset());
|
||||
}
|
||||
|
||||
static bool SuspendUntilContinue(DebugEvent reason, JSPtLocation location)
|
||||
static bool SuspendUntilContinue(DebugEvent reason, JSPtLocation location = JSPtLocation("", EntityId(0), 0))
|
||||
{
|
||||
os::memory::LockHolder lock(suspendMutex_);
|
||||
suspended_ = true;
|
||||
@ -148,7 +159,12 @@ public:
|
||||
|
||||
// Wait for continue
|
||||
while (suspended_) {
|
||||
suspendCv_.Wait(&suspendMutex_);
|
||||
constexpr uint64_t TIMEOUT_MSEC = 10000U;
|
||||
bool timeExceeded = suspendCv_.TimedWait(&suspendMutex_, TIMEOUT_MSEC);
|
||||
if (timeExceeded) {
|
||||
LOG_DEBUGGER(FATAL) << "Time limit exceeded while suspend";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -269,11 +285,6 @@ std::ostream &operator<<(std::ostream &out, std::nullptr_t);
|
||||
ASSERT_EQ((lhs).GetMethodId().GetOffset(), (rhs).GetMethodId().GetOffset()); \
|
||||
ASSERT_EQ((lhs).GetBytecodeOffset(), (rhs).GetBytecodeOffset()); \
|
||||
} while (0)
|
||||
|
||||
#define ASSERT_BREAKPOINT_SUCCESS(location) \
|
||||
do { \
|
||||
TestUtil::WaitForBreakpoint(location); \
|
||||
} while (0)
|
||||
} // namespace panda::ecmascript::tooling::test
|
||||
|
||||
#endif // ECMASCRIPT_TOOLING_TEST_UTILS_TEST_UTIL_H
|
||||
|
@ -15,14 +15,14 @@
|
||||
<configuration ver="2.0">
|
||||
<target name="DebuggerEntryTest">
|
||||
<preparer>
|
||||
<option name="push" value="obj/arkcompiler/ets_runtime/ecmascript/tooling/test/Sample.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/ets_runtime/ecmascript/tooling/test/sample.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/ets_runtime/ecmascript/tooling/test/exception.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/ets_runtime/ecmascript/tooling/test/ArrowFunc.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/ets_runtime/ecmascript/tooling/test/AsyncFunc.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/ets_runtime/ecmascript/tooling/test/RangeError.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/ets_runtime/ecmascript/tooling/test/syntaxException.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/ets_runtime/ecmascript/tooling/test/throwException.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/ets_runtime/ecmascript/tooling/test/StepInto.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/ets_runtime/ecmascript/tooling/test/arrow_func.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/ets_runtime/ecmascript/tooling/test/async_func.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/ets_runtime/ecmascript/tooling/test/range_error.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/ets_runtime/ecmascript/tooling/test/syntax_exception.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/ets_runtime/ecmascript/tooling/test/throw_exception.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="obj/arkcompiler/ets_runtime/ecmascript/tooling/test/step_into.abc -> /data/test" src="out"/>
|
||||
<option name="push" value="test/test/libjsdebugtest.so -> /data/test" src="out"/>
|
||||
<option name="push" value="test/test/libdebugger_entry.so -> /data/test" src="out"/>
|
||||
<option name="push" value="test/test/libark_jsruntime_test.so -> /data/test" src="out"/>
|
||||
|
Loading…
Reference in New Issue
Block a user