From 7731e02a20224a67974992a7d44711bbdc78c43d Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Tue, 26 Sep 2023 12:54:01 +0200 Subject: [PATCH] monitor: remove terminal write busy loop Fixes #5011 --- repos/os/src/monitor/gdb_stub.h | 4 +++- repos/os/src/monitor/main.cc | 13 +++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/repos/os/src/monitor/gdb_stub.h b/repos/os/src/monitor/gdb_stub.h index 1a190be55c..d0c2461fe1 100644 --- a/repos/os/src/monitor/gdb_stub.h +++ b/repos/os/src/monitor/gdb_stub.h @@ -346,7 +346,9 @@ struct qXfer : Command_with_separator static Window from_args(Const_byte_range_ptr const &args) { return { .offset = comma_separated_hex_value(args, 0, 0UL), - .len = comma_separated_hex_value(args, 1, 0UL) }; + /* terminal_crosslink currently buffers 4096 bytes */ + .len = min(comma_separated_hex_value(args, 1, 0UL), + 2048UL) }; } }; diff --git a/repos/os/src/monitor/main.cc b/repos/os/src/monitor/main.cc index 173ce3cc97..435412b39c 100644 --- a/repos/os/src/monitor/main.cc +++ b/repos/os/src/monitor/main.cc @@ -133,14 +133,11 @@ struct Monitor::Main : Sandbox::State_handler, Terminal::Connection &_terminal; void operator () (char const *str) { - for (;;) { - size_t const num_bytes = strlen(str); - size_t const written_bytes = _terminal.write(str, num_bytes); - if (written_bytes == num_bytes) - break; - - str = str + written_bytes; - } + size_t const num_bytes = strlen(str); + size_t const written_bytes = _terminal.write(str, num_bytes); + if (written_bytes != num_bytes) + Genode::warning("Could not send the debug response " + "message completely."); } } _write_fn;