mirror of
https://github.com/0intro/libtask
synced 2024-11-21 21:31:30 +03:00
notice valgrind about stack switching
This commit is contained in:
parent
cbb722db29
commit
b0c00d19fb
1
Makefile
1
Makefile
@ -21,6 +21,7 @@ $(OFILES): taskimpl.h task.h 386-ucontext.h power-ucontext.h ip.h
|
||||
AS=gcc -c
|
||||
CC=gcc
|
||||
CFLAGS=-Wall -Wextra -c -I. -ggdb
|
||||
#CFLAGS+=-DUSE_VALGRIND -I/usr/include/valgrind
|
||||
|
||||
%.o: %.S
|
||||
$(AS) $*.S
|
||||
|
10
task.c
10
task.c
@ -3,6 +3,9 @@
|
||||
#include "taskimpl.h"
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#ifdef USE_VALGRIND
|
||||
#include <valgrind.h>
|
||||
#endif
|
||||
|
||||
int taskdebuglevel;
|
||||
int taskcount;
|
||||
@ -107,6 +110,10 @@ taskalloc(void (*fn)(void*), void *arg, uint stack)
|
||||
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. */
|
||||
/* leave a few words open on both ends */
|
||||
t->context.uc.uc_stack.ss_sp = t->stk+8;
|
||||
@ -208,6 +215,9 @@ taskexit(int val)
|
||||
taskexitval = val;
|
||||
taskrunning->exiting = 1;
|
||||
taskswitch();
|
||||
#ifdef USE_VALGRIND
|
||||
VALGRIND_STACK_DEREGISTER(taskrunning->vid);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -179,6 +179,9 @@ struct Task
|
||||
void (*startfn)(void*);
|
||||
void *startarg;
|
||||
void *udata;
|
||||
#ifdef USE_VALGRIND
|
||||
int vid;
|
||||
#endif
|
||||
};
|
||||
|
||||
void taskready(Task*);
|
||||
|
Loading…
Reference in New Issue
Block a user