diff --git a/inspector/inspector.cpp b/inspector/inspector.cpp index 724551b0733f1c90d0d1e67cdbc83963b8b7aadb..0ef5bba2eade8136b374237f714599cd4f6761a8 100644 --- a/inspector/inspector.cpp +++ b/inspector/inspector.cpp @@ -36,9 +36,6 @@ #include "ffrt.h" #endif -#include -#include - namespace OHOS::ArkCompiler::Toolchain { namespace { enum DispatchStatus : int32_t { @@ -318,17 +315,9 @@ bool InitializeArkFunctions() void Inspector::OnMessage(std::string&& msg, bool isHybrid) { if (isHybrid) { - std::regex pattern("\"sessionId\":\\s*(\\d)"); - std::smatch matches; - if (std::regex_search(msg, matches, pattern)) { - HandleMessage(std::move(msg)); - } else { - HandleMessage(std::move(msg)); // IDE not adjusted - g_onMessage(vm_, std::move(msg)); - } - } else { - g_onMessage(vm_, std::move(msg)); + HandleMessage(std::move(msg)); } + g_onMessage(vm_, std::move(msg)); // message will be processed soon if the debugger thread is in running or waiting status if (g_getDispatchStatus(vm_) != DispatchStatus::UNKNOWN) { @@ -512,14 +501,8 @@ void StopDebug(void* vm, bool isHybrid) if (debuggerInfo != g_debuggerInfo.end()) { g_debuggerInfo.erase(debuggerInfo); } - ResetServiceLocked(vm, false); + ResetServiceLocked(vm, true); g_uninitializeDebugger(vm); -#if !defined(IOS_PLATFORM) - if (g_handle != nullptr) { - CloseHandle(g_handle); - g_handle = nullptr; - } -#endif if (isHybrid) { StopDebuggerForStatic(); } diff --git a/tooling/dynamic/backend/js_pt_hooks.cpp b/tooling/dynamic/backend/js_pt_hooks.cpp index 1ccb46ec49b351d76b8ecc8661cae8ce3453b246..c72be824dd0a17b89e57e574488e13af5b8732b1 100644 --- a/tooling/dynamic/backend/js_pt_hooks.cpp +++ b/tooling/dynamic/backend/js_pt_hooks.cpp @@ -20,14 +20,14 @@ namespace panda::ecmascript::tooling { void JSPtHooks::DebuggerStmt([[maybe_unused]] const JSPtLocation &location) { - LOG_DEBUGGER(DEBUG) << "JSPHooks: Debugger Statement"; + LOG_DEBUGGER(VERBOSE) << "JSPHooks: Debugger Statement"; [[maybe_unused]] LocalScope scope(debugger_->vm_); debugger_->NotifyPaused({}, DEBUGGERSTMT); } void JSPtHooks::Breakpoint(const JSPtLocation &location) { - LOG_DEBUGGER(DEBUG) << "JSPtHooks: Breakpoint => " << location.GetMethodId() << ": " + LOG_DEBUGGER(VERBOSE) << "JSPtHooks: Breakpoint => " << location.GetMethodId() << ": " << location.GetBytecodeOffset(); [[maybe_unused]] LocalScope scope(debugger_->vm_); @@ -36,7 +36,7 @@ void JSPtHooks::Breakpoint(const JSPtLocation &location) void JSPtHooks::Exception([[maybe_unused]] const JSPtLocation &location) { - LOG_DEBUGGER(DEBUG) << "JSPtHooks: Exception"; + LOG_DEBUGGER(VERBOSE) << "JSPtHooks: Exception"; [[maybe_unused]] LocalScope scope(debugger_->vm_); debugger_->NotifyPaused({}, EXCEPTION); @@ -44,16 +44,13 @@ void JSPtHooks::Exception([[maybe_unused]] const JSPtLocation &location) bool JSPtHooks::SingleStep(const JSPtLocation &location) { - LOG_DEBUGGER(DEBUG) << "JSPtHooks: SingleStep => " << location.GetBytecodeOffset(); + LOG_DEBUGGER(VERBOSE) << "JSPtHooks: SingleStep => " << location.GetBytecodeOffset(); [[maybe_unused]] LocalScope scope(debugger_->vm_); - DebugStepFlags::Get().SetDyn2StatInto(true); if (DebugStepFlags::Get().GetStat2DynInto()) { - LOG_DEBUGGER(DEBUG) << "SingleStep from Static"; - debugger_->NotifyPaused({}, OTHER); + debugger_->NotifyPaused({}, BREAK_ON_START); DebugStepFlags::Get().SetStat2DynInto(false); - return false; } if (UNLIKELY(firstTime_)) { firstTime_ = false; @@ -93,7 +90,7 @@ bool JSPtHooks::NativeOut() void JSPtHooks::LoadModule(std::string_view pandaFileName, std::string_view entryPoint) { - LOG_DEBUGGER(DEBUG) << "JSPtHooks: LoadModule: " << pandaFileName; + LOG_DEBUGGER(VERBOSE) << "JSPtHooks: LoadModule: " << pandaFileName; [[maybe_unused]] LocalScope scope(debugger_->vm_); @@ -106,7 +103,7 @@ void JSPtHooks::LoadModule(std::string_view pandaFileName, std::string_view entr void JSPtHooks::NativeCalling(const void *nativeAddress) { - LOG_DEBUGGER(DEBUG) << "JSPtHooks: NativeCalling, addr = " << nativeAddress; + LOG_DEBUGGER(VERBOSE) << "JSPtHooks: NativeCalling, addr = " << nativeAddress; [[maybe_unused]] LocalScope scope(debugger_->vm_); @@ -122,7 +119,7 @@ void JSPtHooks::NativeReturn(const void *nativeAddress) void JSPtHooks::SendableMethodEntry(JSHandle method) { - LOG_DEBUGGER(DEBUG) << "JSPtHooks: MethodEntry"; + LOG_DEBUGGER(VERBOSE) << "JSPtHooks: MethodEntry"; [[maybe_unused]] LocalScope scope(debugger_->vm_); @@ -147,7 +144,7 @@ void JSPtHooks::GenerateAsyncFrames(std::shared_ptr asyncStack, bool void JSPtHooks::HitSymbolicBreakpoint() { - LOG_DEBUGGER(DEBUG) << "JSPtHooks: HitSymbolicBreakpoint"; + LOG_DEBUGGER(VERBOSE) << "JSPtHooks: HitSymbolicBreakpoint"; breakOnSymbol_ = true; diff --git a/tooling/dynamic/test/client_utils/test_list.cpp b/tooling/dynamic/test/client_utils/test_list.cpp index 31b7562c3f6a43765b2aca43018cf84cf7cb35fb..d7d0df598b35597eca968b41fa91b1b76e29ee68 100644 --- a/tooling/dynamic/test/client_utils/test_list.cpp +++ b/tooling/dynamic/test/client_utils/test_list.cpp @@ -22,6 +22,7 @@ #include "tooling/dynamic/test/testcases/js_allocationtrack_loop_test.h" #include "tooling/dynamic/test/testcases/js_allocationtrack_recursion_test.h" #include "tooling/dynamic/test/testcases/js_allocationtrack_test.h" +#include "tooling/dynamic/test/testcases/js_asyn_stack_test.h" #include "tooling/dynamic/test/testcases/js_breakpoint_arrow_test.h" #include "tooling/dynamic/test/testcases/js_breakpoint_async_test.h" #include "tooling/dynamic/test/testcases/js_breakpoint_cannot_hit_test.h" @@ -142,6 +143,7 @@ static void RegisterTests() TestUtil::RegisterTest("JsHeapusageRecursionTest", GetJsHeapusageRecursionTest()); TestUtil::RegisterTest("JsSmartStepoutTest", GetJsSmartStepoutTest()); TestUtil::RegisterTest("JsAccelerateLaunchTest", GetJsAccelerateLaunchTest()); + TestUtil::RegisterTest("JsAsynStackTest", GetJsAsynStackTest()); TestUtil::RegisterTest("JsSymbolicBreakpointTest", GetJsSymbolicBreakpointTest()); } diff --git a/tooling/static/debugger/thread_state.cpp b/tooling/static/debugger/thread_state.cpp index 5ddee141d8bc12bd3db9840bb37b488f42edfb18..94554d9c7f79fb045ae64e36990aad416a1204a8 100644 --- a/tooling/static/debugger/thread_state.cpp +++ b/tooling/static/debugger/thread_state.cpp @@ -25,7 +25,6 @@ #include "error.h" #include "types/numeric_id.h" -#include "../../hybrid_step/debug_step_flags.h" namespace ark::tooling::inspector { void ThreadState::Reset() @@ -178,13 +177,6 @@ bool ThreadState::OnMethodEntry() void ThreadState::OnSingleStep(const PtLocation &location, const char *sourceFile) { ASSERT(!paused_); - DebugStepFlags::Get().SetStat2DynInto(true); - if (DebugStepFlags::Get().GetDyn2StatInto()) { - LOG(DEBUG, DEBUGGER) << "SingleStep from Dynamic"; - paused_ = true; - DebugStepFlags::Get().SetDyn2StatInto(false); - return; - } if (breakOnStart_) { std::string_view file = sourceFile; diff --git a/tooling/static/init.cpp b/tooling/static/init.cpp index ccaf3099b21bd84f1599bcd731c53db7d4c04dcc..9c3366968bff00df77e1c492e41c29af0620f825 100644 --- a/tooling/static/init.cpp +++ b/tooling/static/init.cpp @@ -112,6 +112,6 @@ void WaitForDebugger() void HandleMessage(std::string &&msg) { - LOG(ERROR, DEBUGGER) << "Static OnMessage start"; + LOG(ERROR, DEBUGGER) << "FTDEG HandleMessage start"; g_inspector->Run(msg); } \ No newline at end of file diff --git a/tooling/static/inspector.cpp b/tooling/static/inspector.cpp index 38fa534ad7b66c40f0d1144bebba41cdf5eae006..641f5fd87d6897c700e2ff88c5e7edbb3acc7fe4 100644 --- a/tooling/static/inspector.cpp +++ b/tooling/static/inspector.cpp @@ -102,14 +102,8 @@ void Inspector::ConsoleCall(PtThread thread, ConsoleCallType type, uint64_t time os::memory::ReadLockHolder lock(debuggerEventsLock_); auto *debuggableThread = GetDebuggableThread(thread); - if (debuggableThread != nullptr) { - inspectorServer_.CallRuntimeConsoleApiCalled( - thread, - type, - timestamp, - debuggableThread->OnConsoleCall(arguments) - ); - } + ASSERT(debuggableThread != nullptr); + inspectorServer_.CallRuntimeConsoleApiCalled(thread, type, timestamp, debuggableThread->OnConsoleCall(arguments)); } // CC-OFFNXT(G.FUN.01-CPP) Decreasing the number of arguments will decrease the clarity of the code. @@ -119,9 +113,8 @@ void Inspector::Exception(PtThread thread, Method * /* method */, const PtLocati os::memory::ReadLockHolder lock(debuggerEventsLock_); auto *debuggableThread = GetDebuggableThread(thread); - if (debuggableThread != nullptr) { - debuggableThread->OnException(catchLocation.GetBytecodeOffset() == panda_file::INVALID_OFFSET); - } + ASSERT(debuggableThread != nullptr); + debuggableThread->OnException(catchLocation.GetBytecodeOffset() == panda_file::INVALID_OFFSET); } void Inspector::FramePop(PtThread thread, Method * /* method */, bool /* was_popped_by_exception */) @@ -129,9 +122,8 @@ void Inspector::FramePop(PtThread thread, Method * /* method */, bool /* was_pop os::memory::ReadLockHolder lock(debuggerEventsLock_); auto *debuggableThread = GetDebuggableThread(thread); - if (debuggableThread != nullptr) { - debuggableThread->OnFramePop(); - } + ASSERT(debuggableThread != nullptr); + debuggableThread->OnFramePop(); } void Inspector::MethodEntry(PtThread thread, Method * /* method */) @@ -139,6 +131,7 @@ void Inspector::MethodEntry(PtThread thread, Method * /* method */) os::memory::ReadLockHolder lock(debuggerEventsLock_); auto *debuggableThread = GetDebuggableThread(thread); + ASSERT(debuggableThread != nullptr); auto stack = StackWalker::Create(thread.GetManagedThread()); if (stack.IsCFrame()) { return; @@ -146,10 +139,8 @@ void Inspector::MethodEntry(PtThread thread, Method * /* method */) if (debuggableThread == nullptr) { return; } - if (debuggableThread != nullptr) { - if (debuggableThread->OnMethodEntry()) { - HandleError(debugger_.NotifyFramePop(thread, 0)); - } + if (debuggableThread->OnMethodEntry()) { + HandleError(debugger_.NotifyFramePop(thread, 0)); } } @@ -198,9 +189,8 @@ void Inspector::SingleStep(PtThread thread, Method *method, const PtLocation &lo } auto *debuggableThread = GetDebuggableThread(thread); - if (debuggableThread != nullptr) { - debuggableThread->OnSingleStep(location, sourceFile); - } + ASSERT(debuggableThread != nullptr); + debuggableThread->OnSingleStep(location, sourceFile); } void Inspector::ThreadStart(PtThread thread)