mirror of
https://github.com/0intro/libtask
synced 2024-11-24 22:59:43 +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
|
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
10
task.c
@ -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
|
||||||
|
@ -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*);
|
||||||
|
Loading…
Reference in New Issue
Block a user