replace 'debug.breakpoint' with 'debug.pause'

This commit is contained in:
MihailRis 2025-10-08 23:11:10 +03:00
parent 8f56969997
commit 4f6a443fa3
4 changed files with 21 additions and 18 deletions

View File

@ -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

View File

@ -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<ClientConnection>(engine.getNetwork(), client);

View File

@ -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);

View File

@ -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<l_debug_print>);
lua::setfield(L, "print");
lua::pushcfunction(L, lua::wrap<l_debug_breakpoint>);
lua::setfield(L, "breakpoint");
lua::pushcfunction(L, lua::wrap<l_debug_pause>);
lua::setfield(L, "pause");
lua::pushcfunction(L, lua::wrap<l_debug_pull_events>);
lua::setfield(L, "__pull_events");