diff mbox series

[v2,04/39] gdbserver: fix put_mem command parsing

Message ID 20220420065013.222816-5-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
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 | 139 +++++++++++++++++-------------------
 2 files changed, 68 insertions(+), 73 deletions(-)
diff mbox series

Patch

diff --git a/src/gdb_parser.rl b/src/gdb_parser.rl
index 93213e4f..629a091c 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 e0df0051..734b0f8b 100644
--- a/src/gdb_parser_precompile.c
+++ b/src/gdb_parser_precompile.c
@@ -30,19 +30,18 @@  static const char _gdb_actions[] = {
 	11, 1, 2, 12, 1, 2, 13, 1, 
 	2, 14, 1, 2, 15, 1, 2, 16, 
 	1, 2, 17, 1, 2, 18, 1, 2, 
-	19, 0, 3, 1, 19, 0, 3, 6, 
-	2, 1, 3, 6, 3, 1
+	19, 0, 3, 1, 19, 0
 };
 
 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
+	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[] = {
@@ -56,9 +55,7 @@  static const char _gdb_trans_keys[] = {
 	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, 58, 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, 
@@ -77,35 +74,35 @@  static const char _gdb_trans_keys[] = {
 
 static const char _gdb_single_lengths[] = {
 	0, 2, 12, 1, 0, 0, 3, 2, 
-	2, 1, 1, 1, 1, 2, 1, 3, 
-	1, 2, 1, 2, 5, 2, 2, 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, 3, 3, 0, 3, 3, 3, 3, 
-	3, 3, 3, 3, 0, 0, 0, 0, 
-	0, 0, 0, 0, 0, 3, 0, 0, 
+	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, 16, 18, 22, 26, 30, 
 	36, 42, 47, 52, 54, 59, 65, 70, 
-	77, 82, 88, 93, 99, 105, 108, 111, 
-	114, 117, 120, 123, 126, 129, 134, 137, 
-	140, 143, 146, 149, 152, 155, 158, 161, 
-	163, 166, 169, 172, 175, 178, 181, 184, 
-	187, 190, 193, 196, 199, 202, 205, 209, 
-	213, 215, 217, 220
+	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[] = {
@@ -115,62 +112,60 @@  static const char _gdb_indicies[] = {
 	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, 27, 
-	27, 27, 26, 4, 28, 27, 27, 27, 
-	26, 4, 29, 29, 29, 26, 4, 28, 
-	30, 29, 29, 29, 26, 4, 31, 31, 
-	31, 26, 24, 28, 31, 31, 31, 26, 
-	4, 32, 32, 32, 3, 4, 33, 32, 
-	32, 32, 3, 4, 34, 35, 36, 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, 
-	3, 4, 46, 46, 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, 
-	3, 4, 56, 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, 3, 4, 71, 72, 
-	3, 4, 73, 74, 3, 4, 75, 4, 
-	76, 1, 2, 0, 19, 20, 21, 18, 
-	0
+	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, 
-	11, 12, 3, 18, 9, 20, 50, 5, 
-	0, 58, 6, 2, 7, 2, 8, 10, 
-	4, 11, 12, 13, 14, 15, 16, 17, 
-	19, 9, 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, 63, 1, 3, 0, 3, 33, 39, 
-	3, 3, 27, 21, 30, 3, 3, 7, 
+	3, 24, 27, 21, 30, 3, 3, 7, 
 	0, 18, 3, 66, 0, 9, 7, 15, 
-	5, 36, 24, 74, 70, 74, 70, 74, 
-	15, 12, 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
+	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 119 "src/gdb_parser.rl"
@@ -178,7 +173,7 @@  static const int gdb_en_main = 58;
 void parser_init(command_cb *callbacks)
 {
 	
-#line 182 "src/gdb_parser_precompile.c"
+#line 177 "src/gdb_parser_precompile.c"
 	{
 	cs = gdb_start;
 	}
@@ -194,7 +189,7 @@  int parse_buffer(char *buf, size_t len, void *priv)
 	char *pe = p + len + 1;
 
 	
-#line 198 "src/gdb_parser_precompile.c"
+#line 193 "src/gdb_parser_precompile.c"
 	{
 	int _klen;
 	unsigned int _trans;
@@ -385,7 +380,7 @@  _match:
 #line 93 "src/gdb_parser.rl"
 	{command_callbacks[INTERRUPT](stack, priv);}
 	break;
-#line 389 "src/gdb_parser_precompile.c"
+#line 384 "src/gdb_parser_precompile.c"
 		}
 	}