gdbserver: allow suppressing the next putpkt remote-debug log

When started with the --debug=remote flag, gdbserver enables the debug
logs for the received and sent remote packets.  If the packet contents
are too long or contain verbatim binary data, printing the contents
may create noise in the logs or even distortion in the terminal output.

Introduce a function, `suppress_next_putpkt_log`, that allows omitting
the contents of a sent package in the logs.  This can be useful when a
certain packet handler knows that it is sending binary data.

My first attempt was to implement this mechanism by passing an extra
parameter to putpt_binary_1 that could be controlled by the caller,
putpkt_binary or putpkt.  However, all qxfer handlers, regardless of
whether they send binary or ascii data, cause the data to be sent via
putpkt_binary. Hence, the solution was going to be either too
suppressive or too intrusive.  I opted for the approach where a package
handler would suppress the log explicitly.

Approved-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
Tankut Baris Aktemur
2024-12-19 12:31:50 +01:00
parent 53a7b478f5
commit 792b26bb0c
3 changed files with 28 additions and 5 deletions

View File

@@ -20,6 +20,8 @@
#if !defined (IN_PROCESS_AGENT)
bool remote_debug = false;
bool suppressed_remote_debug = false;
#endif
/* Output file for debugging. Default to standard error. */
@@ -117,3 +119,11 @@ debug_write (const void *buf, size_t nbyte)
int fd = fileno (debug_file);
return write (fd, buf, nbyte);
}
/* See debug.h. */
void
suppress_next_putpkt_log ()
{
suppressed_remote_debug = true;
}