[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] Suppressing exception stack dumps
From: |
Vadim Zeitlin |
Subject: |
Re: [lmi] Suppressing exception stack dumps |
Date: |
Mon, 15 Mar 2021 11:34:40 +0100 |
On Mon, 15 Mar 2021 00:27:02 +0100 I wrote:
Me> IOW I'd like to propose the following patch:
[...untested patch snipped...]
This morning I'd rather like propose a different patch which has a
non-negligible advantage of not resulting in an immediate crash when
LMI_VERBOSE_EXCEPTIONS environment variable doesn't exist:
---------------------------------- >8 --------------------------------------
diff --git a/unwind.cpp b/unwind.cpp
index 8260cc94a..e4a7d9c8f 100644
--- a/unwind.cpp
+++ b/unwind.cpp
@@ -28,7 +28,8 @@
#define UNW_LOCAL_ONLY
#include <cstdio> // fprintf()
-#include <cstdlib> // free()
+#include <cstdlib> // free(), getenv()
+#include <cstring> // strcmp()
#include <cxxabi.h>
#include <dlfcn.h>
#include <elfutils/libdwfl.h>
@@ -186,8 +187,12 @@ void print_backtrace()
extern "C"
void __cxa_throw(void* thrown_exception, std::type_info* tinfo, void
(*dest)(void*))
{
- identify_exception(thrown_exception, tinfo);
- print_backtrace();
+ static char const* const env_var = std::getenv("LMI_VERBOSE_EXCEPTIONS");
+ if (env_var && std::strcmp(env_var, "1") == 0)
+ {
+ identify_exception(thrown_exception, tinfo);
+ print_backtrace();
+ }
original_cxa_throw(thrown_exception, tinfo, dest);
}
---------------------------------- >8 --------------------------------------
Sorry for the broken first version,
VZ
pgp1Zv1yJ_Wfy.pgp
Description: PGP signature