[Intel-gfx] [PATCH i-g-t v2] lib/igt_core: Print stacktrace when receiving one of the crash signals.

Chris Wilson chris at chris-wilson.co.uk
Tue Aug 23 08:55:31 UTC 2016


On Tue, Aug 23, 2016 at 11:38:43AM +0300, Marius Vlad wrote:
> While at it add SIGFPE as a crash signal.
> 
> v2: Added some helpers to avoid printf() inside a signal handler.
> (Chris Wilson)
> 
> Signed-off-by: Marius Vlad <marius.c.vlad at intel.com>
> CC: Chris Wilson <chris at chris-wilson.co.uk>
> ---
>  lib/igt_core.c | 165 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 163 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/igt_core.c b/lib/igt_core.c
> index 801f02f..472d01a 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -1098,6 +1098,165 @@ static void print_backtrace(void)
>  		       (unsigned int) off);
>  	}
>  }
> +
> +static const char hex[] = "0123456789abcdef";
> +typedef void (*print_func)(int ch);
> +
> +static void
> +xputch(int c)
> +{
> +	igt_assert_eq(write(STDERR_FILENO, (const void *) &c, 1), 1);

I thought you said you were avoiding !sigsafe functions....

igt_assert_eq() is unsafe. Just ignore the warn.

> +static void print_backtrace_sig_safe(void)
> +{
> +	unw_cursor_t cursor;
> +	unw_context_t uc;
> +	int stack_num = 0;
> +
> +	igt_assert_eq(write(STDERR_FILENO, "Stack trace: \n", 15), 15);

Will someone please turn off this compiler warning, it has resulted in
more broken code than fixes.

Other than recursively generating signals and calling !sigsafe functions
because of igt_assert_eq(), looks good. Though there is only one user of
xprintffmt, so you can simplify the chain a bit by removing the wrapper
and function pointer. At this point, we should be splitting off into
igt_signal.c
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


More information about the Intel-gfx mailing list