Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Jun 2004 01:14:21 GMT
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 54878 for review
Message-ID:  <200406140114.i5E1EL5v022541@repoman.freebsd.org>

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

Change 54878 by marcel@marcel_nfs on 2004/06/14 01:13:22

	Make it possible to synthesize information. Synthesized info
	does not live in the core file and thus should not be fetched
	with kvm_read first. The implementation is a bit primitive,
	but it's not clear how frequently it's needed, let alone how
	complex the use cases can get.

Affected files ...

.. //depot/projects/gdb/usr.bin/kgdb/kgdb.h#8 edit
.. //depot/projects/gdb/usr.bin/kgdb/packet.c#6 edit

Differences ...

==== //depot/projects/gdb/usr.bin/kgdb/kgdb.h#8 (text+ko) ====

@@ -27,6 +27,8 @@
 #ifndef _KGDB_H_
 #define	_KGDB_H_
 
+extern unsigned char gdb_membuf[];
+
 extern char *gdb_rxp;
 extern size_t gdb_rxsz;
 extern char *gdb_txp;

==== //depot/projects/gdb/usr.bin/kgdb/packet.c#6 (text+ko) ====

@@ -56,6 +56,8 @@
 	    10 + (((c) < 'a') ? (c) - 'A' : (c) - 'a'))
 #define	N2C(n)	(((n) < 10) ? (n) + '0' : (n) + 'a' - 10)
 
+unsigned char gdb_membuf[256];
+
 static int
 gdb_packet(void)
 {
@@ -318,21 +320,24 @@
 int
 gdb_tx_mem(const unsigned char *addr, size_t size)
 {
-	unsigned char sbuf[256];
 	unsigned char *dbuf, *p;
 	ssize_t res;
 
-	dbuf = (size > sizeof(sbuf)) ? malloc(size) : sbuf;
-	res = kvm_read(kvm, (unsigned long)addr, dbuf, size);
-	if (res != (ssize_t)size)
-		return (0);
+	if (addr != gdb_membuf) {
+		dbuf = (size > sizeof(gdb_membuf)) ? malloc(size) : gdb_membuf;
+		res = kvm_read(kvm, (unsigned long)addr, dbuf, size);
+		if (res != (ssize_t)size)
+			return (0);
+	} else
+		dbuf = (unsigned char *)(uintptr_t)addr;
+
 	p = dbuf;
 	while (size-- > 0) {
 		*gdb_txp++ = N2C(*p >> 4);
 		*gdb_txp++ = N2C(*p & 0x0f);
 		p++;
 	}
-	if (dbuf != sbuf)
+	if (dbuf != gdb_membuf)
 		free(dbuf);
 	return (1);
 }



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