Skip to content
3 changes: 3 additions & 0 deletions examples/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions include/sentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
4 changes: 3 additions & 1 deletion src/backends/sentry_backend_breakpad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
1 change: 0 additions & 1 deletion src/path/sentry_path_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
7 changes: 7 additions & 0 deletions src/sentry_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/sentry_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/tests.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Loading