Don't read beyond the end of the buffer with INTEL_DEBUG=bat.

This commit is contained in:
Eric Anholt
2007-05-21 13:06:12 -07:00
parent b0b84529cf
commit b1fcabefa2

View File

@@ -67,13 +67,23 @@
*/
static void
intel_dump_batchbuffer(GLuint offset, GLuint * ptr, GLuint count)
intel_dump_batchbuffer(GLuint offset, GLuint * ptr, GLuint size)
{
int i;
fprintf(stderr, "\n\n\nSTART BATCH (%d dwords):\n", count / 4);
for (i = 0; i < count / 4; i += 4)
fprintf(stderr, "0x%x:\t0x%08x 0x%08x 0x%08x 0x%08x\n",
offset + i * 4, ptr[i], ptr[i + 1], ptr[i + 2], ptr[i + 3]);
fprintf(stderr, "\n\n\nSTART BATCH (%d dwords):\n", size / 4);
for (i = 0; i < size / 4; i += 4) {
char dw1[11], dw2[11] = "", dw3[11] = "", dw4[11] = "";
sprintf(dw1, "0x%08x", ptr[i]);
if (i + 1 < size / 4)
sprintf(dw2, "0x%08x", ptr[i + 1]);
if (i + 2 < size / 4)
sprintf(dw3, "0x%08x", ptr[i + 2]);
if (i + 3 < size / 4)
sprintf(dw4, "0x%08x", ptr[i + 3]);
fprintf(stderr, "0x%x:\t%s %s %s %s\n", offset + i * 4,
dw1, dw2, dw3, dw4);
}
fprintf(stderr, "END BATCH\n\n\n");
}