]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
global: set up breakpad crash reporting
authorMarcel Lauhoff <marcel.lauhoff@suse.com>
Fri, 26 Jul 2024 07:44:45 +0000 (09:44 +0200)
committerMarcel Lauhoff <marcel.lauhoff@clyso.com>
Tue, 13 May 2025 10:39:44 +0000 (12:39 +0200)
Signed-off-by: Marcel Lauhoff <marcel.lauhoff@clyso.com>
src/common/ceph_context.h
src/common/options/global.yaml.in
src/global/global_init.cc

index cd8dd1404d57774c44d64e96e8bfe490367adc73..14e157f41c6f7fa635ef24989cf0829d4c8e97ce 100644 (file)
@@ -34,6 +34,7 @@
 #include "common/cmdparse.h"
 #include "common/code_environment.h"
 #include "msg/msg_types.h"
+#include "breakpad/src/client/linux/handler/exception_handler.h"
 #ifdef WITH_CRIMSON
 #include "crimson/common/config_proxy.h"
 #include "crimson/common/perf_counters_collection.h"
@@ -143,6 +144,7 @@ public:
 
   ConfigProxy _conf;
   ceph::logging::Log *_log;
+  std::unique_ptr<google_breakpad::ExceptionHandler> _ex_handler;
 
   /* init ceph::crypto */
   void init_crypto();
index c7a707c3f2131246b9a6475aaa8c3d6b591a45de..484b58cd933ef469d83d22d3633c0df6f91c987b 100644 (file)
@@ -433,6 +433,14 @@ options:
   flags:
   - startup
   with_legacy: true
+- name: breakpad
+  type: bool
+  level: advanced
+  desc: setup breakpad crash handler
+  default: false
+  flags:
+  - startup
+  with_legacy: true
 - name: crash_dir
   type: str
   level: advanced
index 79defaec3761c019790e2137206976a88e958a98..839951249c9b7aa433e0cd2aa40dd5142555fe2f 100644 (file)
@@ -26,6 +26,8 @@
 #include "extblkdev/ExtBlkDevPlugin.h"
 #include "global/global_context.h"
 #include "global/global_init.h"
+#include <client/linux/handler/minidump_descriptor.h>
+#include <google_breakpad/common/minidump_format.h>
 #include "global/pidfile.h"
 #include "global/signal_handler.h"
 #include "include/compat.h"
@@ -178,6 +180,15 @@ void global_pre_init(
   g_conf().complain_about_parse_error(g_ceph_context);
 }
 
+static bool dumpCallback(
+    const google_breakpad::MinidumpDescriptor& descriptor, void* context,
+    bool succeeded) {
+  char buf[1024];
+  snprintf(buf, sizeof(buf), "minidump created in path %s", descriptor.path());
+  dout_emergency(buf);
+  return succeeded;
+}
+
 boost::intrusive_ptr<CephContext>
 global_init(const std::map<std::string,std::string> *defaults,
            std::vector < const char* >& args,
@@ -215,6 +226,13 @@ global_init(const std::map<std::string,std::string> *defaults,
   if (g_conf()->fatal_signal_handlers) {
     install_standard_sighandlers();
   }
+
+  if (g_conf()->breakpad) {
+    google_breakpad::MinidumpDescriptor descriptor(g_conf()->crash_dir);
+    g_ceph_context->_ex_handler.reset(
+       new google_breakpad::ExceptionHandler(descriptor, nullptr, dumpCallback, nullptr, true, -1));
+  }
+
   ceph::register_assert_context(g_ceph_context);
 
   if (g_conf()->log_flush_on_exit)