From 5c761256265b1ec48d02c462212d1238ddc0d6e2 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Fri, 19 Jun 2015 03:25:18 +0300 Subject: add call stacks to errors --- src/error.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/error.c b/src/error.c index 96f0e01..4985cca 100644 --- a/src/error.c +++ b/src/error.c @@ -115,6 +115,20 @@ size_t aesni_format_error( return err_formatters[err_details->ec](err_details, dest, dest_size); } +#ifdef WIN32 +#include + +static void aesni_collect_call_stack(AesNI_ErrorDetails* err_details) +{ + err_details->call_stack_size = CaptureStackBackTrace(1, AESNI_MAX_CALL_STACK_LENGTH, err_details->call_stack, NULL); +} +#else +static void aesni_collect_call_stack(AesNI_ErrorDetails* err_details) +{ + err_details->call_stack_size = 0; +} +#endif + static AesNI_StatusCode aesni_make_error( AesNI_ErrorDetails* err_details, AesNI_StatusCode ec) @@ -122,6 +136,9 @@ static AesNI_StatusCode aesni_make_error( if (err_details == NULL) return ec; + if (aesni_is_error(ec)) + aesni_collect_call_stack(err_details); + return err_details->ec = ec; } -- cgit v1.2.3