notice valgrind about stack switching

This commit is contained in:
David du Colombier 2014-08-03 18:40:18 +02:00
parent cbb722db29
commit b0c00d19fb
3 changed files with 14 additions and 0 deletions

View File

@ -21,6 +21,7 @@ $(OFILES): taskimpl.h task.h 386-ucontext.h power-ucontext.h ip.h
AS=gcc -c AS=gcc -c
CC=gcc CC=gcc
CFLAGS=-Wall -Wextra -c -I. -ggdb CFLAGS=-Wall -Wextra -c -I. -ggdb
#CFLAGS+=-DUSE_VALGRIND -I/usr/include/valgrind
%.o: %.S %.o: %.S
$(AS) $*.S $(AS) $*.S

10
task.c
View File

@ -3,6 +3,9 @@
#include "taskimpl.h" #include "taskimpl.h"
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#ifdef USE_VALGRIND
#include <valgrind.h>
#endif
int taskdebuglevel; int taskdebuglevel;
int taskcount; int taskcount;
@ -107,6 +110,10 @@ taskalloc(void (*fn)(void*), void *arg, uint stack)
abort(); abort();
} }
#ifdef USE_VALGRIND
t->vid = VALGRIND_STACK_REGISTER(t->stk+8, t->stk+8 + t->stksize-64);
#endif
/* call makecontext to do the real work. */ /* call makecontext to do the real work. */
/* leave a few words open on both ends */ /* leave a few words open on both ends */
t->context.uc.uc_stack.ss_sp = t->stk+8; t->context.uc.uc_stack.ss_sp = t->stk+8;
@ -208,6 +215,9 @@ taskexit(int val)
taskexitval = val; taskexitval = val;
taskrunning->exiting = 1; taskrunning->exiting = 1;
taskswitch(); taskswitch();
#ifdef USE_VALGRIND
VALGRIND_STACK_DEREGISTER(taskrunning->vid);
#endif
} }
static void static void

View File

@ -179,6 +179,9 @@ struct Task
void (*startfn)(void*); void (*startfn)(void*);
void *startarg; void *startarg;
void *udata; void *udata;
#ifdef USE_VALGRIND
int vid;
#endif
}; };
void taskready(Task*); void taskready(Task*);