diff mbox series

[10/14] gdbserver: implement NoAckMode

Message ID 20220314041735.542867-12-npiggin@gmail.com
State New
Headers show
Series gdbserver fixes and POWER10 support | expand

Commit Message

Nicholas Piggin March 14, 2022, 4:17 a.m. UTC
This removes a bunch of synchronous round-trips and makes things
significantly faster when attached to a high latency link.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 src/gdb_parser.rl           |  14 +-
 src/gdb_parser_precompile.c | 291 ++++++++++++++++++++----------------
 2 files changed, 170 insertions(+), 135 deletions(-)

Comments

Joel Stanley March 15, 2022, 11:16 p.m. UTC | #1
On Mon, 14 Mar 2022 at 04:18, Nicholas Piggin <npiggin@gmail.com> wrote:
>
> This removes a bunch of synchronous round-trips and makes things
> significantly faster when attached to a high latency link.
>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>

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

> ---
>  src/gdb_parser.rl           |  14 +-
>  src/gdb_parser_precompile.c | 291 ++++++++++++++++++++----------------
>  2 files changed, 170 insertions(+), 135 deletions(-)
>
> diff --git a/src/gdb_parser.rl b/src/gdb_parser.rl
> index daa4167..f7f9a54 100644
> --- a/src/gdb_parser.rl
> +++ b/src/gdb_parser.rl
> @@ -43,10 +43,12 @@
>                 /* *data should point to the CRC */
>                 if (crc != *data) {
>                         printf("CRC error cmd %d\n", cmd);
> -                       send_nack(priv);
> +                       if (ack_mode)
> +                               send_nack(priv);
>                 } else {
>                         PR_INFO("Cmd %d\n", cmd);
> -                       send_ack(priv);
> +                       if (ack_mode)
> +                               send_ack(priv);
>
>                         /* Push the response onto the stack */
>                         if (rsp)
> @@ -86,8 +88,9 @@
>         # TODO: We don't actually listen to what's supported
>         q_attached = ('qAttached:' xdigit* @{rsp = "1";});
>         q_C = ('qC' @{rsp = "QC1";});
> -       q_supported = ('qSupported:' (any & ^'#')* >{rsp = "multiprocess+;vContSupported+";});
> +       q_supported = ('qSupported:' (any & ^'#')* >{rsp = "multiprocess+;vContSupported+;QStartNoAckMode+";});
>         qf_threadinfo = ('qfThreadInfo' @{rsp = "m1l";});
> +       q_start_noack = ('QStartNoAckMode' @{rsp = "OK"; send_ack(priv); ack_mode = false;});
>
>         # vCont packet parsing
>         v_contq = ('vCont?' @{rsp = "vCont;c;C;s;S";});
> @@ -99,7 +102,8 @@
>
>         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 | detach | unknown );
> +                   q_start_noack | v_contq | v_contc | v_conts | put_mem |
> +                   detach | unknown );
>
>         cmd = (('$' ((commands & ^'#'*) >reset $crc)
>               ('#' xdigit{2} $hex_digit @end)) >{PR_INFO("RAGEL:cmd\n");});
> @@ -120,6 +124,8 @@ static int cs;
>
>  static command_cb *command_callbacks;
>
> +static bool ack_mode = true;
> +
>  %%write data;
>
>  void parser_init(command_cb *callbacks)
> diff --git a/src/gdb_parser_precompile.c b/src/gdb_parser_precompile.c
> index b8cdbc1..b02ebf0 100644
> --- a/src/gdb_parser_precompile.c
> +++ b/src/gdb_parser_precompile.c
> @@ -10,7 +10,7 @@
>  #include "debug.h"
>
>
> -#line 113 "src/gdb_parser.rl"
> +#line 117 "src/gdb_parser.rl"
>
>
>  static enum gdb_command cmd = NONE;
> @@ -21,162 +21,185 @@ static int cs;
>
>  static command_cb *command_callbacks;
>
> +static bool ack_mode = true;
> +
>
> -#line 26 "src/gdb_parser.c"
> +#line 28 "src/gdb_parser.c"
>  static const char _gdb_actions[] = {
>         0, 1, 0, 1, 1, 1, 2, 1,
> -       3, 1, 14, 1, 19, 1, 20, 1,
> -       21, 1, 22, 2, 0, 1, 2, 2,
> +       3, 1, 14, 1, 20, 1, 21, 1,
> +       22, 1, 23, 2, 0, 1, 2, 2,
>         1, 2, 3, 1, 2, 3, 4, 2,
>         6, 1, 2, 10, 1, 2, 12, 1,
>         2, 13, 1, 2, 14, 1, 2, 15,
>         1, 2, 16, 1, 2, 17, 1, 2,
> -       18, 1, 3, 0, 5, 1, 3, 0,
> -       7, 1, 3, 0, 8, 1, 3, 0,
> -       9, 1, 3, 0, 11, 1, 3, 6,
> -       2, 1, 3, 6, 3, 1
> +       18, 1, 2, 19, 1, 3, 0, 5,
> +       1, 3, 0, 7, 1, 3, 0, 8,
> +       1, 3, 0, 9, 1, 3, 0, 11,
> +       1, 3, 6, 2, 1, 3, 6, 3,
> +       1
>  };
>
>  static const unsigned char _gdb_key_offsets[] = {
> -       0, 0, 10, 11, 17, 23, 30, 37,
> -       38, 45, 53, 60, 69, 76, 84, 91,
> -       99, 104, 106, 108, 110, 112, 114, 116,
> -       118, 120, 127, 129, 131, 133, 135, 137,
> -       139, 141, 143, 145, 146, 148, 150, 152,
> -       154, 156, 158, 160, 162, 164, 166, 168,
> -       170, 172, 174, 177, 180, 181, 182
> +       0, 0, 11, 12, 18, 24, 31, 38,
> +       39, 46, 54, 61, 70, 77, 85, 87,
> +       89, 91, 93, 95, 97, 99, 101, 103,
> +       105, 107, 109, 111, 113, 120, 128, 133,
> +       135, 137, 139, 141, 143, 145, 147, 149,
> +       156, 158, 160, 162, 164, 166, 168, 170,
> +       172, 174, 175, 177, 179, 181, 183, 185,
> +       187, 189, 191, 193, 195, 197, 199, 201,
> +       203, 206, 209, 210, 211
>  };
>
>  static const char _gdb_trans_keys[] = {
> -       35, 63, 68, 72, 77, 103, 109, 112,
> -       113, 118, 35, 48, 57, 65, 70, 97,
> -       102, 48, 57, 65, 70, 97, 102, 35,
> +       35, 63, 68, 72, 77, 81, 103, 109,
> +       112, 113, 118, 35, 48, 57, 65, 70,
> +       97, 102, 48, 57, 65, 70, 97, 102,
> +       35, 48, 57, 65, 70, 97, 102, 35,
> +       48, 57, 65, 70, 97, 102, 35, 35,
> +       48, 57, 65, 70, 97, 102, 35, 44,
> +       48, 57, 65, 70, 97, 102, 35, 48,
> +       57, 65, 70, 97, 102, 35, 44, 58,
>         48, 57, 65, 70, 97, 102, 35, 48,
> -       57, 65, 70, 97, 102, 35, 35, 48,
>         57, 65, 70, 97, 102, 35, 44, 48,
> -       57, 65, 70, 97, 102, 35, 48, 57,
> -       65, 70, 97, 102, 35, 44, 58, 48,
> -       57, 65, 70, 97, 102, 35, 48, 57,
> -       65, 70, 97, 102, 35, 44, 48, 57,
> -       65, 70, 97, 102, 35, 48, 57, 65,
> -       70, 97, 102, 35, 44, 48, 57, 65,
> -       70, 97, 102, 35, 65, 67, 83, 102,
> -       35, 116, 35, 116, 35, 97, 35, 99,
> -       35, 104, 35, 101, 35, 100, 35, 58,
> -       35, 48, 57, 65, 70, 97, 102, 35,
> -       117, 35, 112, 35, 112, 35, 111, 35,
> -       114, 35, 116, 35, 101, 35, 100, 35,
> -       58, 35, 35, 84, 35, 104, 35, 114,
> -       35, 101, 35, 97, 35, 100, 35, 73,
> -       35, 110, 35, 102, 35, 111, 35, 67,
> -       35, 111, 35, 110, 35, 116, 35, 59,
> -       63, 35, 99, 115, 35, 35, 3, 36,
> -       43, 45, 0
> +       57, 65, 70, 97, 102, 35, 83, 35,
> +       116, 35, 97, 35, 114, 35, 116, 35,
> +       78, 35, 111, 35, 65, 35, 99, 35,
> +       107, 35, 77, 35, 111, 35, 100, 35,
> +       101, 35, 48, 57, 65, 70, 97, 102,
> +       35, 44, 48, 57, 65, 70, 97, 102,
> +       35, 65, 67, 83, 102, 35, 116, 35,
> +       116, 35, 97, 35, 99, 35, 104, 35,
> +       101, 35, 100, 35, 58, 35, 48, 57,
> +       65, 70, 97, 102, 35, 117, 35, 112,
> +       35, 112, 35, 111, 35, 114, 35, 116,
> +       35, 101, 35, 100, 35, 58, 35, 35,
> +       84, 35, 104, 35, 114, 35, 101, 35,
> +       97, 35, 100, 35, 73, 35, 110, 35,
> +       102, 35, 111, 35, 67, 35, 111, 35,
> +       110, 35, 116, 35, 59, 63, 35, 99,
> +       115, 35, 35, 3, 36, 43, 45, 0
>  };
>
>  static const char _gdb_single_lengths[] = {
> -       0, 10, 1, 0, 0, 1, 1, 1,
> -       1, 2, 1, 3, 1, 2, 1, 2,
> -       5, 2, 2, 2, 2, 2, 2, 2,
> +       0, 11, 1, 0, 0, 1, 1, 1,
> +       1, 2, 1, 3, 1, 2, 2, 2,
> +       2, 2, 2, 2, 2, 2, 2, 2,
> +       2, 2, 2, 2, 1, 2, 5, 2,
> +       2, 2, 2, 2, 2, 2, 2, 1,
> +       2, 2, 2, 2, 2, 2, 2, 2,
>         2, 1, 2, 2, 2, 2, 2, 2,
> -       2, 2, 2, 1, 2, 2, 2, 2,
>         2, 2, 2, 2, 2, 2, 2, 2,
> -       2, 2, 3, 3, 1, 1, 4
> +       3, 3, 1, 1, 4
>  };
>
>  static const char _gdb_range_lengths[] = {
>         0, 0, 0, 3, 3, 3, 3, 0,
> -       3, 3, 3, 3, 3, 3, 3, 3,
> +       3, 3, 3, 3, 3, 3, 0, 0,
> +       0, 0, 0, 0, 0, 0, 0, 0,
> +       0, 0, 0, 0, 3, 3, 0, 0,
> +       0, 0, 0, 0, 0, 0, 0, 3,
>         0, 0, 0, 0, 0, 0, 0, 0,
> -       0, 3, 0, 0, 0, 0, 0, 0,
>         0, 0, 0, 0, 0, 0, 0, 0,
>         0, 0, 0, 0, 0, 0, 0, 0,
> -       0, 0, 0, 0, 0, 0, 0
> +       0, 0, 0, 0, 0
>  };
>
> -static const unsigned char _gdb_index_offsets[] = {
> -       0, 0, 11, 13, 17, 21, 26, 31,
> -       33, 38, 44, 49, 56, 61, 67, 72,
> -       78, 84, 87, 90, 93, 96, 99, 102,
> -       105, 108, 113, 116, 119, 122, 125, 128,
> -       131, 134, 137, 140, 142, 145, 148, 151,
> -       154, 157, 160, 163, 166, 169, 172, 175,
> -       178, 181, 184, 188, 192, 194, 196
> +static const short _gdb_index_offsets[] = {
> +       0, 0, 12, 14, 18, 22, 27, 32,
> +       34, 39, 45, 50, 57, 62, 68, 71,
> +       74, 77, 80, 83, 86, 89, 92, 95,
> +       98, 101, 104, 107, 110, 115, 121, 127,
> +       130, 133, 136, 139, 142, 145, 148, 151,
> +       156, 159, 162, 165, 168, 171, 174, 177,
> +       180, 183, 185, 188, 191, 194, 197, 200,
> +       203, 206, 209, 212, 215, 218, 221, 224,
> +       227, 231, 235, 237, 239
>  };
>
>  static const char _gdb_indicies[] = {
>         1, 2, 3, 4, 5, 6, 7, 8,
> -       9, 10, 0, 12, 11, 13, 13, 13,
> -       14, 15, 15, 15, 14, 12, 16, 16,
> -       16, 11, 17, 16, 16, 16, 11, 12,
> -       18, 12, 20, 20, 20, 19, 12, 21,
> -       20, 20, 20, 19, 12, 22, 22, 22,
> -       19, 12, 21, 23, 22, 22, 22, 19,
> -       12, 24, 24, 24, 19, 17, 21, 24,
> -       24, 24, 19, 12, 25, 25, 25, 11,
> -       12, 26, 25, 25, 25, 11, 12, 27,
> -       28, 29, 30, 11, 12, 31, 11, 12,
> -       32, 11, 12, 33, 11, 12, 34, 11,
> -       12, 35, 11, 12, 36, 11, 12, 37,
> -       11, 12, 38, 11, 12, 39, 39, 39,
> -       11, 12, 40, 11, 12, 41, 11, 12,
> -       42, 11, 12, 43, 11, 12, 44, 11,
> -       12, 45, 11, 12, 46, 11, 12, 47,
> -       11, 12, 48, 11, 50, 49, 12, 51,
> -       11, 12, 52, 11, 12, 53, 11, 12,
> -       54, 11, 12, 55, 11, 12, 56, 11,
> -       12, 57, 11, 12, 58, 11, 12, 59,
> -       11, 12, 60, 11, 12, 61, 11, 12,
> -       62, 11, 12, 63, 11, 12, 64, 11,
> -       12, 65, 66, 11, 12, 67, 68, 11,
> -       12, 69, 12, 70, 71, 72, 73, 74,
> -       14, 0
> +       9, 10, 11, 0, 13, 12, 14, 14,
> +       14, 15, 16, 16, 16, 15, 13, 17,
> +       17, 17, 12, 18, 17, 17, 17, 12,
> +       13, 19, 13, 21, 21, 21, 20, 13,
> +       22, 21, 21, 21, 20, 13, 23, 23,
> +       23, 20, 13, 22, 24, 23, 23, 23,
> +       20, 13, 25, 25, 25, 20, 18, 22,
> +       25, 25, 25, 20, 13, 26, 12, 13,
> +       27, 12, 13, 28, 12, 13, 29, 12,
> +       13, 30, 12, 13, 31, 12, 13, 32,
> +       12, 13, 33, 12, 13, 34, 12, 13,
> +       35, 12, 13, 36, 12, 13, 37, 12,
> +       13, 38, 12, 13, 39, 12, 13, 40,
> +       40, 40, 12, 13, 41, 40, 40, 40,
> +       12, 13, 42, 43, 44, 45, 12, 13,
> +       46, 12, 13, 47, 12, 13, 48, 12,
> +       13, 49, 12, 13, 50, 12, 13, 51,
> +       12, 13, 52, 12, 13, 53, 12, 13,
> +       54, 54, 54, 12, 13, 55, 12, 13,
> +       56, 12, 13, 57, 12, 13, 58, 12,
> +       13, 59, 12, 13, 60, 12, 13, 61,
> +       12, 13, 62, 12, 13, 63, 12, 65,
> +       64, 13, 66, 12, 13, 67, 12, 13,
> +       68, 12, 13, 69, 12, 13, 70, 12,
> +       13, 71, 12, 13, 72, 12, 13, 73,
> +       12, 13, 74, 12, 13, 75, 12, 13,
> +       76, 12, 13, 77, 12, 13, 78, 12,
> +       13, 79, 12, 13, 80, 81, 12, 13,
> +       82, 83, 12, 13, 84, 13, 85, 86,
> +       87, 88, 89, 15, 0
>  };
>
>  static const char _gdb_trans_targs[] = {
> -       2, 3, 2, 5, 7, 8, 2, 14,
> -       5, 16, 46, 2, 3, 4, 0, 54,
> -       6, 3, 7, 8, 9, 10, 11, 12,
> -       13, 15, 5, 17, 2, 26, 36, 18,
> -       19, 20, 21, 22, 23, 24, 25, 25,
> -       27, 28, 29, 30, 31, 32, 33, 34,
> -       35, 2, 3, 37, 38, 39, 40, 41,
> -       42, 43, 44, 45, 2, 47, 48, 49,
> -       50, 51, 2, 52, 53, 52, 53, 54,
> -       1, 54, 54
> +       2, 3, 2, 5, 7, 8, 14, 2,
> +       28, 5, 30, 60, 2, 3, 4, 0,
> +       68, 6, 3, 7, 8, 9, 10, 11,
> +       12, 13, 15, 16, 17, 18, 19, 20,
> +       21, 22, 23, 24, 25, 26, 27, 2,
> +       29, 5, 31, 2, 40, 50, 32, 33,
> +       34, 35, 36, 37, 38, 39, 39, 41,
> +       42, 43, 44, 45, 46, 47, 48, 49,
> +       2, 3, 51, 52, 53, 54, 55, 56,
> +       57, 58, 59, 2, 61, 62, 63, 64,
> +       65, 2, 66, 67, 66, 67, 68, 1,
> +       68, 68
>  };
>
>  static const char _gdb_trans_actions[] = {
> -       19, 1, 70, 74, 19, 19, 62, 58,
> -       66, 19, 19, 3, 0, 7, 0, 28,
> -       25, 5, 34, 31, 82, 78, 82, 78,
> -       82, 25, 22, 3, 40, 3, 3, 3,
> -       3, 3, 3, 3, 3, 3, 3, 37,
> +       19, 1, 73, 77, 19, 19, 19, 65,
> +       61, 69, 19, 19, 3, 0, 7, 0,
> +       28, 25, 5, 34, 31, 85, 81, 85,
> +       81, 85, 3, 3, 3, 3, 3, 3,
> +       3, 3, 3, 3, 3, 3, 3, 49,
> +       25, 22, 3, 40, 3, 3, 3, 3,
> +       3, 3, 3, 3, 3, 3, 37, 3,
>         3, 3, 3, 3, 3, 3, 3, 3,
> -       3, 43, 9, 3, 3, 3, 3, 3,
> -       3, 3, 3, 3, 46, 3, 3, 3,
> -       3, 3, 49, 3, 3, 52, 55, 11,
> -       13, 15, 17
> +       43, 9, 3, 3, 3, 3, 3, 3,
> +       3, 3, 3, 46, 3, 3, 3, 3,
> +       3, 52, 3, 3, 55, 58, 11, 13,
> +       15, 17
>  };
>
> -static const int gdb_start = 54;
> -static const int gdb_first_final = 54;
> +static const int gdb_start = 68;
> +static const int gdb_first_final = 68;
>  static const int gdb_error = 0;
>
> -static const int gdb_en_main = 54;
> +static const int gdb_en_main = 68;
>
>
> -#line 124 "src/gdb_parser.rl"
> +#line 130 "src/gdb_parser.rl"
>
>  void parser_init(command_cb *callbacks)
>  {
>
> -#line 175 "src/gdb_parser.c"
> +#line 198 "src/gdb_parser.c"
>         {
>         cs = gdb_start;
>         }
>
> -#line 128 "src/gdb_parser.rl"
> +#line 134 "src/gdb_parser.rl"
>
>         command_callbacks = callbacks;
>  }
> @@ -187,7 +210,7 @@ int parse_buffer(char *buf, size_t len, void *priv)
>         char *pe = p + len;
>
>
> -#line 191 "src/gdb_parser.c"
> +#line 214 "src/gdb_parser.c"
>         {
>         int _klen;
>         unsigned int _trans;
> @@ -304,10 +327,12 @@ _match:
>                 /* *data should point to the CRC */
>                 if (crc != *data) {
>                         printf("CRC error cmd %d\n", cmd);
> -                       send_nack(priv);
> +                       if (ack_mode)
> +                               send_nack(priv);
>                 } else {
>                         PR_INFO("Cmd %d\n", cmd);
> -                       send_ack(priv);
> +                       if (ack_mode)
> +                               send_ack(priv);
>
>                         /* Push the response onto the stack */
>                         if (rsp)
> @@ -321,78 +346,82 @@ _match:
>         }
>         break;
>         case 5:
> -#line 62 "src/gdb_parser.rl"
> +#line 64 "src/gdb_parser.rl"
>         {cmd = GET_MEM;}
>         break;
>         case 6:
> -#line 67 "src/gdb_parser.rl"
> +#line 69 "src/gdb_parser.rl"
>         {cmd = PUT_MEM;}
>         break;
>         case 7:
> -#line 74 "src/gdb_parser.rl"
> +#line 76 "src/gdb_parser.rl"
>         {cmd = GET_GPRS;}
>         break;
>         case 8:
> -#line 76 "src/gdb_parser.rl"
> +#line 78 "src/gdb_parser.rl"
>         {cmd = GET_SPR;}
>         break;
>         case 9:
> -#line 79 "src/gdb_parser.rl"
> +#line 81 "src/gdb_parser.rl"
>         {cmd = STOP_REASON;}
>         break;
>         case 10:
> -#line 81 "src/gdb_parser.rl"
> +#line 83 "src/gdb_parser.rl"
>         {cmd = SET_THREAD;}
>         break;
>         case 11:
> -#line 83 "src/gdb_parser.rl"
> +#line 85 "src/gdb_parser.rl"
>         {cmd = DETACH;}
>         break;
>         case 12:
> -#line 87 "src/gdb_parser.rl"
> +#line 89 "src/gdb_parser.rl"
>         {rsp = "1";}
>         break;
>         case 13:
> -#line 88 "src/gdb_parser.rl"
> +#line 90 "src/gdb_parser.rl"
>         {rsp = "QC1";}
>         break;
>         case 14:
> -#line 89 "src/gdb_parser.rl"
> -       {rsp = "multiprocess+;vContSupported+";}
> +#line 91 "src/gdb_parser.rl"
> +       {rsp = "multiprocess+;vContSupported+;QStartNoAckMode+";}
>         break;
>         case 15:
> -#line 90 "src/gdb_parser.rl"
> +#line 92 "src/gdb_parser.rl"
>         {rsp = "m1l";}
>         break;
>         case 16:
>  #line 93 "src/gdb_parser.rl"
> -       {rsp = "vCont;c;C;s;S";}
> +       {rsp = "OK"; send_ack(priv); ack_mode = false;}
>         break;
>         case 17:
> -#line 94 "src/gdb_parser.rl"
> -       {cmd = V_CONTC;}
> +#line 96 "src/gdb_parser.rl"
> +       {rsp = "vCont;c;C;s;S";}
>         break;
>         case 18:
> -#line 95 "src/gdb_parser.rl"
> -       {cmd = V_CONTS;}
> +#line 97 "src/gdb_parser.rl"
> +       {cmd = V_CONTC;}
>         break;
>         case 19:
>  #line 98 "src/gdb_parser.rl"
> -       { if (command_callbacks) command_callbacks[INTERRUPT](stack, priv); PR_INFO("RAGEL:interrupt\n");}
> +       {cmd = V_CONTS;}
>         break;
>         case 20:
> -#line 105 "src/gdb_parser.rl"
> -       {PR_INFO("RAGEL:cmd\n");}
> +#line 101 "src/gdb_parser.rl"
> +       { if (command_callbacks) command_callbacks[INTERRUPT](stack, priv); PR_INFO("RAGEL:interrupt\n");}
>         break;
>         case 21:
> -#line 108 "src/gdb_parser.rl"
> -       {PR_INFO("RAGEL:ack\n");}
> +#line 109 "src/gdb_parser.rl"
> +       {PR_INFO("RAGEL:cmd\n");}
>         break;
>         case 22:
> -#line 109 "src/gdb_parser.rl"
> +#line 112 "src/gdb_parser.rl"
> +       {PR_INFO("RAGEL:ack\n");}
> +       break;
> +       case 23:
> +#line 113 "src/gdb_parser.rl"
>         {PR_INFO("RAGEL:nack\n");}
>         break;
> -#line 396 "src/gdb_parser.c"
> +#line 425 "src/gdb_parser.c"
>                 }
>         }
>
> @@ -405,7 +434,7 @@ _again:
>         _out: {}
>         }
>
> -#line 138 "src/gdb_parser.rl"
> +#line 144 "src/gdb_parser.rl"
>
>         if (cs == gdb_error) {
>                 printf("parse error\n");
> --
> 2.23.0
>
> --
> Pdbg mailing list
> Pdbg@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/pdbg
diff mbox series

Patch

diff --git a/src/gdb_parser.rl b/src/gdb_parser.rl
index daa4167..f7f9a54 100644
--- a/src/gdb_parser.rl
+++ b/src/gdb_parser.rl
@@ -43,10 +43,12 @@ 
 		/* *data should point to the CRC */
 		if (crc != *data) {
 			printf("CRC error cmd %d\n", cmd);
-			send_nack(priv);
+			if (ack_mode)
+				send_nack(priv);
 		} else {
 			PR_INFO("Cmd %d\n", cmd);
-			send_ack(priv);
+			if (ack_mode)
+				send_ack(priv);
 
 			/* Push the response onto the stack */
 			if (rsp)
@@ -86,8 +88,9 @@ 
 	# TODO: We don't actually listen to what's supported
 	q_attached = ('qAttached:' xdigit* @{rsp = "1";});
 	q_C = ('qC' @{rsp = "QC1";});
-	q_supported = ('qSupported:' (any & ^'#')* >{rsp = "multiprocess+;vContSupported+";});
+	q_supported = ('qSupported:' (any & ^'#')* >{rsp = "multiprocess+;vContSupported+;QStartNoAckMode+";});
 	qf_threadinfo = ('qfThreadInfo' @{rsp = "m1l";});
+	q_start_noack = ('QStartNoAckMode' @{rsp = "OK"; send_ack(priv); ack_mode = false;});
 
 	# vCont packet parsing
 	v_contq = ('vCont?' @{rsp = "vCont;c;C;s;S";});
@@ -99,7 +102,8 @@ 
 
 	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 | detach | unknown );
+		    q_start_noack | v_contq | v_contc | v_conts | put_mem |
+		    detach | unknown );
 
 	cmd = (('$' ((commands & ^'#'*) >reset $crc)
 	      ('#' xdigit{2} $hex_digit @end)) >{PR_INFO("RAGEL:cmd\n");});
@@ -120,6 +124,8 @@  static int cs;
 
 static command_cb *command_callbacks;
 
+static bool ack_mode = true;
+
 %%write data;
 
 void parser_init(command_cb *callbacks)
diff --git a/src/gdb_parser_precompile.c b/src/gdb_parser_precompile.c
index b8cdbc1..b02ebf0 100644
--- a/src/gdb_parser_precompile.c
+++ b/src/gdb_parser_precompile.c
@@ -10,7 +10,7 @@ 
 #include "debug.h"
 
 
-#line 113 "src/gdb_parser.rl"
+#line 117 "src/gdb_parser.rl"
 
 
 static enum gdb_command cmd = NONE;
@@ -21,162 +21,185 @@  static int cs;
 
 static command_cb *command_callbacks;
 
+static bool ack_mode = true;
+
 
-#line 26 "src/gdb_parser.c"
+#line 28 "src/gdb_parser.c"
 static const char _gdb_actions[] = {
 	0, 1, 0, 1, 1, 1, 2, 1, 
-	3, 1, 14, 1, 19, 1, 20, 1, 
-	21, 1, 22, 2, 0, 1, 2, 2, 
+	3, 1, 14, 1, 20, 1, 21, 1, 
+	22, 1, 23, 2, 0, 1, 2, 2, 
 	1, 2, 3, 1, 2, 3, 4, 2, 
 	6, 1, 2, 10, 1, 2, 12, 1, 
 	2, 13, 1, 2, 14, 1, 2, 15, 
 	1, 2, 16, 1, 2, 17, 1, 2, 
-	18, 1, 3, 0, 5, 1, 3, 0, 
-	7, 1, 3, 0, 8, 1, 3, 0, 
-	9, 1, 3, 0, 11, 1, 3, 6, 
-	2, 1, 3, 6, 3, 1
+	18, 1, 2, 19, 1, 3, 0, 5, 
+	1, 3, 0, 7, 1, 3, 0, 8, 
+	1, 3, 0, 9, 1, 3, 0, 11, 
+	1, 3, 6, 2, 1, 3, 6, 3, 
+	1
 };
 
 static const unsigned char _gdb_key_offsets[] = {
-	0, 0, 10, 11, 17, 23, 30, 37, 
-	38, 45, 53, 60, 69, 76, 84, 91, 
-	99, 104, 106, 108, 110, 112, 114, 116, 
-	118, 120, 127, 129, 131, 133, 135, 137, 
-	139, 141, 143, 145, 146, 148, 150, 152, 
-	154, 156, 158, 160, 162, 164, 166, 168, 
-	170, 172, 174, 177, 180, 181, 182
+	0, 0, 11, 12, 18, 24, 31, 38, 
+	39, 46, 54, 61, 70, 77, 85, 87, 
+	89, 91, 93, 95, 97, 99, 101, 103, 
+	105, 107, 109, 111, 113, 120, 128, 133, 
+	135, 137, 139, 141, 143, 145, 147, 149, 
+	156, 158, 160, 162, 164, 166, 168, 170, 
+	172, 174, 175, 177, 179, 181, 183, 185, 
+	187, 189, 191, 193, 195, 197, 199, 201, 
+	203, 206, 209, 210, 211
 };
 
 static const char _gdb_trans_keys[] = {
-	35, 63, 68, 72, 77, 103, 109, 112, 
-	113, 118, 35, 48, 57, 65, 70, 97, 
-	102, 48, 57, 65, 70, 97, 102, 35, 
+	35, 63, 68, 72, 77, 81, 103, 109, 
+	112, 113, 118, 35, 48, 57, 65, 70, 
+	97, 102, 48, 57, 65, 70, 97, 102, 
+	35, 48, 57, 65, 70, 97, 102, 35, 
+	48, 57, 65, 70, 97, 102, 35, 35, 
+	48, 57, 65, 70, 97, 102, 35, 44, 
+	48, 57, 65, 70, 97, 102, 35, 48, 
+	57, 65, 70, 97, 102, 35, 44, 58, 
 	48, 57, 65, 70, 97, 102, 35, 48, 
-	57, 65, 70, 97, 102, 35, 35, 48, 
 	57, 65, 70, 97, 102, 35, 44, 48, 
-	57, 65, 70, 97, 102, 35, 48, 57, 
-	65, 70, 97, 102, 35, 44, 58, 48, 
-	57, 65, 70, 97, 102, 35, 48, 57, 
-	65, 70, 97, 102, 35, 44, 48, 57, 
-	65, 70, 97, 102, 35, 48, 57, 65, 
-	70, 97, 102, 35, 44, 48, 57, 65, 
-	70, 97, 102, 35, 65, 67, 83, 102, 
-	35, 116, 35, 116, 35, 97, 35, 99, 
-	35, 104, 35, 101, 35, 100, 35, 58, 
-	35, 48, 57, 65, 70, 97, 102, 35, 
-	117, 35, 112, 35, 112, 35, 111, 35, 
-	114, 35, 116, 35, 101, 35, 100, 35, 
-	58, 35, 35, 84, 35, 104, 35, 114, 
-	35, 101, 35, 97, 35, 100, 35, 73, 
-	35, 110, 35, 102, 35, 111, 35, 67, 
-	35, 111, 35, 110, 35, 116, 35, 59, 
-	63, 35, 99, 115, 35, 35, 3, 36, 
-	43, 45, 0
+	57, 65, 70, 97, 102, 35, 83, 35, 
+	116, 35, 97, 35, 114, 35, 116, 35, 
+	78, 35, 111, 35, 65, 35, 99, 35, 
+	107, 35, 77, 35, 111, 35, 100, 35, 
+	101, 35, 48, 57, 65, 70, 97, 102, 
+	35, 44, 48, 57, 65, 70, 97, 102, 
+	35, 65, 67, 83, 102, 35, 116, 35, 
+	116, 35, 97, 35, 99, 35, 104, 35, 
+	101, 35, 100, 35, 58, 35, 48, 57, 
+	65, 70, 97, 102, 35, 117, 35, 112, 
+	35, 112, 35, 111, 35, 114, 35, 116, 
+	35, 101, 35, 100, 35, 58, 35, 35, 
+	84, 35, 104, 35, 114, 35, 101, 35, 
+	97, 35, 100, 35, 73, 35, 110, 35, 
+	102, 35, 111, 35, 67, 35, 111, 35, 
+	110, 35, 116, 35, 59, 63, 35, 99, 
+	115, 35, 35, 3, 36, 43, 45, 0
 };
 
 static const char _gdb_single_lengths[] = {
-	0, 10, 1, 0, 0, 1, 1, 1, 
-	1, 2, 1, 3, 1, 2, 1, 2, 
-	5, 2, 2, 2, 2, 2, 2, 2, 
+	0, 11, 1, 0, 0, 1, 1, 1, 
+	1, 2, 1, 3, 1, 2, 2, 2, 
+	2, 2, 2, 2, 2, 2, 2, 2, 
+	2, 2, 2, 2, 1, 2, 5, 2, 
+	2, 2, 2, 2, 2, 2, 2, 1, 
+	2, 2, 2, 2, 2, 2, 2, 2, 
 	2, 1, 2, 2, 2, 2, 2, 2, 
-	2, 2, 2, 1, 2, 2, 2, 2, 
 	2, 2, 2, 2, 2, 2, 2, 2, 
-	2, 2, 3, 3, 1, 1, 4
+	3, 3, 1, 1, 4
 };
 
 static const char _gdb_range_lengths[] = {
 	0, 0, 0, 3, 3, 3, 3, 0, 
-	3, 3, 3, 3, 3, 3, 3, 3, 
+	3, 3, 3, 3, 3, 3, 0, 0, 
+	0, 0, 0, 0, 0, 0, 0, 0, 
+	0, 0, 0, 0, 3, 3, 0, 0, 
+	0, 0, 0, 0, 0, 0, 0, 3, 
 	0, 0, 0, 0, 0, 0, 0, 0, 
-	0, 3, 0, 0, 0, 0, 0, 0, 
 	0, 0, 0, 0, 0, 0, 0, 0, 
 	0, 0, 0, 0, 0, 0, 0, 0, 
-	0, 0, 0, 0, 0, 0, 0
+	0, 0, 0, 0, 0
 };
 
-static const unsigned char _gdb_index_offsets[] = {
-	0, 0, 11, 13, 17, 21, 26, 31, 
-	33, 38, 44, 49, 56, 61, 67, 72, 
-	78, 84, 87, 90, 93, 96, 99, 102, 
-	105, 108, 113, 116, 119, 122, 125, 128, 
-	131, 134, 137, 140, 142, 145, 148, 151, 
-	154, 157, 160, 163, 166, 169, 172, 175, 
-	178, 181, 184, 188, 192, 194, 196
+static const short _gdb_index_offsets[] = {
+	0, 0, 12, 14, 18, 22, 27, 32, 
+	34, 39, 45, 50, 57, 62, 68, 71, 
+	74, 77, 80, 83, 86, 89, 92, 95, 
+	98, 101, 104, 107, 110, 115, 121, 127, 
+	130, 133, 136, 139, 142, 145, 148, 151, 
+	156, 159, 162, 165, 168, 171, 174, 177, 
+	180, 183, 185, 188, 191, 194, 197, 200, 
+	203, 206, 209, 212, 215, 218, 221, 224, 
+	227, 231, 235, 237, 239
 };
 
 static const char _gdb_indicies[] = {
 	1, 2, 3, 4, 5, 6, 7, 8, 
-	9, 10, 0, 12, 11, 13, 13, 13, 
-	14, 15, 15, 15, 14, 12, 16, 16, 
-	16, 11, 17, 16, 16, 16, 11, 12, 
-	18, 12, 20, 20, 20, 19, 12, 21, 
-	20, 20, 20, 19, 12, 22, 22, 22, 
-	19, 12, 21, 23, 22, 22, 22, 19, 
-	12, 24, 24, 24, 19, 17, 21, 24, 
-	24, 24, 19, 12, 25, 25, 25, 11, 
-	12, 26, 25, 25, 25, 11, 12, 27, 
-	28, 29, 30, 11, 12, 31, 11, 12, 
-	32, 11, 12, 33, 11, 12, 34, 11, 
-	12, 35, 11, 12, 36, 11, 12, 37, 
-	11, 12, 38, 11, 12, 39, 39, 39, 
-	11, 12, 40, 11, 12, 41, 11, 12, 
-	42, 11, 12, 43, 11, 12, 44, 11, 
-	12, 45, 11, 12, 46, 11, 12, 47, 
-	11, 12, 48, 11, 50, 49, 12, 51, 
-	11, 12, 52, 11, 12, 53, 11, 12, 
-	54, 11, 12, 55, 11, 12, 56, 11, 
-	12, 57, 11, 12, 58, 11, 12, 59, 
-	11, 12, 60, 11, 12, 61, 11, 12, 
-	62, 11, 12, 63, 11, 12, 64, 11, 
-	12, 65, 66, 11, 12, 67, 68, 11, 
-	12, 69, 12, 70, 71, 72, 73, 74, 
-	14, 0
+	9, 10, 11, 0, 13, 12, 14, 14, 
+	14, 15, 16, 16, 16, 15, 13, 17, 
+	17, 17, 12, 18, 17, 17, 17, 12, 
+	13, 19, 13, 21, 21, 21, 20, 13, 
+	22, 21, 21, 21, 20, 13, 23, 23, 
+	23, 20, 13, 22, 24, 23, 23, 23, 
+	20, 13, 25, 25, 25, 20, 18, 22, 
+	25, 25, 25, 20, 13, 26, 12, 13, 
+	27, 12, 13, 28, 12, 13, 29, 12, 
+	13, 30, 12, 13, 31, 12, 13, 32, 
+	12, 13, 33, 12, 13, 34, 12, 13, 
+	35, 12, 13, 36, 12, 13, 37, 12, 
+	13, 38, 12, 13, 39, 12, 13, 40, 
+	40, 40, 12, 13, 41, 40, 40, 40, 
+	12, 13, 42, 43, 44, 45, 12, 13, 
+	46, 12, 13, 47, 12, 13, 48, 12, 
+	13, 49, 12, 13, 50, 12, 13, 51, 
+	12, 13, 52, 12, 13, 53, 12, 13, 
+	54, 54, 54, 12, 13, 55, 12, 13, 
+	56, 12, 13, 57, 12, 13, 58, 12, 
+	13, 59, 12, 13, 60, 12, 13, 61, 
+	12, 13, 62, 12, 13, 63, 12, 65, 
+	64, 13, 66, 12, 13, 67, 12, 13, 
+	68, 12, 13, 69, 12, 13, 70, 12, 
+	13, 71, 12, 13, 72, 12, 13, 73, 
+	12, 13, 74, 12, 13, 75, 12, 13, 
+	76, 12, 13, 77, 12, 13, 78, 12, 
+	13, 79, 12, 13, 80, 81, 12, 13, 
+	82, 83, 12, 13, 84, 13, 85, 86, 
+	87, 88, 89, 15, 0
 };
 
 static const char _gdb_trans_targs[] = {
-	2, 3, 2, 5, 7, 8, 2, 14, 
-	5, 16, 46, 2, 3, 4, 0, 54, 
-	6, 3, 7, 8, 9, 10, 11, 12, 
-	13, 15, 5, 17, 2, 26, 36, 18, 
-	19, 20, 21, 22, 23, 24, 25, 25, 
-	27, 28, 29, 30, 31, 32, 33, 34, 
-	35, 2, 3, 37, 38, 39, 40, 41, 
-	42, 43, 44, 45, 2, 47, 48, 49, 
-	50, 51, 2, 52, 53, 52, 53, 54, 
-	1, 54, 54
+	2, 3, 2, 5, 7, 8, 14, 2, 
+	28, 5, 30, 60, 2, 3, 4, 0, 
+	68, 6, 3, 7, 8, 9, 10, 11, 
+	12, 13, 15, 16, 17, 18, 19, 20, 
+	21, 22, 23, 24, 25, 26, 27, 2, 
+	29, 5, 31, 2, 40, 50, 32, 33, 
+	34, 35, 36, 37, 38, 39, 39, 41, 
+	42, 43, 44, 45, 46, 47, 48, 49, 
+	2, 3, 51, 52, 53, 54, 55, 56, 
+	57, 58, 59, 2, 61, 62, 63, 64, 
+	65, 2, 66, 67, 66, 67, 68, 1, 
+	68, 68
 };
 
 static const char _gdb_trans_actions[] = {
-	19, 1, 70, 74, 19, 19, 62, 58, 
-	66, 19, 19, 3, 0, 7, 0, 28, 
-	25, 5, 34, 31, 82, 78, 82, 78, 
-	82, 25, 22, 3, 40, 3, 3, 3, 
-	3, 3, 3, 3, 3, 3, 3, 37, 
+	19, 1, 73, 77, 19, 19, 19, 65, 
+	61, 69, 19, 19, 3, 0, 7, 0, 
+	28, 25, 5, 34, 31, 85, 81, 85, 
+	81, 85, 3, 3, 3, 3, 3, 3, 
+	3, 3, 3, 3, 3, 3, 3, 49, 
+	25, 22, 3, 40, 3, 3, 3, 3, 
+	3, 3, 3, 3, 3, 3, 37, 3, 
 	3, 3, 3, 3, 3, 3, 3, 3, 
-	3, 43, 9, 3, 3, 3, 3, 3, 
-	3, 3, 3, 3, 46, 3, 3, 3, 
-	3, 3, 49, 3, 3, 52, 55, 11, 
-	13, 15, 17
+	43, 9, 3, 3, 3, 3, 3, 3, 
+	3, 3, 3, 46, 3, 3, 3, 3, 
+	3, 52, 3, 3, 55, 58, 11, 13, 
+	15, 17
 };
 
-static const int gdb_start = 54;
-static const int gdb_first_final = 54;
+static const int gdb_start = 68;
+static const int gdb_first_final = 68;
 static const int gdb_error = 0;
 
-static const int gdb_en_main = 54;
+static const int gdb_en_main = 68;
 
 
-#line 124 "src/gdb_parser.rl"
+#line 130 "src/gdb_parser.rl"
 
 void parser_init(command_cb *callbacks)
 {
 	
-#line 175 "src/gdb_parser.c"
+#line 198 "src/gdb_parser.c"
 	{
 	cs = gdb_start;
 	}
 
-#line 128 "src/gdb_parser.rl"
+#line 134 "src/gdb_parser.rl"
 
 	command_callbacks = callbacks;
 }
@@ -187,7 +210,7 @@  int parse_buffer(char *buf, size_t len, void *priv)
 	char *pe = p + len;
 
 	
-#line 191 "src/gdb_parser.c"
+#line 214 "src/gdb_parser.c"
 	{
 	int _klen;
 	unsigned int _trans;
@@ -304,10 +327,12 @@  _match:
 		/* *data should point to the CRC */
 		if (crc != *data) {
 			printf("CRC error cmd %d\n", cmd);
-			send_nack(priv);
+			if (ack_mode)
+				send_nack(priv);
 		} else {
 			PR_INFO("Cmd %d\n", cmd);
-			send_ack(priv);
+			if (ack_mode)
+				send_ack(priv);
 
 			/* Push the response onto the stack */
 			if (rsp)
@@ -321,78 +346,82 @@  _match:
 	}
 	break;
 	case 5:
-#line 62 "src/gdb_parser.rl"
+#line 64 "src/gdb_parser.rl"
 	{cmd = GET_MEM;}
 	break;
 	case 6:
-#line 67 "src/gdb_parser.rl"
+#line 69 "src/gdb_parser.rl"
 	{cmd = PUT_MEM;}
 	break;
 	case 7:
-#line 74 "src/gdb_parser.rl"
+#line 76 "src/gdb_parser.rl"
 	{cmd = GET_GPRS;}
 	break;
 	case 8:
-#line 76 "src/gdb_parser.rl"
+#line 78 "src/gdb_parser.rl"
 	{cmd = GET_SPR;}
 	break;
 	case 9:
-#line 79 "src/gdb_parser.rl"
+#line 81 "src/gdb_parser.rl"
 	{cmd = STOP_REASON;}
 	break;
 	case 10:
-#line 81 "src/gdb_parser.rl"
+#line 83 "src/gdb_parser.rl"
 	{cmd = SET_THREAD;}
 	break;
 	case 11:
-#line 83 "src/gdb_parser.rl"
+#line 85 "src/gdb_parser.rl"
 	{cmd = DETACH;}
 	break;
 	case 12:
-#line 87 "src/gdb_parser.rl"
+#line 89 "src/gdb_parser.rl"
 	{rsp = "1";}
 	break;
 	case 13:
-#line 88 "src/gdb_parser.rl"
+#line 90 "src/gdb_parser.rl"
 	{rsp = "QC1";}
 	break;
 	case 14:
-#line 89 "src/gdb_parser.rl"
-	{rsp = "multiprocess+;vContSupported+";}
+#line 91 "src/gdb_parser.rl"
+	{rsp = "multiprocess+;vContSupported+;QStartNoAckMode+";}
 	break;
 	case 15:
-#line 90 "src/gdb_parser.rl"
+#line 92 "src/gdb_parser.rl"
 	{rsp = "m1l";}
 	break;
 	case 16:
 #line 93 "src/gdb_parser.rl"
-	{rsp = "vCont;c;C;s;S";}
+	{rsp = "OK"; send_ack(priv); ack_mode = false;}
 	break;
 	case 17:
-#line 94 "src/gdb_parser.rl"
-	{cmd = V_CONTC;}
+#line 96 "src/gdb_parser.rl"
+	{rsp = "vCont;c;C;s;S";}
 	break;
 	case 18:
-#line 95 "src/gdb_parser.rl"
-	{cmd = V_CONTS;}
+#line 97 "src/gdb_parser.rl"
+	{cmd = V_CONTC;}
 	break;
 	case 19:
 #line 98 "src/gdb_parser.rl"
-	{ if (command_callbacks) command_callbacks[INTERRUPT](stack, priv); PR_INFO("RAGEL:interrupt\n");}
+	{cmd = V_CONTS;}
 	break;
 	case 20:
-#line 105 "src/gdb_parser.rl"
-	{PR_INFO("RAGEL:cmd\n");}
+#line 101 "src/gdb_parser.rl"
+	{ if (command_callbacks) command_callbacks[INTERRUPT](stack, priv); PR_INFO("RAGEL:interrupt\n");}
 	break;
 	case 21:
-#line 108 "src/gdb_parser.rl"
-	{PR_INFO("RAGEL:ack\n");}
+#line 109 "src/gdb_parser.rl"
+	{PR_INFO("RAGEL:cmd\n");}
 	break;
 	case 22:
-#line 109 "src/gdb_parser.rl"
+#line 112 "src/gdb_parser.rl"
+	{PR_INFO("RAGEL:ack\n");}
+	break;
+	case 23:
+#line 113 "src/gdb_parser.rl"
 	{PR_INFO("RAGEL:nack\n");}
 	break;
-#line 396 "src/gdb_parser.c"
+#line 425 "src/gdb_parser.c"
 		}
 	}
 
@@ -405,7 +434,7 @@  _again:
 	_out: {}
 	}
 
-#line 138 "src/gdb_parser.rl"
+#line 144 "src/gdb_parser.rl"
 
 	if (cs == gdb_error) {
 		printf("parse error\n");