iris: packing with valgrind.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 8 Jan 2018 22:44:14 +0000 (14:44 -0800)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 21 Feb 2019 18:26:04 +0000 (10:26 -0800)
borrowed macros from anv!

src/gallium/drivers/iris/iris_state.c
src/gallium/drivers/iris/meson.build

index b156183fa3e96c27d7ebaa954da16a45f422ac95..7da0e8956dd50765123c5e05af75b9d7265337ba 100644 (file)
  */
 #include <stdio.h>
 #include <errno.h>
+
+#ifdef HAVE_VALGRIND
+#include <valgrind.h>
+#include <memcheck.h>
+#define VG(x) x
+#define __gen_validate_value(x) VALGRIND_CHECK_MEM_IS_DEFINED(&(x), sizeof(x))
+#else
+#define VG(x)
+#endif
+
 #include "pipe/p_defines.h"
 #include "pipe/p_state.h"
 #include "pipe/p_context.h"
@@ -51,8 +61,10 @@ __gen_combine_address(void *user_data, void *location,
 #define iris_pack_command(cmd, dst, name)                         \
    for (struct cmd name = { __genxml_cmd_header(cmd) },           \
         *_dst = (void *)(dst); __builtin_expect(_dst != NULL, 1); \
-        __genxml_cmd_pack(cmd)(NULL, (void *)dst, &name),         \
-        _dst = NULL)
+        ({ __genxml_cmd_pack(cmd)(NULL, (void *)_dst, &name);     \
+           VG(VALGRIND_CHECK_MEM_IS_DEFINED(_dst, __genxml_cmd_length(cmd) * 4)); \
+           _dst = NULL;                                           \
+           }))
 
 #define iris_pack_state(cmd, dst, name)                           \
    for (struct cmd name = {},                                     \
index 4728badd54bc86568973c3d555c323a1ca4e9a4e..3c19a5bbdd35b6025f8f137694d2444a3f907616 100644 (file)
@@ -41,7 +41,7 @@ foreach v : ['90', '100']
     include_directories : [inc_common, inc_intel],
     c_args : [c_vis_args, no_override_init_args,
               '-DGEN_VERSIONx10=@0@'.format(v)],
-    dependencies : [dep_libdrm],
+    dependencies : [dep_libdrm, dep_valgrind],
   )
   iris_gen_libs += _lib
 endforeach