diff --git a/src/core/debugger/debugger.cpp b/src/core/debugger/debugger.cpp index e86aae8460..a4dca23770 100644 --- a/src/core/debugger/debugger.cpp +++ b/src/core/debugger/debugger.cpp @@ -5,7 +5,13 @@ #include #include -#include +// Use basic asio functionality only +#define BOOST_ASIO_STANDALONE +#include +#include +#include +#include + #include #include "common/logging/log.h" @@ -21,17 +27,22 @@ template static void AsyncReceiveInto(Readable& r, Buffer& buffer, Callback&& c) { - static_assert(std::is_trivial_v); - auto boost_buffer{boost::asio::buffer(&buffer, sizeof(Buffer))}; - r.async_read_some( - boost_buffer, [&, c](const boost::system::error_code& error, size_t bytes_read) { - if (!error.failed()) { - const u8* buffer_start = reinterpret_cast(&buffer); - std::span received_data{buffer_start, buffer_start + bytes_read}; - c(received_data); - AsyncReceiveInto(r, buffer, c); - } - }); + try { + static_assert(std::is_trivial_v); + auto boost_buffer{boost::asio::buffer(&buffer, sizeof(Buffer))}; + r.async_read_some( + boost_buffer, + [&, c](const boost::system::error_code& error, size_t bytes_read) { + if (!error) { + const u8* buffer_start = reinterpret_cast(&buffer); + std::span received_data{buffer_start, buffer_start + bytes_read}; + c(received_data); + AsyncReceiveInto(r, buffer, c); + } + }); + } catch (const std::exception& e) { + LOG_ERROR(Debug_GDBStub, "AsyncReceiveInto error: {}", e.what()); + } } template