add 'reason' argument to debug.pause

This commit is contained in:
MihailRis
2025-10-09 00:23:54 +03:00
parent 972181022a
commit 33a5410ca2
4 changed files with 17 additions and 6 deletions
+2 -2
View File
@@ -55,7 +55,7 @@ debug.sethook(function (e, line)
end end
current_func = _debug_getinfo(2).func current_func = _debug_getinfo(2).func
current_func_stack_size = calc_stack_size() current_func_stack_size = calc_stack_size()
__pause("paused on breakpoint") __pause("breakpoint")
debug.pull_events() debug.pull_events()
end, "lr") end, "lr")
@@ -122,7 +122,7 @@ function debug.remove_breakpoint(source, line)
end end
function error(message, level) function error(message, level)
__pause("paused on exception: " .. message) __pause("exception", message)
__error(message, level) __error(message, level)
end end
+4 -1
View File
@@ -213,13 +213,16 @@ bool DebuggingServer::performCommand(
return false; 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) { if (connection == nullptr) {
return; return;
} }
if (stackTrace != nullptr) { if (stackTrace != nullptr) {
connection->send(dv::object({ connection->send(dv::object({
{"type", std::string("hit-breakpoint")}, {"type", std::string("hit-breakpoint")},
{"reason", std::move(reason)},
{"message", std::move(message)}, {"message", std::move(message)},
{"stack", std::move(stackTrace)} {"stack", std::move(stackTrace)}
})); }));
+3 -1
View File
@@ -73,7 +73,9 @@ namespace devtools {
~DebuggingServer(); ~DebuggingServer();
bool update(); 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); void sendValue(dv::value&& value, int frame, int local, ValuePath&& path);
+8 -2
View File
@@ -268,11 +268,17 @@ static dv::value create_stack_trace(lua::State* L, int initFrame = 2) {
static int l_debug_pause(lua::State* L) { static int l_debug_pause(lua::State* L) {
if (auto server = engine->getDebuggingServer()) { if (auto server = engine->getDebuggingServer()) {
std::string reason;
std::string message; std::string message;
if (lua::isstring(L, 1)) { 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; return 0;
} }