freedreno: add some debug_asserts() to catch insane offsets
authorRob Clark <robclark@freedesktop.org>
Tue, 3 May 2016 19:20:13 +0000 (15:20 -0400)
committerRob Clark <robclark@freedesktop.org>
Wed, 4 May 2016 15:25:55 +0000 (11:25 -0400)
Ofc won't catch *all* faults, but at least helpful for catching offsets
which are completely bogus.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
src/gallium/drivers/freedreno/freedreno_util.h

index 85dac98..34b21a3 100644 (file)
@@ -207,6 +207,7 @@ OUT_RELOC(struct fd_ringbuffer *ring, struct fd_bo *bo,
                DBG("ring[%p]: OUT_RELOC   %04x:  %p+%u << %d", ring,
                                (uint32_t)(ring->cur - ring->last_start), bo, offset, shift);
        }
+       debug_assert(offset < fd_bo_size(bo));
        fd_ringbuffer_reloc(ring, &(struct fd_reloc){
                .bo = bo,
                .flags = FD_RELOC_READ,
@@ -224,6 +225,7 @@ OUT_RELOCW(struct fd_ringbuffer *ring, struct fd_bo *bo,
                DBG("ring[%p]: OUT_RELOCW  %04x:  %p+%u << %d", ring,
                                (uint32_t)(ring->cur - ring->last_start), bo, offset, shift);
        }
+       debug_assert(offset < fd_bo_size(bo));
        fd_ringbuffer_reloc(ring, &(struct fd_reloc){
                .bo = bo,
                .flags = FD_RELOC_READ | FD_RELOC_WRITE,