From ed1e5752fcedaaa21f894e72e30867370558a2f3 Mon Sep 17 00:00:00 2001 From: Ariadne Conill Date: Tue, 8 Dec 2020 18:28:35 -0700 Subject: [PATCH] libucontext_posix: add some tracing --- libucontext_posix.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libucontext_posix.c b/libucontext_posix.c index 0b42a4f..19a6b17 100644 --- a/libucontext_posix.c +++ b/libucontext_posix.c @@ -11,15 +11,24 @@ */ #include +#include #include #ifdef FREESTANDING # error libucontext_posix cannot be built in FREESTANDING mode. #endif +#ifdef DEBUG +# define TRACE(...) fprintf(stderr, "TRACE: " __VA_ARGS__) +#else +# define TRACE(...) +#endif + int getcontext(libucontext_ucontext_t *ucp) { + TRACE("getcontext(%p)\n", ucp); + if (sigprocmask(SIG_SETMASK, NULL, &ucp->uc_sigmask)) return -1; @@ -29,6 +38,8 @@ getcontext(libucontext_ucontext_t *ucp) int setcontext(const libucontext_ucontext_t *ucp) { + TRACE("setcontext(%p)\n", ucp); + if (sigprocmask(SIG_SETMASK, &ucp->uc_sigmask, NULL)) return -1; @@ -38,6 +49,8 @@ setcontext(const libucontext_ucontext_t *ucp) int swapcontext(libucontext_ucontext_t *oucp, const libucontext_ucontext_t *ucp) { + TRACE("swapcontext(%p, %p)\n", oucp, ucp); + if (sigprocmask(SIG_SETMASK, &ucp->uc_sigmask, &oucp->uc_sigmask)) return -1;