Merge pull request #16 from anttirt/develop
Optionally register stacks with valgrind
This commit is contained in:
commit
5827586ce3
@ -11,6 +11,9 @@ import toolset ;
|
||||
feature.feature segmented-stacks : on : optional propagated composite ;
|
||||
feature.compose <segmented-stacks>on : <define>BOOST_USE_SEGMENTED_STACKS ;
|
||||
|
||||
feature.feature valgrind : on : optional propagated composite ;
|
||||
feature.compose <valgrind>on : <define>BOOST_USE_VALGRIND ;
|
||||
|
||||
project boost/coroutine
|
||||
: requirements
|
||||
<library>/boost/context//boost_context
|
||||
|
@ -14,6 +14,10 @@ extern "C" {
|
||||
#include <unistd.h>
|
||||
}
|
||||
|
||||
#if defined(BOOST_USE_VALGRIND)
|
||||
#include <valgrind/valgrind.h>
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <new>
|
||||
@ -70,6 +74,9 @@ struct basic_protected_stack_allocator
|
||||
|
||||
ctx.size = size_;
|
||||
ctx.sp = static_cast< char * >( limit) + ctx.size;
|
||||
#if defined(BOOST_USE_VALGRIND)
|
||||
ctx.valgrind_stack_id = VALGRIND_STACK_REGISTER( ctx.sp, limit);
|
||||
#endif
|
||||
}
|
||||
|
||||
void deallocate( stack_context & ctx)
|
||||
@ -78,6 +85,9 @@ struct basic_protected_stack_allocator
|
||||
BOOST_ASSERT( traits_type::minimum_size() <= ctx.size);
|
||||
BOOST_ASSERT( traits_type::is_unbounded() || ( traits_type::maximum_size() >= ctx.size) );
|
||||
|
||||
#if defined(BOOST_USE_VALGRIND)
|
||||
VALGRIND_STACK_DEREGISTER( ctx.valgrind_stack_id);
|
||||
#endif
|
||||
void * limit = static_cast< char * >( ctx.sp) - ctx.size;
|
||||
// conform to POSIX.4 (POSIX.1b-1993, _POSIX_C_SOURCE=199309L)
|
||||
::munmap( limit, ctx.size);
|
||||
|
@ -28,9 +28,15 @@ struct stack_context
|
||||
std::size_t size;
|
||||
void * sp;
|
||||
segments_context segments_ctx;
|
||||
#if defined(BOOST_USE_VALGRIND)
|
||||
unsigned valgrind_stack_id;
|
||||
#endif
|
||||
|
||||
stack_context() :
|
||||
size( 0), sp( 0), segments_ctx()
|
||||
#if defined(BOOST_USE_VALGRIND)
|
||||
, valgrind_stack_id( 0)
|
||||
#endif
|
||||
{}
|
||||
};
|
||||
#else
|
||||
@ -38,9 +44,15 @@ struct stack_context
|
||||
{
|
||||
std::size_t size;
|
||||
void * sp;
|
||||
#if defined(BOOST_USE_VALGRIND)
|
||||
unsigned valgrind_stack_id;
|
||||
#endif
|
||||
|
||||
stack_context() :
|
||||
size( 0), sp( 0)
|
||||
#if defined(BOOST_USE_VALGRIND)
|
||||
, valgrind_stack_id( 0)
|
||||
#endif
|
||||
{}
|
||||
};
|
||||
#endif
|
||||
|
@ -7,6 +7,10 @@
|
||||
#ifndef BOOST_COROUTINES_STANDARD_STACK_ALLOCATOR_H
|
||||
#define BOOST_COROUTINES_STANDARD_STACK_ALLOCATOR_H
|
||||
|
||||
#if defined(BOOST_USE_VALGRIND)
|
||||
#include <valgrind/valgrind.h>
|
||||
#endif
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <new>
|
||||
@ -40,6 +44,9 @@ struct basic_standard_stack_allocator
|
||||
|
||||
ctx.size = size;
|
||||
ctx.sp = static_cast< char * >( limit) + ctx.size;
|
||||
#if defined(BOOST_USE_VALGRIND)
|
||||
ctx.valgrind_stack_id = VALGRIND_STACK_REGISTER( ctx.sp, limit);
|
||||
#endif
|
||||
}
|
||||
|
||||
void deallocate( stack_context & ctx)
|
||||
@ -48,6 +55,10 @@ struct basic_standard_stack_allocator
|
||||
BOOST_ASSERT( traits_type::minimum_size() <= ctx.size);
|
||||
BOOST_ASSERT( traits_type::is_unbounded() || ( traits_type::maximum_size() >= ctx.size) );
|
||||
|
||||
#if defined(BOOST_USE_VALGRIND)
|
||||
VALGRIND_STACK_DEREGISTER( ctx.valgrind_stack_id);
|
||||
#endif
|
||||
|
||||
void * limit = static_cast< char * >( ctx.sp) - ctx.size;
|
||||
std::free( limit);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user