[Pdbg] [PATCH v2 11/39] gdbserver: reduce PR_INFO noise

Nicholas Piggin npiggin at gmail.com
Tue May 10 19:47:40 AEST 2022


Excerpts from Joel Stanley's message of May 3, 2022 5:00 pm:
> On Wed, 20 Apr 2022 at 06:50, Nicholas Piggin <npiggin at 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 at 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


More information about the Pdbg mailing list