aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2015-06-19 03:25:18 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2015-06-19 03:25:18 +0300
commit5c761256265b1ec48d02c462212d1238ddc0d6e2 (patch)
tree417d9065e55840bdeac4a7b141c30c5b4e99b75f /src
parentOFB/CTR decryption is the same as encryption (diff)
downloadaes-tools-5c761256265b1ec48d02c462212d1238ddc0d6e2.tar.gz
aes-tools-5c761256265b1ec48d02c462212d1238ddc0d6e2.zip
add call stacks to errors
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;
}