arch: Dump semihosting write buffer in debug output (#1389)

This makes it easier to debug unexpected semihosting outputs (in my case
a wrong buffer argument was being passed).

Change-Id: I342610a92fb8efe121d030f7b9ea3307efc4fec3
This commit is contained in:
Alexander Richardson
2024-07-30 01:39:05 -07:00
committed by GitHub
parent ddc9a18536
commit b64aa0b9b3

View File

@@ -250,6 +250,7 @@ BaseSemihosting::callWrite0(ThreadContext *tc, InPlaceArg arg)
PortProxy &proxy = portProxy(tc);
std::string str;
proxy.readString(str, arg.addr);
DDUMP(Semihosting, str.data(), str.size());
std::cout.write(str.c_str(), str.size());
std::cout.flush();
@@ -263,8 +264,10 @@ BaseSemihosting::callWrite(
if (handle > files.size() || !files[handle])
return RetErrno(size, EBADF);
DPRINTF(Semihosting, "Semihosting SYS_WRITE(%x, %d)\n", addr, size);
std::vector<uint8_t> buffer(size);
portProxy(tc).readBlob(addr, buffer.data(), buffer.size());
DDUMP(Semihosting, buffer.data(), buffer.size());
int64_t ret = files[handle]->write(buffer.data(), buffer.size());
if (ret < 0) {