From 33a5410ca2b23299768663cdc8eb12037c21cf7a Mon Sep 17 00:00:00 2001 From: MihailRis Date: Thu, 9 Oct 2025 00:23:54 +0300 Subject: [PATCH] add 'reason' argument to debug.pause --- res/scripts/stdmin.lua | 4 ++-- src/devtools/DebuggingServer.cpp | 5 ++++- src/devtools/DebuggingServer.hpp | 4 +++- src/logic/scripting/lua/lua_extensions.cpp | 10 ++++++++-- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/res/scripts/stdmin.lua b/res/scripts/stdmin.lua index 4487860f..3e07c26b 100644 --- a/res/scripts/stdmin.lua +++ b/res/scripts/stdmin.lua @@ -55,7 +55,7 @@ debug.sethook(function (e, line) end current_func = _debug_getinfo(2).func current_func_stack_size = calc_stack_size() - __pause("paused on breakpoint") + __pause("breakpoint") debug.pull_events() end, "lr") @@ -122,7 +122,7 @@ function debug.remove_breakpoint(source, line) end function error(message, level) - __pause("paused on exception: " .. message) + __pause("exception", message) __error(message, level) end diff --git a/src/devtools/DebuggingServer.cpp b/src/devtools/DebuggingServer.cpp index 2cf67f48..505f1ff5 100644 --- a/src/devtools/DebuggingServer.cpp +++ b/src/devtools/DebuggingServer.cpp @@ -213,13 +213,16 @@ bool DebuggingServer::performCommand( return false; } -void DebuggingServer::pause(std::string&& message, dv::value&& stackTrace) { +void DebuggingServer::pause( + std::string&& reason, std::string&& message, dv::value&& stackTrace +) { if (connection == nullptr) { return; } if (stackTrace != nullptr) { connection->send(dv::object({ {"type", std::string("hit-breakpoint")}, + {"reason", std::move(reason)}, {"message", std::move(message)}, {"stack", std::move(stackTrace)} })); diff --git a/src/devtools/DebuggingServer.hpp b/src/devtools/DebuggingServer.hpp index 0f3b4566..cd4931cb 100644 --- a/src/devtools/DebuggingServer.hpp +++ b/src/devtools/DebuggingServer.hpp @@ -73,7 +73,9 @@ namespace devtools { ~DebuggingServer(); bool update(); - void pause(std::string&& message, dv::value&& stackTrace); + void pause( + std::string&& reason, 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 f1b7638f..b2224104 100644 --- a/src/logic/scripting/lua/lua_extensions.cpp +++ b/src/logic/scripting/lua/lua_extensions.cpp @@ -268,11 +268,17 @@ static dv::value create_stack_trace(lua::State* L, int initFrame = 2) { static int l_debug_pause(lua::State* L) { if (auto server = engine->getDebuggingServer()) { + std::string reason; std::string message; if (lua::isstring(L, 1)) { - message = lua::tolstring(L, 1); + reason = lua::tolstring(L, 1); } - server->pause(std::move(message), create_stack_trace(L)); + if (lua::isstring(L, 2)) { + message = lua::tolstring(L, 2); + } + server->pause( + std::move(reason), std::move(message), create_stack_trace(L) + ); } return 0; }