From 4f6a443fa3e59e0304315b274a1b31544701a76a Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 8 Oct 2025 23:11:10 +0300 Subject: [PATCH] replace 'debug.breakpoint' with 'debug.pause' --- res/scripts/stdmin.lua | 6 ++++-- src/devtools/DebuggingServer.cpp | 18 ++++++++---------- src/devtools/DebuggingServer.hpp | 3 +-- src/logic/scripting/lua/lua_extensions.cpp | 12 ++++++++---- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/res/scripts/stdmin.lua b/res/scripts/stdmin.lua index 5854f428..60961653 100644 --- a/res/scripts/stdmin.lua +++ b/res/scripts/stdmin.lua @@ -39,7 +39,7 @@ debug.sethook(function (e, line) end end current_func = func - debug.breakpoint() + debug.pause() debug.pull_events() end hook_lock = false @@ -53,7 +53,7 @@ debug.sethook(function (e, line) end current_func = _debug_getinfo(2).func current_func_stack_size = calc_stack_size() - debug.breakpoint() + debug.pause() debug.pull_events() end, "lr") @@ -65,6 +65,7 @@ local DBG_EVENT_RESUME = 5 local DBG_EVENT_GET_VALUE = 6 local __pull_events = debug.__pull_events local __sendvalue = debug.__sendvalue +local __pause = debug.pause debug.__pull_events = nil debug.__sendvalue = nil @@ -97,6 +98,7 @@ function debug.pull_events() value = value[key] end __sendvalue(value, event[2], event[3], event[4]) + __pause() end end end diff --git a/src/devtools/DebuggingServer.cpp b/src/devtools/DebuggingServer.cpp index d6777db7..2cf67f48 100644 --- a/src/devtools/DebuggingServer.cpp +++ b/src/devtools/DebuggingServer.cpp @@ -213,15 +213,17 @@ bool DebuggingServer::performCommand( return false; } -void DebuggingServer::onHitBreakpoint(dv::value&& stackTrace) { +void DebuggingServer::pause(std::string&& message, dv::value&& stackTrace) { if (connection == nullptr) { return; } - connection->send(dv::object({ - {"type", std::string("hit-breakpoint")}, - {"stack", std::move(stackTrace)} - })); - + if (stackTrace != nullptr) { + connection->send(dv::object({ + {"type", std::string("hit-breakpoint")}, + {"message", std::move(message)}, + {"stack", std::move(stackTrace)} + })); + } engine.startPauseLoop(); } @@ -245,10 +247,6 @@ void DebuggingServer::sendValue( })); } -void DebuggingServer::pause() { - engine.startPauseLoop(); -} - void DebuggingServer::setClient(u64id_t client) { this->connection = std::make_unique(engine.getNetwork(), client); diff --git a/src/devtools/DebuggingServer.hpp b/src/devtools/DebuggingServer.hpp index a4557a7a..0f3b4566 100644 --- a/src/devtools/DebuggingServer.hpp +++ b/src/devtools/DebuggingServer.hpp @@ -73,8 +73,7 @@ namespace devtools { ~DebuggingServer(); bool update(); - void onHitBreakpoint(dv::value&& stackTrace); - void pause(); + void pause(std::string&& message, dv::value&& stackTrace); void sendValue(dv::value&& value, int frame, int local, ValuePath&& path); diff --git a/src/logic/scripting/lua/lua_extensions.cpp b/src/logic/scripting/lua/lua_extensions.cpp index e791a87d..88d8427f 100644 --- a/src/logic/scripting/lua/lua_extensions.cpp +++ b/src/logic/scripting/lua/lua_extensions.cpp @@ -262,9 +262,13 @@ static dv::value create_stack_trace(lua::State* L, int initFrame = 2) { return entriesList; } -static int l_debug_breakpoint(lua::State* L) { +static int l_debug_pause(lua::State* L) { if (auto server = engine->getDebuggingServer()) { - server->onHitBreakpoint(create_stack_trace(L)); + std::string message; + if (lua::isstring(L, 1)) { + message = lua::tolstring(L, 1); + } + server->pause(std::move(message), create_stack_trace(L)); } return 0; } @@ -376,8 +380,8 @@ void initialize_libs_extends(lua::State* L) { lua::pushcfunction(L, lua::wrap); lua::setfield(L, "print"); - lua::pushcfunction(L, lua::wrap); - lua::setfield(L, "breakpoint"); + lua::pushcfunction(L, lua::wrap); + lua::setfield(L, "pause"); lua::pushcfunction(L, lua::wrap); lua::setfield(L, "__pull_events");