From b0e59ce2f51b15e6f22b217fb28971746b350806 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 15 Jun 2018 21:53:32 -0500 Subject: [PATCH] common/assert: record assert info in g_assert_* globals These will then be available for others who are interested. Signed-off-by: Sage Weil --- src/common/assert.cc | 16 ++++++++++++++++ src/global/global_context.cc | 7 +++++++ src/global/global_context.h | 7 +++++++ 3 files changed, 30 insertions(+) diff --git a/src/common/assert.cc b/src/common/assert.cc index 4501c8b38a1..45d44d12ea1 100644 --- a/src/common/assert.cc +++ b/src/common/assert.cc @@ -35,6 +35,14 @@ namespace ceph { void __ceph_assert_fail(const char *assertion, const char *file, int line, const char *func) { + g_assert_condition = assertion; + g_assert_file = file; + g_assert_line = line; + g_assert_func = func; + g_assert_thread = (unsigned long long)pthread_self(); + pthread_getname_np(pthread_self(), g_assert_thread_name, + sizeof(g_assert_thread_name)); + ostringstream tss; tss << ceph_clock_now(); @@ -75,6 +83,14 @@ namespace ceph { ostringstream tss; tss << ceph_clock_now(); + g_assert_condition = assertion; + g_assert_file = file; + g_assert_line = line; + g_assert_func = func; + g_assert_thread = (unsigned long long)pthread_self(); + pthread_getname_np(pthread_self(), g_assert_thread_name, + sizeof(g_assert_thread_name)); + class BufAppender { public: BufAppender(char* buf, int size) : bufptr(buf), remaining(size) { diff --git a/src/global/global_context.cc b/src/global/global_context.cc index 05f76321ca3..9e511d44da9 100644 --- a/src/global/global_context.cc +++ b/src/global/global_context.cc @@ -20,3 +20,10 @@ */ CephContext *g_ceph_context = NULL; md_config_t *g_conf = NULL; + +const char *g_assert_file = 0; +int g_assert_line = 0; +const char *g_assert_func = 0; +const char *g_assert_condition = 0; +unsigned long long g_assert_thread = 0; +char g_assert_thread_name[4096]; diff --git a/src/global/global_context.h b/src/global/global_context.h index 29e5a973eb5..9ac4388d08a 100644 --- a/src/global/global_context.h +++ b/src/global/global_context.h @@ -21,4 +21,11 @@ struct md_config_t; extern CephContext *g_ceph_context; extern md_config_t *g_conf; +extern const char *g_assert_file; +extern int g_assert_line; +extern const char *g_assert_func; +extern const char *g_assert_condition; +extern unsigned long long g_assert_thread; +extern char g_assert_thread_name[4096]; + #endif -- 2.39.5