This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[rfa/i386] Make codestream deprecated?
- From: Andrew Cagney <ac131313 at redhat dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Sun, 01 Dec 2002 19:37:43 -0500
- Subject: [rfa/i386] Make codestream deprecated?
Hello,
The attached is to make it clear that codestream isn't the way to go
when trying to improve GDB's performance. I don't see any urgency in
actually removing the code, though.
The codestream has been supperseeded by a dcache.
thoughts?
ok to commit?
Andrew
2002-12-01 Andrew Cagney <ac131313@redhat.com>
* i386-tdep.c: Replace `codestream' with `deprecated_codestream'.
Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.100
diff -u -r1.100 i386-tdep.c
--- i386-tdep.c 28 Nov 2002 18:15:58 -0000 1.100
+++ i386-tdep.c 2 Dec 2002 00:17:08 -0000
@@ -214,55 +214,55 @@
It probably needs the bfd library's help and support. For now, the
buffer size is set to 1. (FIXME -fnf) */
-#define CODESTREAM_BUFSIZ 1 /* Was sizeof(int), see note above. */
-static CORE_ADDR codestream_next_addr;
-static CORE_ADDR codestream_addr;
-static unsigned char codestream_buf[CODESTREAM_BUFSIZ];
-static int codestream_off;
-static int codestream_cnt;
-
-#define codestream_tell() (codestream_addr + codestream_off)
-#define codestream_peek() \
- (codestream_cnt == 0 ? \
- codestream_fill(1) : codestream_buf[codestream_off])
-#define codestream_get() \
- (codestream_cnt-- == 0 ? \
- codestream_fill(0) : codestream_buf[codestream_off++])
+#define DEPRECATED_CODESTREAM_BUFSIZ 1 /* Was sizeof(int), see note above. */
+static CORE_ADDR deprecated_codestream_next_addr;
+static CORE_ADDR deprecated_codestream_addr;
+static unsigned char deprecated_codestream_buf[DEPRECATED_CODESTREAM_BUFSIZ];
+static int deprecated_codestream_off;
+static int deprecated_codestream_cnt;
+
+#define deprecated_codestream_tell() (deprecated_codestream_addr + deprecated_codestream_off)
+#define deprecated_codestream_peek() \
+ (deprecated_codestream_cnt == 0 ? \
+ deprecated_codestream_fill(1) : deprecated_codestream_buf[deprecated_codestream_off])
+#define deprecated_codestream_get() \
+ (deprecated_codestream_cnt-- == 0 ? \
+ deprecated_codestream_fill(0) : deprecated_codestream_buf[deprecated_codestream_off++])
static unsigned char
-codestream_fill (int peek_flag)
+deprecated_codestream_fill (int peek_flag)
{
- codestream_addr = codestream_next_addr;
- codestream_next_addr += CODESTREAM_BUFSIZ;
- codestream_off = 0;
- codestream_cnt = CODESTREAM_BUFSIZ;
- read_memory (codestream_addr, (char *) codestream_buf, CODESTREAM_BUFSIZ);
+ deprecated_codestream_addr = deprecated_codestream_next_addr;
+ deprecated_codestream_next_addr += DEPRECATED_CODESTREAM_BUFSIZ;
+ deprecated_codestream_off = 0;
+ deprecated_codestream_cnt = DEPRECATED_CODESTREAM_BUFSIZ;
+ read_memory (deprecated_codestream_addr, (char *) deprecated_codestream_buf, DEPRECATED_CODESTREAM_BUFSIZ);
if (peek_flag)
- return (codestream_peek ());
+ return (deprecated_codestream_peek ());
else
- return (codestream_get ());
+ return (deprecated_codestream_get ());
}
static void
-codestream_seek (CORE_ADDR place)
+deprecated_codestream_seek (CORE_ADDR place)
{
- codestream_next_addr = place / CODESTREAM_BUFSIZ;
- codestream_next_addr *= CODESTREAM_BUFSIZ;
- codestream_cnt = 0;
- codestream_fill (1);
- while (codestream_tell () != place)
- codestream_get ();
+ deprecated_codestream_next_addr = place / DEPRECATED_CODESTREAM_BUFSIZ;
+ deprecated_codestream_next_addr *= DEPRECATED_CODESTREAM_BUFSIZ;
+ deprecated_codestream_cnt = 0;
+ deprecated_codestream_fill (1);
+ while (deprecated_codestream_tell () != place)
+ deprecated_codestream_get ();
}
static void
-codestream_read (unsigned char *buf, int count)
+deprecated_codestream_read (unsigned char *buf, int count)
{
unsigned char *p;
int i;
p = buf;
for (i = 0; i < count; i++)
- *p++ = codestream_get ();
+ *p++ = deprecated_codestream_get ();
}
@@ -277,22 +277,22 @@
int data16;
CORE_ADDR pos;
- pos = codestream_tell ();
+ pos = deprecated_codestream_tell ();
data16 = 0;
- if (codestream_peek () == 0x66)
+ if (deprecated_codestream_peek () == 0x66)
{
- codestream_get ();
+ deprecated_codestream_get ();
data16 = 1;
}
- switch (codestream_get ())
+ switch (deprecated_codestream_get ())
{
case 0xe9:
/* Relative jump: if data16 == 0, disp32, else disp16. */
if (data16)
{
- codestream_read (buf, 2);
+ deprecated_codestream_read (buf, 2);
delta = extract_signed_integer (buf, 2);
/* Include the size of the jmp instruction (including the
@@ -301,7 +301,7 @@
}
else
{
- codestream_read (buf, 4);
+ deprecated_codestream_read (buf, 4);
delta = extract_signed_integer (buf, 4);
pos += delta + 5;
@@ -309,32 +309,32 @@
break;
case 0xeb:
/* Relative jump, disp8 (ignore data16). */
- codestream_read (buf, 1);
+ deprecated_codestream_read (buf, 1);
/* Sign-extend it. */
delta = extract_signed_integer (buf, 1);
pos += delta + 2;
break;
}
- codestream_seek (pos);
+ deprecated_codestream_seek (pos);
}
/* Find & return the amount a local space allocated, and advance the
- codestream to the first register push (if any).
+ deprecated_codestream to the first register push (if any).
If the entry sequence doesn't make sense, return -1, and leave
- codestream pointer at a random spot. */
+ deprecated_codestream pointer at a random spot. */
static long
i386_get_frame_setup (CORE_ADDR pc)
{
unsigned char op;
- codestream_seek (pc);
+ deprecated_codestream_seek (pc);
i386_follow_jump ();
- op = codestream_get ();
+ op = deprecated_codestream_get ();
if (op == 0x58) /* popl %eax */
{
@@ -354,15 +354,15 @@
static unsigned char proto1[3] = { 0x87, 0x04, 0x24 };
static unsigned char proto2[4] = { 0x87, 0x44, 0x24, 0x00 };
- pos = codestream_tell ();
- codestream_read (buf, 4);
+ pos = deprecated_codestream_tell ();
+ deprecated_codestream_read (buf, 4);
if (memcmp (buf, proto1, 3) == 0)
pos += 3;
else if (memcmp (buf, proto2, 4) == 0)
pos += 4;
- codestream_seek (pos);
- op = codestream_get (); /* Update next opcode. */
+ deprecated_codestream_seek (pos);
+ op = deprecated_codestream_get (); /* Update next opcode. */
}
if (op == 0x68 || op == 0x6a)
@@ -383,33 +383,33 @@
/* Skip past the `pushl' instruction; it has either a one-byte
or a four-byte operand, depending on the opcode. */
- pos = codestream_tell ();
+ pos = deprecated_codestream_tell ();
if (op == 0x68)
pos += 4;
else
pos += 1;
- codestream_seek (pos);
+ deprecated_codestream_seek (pos);
/* Read the following 8 bytes, which should be "call _probe" (6
bytes) followed by "addl $4,%esp" (2 bytes). */
- codestream_read (buf, sizeof (buf));
+ deprecated_codestream_read (buf, sizeof (buf));
if (buf[0] == 0xe8 && buf[6] == 0xc4 && buf[7] == 0x4)
pos += sizeof (buf);
- codestream_seek (pos);
- op = codestream_get (); /* Update next opcode. */
+ deprecated_codestream_seek (pos);
+ op = deprecated_codestream_get (); /* Update next opcode. */
}
if (op == 0x55) /* pushl %ebp */
{
/* Check for "movl %esp, %ebp" -- can be written in two ways. */
- switch (codestream_get ())
+ switch (deprecated_codestream_get ())
{
case 0x8b:
- if (codestream_get () != 0xec)
+ if (deprecated_codestream_get () != 0xec)
return -1;
break;
case 0x89:
- if (codestream_get () != 0xe5)
+ if (deprecated_codestream_get () != 0xe5)
return -1;
break;
default:
@@ -421,34 +421,34 @@
NOTE: You can't subtract a 16 bit immediate from a 32 bit
reg, so we don't have to worry about a data16 prefix. */
- op = codestream_peek ();
+ op = deprecated_codestream_peek ();
if (op == 0x83)
{
/* `subl' with 8 bit immediate. */
- codestream_get ();
- if (codestream_get () != 0xec)
+ deprecated_codestream_get ();
+ if (deprecated_codestream_get () != 0xec)
/* Some instruction starting with 0x83 other than `subl'. */
{
- codestream_seek (codestream_tell () - 2);
+ deprecated_codestream_seek (deprecated_codestream_tell () - 2);
return 0;
}
/* `subl' with signed byte immediate (though it wouldn't
make sense to be negative). */
- return (codestream_get ());
+ return (deprecated_codestream_get ());
}
else if (op == 0x81)
{
char buf[4];
/* Maybe it is `subl' with a 32 bit immedediate. */
- codestream_get ();
- if (codestream_get () != 0xec)
+ deprecated_codestream_get ();
+ if (deprecated_codestream_get () != 0xec)
/* Some instruction starting with 0x81 other than `subl'. */
{
- codestream_seek (codestream_tell () - 2);
+ deprecated_codestream_seek (deprecated_codestream_tell () - 2);
return 0;
}
/* It is `subl' with a 32 bit immediate. */
- codestream_read ((unsigned char *) buf, 4);
+ deprecated_codestream_read ((unsigned char *) buf, 4);
return extract_signed_integer (buf, 4);
}
else
@@ -460,8 +460,8 @@
{
char buf[2];
/* `enter' with 16 bit unsigned immediate. */
- codestream_read ((unsigned char *) buf, 2);
- codestream_get (); /* Flush final byte of enter instruction. */
+ deprecated_codestream_read ((unsigned char *) buf, 2);
+ deprecated_codestream_get (); /* Flush final byte of enter instruction. */
return extract_unsigned_integer (buf, 2);
}
return (-1);
@@ -720,7 +720,7 @@
addr = fip->frame - 4 - locals;
for (i = 0; i < 8; i++)
{
- op = codestream_get ();
+ op = deprecated_codestream_get ();
if (op < 0x50 || op > 0x57)
break;
#ifdef I386_REGNO_TO_SYMMETRY
@@ -753,17 +753,17 @@
if (i386_get_frame_setup (pc) < 0)
return (pc);
- /* Found valid frame setup -- codestream now points to start of push
+ /* Found valid frame setup -- deprecated_codestream now points to start of push
instructions for saving registers. */
/* Skip over register saves. */
for (i = 0; i < 8; i++)
{
- op = codestream_peek ();
+ op = deprecated_codestream_peek ();
/* Break if not `pushl' instrunction. */
if (op < 0x50 || op > 0x57)
break;
- codestream_get ();
+ deprecated_codestream_get ();
}
/* The native cc on SVR4 in -K PIC mode inserts the following code
@@ -779,10 +779,10 @@
function), so we have to skip it to get to the first real
instruction at the start of the function. */
- pos = codestream_tell ();
+ pos = deprecated_codestream_tell ();
for (i = 0; i < 6; i++)
{
- op = codestream_get ();
+ op = deprecated_codestream_get ();
if (pic_pat[i] != op)
break;
}
@@ -791,35 +791,35 @@
unsigned char buf[4];
long delta = 6;
- op = codestream_get ();
+ op = deprecated_codestream_get ();
if (op == 0x89) /* movl %ebx, x(%ebp) */
{
- op = codestream_get ();
+ op = deprecated_codestream_get ();
if (op == 0x5d) /* One byte offset from %ebp. */
{
delta += 3;
- codestream_read (buf, 1);
+ deprecated_codestream_read (buf, 1);
}
else if (op == 0x9d) /* Four byte offset from %ebp. */
{
delta += 6;
- codestream_read (buf, 4);
+ deprecated_codestream_read (buf, 4);
}
else /* Unexpected instruction. */
delta = -1;
- op = codestream_get ();
+ op = deprecated_codestream_get ();
}
/* addl y,%ebx */
- if (delta > 0 && op == 0x81 && codestream_get () == 0xc3)
+ if (delta > 0 && op == 0x81 && deprecated_codestream_get () == 0xc3)
{
pos += delta + 6;
}
}
- codestream_seek (pos);
+ deprecated_codestream_seek (pos);
i386_follow_jump ();
- return (codestream_tell ());
+ return (deprecated_codestream_tell ());
}
/* Use the program counter to determine the contents and size of a