Skip to content

Commit 5729a4b

Browse files
Marcel Lauhoffirq0
authored andcommitted
global: set up breakpad crash reporting
Signed-off-by: Marcel Lauhoff <[email protected]>
1 parent c0e9791 commit 5729a4b

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

src/common/ceph_context.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "common/cmdparse.h"
3535
#include "common/code_environment.h"
3636
#include "msg/msg_types.h"
37+
#include "breakpad/src/client/linux/handler/exception_handler.h"
3738
#ifdef WITH_CRIMSON
3839
#include "crimson/common/config_proxy.h"
3940
#include "crimson/common/perf_counters_collection.h"
@@ -143,6 +144,7 @@ class CephContext {
143144

144145
ConfigProxy _conf;
145146
ceph::logging::Log *_log;
147+
std::unique_ptr<google_breakpad::ExceptionHandler> _ex_handler;
146148

147149
/* init ceph::crypto */
148150
void init_crypto();

src/common/options/global.yaml.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,14 @@ options:
433433
flags:
434434
- startup
435435
with_legacy: true
436+
- name: breakpad
437+
type: bool
438+
level: advanced
439+
desc: setup breakpad crash handler
440+
default: false
441+
flags:
442+
- startup
443+
with_legacy: true
436444
- name: crash_dir
437445
type: str
438446
level: advanced

src/global/global_init.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
#include "extblkdev/ExtBlkDevPlugin.h"
2727
#include "global/global_context.h"
2828
#include "global/global_init.h"
29+
#include <client/linux/handler/minidump_descriptor.h>
30+
#include <google_breakpad/common/minidump_format.h>
2931
#include "global/pidfile.h"
3032
#include "global/signal_handler.h"
3133
#include "include/compat.h"
@@ -178,6 +180,15 @@ void global_pre_init(
178180
g_conf().complain_about_parse_error(g_ceph_context);
179181
}
180182

183+
static bool dumpCallback(
184+
const google_breakpad::MinidumpDescriptor& descriptor, void* context,
185+
bool succeeded) {
186+
char buf[1024];
187+
snprintf(buf, sizeof(buf), "minidump created in path %s", descriptor.path());
188+
dout_emergency(buf);
189+
return succeeded;
190+
}
191+
181192
boost::intrusive_ptr<CephContext>
182193
global_init(const std::map<std::string,std::string> *defaults,
183194
std::vector < const char* >& args,
@@ -215,6 +226,13 @@ global_init(const std::map<std::string,std::string> *defaults,
215226
if (g_conf()->fatal_signal_handlers) {
216227
install_standard_sighandlers();
217228
}
229+
230+
if (g_conf()->breakpad) {
231+
google_breakpad::MinidumpDescriptor descriptor(g_conf()->crash_dir);
232+
g_ceph_context->_ex_handler.reset(
233+
new google_breakpad::ExceptionHandler(descriptor, nullptr, dumpCallback, nullptr, true, -1));
234+
}
235+
218236
ceph::register_assert_context(g_ceph_context);
219237

220238
if (g_conf()->log_flush_on_exit)

0 commit comments

Comments
 (0)