[Pdbg] [PATCH v2 02/39] gdbserver: add a 'generated' make target, update gdb_parser_precompile.c

Nicholas Piggin npiggin at gmail.com
Wed Apr 20 16:49:36 AEST 2022


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

Update the file to fix this.

Add a 'generated' target that can recreate shipped generated files like
this.

Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
 Makefile.am                 |  12 ++
 README.md                   |   7 ++
 src/gdb_parser_precompile.c | 233 ++++++++++++++++++------------------
 3 files changed, 138 insertions(+), 114 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 90a2ff3c..4f7cdbdf 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -339,4 +339,16 @@ p9z-fsi.dts: p9z-fsi.dts.m4 p9-fsi.dtsi
 %.c: %.rl
 	$(RAGEL_V)$(RAGEL) -o $@ $<
 
+generated_targets =
+if HAVE_RAGEL
+generated_targets += src/gdb_parser_precompile.c
+
+src/gdb_parser_precompile.c: src/gdb_parser.rl FORCE
+	$(RAGEL_V)$(RAGEL) -o $@ $<
+endif
+
+generated: $(generated_targets)
+
 MOSTLYCLEANFILES = *.dtb.S *.dtb $(DT) *.dt.h p9-fsi.dtsi src/gdb_parser.c
+
+FORCE:
diff --git a/README.md b/README.md
index 316976e8..40450e43 100644
--- a/README.md
+++ b/README.md
@@ -39,6 +39,13 @@ make
 rsync pdbg root at bmc:/usr/local/bin
 ```
 
+### Updating generated files
+
+Some generated files are shipped with the source to reduce the toolchain
+requirement for builds. Currently src/gdb_parser.rl creates
+src/gdb_parser_precompile.c so that needs to be updated if the .rl file is
+changed. `make generated` to update such generated files.
+
 ## Testing
 
 There is a test suite to perform some basic testing. The tests on the host
diff --git a/src/gdb_parser_precompile.c b/src/gdb_parser_precompile.c
index 715cdd7f..6012a271 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;
@@ -20,7 +20,7 @@ static int cs;
 command_cb *command_callbacks;
 
 
-#line 24 "src/gdb_parser.c"
+#line 24 "src/gdb_parser_precompile.c"
 static const char _gdb_actions[] = {
 	0, 1, 0, 1, 1, 1, 2, 1, 
 	3, 2, 1, 0, 2, 2, 1, 2, 
@@ -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
 };
 
 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, 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, 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, 3, 
+	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, 
@@ -88,7 +88,7 @@ static const char _gdb_single_lengths[] = {
 
 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, 0, 3, 3, 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, 
@@ -98,71 +98,72 @@ static const char _gdb_range_lengths[] = {
 };
 
 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, 
+	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
 };
 
 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, 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
 };
 
 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
+	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
 };
 
 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, 
+	0, 63, 1, 3, 0, 3, 33, 39, 
+	3, 3, 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, 
-	3, 48, 3, 3, 3, 3, 3, 51, 
-	3, 3, 54, 57
+	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;
@@ -172,17 +173,17 @@ static const int gdb_error = 0;
 static const int gdb_en_main = 58;
 
 
-#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 182 "src/gdb_parser_precompile.c"
 	{
 	cs = gdb_start;
 	}
 
-#line 120 "src/gdb_parser.rl"
+#line 123 "src/gdb_parser.rl"
 
 	command_callbacks = callbacks;
 }
@@ -193,7 +194,7 @@ int parse_buffer(char *buf, size_t len, void *priv)
 	char *pe = p + len + 1;
 
 	
-#line 197 "src/gdb_parser.c"
+#line 198 "src/gdb_parser_precompile.c"
 	{
 	int _klen;
 	unsigned int _trans;
@@ -349,38 +350,42 @@ _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"
+#line 389 "src/gdb_parser_precompile.c"
 		}
 	}
 
@@ -393,7 +398,7 @@ _again:
 	_out: {}
 	}
 
-#line 130 "src/gdb_parser.rl"
+#line 133 "src/gdb_parser.rl"
 
 	return 0;
 }
-- 
2.35.1



More information about the Pdbg mailing list