From 337635ab97bbfc9b4455eadb63214783bb90bb2b Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 28 Dec 2011 10:56:57 +0000 Subject: [PATCH] sna: Add some more debugging to find the source of a read-boxes error Signed-off-by: Chris Wilson --- src/sna/sna_io.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/sna/sna_io.c b/src/sna/sna_io.c index 489c1ccd..0386cef1 100644 --- a/src/sna/sna_io.c +++ b/src/sna/sna_io.c @@ -100,6 +100,20 @@ void sna_read_boxes(struct sna *sna, __FUNCTION__, nbox, src_bo->handle, src_dx, src_dy, dst->drawable.width, dst->drawable.height, dst_dx, dst_dy)); +#ifndef NDEBUG + for (n = 0; n < nbox; n++) { + if (box[n].x1 + src_dx < 0 || box[n].y1 + src_dy < 0 || + (box[n].x2 + src_dx) * dst->drawable.bitsPerPixel/8 > src_bo->pitch || + (box[n].y2 + src_dy) * src_bo->pitch > src_bo->size) + { + FatalError("source out-of-bounds box[%d]=(%d, %d), (%d, %d) + (%d, %d), pitch=%d, size=%d\n", + box[n].x1, box[n].y1, + box[n].x2, box[n].y2, + src_bo->pitch, src_bo->size); + } + } +#endif + if (DEBUG_NO_IO || kgem->wedged || src_bo->tiling == I915_TILING_Y) { read_boxes_inplace(kgem, src_bo, src_dx, src_dy,