aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/error.c17
1 files changed, 17 insertions, 0 deletions
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 <Windows.h>
+
+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;
}