Home > Software > valgrind ruby 1.8.7 updated patch

valgrind ruby 1.8.7 updated patch

This morning I discovered Evan’s patch for valgrind is missing. I rebuilt the patch.

As well here are the bits below:

Index: configure.in
===================================================================
--- configure.in (revision 17858)
+++ configure.in (working copy)
@@ -377,6 +377,10 @@
  : handled by ext/thread/extconf.rb
         ])

+AC_ARG_WITH(valgrind,
+        [  --with-valgrind         enable valgrind memcheck support.],
+        [AC_CHECK_HEADERS(valgrind/memcheck.h)])
+
 dnl Checks for libraries.
 case "$target_os" in
 nextstep*) ;;
Index: gc.c
===================================================================
--- gc.c (revision 17858)
+++ gc.c (working copy)
@@ -37,6 +37,19 @@
 void re_free_registers _((struct re_registers*));
 void rb_io_fptr_finalize _((struct rb_io_t*));

+#ifdef HAVE_VALGRIND_MEMCHECK_H
+# include
+# ifndef VALGRIND_MAKE_MEM_DEFINED
+#  define VALGRIND_MAKE_MEM_DEFINED(p, n) VALGRIND_MAKE_READABLE(p, n)
+# endif
+# ifndef VALGRIND_MAKE_MEM_UNDEFINED
+#  define VALGRIND_MAKE_MEM_UNDEFINED(p, n) VALGRIND_MAKE_WRITABLE(p, n)
+# endif
+#else
+# define VALGRIND_MAKE_MEM_DEFINED(p, n) /* empty */
+# define VALGRIND_MAKE_MEM_UNDEFINED(p, n) /* empty */
+#endif
+
 #define rb_setjmp(env) RUBY_SETJMP(env)
 #define rb_jmp_buf rb_jmpbuf_t
 #ifdef __CYGWIN__
@@ -668,6 +681,7 @@
     VALUE v;
     while (n--) {
         v = *x;
+        VALGRIND_MAKE_MEM_DEFINED(&v, sizeof(v));
  if (is_pointer_to_heap((void *)v)) {
      gc_mark(v, 0);
  }

Software ,

  1. December 5th, 2008 at 10:41 | #1

    I think this is a great patch–you should submit a “compiler directive driven” version to ruby core! :)
    -=R

    rogers last blog post..java gotcha

  1. No trackbacks yet.
CommentLuv Enabled

Comments links could be nofollow free.