Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 23 Mar 2004 23:21:56 -0800 (PST)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 49613 for review
Message-ID:  <200403240721.i2O7Lu8B073298@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=49613

Change 49613 by marcel@marcel_nfs on 2004/03/23 23:21:00

	Implement run-length encoding. For platforms with a large amount
	of register data (like ia64), this can be a major booster. On
	ia64 it will be, because the high FP registers (96 registers, each
	16 bytes) are most of the time zeroes. Instead of pumping 3072
	characters over the link, we can compress that to 96 characters in
	case they are all zero.

Affected files ...

.. //depot/projects/gdb/sys/gdb/gdb_packet.c#5 edit

Differences ...

==== //depot/projects/gdb/sys/gdb/gdb_packet.c#5 (text+ko) ====

@@ -158,6 +158,7 @@
 gdb_tx_end(void)
 {
 	const char *p;
+	int runlen;
 	unsigned char c, cksum;
 
 	do {
@@ -166,8 +167,51 @@
 		cksum = 0;
 		p = gdb_txbuf;
 		while (p < gdb_txp) {
-			gdb_cur->gdb_putc(*p);
-			cksum += *p++;
+			/* Send a character and start run-length encoding. */
+			c = *p++;
+			gdb_cur->gdb_putc(c);
+			cksum += c;
+			runlen = 0;
+			/* Determine run-length and update checksum. */
+			while (p < gdb_txp && *p == c) {
+				runlen++;
+				p++;
+			}
+			/* Emit the run-length encoded string. */
+			while (runlen >= 97) {
+				gdb_cur->gdb_putc('*');
+				cksum += '*';
+				gdb_cur->gdb_putc(97+29);
+				cksum += 97+29;
+				runlen -= 97;
+				if (runlen > 0) {
+					gdb_cur->gdb_putc(c);
+					cksum += c;
+					runlen--;
+				}
+			}
+			if (runlen == 1) {
+				gdb_cur->gdb_putc(c);
+				cksum += c;
+				runlen--;
+			}
+			if (runlen == 0)
+				continue;
+			/* Don't emit '$', '#', '+' or '-'. */
+			if (runlen == 7) {
+				gdb_cur->gdb_putc(c);
+				cksum += c;
+				runlen--;
+			}
+			if (runlen == 6 || runlen == 14 || runlen == 16) {
+				gdb_cur->gdb_putc(c);
+				cksum += c;
+				runlen--;
+			}
+			gdb_cur->gdb_putc('*');
+			cksum += '*';
+			gdb_cur->gdb_putc(runlen+29);
+			cksum += runlen+29;
 		}
 
 		gdb_cur->gdb_putc('#');



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403240721.i2O7Lu8B073298>