diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-12-11 16:23:13 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-12-11 16:23:13 +0000 |
commit | 2674ef864c93034d728ee11ee0b7ab96cd4cba57 (patch) | |
tree | 09625734ec09244ac3a201872f6af20b2d36b7b0 | |
parent | c83fd4e24de187700bc125037cd9ae311514213e (diff) |
sna: Enable hooking up of valgrind during debugging
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | src/sna/Makefile.am | 1 | ||||
-rw-r--r-- | src/sna/compiler.h | 2 | ||||
-rw-r--r-- | src/sna/kgem.c | 13 |
4 files changed, 16 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac index a675a933..6dbeb285 100644 --- a/configure.ac +++ b/configure.ac @@ -263,6 +263,8 @@ if test "x$DEBUG" != xno; then fi if test "x$DEBUG" = xfull; then AC_DEFINE(HAS_DEBUG_FULL,1,[Enable all debugging]) + PKG_CHECK_MODULES(VALGRIND, [valgrind], + AC_DEFINE([HAVE_VALGRIND], 0, [Use valgind intrinsics to suppress false warings]),) CFLAGS="$CFLAGS -O0 -ggdb3" fi diff --git a/src/sna/Makefile.am b/src/sna/Makefile.am index 65e85bfa..60430008 100644 --- a/src/sna/Makefile.am +++ b/src/sna/Makefile.am @@ -91,6 +91,7 @@ libsna_la_SOURCES += \ endif if DEBUG +AM_CFLAGS += @VALGRIND_CFLAGS@ libsna_la_SOURCES += \ kgem_debug.c \ kgem_debug.h \ diff --git a/src/sna/compiler.h b/src/sna/compiler.h index ad1313b6..e84a6812 100644 --- a/src/sna/compiler.h +++ b/src/sna/compiler.h @@ -40,7 +40,7 @@ #define fastcall #endif -#ifdef HAVE_VALGRIND_H +#ifdef HAVE_VALGRIND #define VG(x) x #else #define VG(x) diff --git a/src/sna/kgem.c b/src/sna/kgem.c index d635b7c0..7ff0904c 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -39,6 +39,11 @@ #include <errno.h> #include <fcntl.h> +#ifdef HAVE_VALGRIND +#include <valgrind.h> +#include <memcheck.h> +#endif + static inline void list_move(struct list *list, struct list *head) { __list_del(list->prev, list->next); @@ -181,6 +186,7 @@ static int gem_read(int fd, uint32_t handle, const void *dst, int offset, int length) { struct drm_i915_gem_pread pread; + int ret; DBG(("%s(handle=%d, len=%d)\n", __FUNCTION__, handle, length)); @@ -190,7 +196,12 @@ static int gem_read(int fd, uint32_t handle, const void *dst, pread.offset = offset; pread.size = length; pread.data_ptr = (uintptr_t)dst; - return drmIoctl(fd, DRM_IOCTL_I915_GEM_PREAD, &pread); + ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_PREAD, &pread); + if (ret) + return ret; + + VG(VALGRIND_MAKE_MEM_DEFINED(dst, length)); + return 0; } static bool |