Skip to content

Commit

Permalink
Merge pull request managarm#578 from Dennisbonke/gdbserver
Browse files Browse the repository at this point in the history
thor: Don't launch gdbserver more than once if servers die
  • Loading branch information
qookei authored Oct 17, 2023
2 parents 50477d0 + 3d6b53f commit be82874
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
5 changes: 5 additions & 0 deletions kernel/thor/generic/gdbserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,13 @@ coroutine<frg::expected<ProtocolError>> GdbServer::handleRequest_() {

} // anonymous namespace

static bool launched = false;

void launchGdbServer(smarter::shared_ptr<Thread, ActiveHandle> thread,
frg::string_view path, smarter::shared_ptr<WorkQueue> wq) {
if(launched)
return;
launched = true;
auto channel = solicitIoChannel("kernel-gdbserver");
if(!channel) {
infoLogger() << "thor: No I/O channel available for gdbserver" << frg::endlog;
Expand Down
30 changes: 15 additions & 15 deletions posix/subsystem/src/gdbserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -515,20 +515,20 @@ async::result<frg::expected<ProtocolError>> GdbServer::handleRequest_() {
static bool launched = false;

void launchGdbServer(Process *process) {
if(!launched) {
launched = true;
async::detach([] (Process *process) -> async::result<void> {
std::cout << "posix: Starting GDB server" << std::endl;

auto root = rootPath();
auto fileOrError = co_await open(root, root, "dev/ttyS0", process);
if(!fileOrError) {
std::cout << "posix, gdbserver: Could not open /dev/ttyS0" << std::endl;
co_return;
}
if(launched)
return;
launched = true;
async::detach([] (Process *process) -> async::result<void> {
std::cout << "posix: Starting GDB server" << std::endl;

auto root = rootPath();
auto fileOrError = co_await open(root, root, "dev/ttyS0", process);
if(!fileOrError) {
std::cout << "posix, gdbserver: Could not open /dev/ttyS0" << std::endl;
co_return;
}

GdbServer server{process, fileOrError.value()};
co_await server.run();
}(process));
}
GdbServer server{process, fileOrError.value()};
co_await server.run();
}(process));
}

0 comments on commit be82874

Please sign in to comment.