diff mbox series

[v2,01/38] gdbserver: fix put_mem command parsing

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

Commit Message

Nicholas Piggin March 29, 2022, 3:48 p.m. UTC
The 'M' gdb command (put_mem) should not match characters after
the 'M' which are not part of the first hex number matching.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 src/gdb_parser.rl           |   2 +-
 src/gdb_parser_precompile.c | 248 ++++++++++++++++++------------------
 2 files changed, 125 insertions(+), 125 deletions(-)
diff mbox series

Patch

diff --git a/src/gdb_parser.rl b/src/gdb_parser.rl
index 6259b96..868e31c 100644
--- a/src/gdb_parser.rl
+++ b/src/gdb_parser.rl
@@ -60,7 +60,7 @@ 
 		   ','
 		   xdigit+ $hex_digit %push);
 
-	put_mem = ('M' any* @{cmd = PUT_MEM;}
+	put_mem = ('M' @{cmd = PUT_MEM;}
 		   xdigit+ $hex_digit %push
 		   ','
 		   xdigit+ $hex_digit %push
diff --git a/src/gdb_parser_precompile.c b/src/gdb_parser_precompile.c
index 715cdd7..505e102 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,160 +29,156 @@  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
 };
 
-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, 
+	91, 98, 106, 111, 113, 115, 117, 119, 
+	121, 123, 125, 127, 134, 136, 138, 140, 
+	142, 144, 146, 148, 150, 152, 153, 155, 
+	157, 159, 161, 163, 165, 167, 169, 171, 
+	173, 175, 177, 179, 181, 184, 187, 188, 
+	189, 191
 };
 
 static const char _gdb_trans_keys[] = {
-	3, 36, 35, 43, 45, 63, 72, 77, 
-	103, 109, 112, 113, 118, 35, 48, 57, 
-	65, 70, 97, 102, 48, 57, 65, 70, 
-	97, 102, 3, 35, 36, 3, 36, 48, 
-	57, 65, 70, 97, 102, 3, 36, 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, 
+	3, 36, 35, 43, 45, 63, 68, 72, 
+	77, 103, 109, 112, 113, 118, 35, 48, 
+	57, 65, 70, 97, 102, 48, 57, 65, 
+	70, 97, 102, 3, 35, 36, 3, 36, 
+	48, 57, 65, 70, 97, 102, 3, 36, 
+	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, 48, 57, 65, 
+	70, 97, 102, 35, 58, 48, 57, 65, 
 	70, 97, 102, 35, 48, 57, 65, 70, 
-	97, 102, 35, 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, 3, 35, 
-	36, 0
+	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, 3, 
+	35, 36, 0
 };
 
 static const char _gdb_single_lengths[] = {
-	0, 2, 11, 1, 0, 0, 3, 2, 
-	2, 1, 1, 2, 1, 3, 1, 2, 
-	1, 2, 1, 1, 5, 2, 2, 2, 
+	0, 2, 12, 1, 0, 0, 3, 2, 
+	2, 1, 1, 1, 1, 2, 1, 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, 2, 3
+	2, 2, 2, 2, 3, 3, 1, 1, 
+	2, 3
 };
 
 static const char _gdb_range_lengths[] = {
 	0, 0, 0, 0, 3, 3, 0, 3, 
-	3, 0, 3, 3, 3, 3, 3, 3, 
-	3, 3, 3, 3, 0, 0, 0, 0, 
-	0, 0, 0, 0, 0, 3, 0, 0, 
+	3, 3, 3, 0, 3, 3, 3, 3, 
+	3, 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 short _gdb_index_offsets[] = {
-	0, 0, 3, 15, 17, 21, 25, 29, 
-	35, 41, 43, 48, 54, 59, 66, 71, 
-	77, 82, 88, 93, 98, 104, 107, 110, 
-	113, 116, 119, 122, 125, 128, 133, 136, 
-	139, 142, 145, 148, 151, 154, 157, 160, 
-	162, 165, 168, 171, 174, 177, 180, 183, 
-	186, 189, 192, 195, 198, 201, 204, 208, 
-	212, 214, 216, 219
+	0, 0, 3, 16, 18, 22, 26, 30, 
+	36, 42, 47, 52, 54, 59, 65, 70, 
+	76, 81, 87, 93, 96, 99, 102, 105, 
+	108, 111, 114, 117, 122, 125, 128, 131, 
+	134, 137, 140, 143, 146, 149, 151, 154, 
+	157, 160, 163, 166, 169, 172, 175, 178, 
+	181, 184, 187, 190, 193, 197, 201, 203, 
+	205, 208
 };
 
 static const char _gdb_indicies[] = {
 	1, 2, 0, 4, 5, 5, 6, 7, 
-	8, 9, 10, 11, 12, 13, 3, 4, 
-	3, 14, 14, 14, 15, 16, 16, 16, 
-	15, 18, 19, 20, 17, 1, 2, 21, 
-	21, 21, 0, 1, 2, 16, 16, 16, 
-	0, 4, 22, 4, 24, 24, 24, 23, 
-	4, 25, 24, 24, 24, 23, 4, 26, 
-	26, 26, 23, 4, 25, 27, 26, 26, 
-	26, 23, 4, 28, 28, 28, 23, 29, 
-	25, 28, 28, 28, 23, 4, 30, 30, 
-	30, 3, 4, 31, 30, 30, 30, 3, 
-	4, 32, 32, 32, 3, 29, 32, 32, 
-	32, 3, 4, 33, 34, 35, 36, 3, 
-	4, 37, 3, 4, 38, 3, 4, 39, 
-	3, 4, 40, 3, 4, 41, 3, 4, 
-	42, 3, 4, 43, 3, 4, 44, 3, 
-	4, 45, 45, 45, 3, 4, 46, 3, 
-	4, 47, 3, 4, 48, 3, 4, 49, 
-	3, 4, 50, 3, 4, 51, 3, 4, 
-	52, 3, 4, 53, 3, 4, 54, 3, 
-	4, 55, 4, 56, 3, 4, 57, 3, 
-	4, 58, 3, 4, 59, 3, 4, 60, 
-	3, 4, 61, 3, 4, 62, 3, 4, 
-	63, 3, 4, 64, 3, 4, 65, 3, 
-	4, 66, 3, 4, 67, 3, 4, 68, 
-	3, 4, 69, 3, 4, 70, 71, 3, 
-	4, 72, 73, 3, 4, 74, 4, 75, 
-	1, 2, 0, 18, 19, 20, 17, 0
+	8, 9, 10, 11, 12, 13, 14, 3, 
+	4, 3, 15, 15, 15, 16, 17, 17, 
+	17, 16, 19, 20, 21, 18, 1, 2, 
+	22, 22, 22, 0, 1, 2, 17, 17, 
+	17, 0, 4, 23, 23, 23, 3, 24, 
+	23, 23, 23, 3, 4, 25, 4, 26, 
+	26, 26, 3, 4, 27, 26, 26, 26, 
+	3, 4, 28, 28, 28, 3, 4, 29, 
+	28, 28, 28, 3, 4, 30, 30, 30, 
+	3, 4, 29, 30, 30, 30, 3, 4, 
+	31, 32, 33, 34, 3, 4, 35, 3, 
+	4, 36, 3, 4, 37, 3, 4, 38, 
+	3, 4, 39, 3, 4, 40, 3, 4, 
+	41, 3, 4, 42, 3, 4, 43, 43, 
+	43, 3, 4, 44, 3, 4, 45, 3, 
+	4, 46, 3, 4, 47, 3, 4, 48, 
+	3, 4, 49, 3, 4, 50, 3, 4, 
+	51, 3, 4, 52, 3, 4, 53, 4, 
+	54, 3, 4, 55, 3, 4, 56, 3, 
+	4, 57, 3, 4, 58, 3, 4, 59, 
+	3, 4, 60, 3, 4, 61, 3, 4, 
+	62, 3, 4, 63, 3, 4, 64, 3, 
+	4, 65, 3, 4, 66, 3, 4, 67, 
+	3, 4, 68, 69, 3, 4, 70, 71, 
+	3, 4, 72, 4, 73, 1, 2, 0, 
+	19, 20, 21, 18, 0
 };
 
 static const char _gdb_trans_targs[] = {
-	1, 2, 2, 3, 4, 59, 3, 9, 
-	10, 3, 16, 18, 20, 50, 5, 0, 
-	58, 6, 2, 7, 2, 8, 9, 10, 
-	11, 12, 13, 14, 15, 4, 17, 18, 
-	19, 21, 3, 30, 40, 22, 23, 24, 
-	25, 26, 27, 28, 29, 29, 31, 32, 
-	33, 34, 35, 36, 37, 38, 39, 39, 
-	41, 42, 43, 44, 45, 46, 47, 48, 
-	49, 3, 51, 52, 53, 54, 55, 3, 
-	56, 57, 56, 57
+	1, 2, 2, 3, 4, 57, 3, 9, 
+	11, 12, 3, 16, 9, 18, 48, 5, 
+	0, 56, 6, 2, 7, 2, 8, 10, 
+	4, 11, 13, 14, 15, 9, 17, 19, 
+	3, 28, 38, 20, 21, 22, 23, 24, 
+	25, 26, 27, 27, 29, 30, 31, 32, 
+	33, 34, 35, 36, 37, 37, 39, 40, 
+	41, 42, 43, 44, 45, 46, 47, 3, 
+	49, 50, 51, 52, 53, 3, 54, 55, 
+	54, 55
 };
 
 static const char _gdb_trans_actions[] = {
-	0, 60, 1, 3, 0, 3, 33, 3, 
-	3, 27, 21, 30, 3, 3, 7, 0, 
-	18, 3, 63, 0, 9, 7, 36, 24, 
-	71, 67, 71, 67, 71, 5, 15, 12, 
-	15, 3, 42, 3, 3, 3, 3, 3, 
-	3, 3, 3, 3, 3, 39, 3, 3, 
-	3, 3, 3, 3, 3, 3, 3, 45, 
-	3, 3, 3, 3, 3, 3, 3, 3, 
-	3, 48, 3, 3, 3, 3, 3, 51, 
-	3, 3, 54, 57
+	0, 63, 1, 3, 0, 3, 33, 39, 
+	3, 24, 27, 21, 30, 3, 3, 7, 
+	0, 18, 3, 66, 0, 9, 7, 15, 
+	5, 36, 15, 12, 15, 12, 15, 3, 
+	45, 3, 3, 3, 3, 3, 3, 3, 
+	3, 3, 3, 42, 3, 3, 3, 3, 
+	3, 3, 3, 3, 3, 48, 3, 3, 
+	3, 3, 3, 3, 3, 3, 3, 51, 
+	3, 3, 3, 3, 3, 54, 3, 3, 
+	57, 60
 };
 
-static const int gdb_start = 58;
-static const int gdb_first_final = 58;
+static const int gdb_start = 56;
+static const int gdb_first_final = 56;
 static const int gdb_error = 0;
 
-static const int gdb_en_main = 58;
+static const int gdb_en_main = 56;
 
 
-#line 116 "src/gdb_parser.rl"
+#line 119 "src/gdb_parser.rl"
 
 void parser_init(command_cb *callbacks)
 {
 	
-#line 181 "src/gdb_parser.c"
+#line 177 "src/gdb_parser.c"
 	{
 	cs = gdb_start;
 	}
 
-#line 120 "src/gdb_parser.rl"
+#line 123 "src/gdb_parser.rl"
 
 	command_callbacks = callbacks;
 }
@@ -193,7 +189,7 @@  int parse_buffer(char *buf, size_t len, void *priv)
 	char *pe = p + len + 1;
 
 	
-#line 197 "src/gdb_parser.c"
+#line 193 "src/gdb_parser.c"
 	{
 	int _klen;
 	unsigned int _trans;
@@ -349,35 +345,39 @@  _match:
 	{cmd = SET_THREAD;}
 	break;
 	case 11:
-#line 80 "src/gdb_parser.rl"
-	{rsp = "1";}
+#line 79 "src/gdb_parser.rl"
+	{cmd = DISCONNECT;}
 	break;
 	case 12:
-#line 81 "src/gdb_parser.rl"
-	{rsp = "QC1";}
+#line 83 "src/gdb_parser.rl"
+	{rsp = "1";}
 	break;
 	case 13:
-#line 82 "src/gdb_parser.rl"
-	{rsp = "multiprocess+;vContSupported+";}
+#line 84 "src/gdb_parser.rl"
+	{rsp = "QC1";}
 	break;
 	case 14:
-#line 83 "src/gdb_parser.rl"
-	{rsp = "m1l";}
+#line 85 "src/gdb_parser.rl"
+	{rsp = "multiprocess+;vContSupported+";}
 	break;
 	case 15:
 #line 86 "src/gdb_parser.rl"
-	{rsp = "vCont;c;C;s;S";}
+	{rsp = "m1l";}
 	break;
 	case 16:
-#line 87 "src/gdb_parser.rl"
-	{cmd = V_CONTC;}
+#line 89 "src/gdb_parser.rl"
+	{rsp = "vCont;c;C;s;S";}
 	break;
 	case 17:
-#line 88 "src/gdb_parser.rl"
-	{cmd = V_CONTS;}
+#line 90 "src/gdb_parser.rl"
+	{cmd = V_CONTC;}
 	break;
 	case 18:
-#line 90 "src/gdb_parser.rl"
+#line 91 "src/gdb_parser.rl"
+	{cmd = V_CONTS;}
+	break;
+	case 19:
+#line 93 "src/gdb_parser.rl"
 	{command_callbacks[INTERRUPT](stack, priv);}
 	break;
 #line 384 "src/gdb_parser.c"
@@ -393,7 +393,7 @@  _again:
 	_out: {}
 	}
 
-#line 130 "src/gdb_parser.rl"
+#line 133 "src/gdb_parser.rl"
 
 	return 0;
 }