summaryrefslogtreecommitdiffstats
path: root/unwind.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-04-16 17:12:56 -0700
committerKaz Kylheku <kaz@kylheku.com>2016-04-16 17:12:56 -0700
commit57662048f3b5340f174f51c4f7d9921968aa6a1a (patch)
tree9063fea457716eb94bf0fff6f0613474f15312d5 /unwind.c
parent60b54600a7b005621b9b7125ae0e726e147a95ff (diff)
downloadtxr-57662048f3b5340f174f51c4f7d9921968aa6a1a.tar.gz
txr-57662048f3b5340f174f51c4f7d9921968aa6a1a.tar.bz2
txr-57662048f3b5340f174f51c4f7d9921968aa6a1a.zip
Valgrind support in continuations.
* unwind.c (revive_cont): When scanning the stack of the revived continuation to fix up pointers, we can save the Valgrind validity bits of each word, mark it defined, and then restore the validity bits.
Diffstat (limited to 'unwind.c')
-rw-r--r--unwind.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/unwind.c b/unwind.c
index a521c732..7495be1e 100644
--- a/unwind.c
+++ b/unwind.c
@@ -33,6 +33,9 @@
#include <stdarg.h>
#include <signal.h>
#include "config.h"
+#if HAVE_VALGRIND
+#include <valgrind/memcheck.h>
+#endif
#include "lib.h"
#include "gc.h"
#include "args.h"
@@ -754,11 +757,25 @@ static val revive_cont(val dc, val arg)
for (ptr = space; ptr < space + cont->size; ptr += sizeof (cnum))
{
uint_ptr_t *wordptr = coerce(uint_ptr_t *, ptr);
- uint_ptr_t word = *wordptr;
+ uint_ptr_t word;
+#if HAVE_VALGRIND
+ uint_ptr_t vbits = 0;
+
+ if (opt_vg_debug) {
+ VALGRIND_GET_VBITS(wordptr, &vbits, sizeof *wordptr);
+ VALGRIND_MAKE_MEM_DEFINED(wordptr, sizeof *wordptr);
+ }
+#endif
+ word = *wordptr;
if (word >= orig_start - frame_slack &&
word < orig_end && is_ptr(coerce(val, word)))
*wordptr = word + delta;
+
+#if HAVE_VALGRIND
+ if (opt_vg_debug)
+ VALGRIND_SET_VBITS(wordptr, &vbits, sizeof *wordptr);
+#endif
}
uw_block_begin (cont->tag, result);