From 71af21899218236439dceca44f63c6247420c3f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Mon, 26 Apr 2021 19:59:32 +0200 Subject: [PATCH] skip internal functions like "raiseExceptionEx.constprop.0" --- libbacktrace.nimble | 2 +- libbacktrace_wrapper.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libbacktrace.nimble b/libbacktrace.nimble index 6e16466..39e7aca 100644 --- a/libbacktrace.nimble +++ b/libbacktrace.nimble @@ -9,7 +9,7 @@ mode = ScriptMode.Verbose packageName = "libbacktrace" -version = "0.0.6" +version = "0.0.7" author = "Status Research & Development GmbH" description = "Nim wrapper for libbacktrace" license = "MIT or Apache License 2.0" diff --git a/libbacktrace_wrapper.c b/libbacktrace_wrapper.c index db525c1..b354440 100644 --- a/libbacktrace_wrapper.c +++ b/libbacktrace_wrapper.c @@ -112,6 +112,16 @@ static int strings_equal(const char *str1, const char *str2) } } +static int string_starts_with(const char *str1, const char *str2) +{ + if (!str1 || !str2) { + return 0; + } else { + size_t len2 = strlen(str2); + return strlen(str1) >= len2 && strncmp(str1, str2, len2) == 0; + } +} + #ifdef __cplusplus # include #endif // __cplusplus @@ -186,7 +196,7 @@ static int success_callback(void *data, uintptr_t pc __attribute__((unused)), strings_equal(demangled_function, "rawWriteStackTrace") || strings_equal(demangled_function, "writeStackTrace") || strings_equal(demangled_function, "raiseExceptionAux") || - strings_equal(demangled_function, "raiseExceptionEx")) { + string_starts_with(demangled_function, "raiseExceptionEx")) { if (!debug) { xfree(demangled_function); return 0; // Skip it, but continue the backtrace.