]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: make ceph_abort store same crash info as ceph_assert 24688/head
authorMykola Golub <mgolub@suse.com>
Sun, 21 Oct 2018 07:41:14 +0000 (10:41 +0300)
committerMykola Golub <mgolub@suse.com>
Sun, 21 Oct 2018 07:44:41 +0000 (10:44 +0300)
Signed-off-by: Mykola Golub <mgolub@suse.com>
src/common/assert.cc

index f5b74263dbaadf76d9c55983fc44190d58b2a7bd..0f3e1e2e097f01388bdc6871c5d73cd053d9a678 100644 (file)
@@ -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