[Pdbg] [PATCH 01/14] gdbserver: update gdb_parser_precompile.c, rename detach command

Nicholas Piggin npiggin at gmail.com
Tue Mar 29 19:40:11 AEDT 2022


Hey Joel,

Thanks for reviewing and the thoughtful comments, sorry it's taken a
while to get back to it...

Excerpts from Joel Stanley's message of March 16, 2022 9:13 am:
> On Mon, 14 Mar 2022 at 04:18, Nicholas Piggin <npiggin at gmail.com> wrote:
>>
>> gdb_parser_precompile.c had not been updated since adding support for
>> the detach command, resulting in client error messages like this:
>>
>>   Detaching from program: /home/npiggin/images/vmlinux, process 42000
>>   Remote doesn't know how to detach
>>
>> The command handler should not be named disconnect, because that is a
>> different concept in gdb (disconnect leaves the target in the same
>> state, detach ends the debugging session).
>>
>> Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
>> ---
>>  src/gdb_parser.rl           |   4 +-
>>  src/gdb_parser_precompile.c | 231 ++++++++++++++++++------------------
>>  src/pdbgproxy.c             |   6 +-
>>  src/pdbgproxy.h             |   2 +-
>>  4 files changed, 124 insertions(+), 119 deletions(-)
>>
>> diff --git a/src/gdb_parser.rl b/src/gdb_parser.rl
>> index 6259b96..93213e4 100644
>> --- a/src/gdb_parser.rl
>> +++ b/src/gdb_parser.rl
>> @@ -76,7 +76,7 @@
>>
>>         set_thread = ('H' any* @{cmd = SET_THREAD;});
>>
>> -       disconnect = ('D' @{cmd = DISCONNECT;}
>> +       detach = ('D' @{cmd = DETACH;}
>>                      xdigit+ $hex_digit %push);
>>
>>         # TODO: We don't actually listen to what's supported
>> @@ -94,7 +94,7 @@
>>
>>         commands = (get_mem | get_gprs | get_spr | stop_reason | set_thread |
>>                     q_attached | q_C | q_supported | qf_threadinfo | q_C |
>> -                   v_contq | v_contc | v_conts | put_mem | disconnect );
>> +                   v_contq | v_contc | v_conts | put_mem | detach );
>>
>>         cmd = ((commands & ^'#'*) | ^'#'*) $crc
>>               ('#' xdigit{2} $hex_digit @end);
>> diff --git a/src/gdb_parser_precompile.c b/src/gdb_parser_precompile.c
>> index 715cdd7..cee2fd0 100644
>> --- a/src/gdb_parser_precompile.c
>> +++ b/src/gdb_parser_precompile.c
>> @@ -5,10 +5,10 @@
>>  #include <string.h>
>>  #include <assert.h>
>>
>> -#include "pdbgproxy.h"
>> +#include "src/pdbgproxy.h"
>>
>>
>> -#line 105 "src/gdb_parser.rl"
>> +#line 108 "src/gdb_parser.rl"
>>
>>
>>  static enum gdb_command cmd = NONE;
>> @@ -29,56 +29,56 @@ static const char _gdb_actions[] = {
>>         1, 2, 9, 1, 2, 10, 1, 2,
>>         11, 1, 2, 12, 1, 2, 13, 1,
>>         2, 14, 1, 2, 15, 1, 2, 16,
>> -       1, 2, 17, 1, 2, 18, 0, 3,
>> -       1, 18, 0, 3, 6, 2, 1, 3,
>> -       6, 3, 1
>> +       1, 2, 17, 1, 2, 18, 1, 2,
>> +       19, 0, 3, 1, 19, 0, 3, 6,
>> +       2, 1, 3, 6, 3, 1
>>  };
>>
>> -static const char _gdb_key_offsets[] = {
>> -       0, 0, 2, 13, 14, 20, 26, 29,
>> -       37, 45, 46, 53, 61, 68, 77, 84,
>> -       92, 99, 107, 114, 121, 126, 128, 130,
>> -       132, 134, 136, 138, 140, 142, 149, 151,
>> -       153, 155, 157, 159, 161, 163, 165, 167,
>> -       168, 170, 172, 174, 176, 178, 180, 182,
>> -       184, 186, 188, 190, 192, 194, 196, 199,
>> -       202, 203, 204, 206
>> +static const unsigned char _gdb_key_offsets[] = {
>> +       0, 0, 2, 14, 15, 21, 27, 30,
>> +       38, 46, 53, 60, 61, 68, 76, 83,
>> +       92, 99, 107, 114, 122, 127, 129, 131,
>> +       133, 135, 137, 139, 141, 143, 150, 152,
>> +       154, 156, 158, 160, 162, 164, 166, 168,
>> +       169, 171, 173, 175, 177, 179, 181, 183,
>> +       185, 187, 189, 191, 193, 195, 197, 200,
>> +       203, 204, 205, 207
> 
> Are these auto generated? How do we update them?

Yes it has to be built with

 ragel src/gdb_parser.rl -o src/gdb_parser_precompile.c

If you configure with 'ragel' installed then it generates
gdb_parser.c as part of the build. Although the build system
is a little bit funny because it calls that part of the sources
and then .gitignores it. That could probably be handled a bit
better, but I guess it works.

It would be nice if we had a target to
make src/gdb_parser_precompile.c for updating too.

Thanks,
Nick


More information about the Pdbg mailing list