diff --git a/examples/example.c b/examples/example.c index 32fbc5587..9a720cab1 100644 --- a/examples/example.c +++ b/examples/example.c @@ -503,6 +503,9 @@ main(int argc, char **argv) if (has_arg(argc, argv, "log-attributes")) { sentry_options_set_logs_with_attributes(options, true); } + if (has_arg(argc, argv, "cache-keep")) { + sentry_options_set_keep_dmp_on_crash(options, true); + } if (0 != sentry_init(options)) { return EXIT_FAILURE; diff --git a/include/sentry.h b/include/sentry.h index f9870d5aa..ce25b919b 100644 --- a/include/sentry.h +++ b/include/sentry.h @@ -1374,6 +1374,12 @@ SENTRY_API void sentry_options_set_symbolize_stacktraces( SENTRY_API int sentry_options_get_symbolize_stacktraces( const sentry_options_t *opts); +/** + * Sets whether we should keep .dmp files for breakpad crashes + */ +SENTRY_API void sentry_options_set_keep_dmp_on_crash( + sentry_options_t *opts, int enabled); + /** * Adds a new attachment to be sent along. * diff --git a/src/backends/sentry_backend_breakpad.cpp b/src/backends/sentry_backend_breakpad.cpp index 1c737ce55..5c1de136b 100644 --- a/src/backends/sentry_backend_breakpad.cpp +++ b/src/backends/sentry_backend_breakpad.cpp @@ -196,7 +196,9 @@ breakpad_backend_callback(const google_breakpad::MinidumpDescriptor &descriptor, // now that the envelope was written, we can remove the temporary // minidump file - sentry__path_remove(dump_path); + if (!options->keep_dmp_on_crash) { + sentry__path_remove(dump_path); + } sentry__path_free(dump_path); } else { SENTRY_DEBUG("event was discarded by the `on_crash` hook"); diff --git a/src/path/sentry_path_windows.c b/src/path/sentry_path_windows.c index 5b76497f4..5dc70a058 100644 --- a/src/path/sentry_path_windows.c +++ b/src/path/sentry_path_windows.c @@ -510,7 +510,6 @@ sentry__path_remove(const sentry_path_t *path) : DeleteFileW(path_w); return removal_success ? 0 : !is_last_error_path_not_found(); } - int sentry__path_create_dir_all(const sentry_path_t *path) { diff --git a/src/sentry_options.c b/src/sentry_options.c index b9b6ea4c6..4db2c851c 100644 --- a/src/sentry_options.c +++ b/src/sentry_options.c @@ -53,6 +53,7 @@ sentry_options_new(void) opts->enable_logging_when_crashed = true; opts->propagate_traceparent = false; opts->crashpad_limit_stack_capture_to_sp = false; + opts->keep_dmp_on_crash = false; opts->symbolize_stacktraces = // AIX doesn't have reliable debug IDs for server-side symbolication, // and the diversity of Android makes it infeasible to have access to debug @@ -475,6 +476,12 @@ sentry_options_get_symbolize_stacktraces(const sentry_options_t *opts) return opts->symbolize_stacktraces; } +void +sentry_options_set_keep_dmp_on_crash(sentry_options_t *opts, int enabled) +{ + opts->keep_dmp_on_crash = !!enabled; +} + void sentry_options_set_system_crash_reporter_enabled( sentry_options_t *opts, int enabled) diff --git a/src/sentry_options.h b/src/sentry_options.h index 280703d40..bac09de0b 100644 --- a/src/sentry_options.h +++ b/src/sentry_options.h @@ -45,6 +45,7 @@ struct sentry_options_s { bool enable_logging_when_crashed; bool propagate_traceparent; bool crashpad_limit_stack_capture_to_sp; + bool keep_dmp_on_crash; sentry_attachment_t *attachments; sentry_run_t *run; diff --git a/tests/unit/tests.inc b/tests/unit/tests.inc index f8fa3c920..d09250663 100644 --- a/tests/unit/tests.inc +++ b/tests/unit/tests.inc @@ -8,7 +8,6 @@ XX(attachments_bytes) XX(attachments_extend) XX(background_worker) XX(basic_consent_tracking) -XX(query_consent_requirement) XX(basic_function_transport) XX(basic_function_transport_transaction) XX(basic_function_transport_transaction_ts) @@ -122,6 +121,7 @@ XX(process_invalid) XX(process_spawn) XX(procmaps_parser) XX(propagation_context_init) +XX(query_consent_requirement) XX(rate_limit_parsing) XX(read_envelope_from_file) XX(read_write_envelope_to_file_null)