scripts/pkgs/torzu/fix-debugger.patch
2025-05-15 09:53:25 -06:00

54 lines
2.1 KiB
Diff

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 <mutex>
#include <thread>
-#include <boost/asio.hpp>
+// Use basic asio functionality only
+#define BOOST_ASIO_STANDALONE
+#include <boost/asio/basic_io_object.hpp>
+#include <boost/asio/ip/tcp.hpp>
+#include <boost/asio/write.hpp>
+#include <boost/asio/read.hpp>
+
#include <boost/process/async_pipe.hpp>
#include "common/logging/log.h"
@@ -21,17 +27,22 @@
template <typename Readable, typename Buffer, typename Callback>
static void AsyncReceiveInto(Readable& r, Buffer& buffer, Callback&& c) {
- static_assert(std::is_trivial_v<Buffer>);
- 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<const u8*>(&buffer);
- std::span<const u8> received_data{buffer_start, buffer_start + bytes_read};
- c(received_data);
- AsyncReceiveInto(r, buffer, c);
- }
- });
+ try {
+ static_assert(std::is_trivial_v<Buffer>);
+ 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<const u8*>(&buffer);
+ std::span<const u8> 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 <typename Callback>