From 4402848911a244c0d636e2f021f940fb6b8e1bcf Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Sun, 21 Oct 2018 10:41:14 +0300 Subject: [PATCH] common: make ceph_abort store same crash info as ceph_assert Signed-off-by: Mykola Golub --- src/common/assert.cc | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/common/assert.cc b/src/common/assert.cc index f5b74263dbaad..0f3e1e2e097f0 100644 --- a/src/common/assert.cc +++ b/src/common/assert.cc @@ -161,12 +161,20 @@ namespace ceph { ostringstream tss; tss << ceph_clock_now(); - char buf[8096]; + g_assert_condition = "abort"; + g_assert_file = file; + g_assert_line = line; + g_assert_func = func; + g_assert_thread = (unsigned long long)pthread_self(); + ceph_pthread_getname(pthread_self(), g_assert_thread_name, + sizeof(g_assert_thread_name)); + BackTrace *bt = new BackTrace(1); - snprintf(buf, sizeof(buf), "%s: In function '%s' thread %llx time %s\n" + snprintf(g_assert_msg, sizeof(g_assert_msg), + "%s: In function '%s' thread %llx time %s\n" "%s: %d: abort()\n", file, func, (unsigned long long)pthread_self(), tss.str().c_str(), file, line); - dout_emergency(msg); + dout_emergency(g_assert_msg); // TODO: get rid of this memory allocation. ostringstream oss; @@ -174,7 +182,7 @@ namespace ceph { dout_emergency(oss.str()); if (g_assert_context) { - lderr(g_assert_context) << buf << std::endl; + lderr(g_assert_context) << g_assert_msg << std::endl; *_dout << oss.str() << dendl; // dump recent only if the abort signal handler won't do it for us @@ -193,8 +201,15 @@ namespace ceph { ostringstream tss; tss << ceph_clock_now(); - char buf[8096]; - BufAppender ba(buf, sizeof(buf)); + g_assert_condition = "abort"; + g_assert_file = file; + g_assert_line = line; + g_assert_func = func; + g_assert_thread = (unsigned long long)pthread_self(); + ceph_pthread_getname(pthread_self(), g_assert_thread_name, + sizeof(g_assert_thread_name)); + + BufAppender ba(g_assert_msg, sizeof(g_assert_msg)); BackTrace *bt = new BackTrace(1); ba.printf("%s: In function '%s' thread %llx time %s\n" "%s: %d: abort()\n", @@ -206,7 +221,7 @@ namespace ceph { ba.vprintf(msg, args); va_end(args); ba.printf("\n"); - dout_emergency(buf); + dout_emergency(g_assert_msg); // TODO: get rid of this memory allocation. ostringstream oss; @@ -214,7 +229,7 @@ namespace ceph { dout_emergency(oss.str()); if (g_assert_context) { - lderr(g_assert_context) << buf << std::endl; + lderr(g_assert_context) << g_assert_msg << std::endl; *_dout << oss.str() << dendl; // dump recent only if the abort signal handler won't do it for us -- 2.39.5