Merge pull request #230 from LudwigOrtmann/issue_154

valgrind support for native
dev/timer
Christian Mehlis 10 years ago
commit ff7cf37ccd

@ -1,3 +1,21 @@
VALGRIND SUPPORT
================
If you want to use valgrind, you should recompile native with either
HAVE_VALGRIND_H or HAVE_VALGRIND_VALGRIND_H depending on the location
of the valgrind header (i.e. <valgrind.h> or <valgrind/valgrind.h>)
like this:
CFLAGS="-DHAVE_VALGRIND_VALGRIND_H" make
That way native can tell valgrind about RIOTs stacks and prevent
valgrind from reporting lots of false positives.
NETWORK SUPPORT
===============
If you compile RIOT for the native cpu and include the native_net
module, you need to specify a network interface like this:
./bin/default-native.elf tap0

@ -18,6 +18,17 @@
#include <unistd.h>
#include <stdlib.h>
#ifdef HAVE_VALGRIND_H
#include <valgrind.h>
#define VALGRIND_DEBUG DEBUG
#elif defined(HAVE_VALGRIND_VALGRIND_H)
#include <valgrind/valgrind.h>
#define VALGRIND_DEBUG DEBUG
#else
#define VALGRIND_STACK_REGISTER(...)
#define VALGRIND_DEBUG(...)
#endif
// __USE_GNU for gregs[REG_EIP] access under Linux
#define __USE_GNU
#include <signal.h>
@ -434,6 +445,9 @@ void native_interrupt_init(void)
err(EXIT_FAILURE, "native_interrupt_init: malloc");
}
VALGRIND_STACK_REGISTER(__isr_stack, __isr_stack + sizeof(__isr_stack));
VALGRIND_DEBUG("VALGRIND_STACK_REGISTER(%p, %p)\n", __isr_stack, (void*)((int)__isr_stack + sizeof(__isr_stack)));
native_interrupts_enabled = 1;
_native_sigpend = 0;

@ -25,11 +25,24 @@
#endif
#include <err.h>
#ifdef HAVE_VALGRIND_H
#include <valgrind.h>
#define VALGRIND_DEBUG DEBUG
#elif defined(HAVE_VALGRIND_VALGRIND_H)
#include <valgrind/valgrind.h>
#define VALGRIND_DEBUG DEBUG
#else
#define VALGRIND_STACK_REGISTER(...)
#define VALGRIND_DEBUG(...)
#endif
#include "kernel_internal.h"
#include "sched.h"
#include "cpu.h"
#include "cpu-conf.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
extern volatile tcb_t *active_thread;
@ -54,6 +67,9 @@ char *thread_stack_init(void (*task_func)(void), void *stack_start, int stacksiz
unsigned int *stk;
ucontext_t *p;
VALGRIND_STACK_REGISTER(stack_start, stack_start + stacksize);
VALGRIND_DEBUG("VALGRIND_STACK_REGISTER(%p, %p)\n", stack_start, (void*)((int)stack_start + stacksize));
DEBUG("thread_stack_init()\n");
stk = stack_start;
@ -144,6 +160,8 @@ void native_cpu_init()
end_context.uc_stack.ss_size = SIGSTKSZ;
end_context.uc_stack.ss_flags = 0;
makecontext(&end_context, sched_task_exit, 0);
VALGRIND_STACK_REGISTER(__end_stack, __end_stack + sizeof(__end_stack));
VALGRIND_DEBUG("VALGRIND_STACK_REGISTER(%p, %p)\n", __end_stack, (void*)((int)__end_stack + sizeof(__end_stack)));
DEBUG("RIOT native cpu initialized.");
}

Loading…
Cancel
Save