From 04bbeb88f4876dcc75c0b97a745596f723a28be8 Mon Sep 17 00:00:00 2001 From: edef Date: Wed, 15 Apr 2015 22:45:50 -0400 Subject: [PATCH] add valgrind_stack_change Unlike valgrind_stack_register, this won't automatically swap if `start > end`. It's probably wiser to pretend it doesn't swap at all. --- src/valgrind.c | 4 ++++ src/valgrind.rs | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/valgrind.c b/src/valgrind.c index 42362d3..fce9486 100644 --- a/src/valgrind.c +++ b/src/valgrind.c @@ -7,6 +7,10 @@ valgrind_stack_id_t valgrind_stack_register(const void *start, const void *end) return VALGRIND_STACK_REGISTER(start, end); } +void valgrind_stack_change(valgrind_stack_id_t id, const void *start, const void *end) { + VALGRIND_STACK_CHANGE(id, start, end); +} + void valgrind_stack_deregister(valgrind_stack_id_t id) { VALGRIND_STACK_DEREGISTER(id); } diff --git a/src/valgrind.rs b/src/valgrind.rs index f1d5e10..37848ff 100644 --- a/src/valgrind.rs +++ b/src/valgrind.rs @@ -1,6 +1,6 @@ #![allow(non_camel_case_types)] //! In order for Valgrind to keep track of stack overflows and such, it needs -//! a little help. That help unfortunately comes in the form of a pair of C +//! a little help. That help unfortunately comes in the form of a set of C //! macros. Calling out to un-inlineable C code for this is pointlessly slow, //! but that's the way it is for now. @@ -9,9 +9,14 @@ extern "C" { #[link_name = "valgrind_stack_register"] /// Register a stack with Valgrind. Returns an integer ID that can /// be used to deregister the stack when it's deallocated. - /// `start < end`, though Valgrind will happily accept either. + /// `start < end`. pub fn stack_register(start: *const u8, end: *const u8) -> stack_id_t; + #[link_name = "valgrind_stack_change"] + /// Change the size or location of a stack registered with Valgrind. + /// `start < end`. + pub fn stack_change(id: stack_id_t, start: *const u8, end: *const u8) -> stack_id_t; + #[link_name = "valgrind_stack_deregister"] /// Deregister a stack from Valgrind. Takes the integer ID that was returned /// on registration.