diff mbox series

[v2,11/39] gdbserver: reduce PR_INFO noise

Message ID 20220420065013.222816-12-npiggin@gmail.com
State New
Headers show
Series gdbserver multi-threaded debugging and POWER9/10 support | expand

Commit Message

Nicholas Piggin April 20, 2022, 6:49 a.m. UTC
Printing the first byte of the received packet in hex on its own line is
not very useful and clutters debug output. We print the full received
packet anyway which is generally quite readable.

Remove the first byte info line, and replace it with a debug line that
contains the entire hex string as hex bytes.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 src/pdbgproxy.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Joel Stanley May 3, 2022, 7 a.m. UTC | #1
On Wed, 20 Apr 2022 at 06:50, Nicholas Piggin <npiggin@gmail.com> wrote:
>
> Printing the first byte of the received packet in hex on its own line is
> not very useful and clutters debug output. We print the full received
> packet anyway which is generally quite readable.
>
> Remove the first byte info line, and replace it with a debug line that
> contains the entire hex string as hex bytes.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
> ---
>  src/pdbgproxy.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c
> index 4c6327fb..9e5e7d80 100644
> --- a/src/pdbgproxy.c
> +++ b/src/pdbgproxy.c
> @@ -396,9 +396,15 @@ static int read_from_client(int fd)
>                 PR_INFO("0 bytes\n");
>                 return -1;
>         } else {
> +               int i;
> +
>                 buffer[nbytes] = '\0';
> -               PR_INFO("%x\n", buffer[0]);
>                 PR_INFO("Recv: %s\n", buffer);
> +               pdbg_log(PDBG_DEBUG, " hex: ");
> +               for (i = 0; i < nbytes; i++)
> +                       pdbg_log(PDBG_DEBUG, "%02x ", buffer[i]);
> +               pdbg_log(PDBG_DEBUG, "\n");

We have a hexdump() in src/util, but it's probably not worth using it here.

Reviewed-by: Joel Stanley <joel@jms.id.au>

> +
>                 parse_buffer(buffer, nbytes, &fd);
>         }
>
> --
> 2.35.1
>
> --
> Pdbg mailing list
> Pdbg@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/pdbg
Nicholas Piggin May 10, 2022, 9:47 a.m. UTC | #2
Excerpts from Joel Stanley's message of May 3, 2022 5:00 pm:
> On Wed, 20 Apr 2022 at 06:50, Nicholas Piggin <npiggin@gmail.com> wrote:
>>
>> Printing the first byte of the received packet in hex on its own line is
>> not very useful and clutters debug output. We print the full received
>> packet anyway which is generally quite readable.
>>
>> Remove the first byte info line, and replace it with a debug line that
>> contains the entire hex string as hex bytes.
>>
>> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
>> ---
>>  src/pdbgproxy.c | 8 +++++++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c
>> index 4c6327fb..9e5e7d80 100644
>> --- a/src/pdbgproxy.c
>> +++ b/src/pdbgproxy.c
>> @@ -396,9 +396,15 @@ static int read_from_client(int fd)
>>                 PR_INFO("0 bytes\n");
>>                 return -1;
>>         } else {
>> +               int i;
>> +
>>                 buffer[nbytes] = '\0';
>> -               PR_INFO("%x\n", buffer[0]);
>>                 PR_INFO("Recv: %s\n", buffer);
>> +               pdbg_log(PDBG_DEBUG, " hex: ");
>> +               for (i = 0; i < nbytes; i++)
>> +                       pdbg_log(PDBG_DEBUG, "%02x ", buffer[i]);
>> +               pdbg_log(PDBG_DEBUG, "\n");
> 
> We have a hexdump() in src/util, but it's probably not worth using it here.

You would be surprised how many bugs I can fit in a seemingly simple
line of string manipulation. So probably not a bad idea.

Thanks,
Nick
diff mbox series

Patch

diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c
index 4c6327fb..9e5e7d80 100644
--- a/src/pdbgproxy.c
+++ b/src/pdbgproxy.c
@@ -396,9 +396,15 @@  static int read_from_client(int fd)
 		PR_INFO("0 bytes\n");
 		return -1;
 	} else {
+		int i;
+
 		buffer[nbytes] = '\0';
-		PR_INFO("%x\n", buffer[0]);
 		PR_INFO("Recv: %s\n", buffer);
+		pdbg_log(PDBG_DEBUG, " hex: ");
+		for (i = 0; i < nbytes; i++)
+			pdbg_log(PDBG_DEBUG, "%02x ", buffer[i]);
+		pdbg_log(PDBG_DEBUG, "\n");
+
 		parse_buffer(buffer, nbytes, &fd);
 	}