From 8f8555f868039017a03d93c325865170ce0fe71c Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Thu, 28 Jul 2011 16:19:29 -0700 Subject: [PATCH] vkernel - Add SIGINFO support (experimental) * Display the lwp id and the pc and sp of the thread. --- sys/platform/vkernel/i386/exception.c | 17 +++++++++++++++++ sys/platform/vkernel64/x86_64/exception.c | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/sys/platform/vkernel/i386/exception.c b/sys/platform/vkernel/i386/exception.c index 8b770ef4fa..a866b41948 100644 --- a/sys/platform/vkernel/i386/exception.c +++ b/sys/platform/vkernel/i386/exception.c @@ -54,6 +54,7 @@ #include #include +#include #include int _ucodesel = LSEL(LUCODE_SEL, SEL_UPL); @@ -140,6 +141,20 @@ iosig(int nada, siginfo_t *info, void *ctxp) #endif +static +void +infosig(int nada, siginfo_t *info, void *ctxp) +{ + ucontext_t *ctx = ctxp; + char buf[256]; + + snprintf(buf, sizeof(buf), "lwp %d pc=%p sp=%p\n", + (int)lwp_gettid(), + (void *)(intptr_t)ctx->uc_mcontext.mc_eip, + (void *)(intptr_t)ctx->uc_mcontext.mc_esp); + write(2, buf, strlen(buf)); +} + void init_exceptions(void) { @@ -168,6 +183,8 @@ init_exceptions(void) sa.sa_sigaction = iosig; sigaction(SIGIO, &sa, NULL); #endif + sa.sa_sigaction = infosig; + sigaction(SIGINFO, &sa, NULL); } /* diff --git a/sys/platform/vkernel64/x86_64/exception.c b/sys/platform/vkernel64/x86_64/exception.c index 34ef724984..cb266e366f 100644 --- a/sys/platform/vkernel64/x86_64/exception.c +++ b/sys/platform/vkernel64/x86_64/exception.c @@ -54,6 +54,7 @@ #include #include +#include #include int _ucodesel = GSEL(GUCODE_SEL, SEL_UPL); @@ -145,6 +146,20 @@ iosig(int nada, siginfo_t *info, void *ctxp) #endif +static +void +infosig(int nada, siginfo_t *info, void *ctxp) +{ + ucontext_t *ctx = ctxp; + char buf[256]; + + snprintf(buf, sizeof(buf), "lwp %d pc=%p sp=%p\n", + (int)lwp_gettid(), + (void *)(intptr_t)ctx->uc_mcontext.mc_rip, + (void *)(intptr_t)ctx->uc_mcontext.mc_rsp); + write(2, buf, strlen(buf)); +} + void init_exceptions(void) { @@ -173,6 +188,8 @@ init_exceptions(void) sa.sa_sigaction = iosig; sigaction(SIGIO, &sa, NULL); #endif + sa.sa_sigaction = infosig; + sigaction(SIGINFO, &sa, NULL); } /* -- 2.41.0