diff --git a/src/backends/sentry_backend_breakpad.cpp b/src/backends/sentry_backend_breakpad.cpp index afbf910a2..670ed23d3 100644 --- a/src/backends/sentry_backend_breakpad.cpp +++ b/src/backends/sentry_backend_breakpad.cpp @@ -119,35 +119,7 @@ sentry__breakpad_backend_callback( } if (should_handle) { - sentry_envelope_t *envelope = sentry__prepare_event( - options, event, nullptr, !options->on_crash_func); - sentry_session_t *session = sentry__end_current_session_with_status( - SENTRY_SESSION_STATUS_CRASHED); - sentry__envelope_add_session(envelope, session); - - // the minidump is added as an attachment, - // with type `event.minidump` - sentry_envelope_item_t *item = sentry__envelope_add_from_path( - envelope, dump_path, "attachment"); - if (item) { - sentry__envelope_item_set_header(item, "attachment_type", - sentry_value_new_string("event.minidump")); - - sentry__envelope_item_set_header(item, "filename", -#ifdef SENTRY_PLATFORM_WINDOWS - sentry__value_new_string_from_wstr( -#else - sentry_value_new_string( -#endif - sentry__path_filename(dump_path))); - } - - // capture the envelope with the disk transport - sentry_transport_t *disk_transport - = sentry_new_disk_transport(options->run); - sentry__capture_envelope(disk_transport, envelope); - sentry__transport_dump_queue(disk_transport, options->run); - sentry_transport_free(disk_transport); + sentry__capture_minidump(dump_path, event, options); // now that the envelope was written, we can remove the temporary // minidump file diff --git a/src/sentry_core.c b/src/sentry_core.c index 8b35d0469..826354c84 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -1169,3 +1169,29 @@ sentry_clear_crashed_last_run(void) sentry__options_unlock(); return success ? 0 : 1; } + +void sentry__capture_minidump(sentry_path_t *dump_path, sentry_value_t event, + const sentry_options_t *options) +{ + sentry_envelope_t *envelope = sentry__prepare_event( + options, event, NULL, !options->on_crash_func); + sentry_session_t *session = sentry__end_current_session_with_status( + SENTRY_SESSION_STATUS_CRASHED); + sentry__envelope_add_session(envelope, session); + + sentry_envelope_item_t *item = sentry__envelope_add_from_path( + envelope, dump_path, "attachment"); + if (item) { + sentry__envelope_item_set_header(item, "attachment_type", + sentry_value_new_string("event.minidump")); + + sentry__envelope_item_set_header(item, "filename", +#ifdef SENTRY_PLATFORM_WINDOWS + sentry__value_new_string_from_wstr( +#else + sentry_value_new_string( +#endif + sentry__path_filename(dump_path))); + } + sentry__capture_envelope(options->transport, envelope); +} \ No newline at end of file diff --git a/src/sentry_core.h b/src/sentry_core.h index 6ee6c387e..7b1e26c6b 100644 --- a/src/sentry_core.h +++ b/src/sentry_core.h @@ -110,6 +110,11 @@ sentry_options_t *sentry__options_lock(void); */ void sentry__options_unlock(void); +/** + * + */ +void sentry__capture_minidump(sentry_path_t *dump_path, sentry_value_t event, const sentry_options_t *options); + #define SENTRY_WITH_OPTIONS(Options) \ for (const sentry_options_t *Options = sentry__options_getref(); Options; \ sentry_options_free((sentry_options_t *)Options), Options = NULL)