| * To use this you need some patches to Valgrind that |
| * let it help out with detecting stack overflow. |
| #include <valgrind/memcheck.h> |
| launcher386(void (*f)(void *arg), void *arg) |
| _threadstacklimit(t->stk, t->stk+t->stksize); |
| _threadinitstack(Thread *t, void (*f)(void*), void *arg) |
| tos = (ulong*)&t->stk[t->stksize&~7]; |
| t->sched.pc = (ulong)launcher386; |
| t->sched.sp = (ulong)tos - 8; /* old PC and new PC */ |
| _threadinswitch(int enter) |
| VALGRIND_SET_STACK_LIMIT(0, 0, 0); |
| VALGRIND_SET_STACK_LIMIT(0, 0, 1); |
| _threadstacklimit(void *bottom, void *top) |
| VALGRIND_SET_STACK_LIMIT(1, bottom, top); |