From: Sage Weil Date: Sat, 16 Jun 2018 02:53:32 +0000 (-0500) Subject: common/assert: record assert info in g_assert_* globals X-Git-Tag: v14.0.1~1042^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b0e59ce2f51b15e6f22b217fb28971746b350806;p=ceph.git common/assert: record assert info in g_assert_* globals These will then be available for others who are interested. Signed-off-by: Sage Weil --- diff --git a/src/common/assert.cc b/src/common/assert.cc index 4501c8b38a1c..45d44d12ea1a 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 05f76321ca3d..9e511d44da95 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 29e5a973eb51..9ac4388d08a2 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