conf.CheckLibWithHeader('protobuf', 'google/protobuf/message.h',
'C++', 'GOOGLE_PROTOBUF_VERIFY_VERSION;')
+# Valgrind gets much less confused if you tell it when you're using
+# alternative stacks.
+main['HAVE_VALGRIND'] = conf.CheckCHeader('valgrind/valgrind.h')
+
# If we have the compiler but not the library, print another warning.
if main['PROTOC'] and not main['HAVE_PROTOBUF']:
print(termcap.Yellow + termcap.Bold +
# These variables get exported to #defines in config/*.hh (see src/SConscript).
export_vars += ['USE_FENV', 'SS_COMPATIBLE_FP', 'TARGET_ISA', 'TARGET_GPU_ISA',
'CP_ANNOTATE', 'USE_POSIX_CLOCK', 'USE_KVM', 'USE_TUNTAP',
- 'PROTOCOL', 'HAVE_PROTOBUF', 'HAVE_PERF_ATTR_EXCLUDE_HOST',
- 'USE_PNG']
+ 'PROTOCOL', 'HAVE_PROTOBUF', 'HAVE_VALGRIND',
+ 'HAVE_PERF_ATTR_EXCLUDE_HOST', 'USE_PNG']
###################################################
#
#include "base/fiber.hh"
+#if HAVE_VALGRIND
+#include <valgrind/valgrind.h>
+#endif
+
#include <cerrno>
#include <cstring>
link(primaryFiber()),
stack(stack_size ? new uint8_t[stack_size] : nullptr),
stackSize(stack_size), started(false), _finished(false)
-{}
+{
+#if HAVE_VALGRIND
+ valgrindStackId = VALGRIND_STACK_REGISTER(stack, stack + stack_size);
+#endif
+}
Fiber::Fiber(Fiber *link, size_t stack_size) :
link(link), stack(stack_size ? new uint8_t[stack_size] : nullptr),
Fiber::~Fiber()
{
panic_if(stack && _currentFiber == this, "Fiber stack is in use.");
+#if HAVE_VALGRIND
+ VALGRIND_STACK_DEREGISTER(valgrindStackId);
+#endif
delete [] stack;
}
#include <cstddef>
#include <cstdint>
+#include "config/have_valgrind.hh"
+
/**
* This class represents a fiber, which is a light weight sort of thread which
* is cooperatively scheduled and runs sequentially with other fibers, swapping
// The stack for this context, or a nullptr if allocated elsewhere.
uint8_t *stack;
size_t stackSize;
+#if HAVE_VALGRIND
+ unsigned valgrindStackId;
+#endif
bool started;
bool _finished;