diff --git a/runtime/base/error_helper.cpp b/runtime/base/error_helper.cpp index f6453e33d7ce61c305d3f4cc2688a931e470b0b2..2c50361ae45c350b26e307de25b9cd2b3ae383d3 100644 --- a/runtime/base/error_helper.cpp +++ b/runtime/base/error_helper.cpp @@ -27,7 +27,7 @@ #include "plugins/ecmascript/runtime/tooling/pt_js_extractor.h" namespace panda::ecmascript::base { -using panda::tooling::ecmascript::PtJSExtractor; +using tooling::PtJSExtractor; JSTaggedValue ErrorHelper::ErrorCommonToString(EcmaRuntimeCallInfo *argv, const ErrorType &errorType) { diff --git a/runtime/ecma_vm.cpp b/runtime/ecma_vm.cpp index a3156c29a33d7f3b969b3539d51f6fc868f906c9..fb606cb3638c350e9380fc00bf45eaf461ba70ba 100644 --- a/runtime/ecma_vm.cpp +++ b/runtime/ecma_vm.cpp @@ -431,12 +431,12 @@ bool EcmaVM::ExecuteFromBuffer(const void *buffer, size_t size, std::string_view return Execute(std::move(pf), entryPoint, args); } -tooling::ecmascript::PtJSExtractor *EcmaVM::GetDebugInfoExtractor(const panda_file::File *file) +tooling::PtJSExtractor *EcmaVM::GetDebugInfoExtractor(const panda_file::File *file) { - tooling::ecmascript::PtJSExtractor *res = nullptr; + tooling::PtJSExtractor *res = nullptr; auto it = extractorCache_.find(file); if (it == extractorCache_.end()) { - auto extractor = std::make_unique(file); + auto extractor = std::make_unique(file); res = extractor.get(); extractorCache_[file] = std::move(extractor); } else { diff --git a/runtime/ecma_vm.h b/runtime/ecma_vm.h index 4499509e321ccbc6e905d61f33037b4af78a73c9..9d6fe5019da6decc2605f0f89537712c4c938d44 100644 --- a/runtime/ecma_vm.h +++ b/runtime/ecma_vm.h @@ -82,7 +82,7 @@ public: }; class EcmaVM final : public PandaVM { - using PtJSExtractor = tooling::ecmascript::PtJSExtractor; + using PtJSExtractor = tooling::PtJSExtractor; public: static EcmaVM *Cast(PandaVM *object) diff --git a/runtime/include/tooling/pt_ecmascript_extension.h b/runtime/include/tooling/pt_ecmascript_extension.h index 582f59f5acd66acc690d5b00603cb8d3d5b00681..c2bbad8da3bcb5419d1154ada2a890145bbf4b88 100644 --- a/runtime/include/tooling/pt_ecmascript_extension.h +++ b/runtime/include/tooling/pt_ecmascript_extension.h @@ -20,14 +20,15 @@ #include "runtime/include/tooling/debug_interface.h" #include "plugins/ecmascript/runtime/js_tagged_value.h" -namespace panda::tooling::ecmascript { -using JSTaggedValue = panda::ecmascript::JSTaggedValue; +namespace panda::ecmascript::tooling { +using panda::tooling::VRegValue; + class PtEcmaScriptExtension { public: static VRegValue TaggedValueToVRegValue(JSTaggedValue value); static JSTaggedValue VRegValueToTaggedValue(VRegValue value); }; -} // namespace panda::tooling::ecmascript +} // namespace panda::ecmascript::tooling #endif // PANDA_TOOLING_ECMASCRIPT_EXTENSION_H diff --git a/runtime/tooling/pt_ecmascript_extension.cpp b/runtime/tooling/pt_ecmascript_extension.cpp index bdc353fbe36121777a72a946769f02055da66645..9310703912fc468fa0051a36aae049e36fea2d9e 100644 --- a/runtime/tooling/pt_ecmascript_extension.cpp +++ b/runtime/tooling/pt_ecmascript_extension.cpp @@ -17,9 +17,7 @@ #include "plugins/ecmascript/runtime/js_handle.h" #include "plugins/ecmascript/runtime/global_env.h" -namespace panda::tooling::ecmascript { -using JSThread = panda::ecmascript::JSThread; - +namespace panda::ecmascript::tooling { /* static */ VRegValue PtEcmaScriptExtension::TaggedValueToVRegValue(JSTaggedValue value) { @@ -31,4 +29,4 @@ JSTaggedValue PtEcmaScriptExtension::VRegValueToTaggedValue(VRegValue value) { return JSTaggedValue(bit_cast(value.GetValue())); } -} // namespace panda::tooling::ecmascript +} // namespace panda::ecmascript::tooling diff --git a/runtime/tooling/pt_js_extractor.h b/runtime/tooling/pt_js_extractor.h index cbd997185ca9470ccce6a8af1a421704c8436d1c..5a23e53c2114e7438ccba1b98b73dbf35b150268 100644 --- a/runtime/tooling/pt_js_extractor.h +++ b/runtime/tooling/pt_js_extractor.h @@ -22,13 +22,11 @@ #include "libpandabase/macros.h" #include "include/tooling/debug_interface.h" -namespace panda::tooling::ecmascript { -using panda::panda_file::DebugInfoExtractor; -using panda::panda_file::File; +namespace panda::ecmascript::tooling { -class PtJSExtractor : public DebugInfoExtractor { +class PtJSExtractor : public panda_file::DebugInfoExtractor { public: - explicit PtJSExtractor(const File *pf) : DebugInfoExtractor(pf) {} + explicit PtJSExtractor(const panda_file::File *pf) : panda_file::DebugInfoExtractor(pf) {} virtual ~PtJSExtractor() = default; template @@ -47,7 +45,7 @@ public: } template - bool MatchWithOffset(const Callback &cb, File::EntityId methodId, uint32_t offset) + bool MatchWithOffset(const Callback &cb, panda_file::File::EntityId methodId, uint32_t offset) { auto lineTable = GetLineNumberTable(methodId); auto columnTable = GetColumnNumberTable(methodId); @@ -81,5 +79,5 @@ public: NO_COPY_SEMANTIC(PtJSExtractor); NO_MOVE_SEMANTIC(PtJSExtractor); }; -} // namespace panda::tooling::ecmascript +} // namespace panda::ecmascript::tooling #endif diff --git a/tests/runtime/tooling/api_tests/js/js_breakpoint_test.h b/tests/runtime/tooling/api_tests/js/js_breakpoint_test.h index 03e6a5156493c88f31eaeabc3ff142317c607b7d..05a5fa82aba95e770667179a249e3c5e8db47e46 100644 --- a/tests/runtime/tooling/api_tests/js/js_breakpoint_test.h +++ b/tests/runtime/tooling/api_tests/js/js_breakpoint_test.h @@ -18,18 +18,18 @@ #include "test_util.h" -namespace panda::tooling::test { -class JsBreakpointTest : public ApiTest { +namespace panda::ecmascript::tooling::test { +class JsBreakpointTest : public panda::tooling::test::ApiTest { public: JsBreakpointTest() { vm_start = [this] { - location_ = TestUtil::GetLocation("Sample.js", 22, panda_file_.c_str()); + location_ = panda::tooling::test::TestUtil::GetLocation("Sample.js", 22, panda_file_.c_str()); ASSERT_TRUE(location_.GetMethodId().IsValid()); return true; }; - breakpoint = [this](PtThread, Method *, const PtLocation &location) { + breakpoint = [this](panda::tooling::PtThread, Method *, const panda::tooling::PtLocation &location) { ASSERT_TRUE(location.GetMethodId().IsValid()); ASSERT_LOCATION_EQ(location, location_); ++breakpoint_counter_; @@ -60,14 +60,14 @@ public: private: std::string panda_file_ = "js/Sample.abc"; std::string entry_point_ = "_GLOBAL::func_main_0"; - PtLocation location_ {nullptr, PtLocation::EntityId(0), 0}; + panda::tooling::PtLocation location_ {nullptr, panda::tooling::PtLocation::EntityId(0), 0}; size_t breakpoint_counter_ = 0; }; -std::unique_ptr GetJsBreakpointTest() +std::unique_ptr GetJsBreakpointTest() { return std::make_unique(); } -} // namespace panda::tooling::test +} // namespace panda::ecmascript::tooling::test #endif // PANDA_TOOLING_TEST_JS_BREAKPOINT_TEST_H diff --git a/tests/runtime/tooling/api_tests/js/js_enumerate_frames_test.h b/tests/runtime/tooling/api_tests/js/js_enumerate_frames_test.h index b2167f7ccbfc3d02c209ae898b9344f9108d0fd9..4ffc5834943dedc557778bf16b5000cf06ea818b 100644 --- a/tests/runtime/tooling/api_tests/js/js_enumerate_frames_test.h +++ b/tests/runtime/tooling/api_tests/js/js_enumerate_frames_test.h @@ -18,8 +18,8 @@ #include "test_util.h" -namespace panda::tooling::test { -class JsEnumerateFrameTest : public ApiTest { +namespace panda::ecmascript::tooling::test { +class JsEnumerateFrameTest : public panda::tooling::test::ApiTest { public: JsEnumerateFrameTest() { @@ -28,7 +28,7 @@ public: return true; }; - method_exit = [this](PtThread thread, Method *method, bool, VRegValue) { + method_exit = [this](panda::tooling::PtThread thread, Method *method, bool, panda::tooling::VRegValue) { if (method->GetFullName() == "_GLOBAL::func_method3_3") { ASSERT_EQ(count_frames_, 0U); debug_interface->EnumerateFrames(thread, callback); @@ -56,18 +56,19 @@ private: std::string entry_point_ = "_GLOBAL::func_main_0"; size_t count_frames_ = 0; - std::function callback {[this](const PtFrame &debugFrame) { - this->count_frames_++; - if (debugFrame.GetArgumentNum() != 1) - return true; - return false; - }}; + std::function callback { + [this](const panda::tooling::PtFrame &debugFrame) { + this->count_frames_++; + if (debugFrame.GetArgumentNum() != 1) + return true; + return false; + }}; }; -std::unique_ptr JsEnumerateFramesTest() +std::unique_ptr JsEnumerateFramesTest() { return std::make_unique(); } -} // namespace panda::tooling::test +} // namespace panda::ecmascript::tooling::test #endif // PANDA_TOOLING_TEST_JS_ENUMERATE_FRAMES_TEST_H diff --git a/tests/runtime/tooling/api_tests/js/js_exception_events_test.h b/tests/runtime/tooling/api_tests/js/js_exception_events_test.h index fdce4363dc45185a54f06e5b1641e8ed6a0d674d..3a9a52104b4b1cc8a3f6f52ad2fd7e9b9059663d 100644 --- a/tests/runtime/tooling/api_tests/js/js_exception_events_test.h +++ b/tests/runtime/tooling/api_tests/js/js_exception_events_test.h @@ -19,8 +19,8 @@ #include "test_util.h" #include "runtime/include/tooling/pt_location.h" -namespace panda::tooling::test { -class JsExceptionEventTest : public ApiTest { +namespace panda::ecmascript::tooling::test { +class JsExceptionEventTest : public panda::tooling::test::ApiTest { public: JsExceptionEventTest() { @@ -30,23 +30,23 @@ public: return true; }; - method_entry = [this](PtThread thread, Method *method) { + method_entry = [this](panda::tooling::PtThread thread, Method *method) { if (method->GetFullName() == "_GLOBAL::func_main_0") { - ASSERT_TRUE(thread_id_ == PtThread::NONE.GetId()); + ASSERT_TRUE(thread_id_ == panda::tooling::PtThread::NONE.GetId()); thread_id_ = thread.GetId(); } return true; }; - method_exit = [this](PtThread, Method *method, bool, VRegValue) { + method_exit = [this](panda::tooling::PtThread, Method *method, bool, panda::tooling::VRegValue) { if (method->GetFullName() == "_GLOBAL::func_main_0") { - thread_id_ = PtThread::NONE.GetId(); + thread_id_ = panda::tooling::PtThread::NONE.GetId(); } return true; }; - exception = [this](PtThread thread, Method *, const PtLocation &, ObjectHeader *, Method *, - const PtLocation &catch_location) { + exception = [this](panda::tooling::PtThread thread, Method *, const panda::tooling::PtLocation &, + ObjectHeader *, Method *, const panda::tooling::PtLocation &catch_location) { if (thread_id_ != thread.GetId()) { return true; } @@ -56,7 +56,8 @@ public: return true; }; - exception_catch = [this](PtThread thread, Method *, const PtLocation &location, ObjectHeader *) { + exception_catch = [this](panda::tooling::PtThread thread, Method *, const panda::tooling::PtLocation &location, + ObjectHeader *) { if (thread_id_ != thread.GetId()) { return true; } @@ -77,14 +78,14 @@ private: std::string entry_point_ = "_GLOBAL::func_main_0"; size_t exception_counter_ = 0; size_t exception_catch_counter_ = 0; - uint32_t thread_id_ = PtThread::NONE.GetId(); - PtLocation catch_location_ {nullptr, PtLocation::EntityId(0), 0}; + uint32_t thread_id_ = panda::tooling::PtThread::NONE.GetId(); + panda::tooling::PtLocation catch_location_ {nullptr, panda::tooling::PtLocation::EntityId(0), 0}; }; -std::unique_ptr GetJsExceptionEventTest() +std::unique_ptr GetJsExceptionEventTest() { return std::make_unique(); } -} // namespace panda::tooling::test +} // namespace panda::ecmascript::tooling::test #endif // PANDA_TOOLING_TEST_JS_EXCEPTION_EVENTS_TEST_H diff --git a/tests/runtime/tooling/api_tests/js/js_frame_pop_test.h b/tests/runtime/tooling/api_tests/js/js_frame_pop_test.h index 9b1502fe7a065dbf8299e2d290fdab3f2765d65f..1ea3986a2f8e5ade2c49b29ecf4379a0d1a76f0c 100644 --- a/tests/runtime/tooling/api_tests/js/js_frame_pop_test.h +++ b/tests/runtime/tooling/api_tests/js/js_frame_pop_test.h @@ -18,8 +18,10 @@ #include "test_util.h" -namespace panda::tooling::test { -class JsFramePopTest : public ApiTest { +namespace panda::ecmascript::tooling::test { +using panda::tooling::test::TestUtil, panda::tooling::PtThread; + +class JsFramePopTest : public panda::tooling::test::ApiTest { public: JsFramePopTest() { @@ -51,11 +53,11 @@ public: return true; }; - breakpoint = [this](PtThread thread, Method *, const PtLocation &location) { + breakpoint = [this](PtThread thread, Method *, const panda::tooling::PtLocation &location) { ASSERT_TRUE(location.GetMethodId().IsValid()); ASSERT_LOCATION_EQ(location, location_); ++breakpoint_counter_; - TestUtil::SuspendUntilContinue(DebugEvent::BREAKPOINT, thread, location); + TestUtil::SuspendUntilContinue(panda::tooling::test::DebugEvent::BREAKPOINT, thread, location); if (breakpoint_counter_ == 1) { ASSERT_SUCCESS(debug_interface->NotifyFramePop(thread, 0)); ASSERT_SUCCESS(debug_interface->NotifyFramePop(thread, 2)); @@ -97,17 +99,17 @@ public: private: std::string panda_file_ = "js/FramePop.abc"; std::string entry_point_ = "_GLOBAL::func_main_0"; - PtLocation location_ {nullptr, PtLocation::EntityId(0), 0}; + panda::tooling::PtLocation location_ {nullptr, panda::tooling::PtLocation::EntityId(0), 0}; size_t breakpoint_counter_ = 0; size_t frame_pop_counter_ = 0; - PtMethod pop_method_ {nullptr}; + panda::tooling::PtMethod pop_method_ {nullptr}; }; -std::unique_ptr GetJsFramePopTest() +std::unique_ptr GetJsFramePopTest() { return std::make_unique(); } -} // namespace panda::tooling::test +} // namespace panda::ecmascript::tooling::test #endif // PANDA_TOOLING_TEST_JS_FRAME_POP_TEST_H diff --git a/tests/runtime/tooling/api_tests/js/js_get_current_frame_test.h b/tests/runtime/tooling/api_tests/js/js_get_current_frame_test.h index 129c99670c151f31ed08f1c0e7761ab00db48634..9848e805fe52bd902b5a9ef285149fb626cc740d 100644 --- a/tests/runtime/tooling/api_tests/js/js_get_current_frame_test.h +++ b/tests/runtime/tooling/api_tests/js/js_get_current_frame_test.h @@ -18,8 +18,8 @@ #include "test_util.h" -namespace panda::tooling::test { -class JsCurrentFrameTest : public ApiTest { +namespace panda::ecmascript::tooling::test { +class JsCurrentFrameTest : public panda::tooling::test::ApiTest { public: JsCurrentFrameTest() { @@ -28,7 +28,7 @@ public: return true; }; - method_exit = [this](PtThread thread, Method *method, bool, VRegValue) { + method_exit = [this](panda::tooling::PtThread thread, Method *method, bool, panda::tooling::VRegValue) { if (method->GetFullName() == "_GLOBAL::func_method3_3") { ASSERT_EQ(entry_, 0U); entry_++; @@ -60,10 +60,10 @@ private: size_t entry_ = 0; }; -std::unique_ptr GetJsCurrentFrameTest() +std::unique_ptr GetJsCurrentFrameTest() { return std::make_unique(); } -} // namespace panda::tooling::test +} // namespace panda::ecmascript::tooling::test #endif // PANDA_TOOLING_TEST_JS_GET_CURRENT_FRAME_TEST_H diff --git a/tests/runtime/tooling/api_tests/js/js_get_variable_test.h b/tests/runtime/tooling/api_tests/js/js_get_variable_test.h index 96f285850229ea182ae6f6990eff4da4e8639b8f..108f4f7da491dd575d793054b73ead76c1ad5d07 100644 --- a/tests/runtime/tooling/api_tests/js/js_get_variable_test.h +++ b/tests/runtime/tooling/api_tests/js/js_get_variable_test.h @@ -23,10 +23,8 @@ #include #include -namespace panda::tooling::test { -using JSTaggedValue = panda::ecmascript::JSTaggedValue; - -class JsGetVariableTest : public ApiTest { +namespace panda::ecmascript::tooling::test { +class JsGetVariableTest : public panda::tooling::test::ApiTest { public: JsGetVariableTest() { @@ -40,13 +38,15 @@ public: if (moduleName.find(panda_file_.c_str()) == std::string_view::npos) { return true; } - auto location = TestUtil::GetLocation("GetVariable.js", 19, panda_file_.c_str()); // getVariable + auto location = + panda::tooling::test::TestUtil::GetLocation("GetVariable.js", 19, panda_file_.c_str()); // getVariable ASSERT_TRUE(location.GetMethodId().IsValid()); ASSERT_SUCCESS(debug_interface->SetBreakpoint(location)); return true; }; - breakpoint = [this](PtThread thread, Method *method, const PtLocation &location) { + breakpoint = [this](panda::tooling::PtThread thread, Method *method, + const panda::tooling::PtLocation &location) { ASSERT_TRUE(CheckSetValues(thread, method, location.GetBytecodeOffset())); return true; }; @@ -57,7 +57,7 @@ public: return {panda_file_.c_str(), entry_point_.c_str()}; } - bool CheckSetValues(PtThread thread, Method *method, uint32_t offset) + bool CheckSetValues(panda::tooling::PtThread thread, Method *method, uint32_t offset) { std::function checkersList[] = { [&](JSTaggedValue value) { // boolean: false @@ -86,19 +86,19 @@ public: [&](JSTaggedValue value) { // String: "new_string" PandaString checkedValue; ASSERT_TRUE(value.IsHeapObject()); - auto vregValue = ecmascript::PtEcmaScriptExtension::TaggedValueToVRegValue(value); - ASSERT_TRUE(ecmascript::JSTestApi::VRegValueToString(vregValue, &checkedValue)); + auto vregValue = PtEcmaScriptExtension::TaggedValueToVRegValue(value); + ASSERT_TRUE(JSTestApi::VRegValueToString(vregValue, &checkedValue)); ASSERT_TRUE(checkedValue.compare("new_string") == 0); return true; }}; ++count_checker_; uint32_t frameDepth = 0; - int32_t argNumber = TestUtil::GetValueRegister(method, "bl1", offset); + int32_t argNumber = panda::tooling::test::TestUtil::GetValueRegister(method, "bl1", offset); for (auto checker : checkersList) { VRegValue vregValue; ASSERT_SUCCESS(debug_interface->GetVariable(thread, frameDepth, argNumber++, &vregValue)); - ASSERT_TRUE(checker(ecmascript::PtEcmaScriptExtension::VRegValueToTaggedValue(vregValue))); + ASSERT_TRUE(checker(PtEcmaScriptExtension::VRegValueToTaggedValue(vregValue))); } return true; @@ -111,10 +111,10 @@ private: int count_checker_ = 0; }; -std::unique_ptr GetJsGetVariableTest() +std::unique_ptr GetJsGetVariableTest() { return std::make_unique(); } -} // namespace panda::tooling::test +} // namespace panda::ecmascript::tooling::test #endif // PANDA_TOOLING_TEST_JS_GET_VARIABLE_TEST_H diff --git a/tests/runtime/tooling/api_tests/js/js_method_event_test.h b/tests/runtime/tooling/api_tests/js/js_method_event_test.h index 7fa342d472f69fdfe3c23be1c3e58e0b3f518ae6..ddee99c90ee0ba0e8d6f186358afd66bc695e4a5 100644 --- a/tests/runtime/tooling/api_tests/js/js_method_event_test.h +++ b/tests/runtime/tooling/api_tests/js/js_method_event_test.h @@ -18,8 +18,8 @@ #include "test_util.h" -namespace panda::tooling::test { -class JsMethodEventTest : public ApiTest { +namespace panda::ecmascript::tooling::test { +class JsMethodEventTest : public panda::tooling::test::ApiTest { public: JsMethodEventTest() { @@ -29,13 +29,13 @@ public: return true; }; - method_entry = [this](PtThread, Method *) { + method_entry = [this](panda::tooling::PtThread, Method *) { method_entry_exit_count_++; method_entry_count_++; return true; }; - method_exit = [this](PtThread, Method *, bool, VRegValue) { + method_exit = [this](panda::tooling::PtThread, Method *, bool, panda::tooling::VRegValue) { method_entry_exit_count_--; return true; }; @@ -54,10 +54,10 @@ private: int method_entry_count_ = 0; }; -std::unique_ptr GetJsMethodEventTest() +std::unique_ptr GetJsMethodEventTest() { return std::make_unique(); } -} // namespace panda::tooling::test +} // namespace panda::ecmascript::tooling::test #endif // PANDA_TOOLING_TEST_JS_METHOD_EVENT_TEST_H diff --git a/tests/runtime/tooling/api_tests/js/js_restart_frame_test.h b/tests/runtime/tooling/api_tests/js/js_restart_frame_test.h index 27858b087a686964b05c1de8e165f2654661d321..9c763cf0fc34f5669275cf96aee061624ff464bb 100644 --- a/tests/runtime/tooling/api_tests/js/js_restart_frame_test.h +++ b/tests/runtime/tooling/api_tests/js/js_restart_frame_test.h @@ -19,10 +19,9 @@ #include "test_util.h" #include "plugins/ecmascript/runtime/include/tooling/pt_ecmascript_extension.h" -namespace panda::tooling::test { -using JSTaggedValue = panda::ecmascript::JSTaggedValue; - -class JsRestartFrameTest : public ApiTest { +namespace panda::ecmascript::tooling::test { +using panda::tooling::test::TestUtil, panda::tooling::PtThread; +class JsRestartFrameTest : public panda::tooling::test::ApiTest { public: JsRestartFrameTest() { @@ -32,11 +31,11 @@ public: return true; }; - breakpoint = [this](PtThread thread, Method *, const PtLocation &location) { + breakpoint = [this](PtThread thread, Method *, const panda::tooling::PtLocation &location) { ASSERT_TRUE(location.GetMethodId().IsValid()); ASSERT_LOCATION_EQ(location, location_); ++breakpoint_counter_; - TestUtil::SuspendUntilContinue(DebugEvent::BREAKPOINT, thread, location); + TestUtil::SuspendUntilContinue(panda::tooling::test::DebugEvent::BREAKPOINT, thread, location); if (breakpoint_counter_ == 1) { ASSERT_SUCCESS(debug_interface->RestartFrame(thread, 2)); } @@ -63,7 +62,7 @@ public: auto moduleName = method->GetFullName(); if (moduleName == "_GLOBAL::func_2") { // Force exit always zero - auto taggedValue = ecmascript::PtEcmaScriptExtension::VRegValueToTaggedValue(val); + auto taggedValue = PtEcmaScriptExtension::VRegValueToTaggedValue(val); if (taggedValue.IsInt()) { result_ = taggedValue.GetInt(); } @@ -110,16 +109,16 @@ public: private: std::string panda_file_ = "js/RestartFrame.abc"; std::string entry_point_ = "_GLOBAL::func_main_0"; - PtLocation location_ {nullptr, PtLocation::EntityId(0), 0}; + panda::tooling::PtLocation location_ {nullptr, panda::tooling::PtLocation::EntityId(0), 0}; size_t breakpoint_counter_ = 0; size_t entry_exit_counter_ = 0; int64_t result_ = 0; }; -std::unique_ptr GetJsRestartFrameTest() +std::unique_ptr GetJsRestartFrameTest() { return std::make_unique(); } -} // namespace panda::tooling::test +} // namespace panda::ecmascript::tooling::test #endif // PANDA_TOOLING_TEST_JS_SET_RESTART_FRAME_TEST_H diff --git a/tests/runtime/tooling/api_tests/js/js_set_notification_test.h b/tests/runtime/tooling/api_tests/js/js_set_notification_test.h index c5c325dff0d085f245de5c4cbabcdd9d9544415d..da09f9ef41c1919e76165be0d287a8f65a2b711e 100644 --- a/tests/runtime/tooling/api_tests/js/js_set_notification_test.h +++ b/tests/runtime/tooling/api_tests/js/js_set_notification_test.h @@ -19,8 +19,8 @@ #include "test_util.h" #include "runtime/include/tooling/debug_interface.h" -namespace panda::tooling::test { -class JsSetNotificationTest : public ApiTest { +namespace panda::ecmascript::tooling::test { +class JsSetNotificationTest : public panda::tooling::test::ApiTest { public: JsSetNotificationTest() { @@ -31,14 +31,14 @@ public: return true; }; - method_entry = [this](PtThread /* thread */, Method *method) { + method_entry = [this](panda::tooling::PtThread /* thread */, Method *method) { if (method->GetFullName() == "_GLOBAL::func__2") { ++entry_; } return true; }; - method_exit = [this](PtThread thread, Method *method, bool, VRegValue) { + method_exit = [this](panda::tooling::PtThread thread, Method *method, bool, panda::tooling::VRegValue) { if (method->GetFullName() == "_GLOBAL::func__2") { ++exit_; ++nn_; @@ -61,25 +61,29 @@ public: ASSERT_EQ(exit_, 1); // Disable the entry hook globaly - debug_interface->SetNotification(PtThread::NONE, false, PtHookType::PT_HOOK_TYPE_METHOD_ENTRY); + debug_interface->SetNotification(panda::tooling::PtThread::NONE, false, + panda::tooling::PtHookType::PT_HOOK_TYPE_METHOD_ENTRY); } else if (nn_ == 2) { ASSERT_EQ(entry_, 1); ASSERT_EQ(exit_, 2); // Enable the entry hook locally - debug_interface->SetNotification(thread, true, PtHookType::PT_HOOK_TYPE_METHOD_ENTRY); + debug_interface->SetNotification(thread, true, + panda::tooling::PtHookType::PT_HOOK_TYPE_METHOD_ENTRY); } else if (nn_ == 3) { ASSERT_EQ(entry_, 2); ASSERT_EQ(exit_, 3); // Disable the entry hook locally - debug_interface->SetNotification(thread, false, PtHookType::PT_HOOK_TYPE_METHOD_ENTRY); + debug_interface->SetNotification(thread, false, + panda::tooling::PtHookType::PT_HOOK_TYPE_METHOD_ENTRY); } else if (nn_ == 4) { ASSERT_EQ(entry_, 2); ASSERT_EQ(exit_, 4); // Enable the entry hook globaly - debug_interface->SetNotification(PtThread::NONE, true, PtHookType::PT_HOOK_TYPE_METHOD_ENTRY); + debug_interface->SetNotification(panda::tooling::PtThread::NONE, true, + panda::tooling::PtHookType::PT_HOOK_TYPE_METHOD_ENTRY); } else if (nn_ == 5) { ASSERT_EQ(entry_, 3); ASSERT_EQ(exit_, 5); @@ -100,10 +104,10 @@ private: int exit_ = 0; }; -std::unique_ptr GetJsSetNotificationTest() +std::unique_ptr GetJsSetNotificationTest() { return std::make_unique(); } -} // namespace panda::tooling::test +} // namespace panda::ecmascript::tooling::test #endif // PANDA_TOOLING_TEST_JS_SET_NOTIFICATION_TEST_H diff --git a/tests/runtime/tooling/api_tests/js/js_set_variable_test.h b/tests/runtime/tooling/api_tests/js/js_set_variable_test.h index 9e92062ad8d7846e8b4c0741d077fad73579a943..b37f0c1b1808ad9e9836b938c7e128bd4a4d7557 100644 --- a/tests/runtime/tooling/api_tests/js/js_set_variable_test.h +++ b/tests/runtime/tooling/api_tests/js/js_set_variable_test.h @@ -23,10 +23,8 @@ #include "plugins/ecmascript/runtime/js_thread.h" #include "plugins/ecmascript/runtime/global_env.h" -namespace panda::tooling::test { -using JSTaggedValue = panda::ecmascript::JSTaggedValue; -using JSThread = panda::ecmascript::JSThread; -class JsSetVariableTest : public ApiTest { +namespace panda::ecmascript::tooling::test { +class JsSetVariableTest : public panda::tooling::test::ApiTest { public: JsSetVariableTest() { @@ -47,34 +45,37 @@ public: return true; }; - breakpoint = [this](PtThread thread, Method *method, PtLocation location) { + breakpoint = [this](panda::tooling::PtThread thread, Method *method, panda::tooling::PtLocation location) { breakpoint_count_ += 1; auto methodName = method->GetFullName(); int frameDepth = 0; uint32_t currOffset = location.GetBytecodeOffset(); if (methodName == "_GLOBAL::func_setBoolean_1") { - VRegValue value = ecmascript::PtEcmaScriptExtension::TaggedValueToVRegValue(JSTaggedValue(true)); + VRegValue value = PtEcmaScriptExtension::TaggedValueToVRegValue(JSTaggedValue(true)); ASSERT_SUCCESS(debug_interface->SetVariable( - thread, frameDepth, TestUtil::GetValueRegister(method, "value", currOffset), value)); + thread, frameDepth, panda::tooling::test::TestUtil::GetValueRegister(method, "value", currOffset), + value)); } else if (methodName == "_GLOBAL::func_setInt_2") { - VRegValue value = - ecmascript::PtEcmaScriptExtension::TaggedValueToVRegValue(JSTaggedValue(123456789)); // 123456789 + VRegValue value = PtEcmaScriptExtension::TaggedValueToVRegValue(JSTaggedValue(123456789)); // 123456789 ASSERT_SUCCESS(debug_interface->SetVariable( - thread, frameDepth, TestUtil::GetValueRegister(method, "value", currOffset), value)); + thread, frameDepth, panda::tooling::test::TestUtil::GetValueRegister(method, "value", currOffset), + value)); } else if (methodName == "_GLOBAL::func_setDouble_3") { VRegValue value = - ecmascript::PtEcmaScriptExtension::TaggedValueToVRegValue(JSTaggedValue(12345.6789)); // 12345.6789 + PtEcmaScriptExtension::TaggedValueToVRegValue(JSTaggedValue(12345.6789)); // 12345.6789 ASSERT_SUCCESS(debug_interface->SetVariable( - thread, frameDepth, TestUtil::GetValueRegister(method, "value", currOffset), value)); + thread, frameDepth, panda::tooling::test::TestUtil::GetValueRegister(method, "value", currOffset), + value)); } else if (methodName == "_GLOBAL::func_setString_4") { - VRegValue value = ecmascript::JSTestApi::StringToVRegValue("x2348x"); + VRegValue value = JSTestApi::StringToVRegValue("x2348x"); ASSERT_SUCCESS(debug_interface->SetVariable( - thread, frameDepth, TestUtil::GetValueRegister(method, "value", currOffset), value)); + thread, frameDepth, panda::tooling::test::TestUtil::GetValueRegister(method, "value", currOffset), + value)); } return true; }; - method_entry = [this](PtThread thread, Method *method) { + method_entry = [this](panda::tooling::PtThread thread, Method *method) { auto methodName = method->GetFullName(); if (methodName == "_GLOBAL::func_checkData_5") { checked_ = CheckData(thread, method); @@ -93,42 +94,40 @@ private: { JSThread *jsThread = JSThread::Cast(JSThread::GetCurrent()); auto ecmaVm = jsThread->GetEcmaVM(); - panda::ecmascript::JSHandle globalEnv = ecmaVm->GetGlobalEnv(); + JSHandle globalEnv = ecmaVm->GetGlobalEnv(); auto globalObject = globalEnv->GetGlobalObject(); - panda::ecmascript::ObjectFactory *factory = ecmaVm->GetFactory(); - panda::ecmascript::JSHandle execHandle( - factory->NewFromStdString(name.c_str())); - panda::ecmascript::JSHandle objectHandle(jsThread, globalObject); - if (!panda::ecmascript::JSObject::HasProperty(jsThread, objectHandle, execHandle)) { + ObjectFactory *factory = ecmaVm->GetFactory(); + JSHandle execHandle(factory->NewFromStdString(name.c_str())); + JSHandle objectHandle(jsThread, globalObject); + if (!JSObject::HasProperty(jsThread, objectHandle, execHandle)) { return false; } - auto property = panda::ecmascript::JSObject::GetProperty(jsThread, objectHandle, execHandle); - *out = ecmascript::PtEcmaScriptExtension::TaggedValueToVRegValue(property.GetValue().GetTaggedValue()); + auto property = JSObject::GetProperty(jsThread, objectHandle, execHandle); + *out = PtEcmaScriptExtension::TaggedValueToVRegValue(property.GetValue().GetTaggedValue()); return true; } - bool CheckData(PtThread, Method *) + bool CheckData(panda::tooling::PtThread, Method *) { { VRegValue ptBool; ASSERT_TRUE(GetGlobalVariable("boolData", &ptBool)); - ASSERT_EQ(ecmascript::PtEcmaScriptExtension::VRegValueToTaggedValue(ptBool).GetRawData(), - JSTaggedValue::VALUE_TRUE); + ASSERT_EQ(PtEcmaScriptExtension::VRegValueToTaggedValue(ptBool).GetRawData(), JSTaggedValue::VALUE_TRUE); } { VRegValue ptInt; const int expectedValue = 123456789; ASSERT_TRUE(GetGlobalVariable("intData", &ptInt)); - int intValue = ecmascript::PtEcmaScriptExtension::VRegValueToTaggedValue(ptInt).GetInt(); + int intValue = PtEcmaScriptExtension::VRegValueToTaggedValue(ptInt).GetInt(); ASSERT_EQ(intValue, expectedValue); } { VRegValue ptDouble; const double expectedValue = 12345.6789; ASSERT_TRUE(GetGlobalVariable("doubleData", &ptDouble)); - double doubleValue = ecmascript::PtEcmaScriptExtension::VRegValueToTaggedValue(ptDouble).GetDouble(); + double doubleValue = PtEcmaScriptExtension::VRegValueToTaggedValue(ptDouble).GetDouble(); ASSERT_EQ(doubleValue, expectedValue); } { @@ -136,7 +135,7 @@ private: PandaString stringValue; const PandaString expectedValue = "x2348x"; ASSERT_TRUE(GetGlobalVariable("stringData", &ptString)); - ASSERT_TRUE(ecmascript::JSTestApi::VRegValueToString(ptString, &stringValue)); + ASSERT_TRUE(JSTestApi::VRegValueToString(ptString, &stringValue)); ASSERT_TRUE(stringValue.compare(expectedValue) == 0); } return true; @@ -144,7 +143,7 @@ private: void SetBreakpoint(uint32_t line) { - auto location = TestUtil::GetLocation("SetVariable.js", line, panda_file_.c_str()); + auto location = panda::tooling::test::TestUtil::GetLocation("SetVariable.js", line, panda_file_.c_str()); ASSERT_TRUE(location.GetMethodId().IsValid()); ASSERT_SUCCESS(debug_interface->SetBreakpoint(location)); } @@ -155,10 +154,10 @@ private: std::string entry_point_ = "_GLOBAL::func_main_0"; }; -std::unique_ptr GetJsSetVariableTest() +std::unique_ptr GetJsSetVariableTest() { return std::make_unique(); } -} // namespace panda::tooling::test +} // namespace panda::ecmascript::tooling::test #endif // PANDA_TOOLING_TEST_JS_SET_VARIABLE_TEST_H diff --git a/tests/runtime/tooling/api_tests/js/js_single_step_test.h b/tests/runtime/tooling/api_tests/js/js_single_step_test.h index 93b57466d317a3f0ebdbc8d985c64c8b54040ecd..4aa814bb56a9cd7b926dfb7a7f25ca8d76c6594a 100644 --- a/tests/runtime/tooling/api_tests/js/js_single_step_test.h +++ b/tests/runtime/tooling/api_tests/js/js_single_step_test.h @@ -18,14 +18,14 @@ #include "test_util.h" -namespace panda::tooling::test { -class JsSingleStepTest : public ApiTest { +namespace panda::ecmascript::tooling::test { +class JsSingleStepTest : public panda::tooling::test::ApiTest { public: JsSingleStepTest() { vm_start = [this] { - location_start_ = TestUtil::GetLocation("Sample.js", 19, panda_file_.c_str()); - location_end_ = TestUtil::GetLocation("Sample.js", 22, panda_file_.c_str()); + location_start_ = panda::tooling::test::TestUtil::GetLocation("Sample.js", 19, panda_file_.c_str()); + location_end_ = panda::tooling::test::TestUtil::GetLocation("Sample.js", 22, panda_file_.c_str()); return true; }; @@ -43,7 +43,7 @@ public: return true; }; - breakpoint = [this](PtThread, Method *, const PtLocation &location) { + breakpoint = [this](panda::tooling::PtThread, Method *, const panda::tooling::PtLocation &location) { ASSERT_TRUE(location.GetMethodId().IsValid()); ASSERT_LOCATION_EQ(location, location_end_); // Check's what step signalled before breakpoint @@ -55,7 +55,7 @@ public: return true; }; - single_step = [this](PtThread, Method *, const PtLocation &location) { + single_step = [this](panda::tooling::PtThread, Method *, const panda::tooling::PtLocation &location) { ASSERT_TRUE(location.GetMethodId().IsValid()); if (!collect_steps_) { if (location_start_ == location) { @@ -80,19 +80,19 @@ public: private: std::string panda_file_ = "js/Sample.abc"; std::string entry_point_ = "_GLOBAL::func_main_0"; - PtLocation location_start_ {nullptr, PtLocation::EntityId(0), 0}; - PtLocation location_end_ {nullptr, PtLocation::EntityId(0), 0}; - PtLocation location_step_ {nullptr, PtLocation::EntityId(0), 0}; + panda::tooling::PtLocation location_start_ {nullptr, panda::tooling::PtLocation::EntityId(0), 0}; + panda::tooling::PtLocation location_end_ {nullptr, panda::tooling::PtLocation::EntityId(0), 0}; + panda::tooling::PtLocation location_step_ {nullptr, panda::tooling::PtLocation::EntityId(0), 0}; int step_count_ = 0; int breakpoint_count_ = 0; bool collect_steps_ = false; uint32_t bytecode_offset_ = std::numeric_limits::max(); }; -std::unique_ptr GetJsSingleStepTest() +std::unique_ptr GetJsSingleStepTest() { return std::make_unique(); } -} // namespace panda::tooling::test +} // namespace panda::ecmascript::tooling::test #endif // PANDA_TOOLING_TEST_JS_SINGLE_STEP_TEST_H diff --git a/tests/runtime/tooling/api_tests/js/js_vm_event_test.h b/tests/runtime/tooling/api_tests/js/js_vm_event_test.h index 5777a8cd2e16cb8eb35616df7cf7e736a5d38115..a84cb5f2b59a08c498e346a8efd129e35a74e9bb 100644 --- a/tests/runtime/tooling/api_tests/js/js_vm_event_test.h +++ b/tests/runtime/tooling/api_tests/js/js_vm_event_test.h @@ -18,8 +18,8 @@ #include "test_util.h" -namespace panda::tooling::test { -class JsVmEventTest : public ApiTest { +namespace panda::ecmascript::tooling::test { +class JsVmEventTest : public panda::tooling::test::ApiTest { public: JsVmEventTest() { @@ -28,7 +28,7 @@ public: return true; }; - vm_init = [this](PtThread thread) { + vm_init = [this](panda::tooling::PtThread thread) { init_thread_ = thread.GetId(); init_counter_++; return true; @@ -36,7 +36,7 @@ public: vm_death = [this]() { death_counter_++; - ASSERT_NE(init_thread_, PtThread::NONE.GetId()); + ASSERT_NE(init_thread_, panda::tooling::PtThread::NONE.GetId()); ASSERT_EQ(start_counter, 1U); ASSERT_EQ(init_counter_, 1U); return true; @@ -54,13 +54,13 @@ private: size_t start_counter = 0; size_t init_counter_ = 0; size_t death_counter_ = 0; - uint32_t init_thread_ = PtThread::NONE.GetId(); + uint32_t init_thread_ = panda::tooling::PtThread::NONE.GetId(); }; -std::unique_ptr GetJsVmEventTest() +std::unique_ptr GetJsVmEventTest() { return std::make_unique(); } -} // namespace panda::tooling::test +} // namespace panda::ecmascript::tooling::test #endif // PANDA_TOOLING_TEST_JS_VM_EVENT_TEST_H diff --git a/tests/runtime/tooling/js_test_api.h b/tests/runtime/tooling/js_test_api.h index 6d8355cccfaad2b1a13c7ce72d6f997c9ce57204..13f7007631bcafe64a02a28d79c5e22ad20d0309 100644 --- a/tests/runtime/tooling/js_test_api.h +++ b/tests/runtime/tooling/js_test_api.h @@ -21,8 +21,7 @@ #include "plugins/ecmascript/runtime/js_handle.h" #include "plugins/ecmascript/runtime/global_env.h" -namespace panda::tooling::ecmascript { -using JSThread = panda::ecmascript::JSThread; +namespace panda::ecmascript::tooling { class JSTestApi { public: static VRegValue StringToVRegValue(const PandaString &value) @@ -30,21 +29,19 @@ public: JSThread *jsThread = JSThread::Cast(JSThread::GetCurrent()); auto ecmaVm = jsThread->GetEcmaVM(); - panda::ecmascript::ObjectFactory *factory = ecmaVm->GetFactory(); - panda::ecmascript::JSHandle strHandle( - factory->NewFromStdString(value.c_str())); + ObjectFactory *factory = ecmaVm->GetFactory(); + JSHandle strHandle(factory->NewFromStdString(value.c_str())); return PtEcmaScriptExtension::TaggedValueToVRegValue(strHandle.GetTaggedValue()); } static bool VRegValueToString(VRegValue value, PandaString *out) { - panda::ecmascript::EcmaString *string = - panda::ecmascript::EcmaString::Cast(PtEcmaScriptExtension::VRegValueToTaggedValue(value).GetHeapObject()); + EcmaString *string = EcmaString::Cast(PtEcmaScriptExtension::VRegValueToTaggedValue(value).GetHeapObject()); - *out = panda::ecmascript::base::StringHelper::ToStdString(string).c_str(); + *out = base::StringHelper::ToStdString(string).c_str(); return true; } }; -} // namespace panda::tooling::ecmascript +} // namespace panda::ecmascript::tooling #endif // PANDA_PLUGINS_ECMASCRIPT_TESTS_RUNTIME_TOOLING_JS_TEST_API_H diff --git a/tests/runtime/tooling/test_list.cpp b/tests/runtime/tooling/test_list.cpp index d62e25544d0e106f0bea65b93e786955cb80f334..2003cbc7f8743d33e63ffd47d8e955a344d228da 100644 --- a/tests/runtime/tooling/test_list.cpp +++ b/tests/runtime/tooling/test_list.cpp @@ -23,20 +23,31 @@ static const char *g_currentTestName = nullptr; static void RegisterTests() { - TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsBreakpoint", GetJsBreakpointTest()); - TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsSingleStepTest", GetJsSingleStepTest()); - TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsVMEvents", GetJsVmEventTest()); - TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsMethodEvent", GetJsMethodEventTest()); - TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsGetVariable", GetJsGetVariableTest()); - TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsSetVariable", GetJsSetVariableTest()); - TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsGetCurrentFrame", GetJsCurrentFrameTest()); - TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsEnumerateFrames", JsEnumerateFramesTest()); + TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsBreakpoint", + panda::ecmascript::tooling::test::GetJsBreakpointTest()); + TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsSingleStepTest", + panda::ecmascript::tooling::test::GetJsSingleStepTest()); + TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsVMEvents", + panda::ecmascript::tooling::test::GetJsVmEventTest()); + TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsMethodEvent", + panda::ecmascript::tooling::test::GetJsMethodEventTest()); + TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsGetVariable", + panda::ecmascript::tooling::test::GetJsGetVariableTest()); + TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsSetVariable", + panda::ecmascript::tooling::test::GetJsSetVariableTest()); + TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsGetCurrentFrame", + panda::ecmascript::tooling::test::GetJsCurrentFrameTest()); + TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsEnumerateFrames", + panda::ecmascript::tooling::test::JsEnumerateFramesTest()); // TODO(maksenov): Enable tests with thread suspension for JS - // TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsFramePopNotification", GetJsFramePopTest()); - // TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsRestartFrame", GetJsRestartFrameTest()); - TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsSetNotification", GetJsSetNotificationTest()); + // TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsFramePopNotification", + // panda::ecmascript::tooling::test::GetJsFramePopTest()); + // TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsRestartFrame", + // panda::ecmascript::tooling::test::GetJsRestartFrameTest()); + TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsSetNotification", + panda::ecmascript::tooling::test::GetJsSetNotificationTest()); TestUtil::RegisterTest(panda_file::SourceLang::ECMASCRIPT, "JsExceptionCatchThrowEvents", - GetJsExceptionEventTest()); + panda::ecmascript::tooling::test::GetJsExceptionEventTest()); } std::vector GetTestList(panda_file::SourceLang language)