From d6e922d3061e84939de12ea75181fac2c9dc46ab Mon Sep 17 00:00:00 2001 From: PlasmaDev5 Date: Fri, 11 Oct 2024 19:57:13 +0100 Subject: [PATCH 01/24] feat: programmatic minidump capture This provides a new function that will allow for independently created minidumps to be captured by sentry Resolves: https://github.com/getsentry/sentry-native/issues/1050 --- src/backends/sentry_backend_breakpad.cpp | 30 +----------------------- src/sentry_core.c | 26 ++++++++++++++++++++ src/sentry_core.h | 5 ++++ 3 files changed, 32 insertions(+), 29 deletions(-) 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) From a84fd99f2d9b4f1f64a95b52c1df4bce27f27e45 Mon Sep 17 00:00:00 2001 From: PlasmaDev5 Date: Fri, 11 Oct 2024 20:50:09 +0100 Subject: [PATCH 02/24] fixed compile errors --- include/sentry.h | 8 ++++++++ src/backends/sentry_backend_breakpad.cpp | 2 +- src/sentry_core.c | 4 ++-- src/sentry_core.h | 5 ----- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/sentry.h b/include/sentry.h index e6aebcbdc..9756f3e92 100644 --- a/include/sentry.h +++ b/include/sentry.h @@ -1362,6 +1362,14 @@ SENTRY_API sentry_user_consent_t sentry_user_consent_get(void); */ SENTRY_API sentry_uuid_t sentry_capture_event(sentry_value_t event); +struct sentry_path_s; +typedef struct sentry_path_s sentry_path_t; + +/** + * This function allows for independently created minidumps to be captured. + */ +SENTRY_API void sentry_capture_minidump(sentry_path_t *dump_path, sentry_value_t event, const sentry_options_t *options); + /** * Captures an exception to be handled by the backend. * diff --git a/src/backends/sentry_backend_breakpad.cpp b/src/backends/sentry_backend_breakpad.cpp index 670ed23d3..9e67e3a86 100644 --- a/src/backends/sentry_backend_breakpad.cpp +++ b/src/backends/sentry_backend_breakpad.cpp @@ -119,7 +119,7 @@ sentry__breakpad_backend_callback( } if (should_handle) { - sentry__capture_minidump(dump_path, event, options); + 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 826354c84..b20cdfa8e 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -1170,7 +1170,7 @@ sentry_clear_crashed_last_run(void) return success ? 0 : 1; } -void sentry__capture_minidump(sentry_path_t *dump_path, sentry_value_t event, +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( @@ -1194,4 +1194,4 @@ void sentry__capture_minidump(sentry_path_t *dump_path, sentry_value_t event, 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 7b1e26c6b..6ee6c387e 100644 --- a/src/sentry_core.h +++ b/src/sentry_core.h @@ -110,11 +110,6 @@ 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) From 2a3c943ac5277e191c927e70e65f5c6b8fc1027c Mon Sep 17 00:00:00 2001 From: PlasmaDev5 Date: Mon, 14 Oct 2024 23:41:53 +0100 Subject: [PATCH 03/24] Rework of programmatic minidumps based on feedback --- CHANGELOG.md | 4 ++ include/sentry.h | 5 +- src/backends/sentry_backend_breakpad.cpp | 32 +++++++++- src/sentry_core.c | 80 ++++++++++++++++++------ 4 files changed, 95 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6462f03ed..cea72e854 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +**Features**: + +- Add ability to capture independently created minidumps ([#1052](https://github.com/getsentry/sentry-native/pull/1052)) + **Fixes**: - Reject invalid trace- and span-ids in context update from header ([#1046](https://github.com/getsentry/sentry-native/pull/1046)) diff --git a/include/sentry.h b/include/sentry.h index 9756f3e92..3f1d4d7ee 100644 --- a/include/sentry.h +++ b/include/sentry.h @@ -1362,13 +1362,10 @@ SENTRY_API sentry_user_consent_t sentry_user_consent_get(void); */ SENTRY_API sentry_uuid_t sentry_capture_event(sentry_value_t event); -struct sentry_path_s; -typedef struct sentry_path_s sentry_path_t; - /** * This function allows for independently created minidumps to be captured. */ -SENTRY_API void sentry_capture_minidump(sentry_path_t *dump_path, sentry_value_t event, const sentry_options_t *options); +SENTRY_API void sentry_capture_minidump(const char *dump_path, sentry_value_t event, const sentry_options_t *options); /** * Captures an exception to be handled by the backend. diff --git a/src/backends/sentry_backend_breakpad.cpp b/src/backends/sentry_backend_breakpad.cpp index 9e67e3a86..45c2b91b4 100644 --- a/src/backends/sentry_backend_breakpad.cpp +++ b/src/backends/sentry_backend_breakpad.cpp @@ -98,7 +98,7 @@ sentry__breakpad_backend_callback( sentry_value_set_by_key( event, "level", sentry__value_new_level(SENTRY_LEVEL_FATAL)); - SENTRY_WITH_OPTIONS (options) { + SENTRY_WITH_OPTIONS (options) { sentry__write_crash_marker(options); bool should_handle = true; @@ -119,7 +119,35 @@ sentry__breakpad_backend_callback( } if (should_handle) { - sentry_capture_minidump(dump_path, event, options); + 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); // 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 b20cdfa8e..28bacaf29 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -1170,28 +1170,68 @@ sentry_clear_crashed_last_run(void) return success ? 0 : 1; } -void sentry_capture_minidump(sentry_path_t *dump_path, sentry_value_t event, +void sentry_capture_minidump(const char *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_path_t *sentry_dump_path = sentry__path_from_str_n(dump_path, strlen(dump_path)); - 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_WITH_OPTIONS (options) { + sentry__write_crash_marker(options); + + sentry_envelope_t *envelope = NULL; + sentry__ensure_event_id(event, NULL); + envelope = sentry__envelope_new(); + if (!envelope || !sentry__envelope_add_event(envelope, event)) { + sentry_envelope_free(envelope); + sentry_value_decref(event); + } + + SENTRY_TRACE("adding attachments to envelope"); + for (sentry_attachment_t *attachment = options->attachments; attachment; + attachment = attachment->next) { + sentry_envelope_item_t *item = sentry__envelope_add_from_path( + envelope, attachment->path, "attachment"); + if (!item) { + continue; + } + 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(attachment->path))); + } + + sentry_envelope_item_t *item = sentry__envelope_add_from_path( + envelope, sentry_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(sentry_dump_path))); + } + + sentry__capture_envelope(options->transport, envelope); + + // now that the envelope was written, we can remove the temporary + // minidump file + sentry__path_remove(sentry_dump_path); + sentry__path_free(sentry_dump_path); + + + // after capturing the crash event, try to dump all the in-flight + // data of the previous transports + sentry__transport_dump_queue(options->transport, options->run); + // and restore the old transport } - sentry__capture_envelope(options->transport, envelope); + + } From 081a05c7b71b125a03f1d62eab29f8a93a609f9a Mon Sep 17 00:00:00 2001 From: PlasmaDev5 Date: Mon, 14 Oct 2024 23:54:16 +0100 Subject: [PATCH 04/24] Remove unused parameters --- include/sentry.h | 2 +- src/sentry_core.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/include/sentry.h b/include/sentry.h index 3f1d4d7ee..d28d34c72 100644 --- a/include/sentry.h +++ b/include/sentry.h @@ -1365,7 +1365,7 @@ SENTRY_API sentry_uuid_t sentry_capture_event(sentry_value_t event); /** * This function allows for independently created minidumps to be captured. */ -SENTRY_API void sentry_capture_minidump(const char *dump_path, sentry_value_t event, const sentry_options_t *options); +SENTRY_API void sentry_capture_minidump(const char *dump_path, sentry_value_t event); /** * Captures an exception to be handled by the backend. diff --git a/src/sentry_core.c b/src/sentry_core.c index 28bacaf29..b215048a3 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -1170,8 +1170,7 @@ sentry_clear_crashed_last_run(void) return success ? 0 : 1; } -void sentry_capture_minidump(const char *dump_path, sentry_value_t event, - const sentry_options_t *options) +void sentry_capture_minidump(const char *dump_path, sentry_value_t event) { sentry_path_t *sentry_dump_path = sentry__path_from_str_n(dump_path, strlen(dump_path)); From c14120120ae71875008a1a11e8a407ce1e8cf7a4 Mon Sep 17 00:00:00 2001 From: PlasmaDev5 Date: Tue, 15 Oct 2024 00:10:49 +0100 Subject: [PATCH 05/24] Address Lint errors --- include/sentry.h | 3 ++- src/sentry_core.c | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/include/sentry.h b/include/sentry.h index d28d34c72..4333fbf8d 100644 --- a/include/sentry.h +++ b/include/sentry.h @@ -1365,7 +1365,8 @@ SENTRY_API sentry_uuid_t sentry_capture_event(sentry_value_t event); /** * This function allows for independently created minidumps to be captured. */ -SENTRY_API void sentry_capture_minidump(const char *dump_path, sentry_value_t event); +SENTRY_API void sentry_capture_minidump( + const char *dump_path, sentry_value_t event); /** * Captures an exception to be handled by the backend. diff --git a/src/sentry_core.c b/src/sentry_core.c index b215048a3..2ea141f5e 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -1170,9 +1170,11 @@ sentry_clear_crashed_last_run(void) return success ? 0 : 1; } -void sentry_capture_minidump(const char *dump_path, sentry_value_t event) +void +sentry_capture_minidump(const char *dump_path, sentry_value_t event) { - sentry_path_t *sentry_dump_path = sentry__path_from_str_n(dump_path, strlen(dump_path)); + sentry_path_t *sentry_dump_path + = sentry__path_from_str_n(dump_path, strlen(dump_path)); SENTRY_WITH_OPTIONS (options) { @@ -1195,11 +1197,11 @@ void sentry_capture_minidump(const char *dump_path, sentry_value_t event) continue; } sentry__envelope_item_set_header(item, "filename", - #ifdef SENTRY_PLATFORM_WINDOWS +#ifdef SENTRY_PLATFORM_WINDOWS sentry__value_new_string_from_wstr( - #else +#else sentry_value_new_string( - #endif +#endif sentry__path_filename(attachment->path))); } @@ -1210,11 +1212,11 @@ void sentry_capture_minidump(const char *dump_path, sentry_value_t event) sentry_value_new_string("event.minidump")); sentry__envelope_item_set_header(item, "filename", - #ifdef SENTRY_PLATFORM_WINDOWS +#ifdef SENTRY_PLATFORM_WINDOWS sentry__value_new_string_from_wstr( - #else +#else sentry_value_new_string( - #endif +#endif sentry__path_filename(sentry_dump_path))); } @@ -1225,7 +1227,6 @@ void sentry_capture_minidump(const char *dump_path, sentry_value_t event) sentry__path_remove(sentry_dump_path); sentry__path_free(sentry_dump_path); - // after capturing the crash event, try to dump all the in-flight // data of the previous transports sentry__transport_dump_queue(options->transport, options->run); From ac83d5ba3ae0e3dbc02f14c0b2d91a00ed6f79bc Mon Sep 17 00:00:00 2001 From: PlasmaDev5 Date: Tue, 15 Oct 2024 22:10:44 +0100 Subject: [PATCH 06/24] Address more review feedback --- include/sentry.h | 2 +- src/sentry_core.c | 27 ++++++++++++--------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/include/sentry.h b/include/sentry.h index 4333fbf8d..8e1e782c4 100644 --- a/include/sentry.h +++ b/include/sentry.h @@ -1366,7 +1366,7 @@ SENTRY_API sentry_uuid_t sentry_capture_event(sentry_value_t event); * This function allows for independently created minidumps to be captured. */ SENTRY_API void sentry_capture_minidump( - const char *dump_path, sentry_value_t event); + const char *dump_path, sentry_value_t event, bool removeDumpOnSend); /** * Captures an exception to be handled by the backend. diff --git a/src/sentry_core.c b/src/sentry_core.c index 2ea141f5e..36c25acef 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -1171,16 +1171,19 @@ sentry_clear_crashed_last_run(void) } void -sentry_capture_minidump(const char *dump_path, sentry_value_t event) +sentry_capture_minidump(const char *dump_path, sentry_value_t event, bool removeDumpOnSend) { sentry_path_t *sentry_dump_path = sentry__path_from_str_n(dump_path, strlen(dump_path)); + if(sentry_dump_path == NULL) { + SENTRY_WARN("'sentry_capture_minidump' Failed due to null path to minidump"); + return; + } SENTRY_WITH_OPTIONS (options) { - sentry__write_crash_marker(options); - - sentry_envelope_t *envelope = NULL; + sentry_envelope_t *envelope + = NULL; sentry__ensure_event_id(event, NULL); envelope = sentry__envelope_new(); if (!envelope || !sentry__envelope_add_event(envelope, event)) { @@ -1222,16 +1225,10 @@ sentry_capture_minidump(const char *dump_path, sentry_value_t event) sentry__capture_envelope(options->transport, envelope); - // now that the envelope was written, we can remove the temporary - // minidump file - sentry__path_remove(sentry_dump_path); - sentry__path_free(sentry_dump_path); - - // after capturing the crash event, try to dump all the in-flight - // data of the previous transports - sentry__transport_dump_queue(options->transport, options->run); - // and restore the old transport - } + if(removeDumpOnSend){ + sentry__path_remove(sentry_dump_path); + } - + sentry__path_free(sentry_dump_path); + } } From 39c0bfd511abcef3f66f79fe0522674939287877 Mon Sep 17 00:00:00 2001 From: PlasmaDev5 Date: Tue, 15 Oct 2024 22:13:01 +0100 Subject: [PATCH 07/24] Address Lint errors --- src/sentry_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/sentry_core.c b/src/sentry_core.c index 36c25acef..f8f18bbfe 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -1177,7 +1177,8 @@ sentry_capture_minidump(const char *dump_path, sentry_value_t event, bool remove = sentry__path_from_str_n(dump_path, strlen(dump_path)); if(sentry_dump_path == NULL) { - SENTRY_WARN("'sentry_capture_minidump' Failed due to null path to minidump"); + SENTRY_WARN( + "'sentry_capture_minidump' Failed due to null path to minidump"); return; } @@ -1225,7 +1226,7 @@ sentry_capture_minidump(const char *dump_path, sentry_value_t event, bool remove sentry__capture_envelope(options->transport, envelope); - if(removeDumpOnSend){ + if (removeDumpOnSend) { sentry__path_remove(sentry_dump_path); } From 6b25152f1f211bc2688e25e92ed716c4da0b2af2 Mon Sep 17 00:00:00 2001 From: PlasmaDev5 Date: Tue, 15 Oct 2024 22:16:36 +0100 Subject: [PATCH 08/24] Address more lint errors --- src/sentry_core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/sentry_core.c b/src/sentry_core.c index f8f18bbfe..9ced90305 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -1171,12 +1171,13 @@ sentry_clear_crashed_last_run(void) } void -sentry_capture_minidump(const char *dump_path, sentry_value_t event, bool removeDumpOnSend) +sentry_capture_minidump( + const char *dump_path, sentry_value_t event, bool removeDumpOnSend) { sentry_path_t *sentry_dump_path = sentry__path_from_str_n(dump_path, strlen(dump_path)); - if(sentry_dump_path == NULL) { + if (sentry_dump_path == NULL) { SENTRY_WARN( "'sentry_capture_minidump' Failed due to null path to minidump"); return; @@ -1231,5 +1232,5 @@ sentry_capture_minidump(const char *dump_path, sentry_value_t event, bool remove } sentry__path_free(sentry_dump_path); - } + } } From 1f42aaab1de5eda6946b0d1b93f711409b1359b0 Mon Sep 17 00:00:00 2001 From: PlasmaDev5 Date: Tue, 15 Oct 2024 22:28:06 +0100 Subject: [PATCH 09/24] changed from bool to int due to undefined errors --- include/sentry.h | 2 +- src/sentry_core.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/sentry.h b/include/sentry.h index 8e1e782c4..134d48859 100644 --- a/include/sentry.h +++ b/include/sentry.h @@ -1366,7 +1366,7 @@ SENTRY_API sentry_uuid_t sentry_capture_event(sentry_value_t event); * This function allows for independently created minidumps to be captured. */ SENTRY_API void sentry_capture_minidump( - const char *dump_path, sentry_value_t event, bool removeDumpOnSend); + const char *dump_path, sentry_value_t event, int removeDumpOnSend); /** * Captures an exception to be handled by the backend. diff --git a/src/sentry_core.c b/src/sentry_core.c index 9ced90305..c95096e6d 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -1172,7 +1172,7 @@ sentry_clear_crashed_last_run(void) void sentry_capture_minidump( - const char *dump_path, sentry_value_t event, bool removeDumpOnSend) + const char *dump_path, sentry_value_t event, int removeDumpOnSend) { sentry_path_t *sentry_dump_path = sentry__path_from_str_n(dump_path, strlen(dump_path)); @@ -1227,7 +1227,8 @@ sentry_capture_minidump( sentry__capture_envelope(options->transport, envelope); - if (removeDumpOnSend) { + bool removeDumpOnSendBool = removeDumpOnSend; + if (removeDumpOnSendBool) { sentry__path_remove(sentry_dump_path); } From 8233951043462c568d4d780c27c801d288a31ed3 Mon Sep 17 00:00:00 2001 From: PlasmaDev5 Date: Wed, 16 Oct 2024 16:54:10 +0100 Subject: [PATCH 10/24] Address review feedback --- include/sentry.h | 2 +- src/sentry_core.c | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/include/sentry.h b/include/sentry.h index 134d48859..ff68bc7f6 100644 --- a/include/sentry.h +++ b/include/sentry.h @@ -1366,7 +1366,7 @@ SENTRY_API sentry_uuid_t sentry_capture_event(sentry_value_t event); * This function allows for independently created minidumps to be captured. */ SENTRY_API void sentry_capture_minidump( - const char *dump_path, sentry_value_t event, int removeDumpOnSend); + const char *dump_path, sentry_value_t event, int remove_dump_on_send); /** * Captures an exception to be handled by the backend. diff --git a/src/sentry_core.c b/src/sentry_core.c index c95096e6d..dc760bcd0 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -1172,7 +1172,7 @@ sentry_clear_crashed_last_run(void) void sentry_capture_minidump( - const char *dump_path, sentry_value_t event, int removeDumpOnSend) + const char *dump_path, sentry_value_t event, int remove_dump_on_send) { sentry_path_t *sentry_dump_path = sentry__path_from_str_n(dump_path, strlen(dump_path)); @@ -1184,10 +1184,8 @@ sentry_capture_minidump( } SENTRY_WITH_OPTIONS (options) { - sentry_envelope_t *envelope - = NULL; sentry__ensure_event_id(event, NULL); - envelope = sentry__envelope_new(); + sentry_envelope_t *envelope = sentry__envelope_new(); if (!envelope || !sentry__envelope_add_event(envelope, event)) { sentry_envelope_free(envelope); sentry_value_decref(event); @@ -1227,8 +1225,8 @@ sentry_capture_minidump( sentry__capture_envelope(options->transport, envelope); - bool removeDumpOnSendBool = removeDumpOnSend; - if (removeDumpOnSendBool) { + bool remove_dump_on_send_bool = remove_dump_on_send; + if (remove_dump_on_send_bool) { sentry__path_remove(sentry_dump_path); } From ed51a88f0a7313eb4ceaa5466e0bae2c6bc5923a Mon Sep 17 00:00:00 2001 From: PlasmaDev5 Date: Wed, 23 Oct 2024 19:02:15 +0100 Subject: [PATCH 11/24] Work on addressing feedback, example and test --- CMakeLists.txt | 3 ++ examples/example.c | 10 ++++++ src/sentry_core.c | 4 ++- tests/fixtures/minidump.dmp | Bin 0 -> 42412 bytes tests/test_capture_minidump.py | 63 +++++++++++++++++++++++++++++++++ 5 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 tests/fixtures/minidump.dmp create mode 100644 tests/test_capture_minidump.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 426bd0682..770ce074d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -582,6 +582,9 @@ if(SENTRY_BUILD_EXAMPLES) set_target_properties(sentry_example PROPERTIES FOLDER ${SENTRY_FOLDER}) endif() + add_custom_command(TARGET sentry_example POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/tests/fixtures/minidump.dmp" "$/minidump.dmp") + add_test(NAME sentry_example COMMAND sentry_example) endif() diff --git a/examples/example.c b/examples/example.c index 42e76231e..f435e7fa0 100644 --- a/examples/example.c +++ b/examples/example.c @@ -428,6 +428,16 @@ main(int argc, char **argv) sentry_transaction_finish(tx); } + if (has_arg(argc, argv, "capture-minidump")) { + sentry_value_t event = sentry_value_new_message_event( + SENTRY_LEVEL_INFO, "my-logger", "Hello Minidump!"); + sentry_capture_minidump( + "minidump.dmp", + event, + 0); + sentry_capture_event(event); + } + // make sure everything flushes sentry_close(); diff --git a/src/sentry_core.c b/src/sentry_core.c index dc760bcd0..23ca3aed6 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -1183,12 +1183,14 @@ sentry_capture_minidump( return; } - SENTRY_WITH_OPTIONS (options) { + SENTRY_WITH_OPTIONS (options) { sentry__ensure_event_id(event, NULL); sentry_envelope_t *envelope = sentry__envelope_new(); if (!envelope || !sentry__envelope_add_event(envelope, event)) { sentry_envelope_free(envelope); sentry_value_decref(event); + sentry__path_free(sentry_dump_path); + return; } SENTRY_TRACE("adding attachments to envelope"); diff --git a/tests/fixtures/minidump.dmp b/tests/fixtures/minidump.dmp new file mode 100644 index 0000000000000000000000000000000000000000..70b2ef7e884da58e045d7cdce3323f90b9db3207 GIT binary patch literal 42412 zcmeHQ34E2swLdpu3CI%G#+3`Wge90@fCwlTNFZ2{$RdkTvO;3EYZ4$qgbP|s(PE@7 zs9+;iNYz3_%VMi9Ptb?Blq$7U1p_XC3q}P5S@O=Ang3nBBsaOV^@%TYf8RZ`oH^&r znKR2b^L_J;iyfEn+qE~BwI?DwU*gLD+;tX0!5luqS4c~uW(*VCu|I^UE&H88L}^`# znzMfwUyn{CYQeCauO#+x7K-6Z(uDpbMr>mv>cajn8SV-r;_S47ugVLEI7p#{2n`<~NR zE`km;!fY-xE}_GsEA@yD#7UgE(KL=Gk)0+|Ath5TrSX40|Jyk>lX56sqxtz4iJQCW z2_k65GOc3DW;(MdgXuS(rqp0_Ei?PJ)zsAVr~WjMuPExLu4I-ijbox|Cd-@7vAN7= zhVo}~IGGAmtmKQN0elUl2+rAG`9;bmcP?rmjZ)Z}QYp{Wy2lRsa_vU49mwTtE&j?G z$_-(mY4^Y@V~<>7fDU)#k%%VubJswZ3C-qj>#s}6-EF0JdFM1+*jM^o^qp)T%GnM4 zv4Gg?(988023g%Qltw8rrXK37U^x#~*>`Ch|8rlWzg(%MbmLcO{Ps@z; z#vgnYk8iUr_&b4rvm5_dvBuwWH7jhM1;1M3$DDaW;cw^vCl_h_7zg_^Ecl^X`9<$P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$XNp#&C$`D}swNv#v z+j+*oZRYG4=oe?n6rIt}n=Llao$==o*!eQUJ)y)RADMm*VH^^GoYf!rwiCo}zuJ08 zfVD>j=8pqQ@6`RZ^RzxQ$7S^7GGR#J{<5b@M|=~kTLXwXLE*JZ+Jzu@Zrg75#McI#eKfD!_LI73XbSoeUu$sAq(N>jV_Qiv@ih(c@^ldX3! z_2$ha8&^WZe&qV({)uWA5VNTG*1qTOCYiGiz|b1Tcch;*XBhymv9Q-seb1UU3x0oi&BxoGSg`P} zRx&%*KD*oJaQl*sFSeCSkYZbvX;7(vt?E@?$9eVm+^sXkweNNpiy}fEu<xm0U#I&5B8d;jd$f zz8%tg)G;oHTMq0L0UAUrJ>*|_gL#_ZIvn{4`%G1UjMquzOliT&Tu@aO`9o%-fA1@4ckc zL12Kv-}#+shv+9v7~g?7{*6x0+oS`G8m7>RL$QXFj{vTl*C#eUZ@@`cwCKb5xHH z7+28m?sVIM9#{BF8k%*P))Vm1Ut8&#>Tr*D)fPS;`g&y)<+8$_(OQ1I1yJ=1Jw9FO zUZvFEy{TG*RdStP6xv6PWBgR5f~A)5wvN8(WtQ**mhcgGc#T?3jd}4o{cUeEj-&iT z_&cHELI>;bdzA2ZRHUjuH{$_6)S?`A8KI{?J)!$A!EcPS+7|b`e8&S}K$IuWL?j`h>AOZv-!)=eX!@>^yFsY& zpy|6tP2V;0SVV2#Ird$n+6DL*W716i(`LSaFvwzlXE)#3!uT`UuICF_8Q%Fvy-qOn zh>k~odPv7(-2-rEUp?+4Y=sr^{?kK8`cHQZ@tc6A_dV8>hQnPZ zG@B1B_x)Ri@A~JgZ)$=myu+r;_8(L0lvuY!zQABv`*k%Bzd3|6$@RPCdoDTA^8=e) zv|`BP-}60!TxmW zgQZl0GJcu4L;#0WU|kG2y2FnkWz#qOFI(D} Awg3PC literal 0 HcmV?d00001 diff --git a/tests/test_capture_minidump.py b/tests/test_capture_minidump.py new file mode 100644 index 000000000..c34697375 --- /dev/null +++ b/tests/test_capture_minidump.py @@ -0,0 +1,63 @@ +import itertools +import json +import os +import time +import uuid + +import pytest + +from . import make_dsn, run, Envelope +from .assertions import ( + assert_attachment, + assert_meta, + assert_breadcrumb, + assert_stacktrace, + assert_event, + assert_exception, + assert_inproc_crash, + assert_session, + assert_user_feedback, + assert_minidump, + assert_breakpad_crash, + assert_gzip_content_encoding, + assert_gzip_file_header, +) +from .conditions import has_http, has_breakpad, has_files + +pytestmark = pytest.mark.skipif(not has_http, reason="tests need http") + +# fmt: off +auth_header = ( + "Sentry sentry_key=uiaeosnrtdy, sentry_version=7, sentry_client=sentry.native/0.7.10" +) +# fmt: on + +def test_capture_minidump(cmake, httpserver, build_args): + build_args.update({"SENTRY_BACKEND": "none"}) + tmp_path = cmake(["sentry_example"], build_args) + + httpserver.expect_oneshot_request( + "/api/123456/envelope/", + headers={"x-sentry-auth": auth_header}, + ).respond_with_data("OK") + env = dict(os.environ, SENTRY_DSN=make_dsn(httpserver), SENTRY_RELEASE="🤮🚀") + + run( + tmp_path, + "sentry_example", + ["log", "release-env", "capture-minidump"], + check=True, + env=env, + ) + + assert len(httpserver.log) == 1 + req = httpserver.log[0][0] + body = req.get_data() + + envelope = Envelope.deserialize(body) + + assert_meta(envelope, "🤮🚀") + assert_breadcrumb(envelope) + assert_stacktrace(envelope) + + assert_event(envelope) \ No newline at end of file From 93b298483b89cd0d2d75129407090176b8fae340 Mon Sep 17 00:00:00 2001 From: PlasmaDev5 Date: Wed, 23 Oct 2024 19:09:03 +0100 Subject: [PATCH 12/24] Fixes to lint errors --- examples/example.c | 5 +---- src/backends/sentry_backend_breakpad.cpp | 2 +- src/sentry_core.c | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/examples/example.c b/examples/example.c index f435e7fa0..f9a45c227 100644 --- a/examples/example.c +++ b/examples/example.c @@ -431,10 +431,7 @@ main(int argc, char **argv) if (has_arg(argc, argv, "capture-minidump")) { sentry_value_t event = sentry_value_new_message_event( SENTRY_LEVEL_INFO, "my-logger", "Hello Minidump!"); - sentry_capture_minidump( - "minidump.dmp", - event, - 0); + sentry_capture_minidump("minidump.dmp", event, 0); sentry_capture_event(event); } diff --git a/src/backends/sentry_backend_breakpad.cpp b/src/backends/sentry_backend_breakpad.cpp index 45c2b91b4..afbf910a2 100644 --- a/src/backends/sentry_backend_breakpad.cpp +++ b/src/backends/sentry_backend_breakpad.cpp @@ -98,7 +98,7 @@ sentry__breakpad_backend_callback( sentry_value_set_by_key( event, "level", sentry__value_new_level(SENTRY_LEVEL_FATAL)); - SENTRY_WITH_OPTIONS (options) { + SENTRY_WITH_OPTIONS (options) { sentry__write_crash_marker(options); bool should_handle = true; diff --git a/src/sentry_core.c b/src/sentry_core.c index 23ca3aed6..395d06859 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -1183,7 +1183,7 @@ sentry_capture_minidump( return; } - SENTRY_WITH_OPTIONS (options) { + SENTRY_WITH_OPTIONS (options) { sentry__ensure_event_id(event, NULL); sentry_envelope_t *envelope = sentry__envelope_new(); if (!envelope || !sentry__envelope_add_event(envelope, event)) { From 293a353875fd4964301f9cd973a5c7e56e858a75 Mon Sep 17 00:00:00 2001 From: PlasmaDev Date: Wed, 23 Oct 2024 20:26:26 +0100 Subject: [PATCH 13/24] Apply comment suggestion --- include/sentry.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/sentry.h b/include/sentry.h index ff68bc7f6..cf86efa09 100644 --- a/include/sentry.h +++ b/include/sentry.h @@ -1363,7 +1363,7 @@ SENTRY_API sentry_user_consent_t sentry_user_consent_get(void); SENTRY_API sentry_uuid_t sentry_capture_event(sentry_value_t event); /** - * This function allows for independently created minidumps to be captured. + * Allows capturing independently created minidumps. */ SENTRY_API void sentry_capture_minidump( const char *dump_path, sentry_value_t event, int remove_dump_on_send); From 5878abcd6d47bc7aef218ebce34acd9d5dfc2b21 Mon Sep 17 00:00:00 2001 From: PlasmaDev Date: Wed, 23 Oct 2024 20:26:50 +0100 Subject: [PATCH 14/24] Add empty line to file end --- tests/test_capture_minidump.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_capture_minidump.py b/tests/test_capture_minidump.py index c34697375..8b13648c7 100644 --- a/tests/test_capture_minidump.py +++ b/tests/test_capture_minidump.py @@ -60,4 +60,5 @@ def test_capture_minidump(cmake, httpserver, build_args): assert_breadcrumb(envelope) assert_stacktrace(envelope) - assert_event(envelope) \ No newline at end of file + assert_event(envelope) + From 6170d7d6e18b854d11a1602dbf89e9a9479f1980 Mon Sep 17 00:00:00 2001 From: PlasmaDev Date: Wed, 23 Oct 2024 20:28:20 +0100 Subject: [PATCH 15/24] use parameter directly --- src/sentry_core.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sentry_core.c b/src/sentry_core.c index 395d06859..4dc842d71 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -1227,8 +1227,7 @@ sentry_capture_minidump( sentry__capture_envelope(options->transport, envelope); - bool remove_dump_on_send_bool = remove_dump_on_send; - if (remove_dump_on_send_bool) { + if (remove_dump_on_send) { sentry__path_remove(sentry_dump_path); } From 0f1c8b65e15205060dd74d1a9cf56d2f957de1d9 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Thu, 31 Oct 2024 15:03:16 +0100 Subject: [PATCH 16/24] chore: fix changelog --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a371fafca..46cddeffb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,13 @@ # Changelog -## 0.7.11 +## Unrelaased **Features**: - Add ability to capture independently created minidumps ([#1052](https://github.com/getsentry/sentry-native/pull/1052)) +## 0.7.11 + **Fixes**: - Reject invalid trace- and span-ids in context update from header ([#1046](https://github.com/getsentry/sentry-native/pull/1046)) From 67bd3af80234b611247cd8b8febbc806288530f7 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Thu, 31 Oct 2024 16:28:14 +0100 Subject: [PATCH 17/24] add capture_minidump_n --- include/sentry.h | 2 ++ src/sentry_core.c | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/include/sentry.h b/include/sentry.h index e57ba54bc..52d7c45a3 100644 --- a/include/sentry.h +++ b/include/sentry.h @@ -1367,6 +1367,8 @@ SENTRY_API sentry_uuid_t sentry_capture_event(sentry_value_t event); */ SENTRY_API void sentry_capture_minidump( const char *dump_path, sentry_value_t event, int remove_dump_on_send); +SENTRY_API void sentry_capture_minidump_n(const char *dump_path, + size_t dump_path_len, sentry_value_t event, int remove_dump_on_send); /** * Captures an exception to be handled by the backend. diff --git a/src/sentry_core.c b/src/sentry_core.c index 0a4fc4fb3..6bce69237 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -501,7 +501,7 @@ sentry__prepare_event(const sentry_options_t *options, sentry_value_t event, SENTRY_TRACE("adding attachments to envelope"); for (sentry_attachment_t *attachment = options->attachments; attachment; - attachment = attachment->next) { + attachment = attachment->next) { sentry_envelope_item_t *item = sentry__envelope_add_from_path( envelope, attachment->path, "attachment"); if (!item) { @@ -1178,13 +1178,21 @@ sentry_clear_crashed_last_run(void) void sentry_capture_minidump( const char *dump_path, sentry_value_t event, int remove_dump_on_send) +{ + sentry_capture_minidump_n(dump_path, sentry__guarded_strlen(dump_path), + event, remove_dump_on_send); +} + +void +sentry_capture_minidump_n(const char *dump_path, size_t dump_path_len, + sentry_value_t event, int remove_dump_on_send) { sentry_path_t *sentry_dump_path - = sentry__path_from_str_n(dump_path, strlen(dump_path)); + = sentry__path_from_str_n(dump_path, dump_path_len); if (sentry_dump_path == NULL) { SENTRY_WARN( - "'sentry_capture_minidump' Failed due to null path to minidump"); + "sentry_capture_minidump() failed due to null path to minidump"); return; } @@ -1200,7 +1208,7 @@ sentry_capture_minidump( SENTRY_TRACE("adding attachments to envelope"); for (sentry_attachment_t *attachment = options->attachments; attachment; - attachment = attachment->next) { + attachment = attachment->next) { sentry_envelope_item_t *item = sentry__envelope_add_from_path( envelope, attachment->path, "attachment"); if (!item) { From 7e56ee416ac37c91dfadf9e7e357d655d87a5710 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Thu, 31 Oct 2024 20:12:35 +0100 Subject: [PATCH 18/24] feat: capture minidump from path --- examples/example.c | 7 ++-- include/sentry.h | 7 ++-- src/sentry_core.c | 66 +++++++++++++--------------------- tests/test_capture_minidump.py | 40 ++++++++------------- 4 files changed, 43 insertions(+), 77 deletions(-) diff --git a/examples/example.c b/examples/example.c index f9a45c227..750dffec1 100644 --- a/examples/example.c +++ b/examples/example.c @@ -19,7 +19,7 @@ #ifdef SENTRY_PLATFORM_WINDOWS # include # include -# define sleep_s(SECONDS) Sleep((SECONDS)*1000) +# define sleep_s(SECONDS) Sleep((SECONDS) * 1000) #else # include @@ -429,10 +429,7 @@ main(int argc, char **argv) } if (has_arg(argc, argv, "capture-minidump")) { - sentry_value_t event = sentry_value_new_message_event( - SENTRY_LEVEL_INFO, "my-logger", "Hello Minidump!"); - sentry_capture_minidump("minidump.dmp", event, 0); - sentry_capture_event(event); + sentry_capture_minidump("minidump.dmp"); } // make sure everything flushes diff --git a/include/sentry.h b/include/sentry.h index 52d7c45a3..0f936f0c0 100644 --- a/include/sentry.h +++ b/include/sentry.h @@ -1365,10 +1365,9 @@ SENTRY_API sentry_uuid_t sentry_capture_event(sentry_value_t event); /** * Allows capturing independently created minidumps. */ -SENTRY_API void sentry_capture_minidump( - const char *dump_path, sentry_value_t event, int remove_dump_on_send); -SENTRY_API void sentry_capture_minidump_n(const char *dump_path, - size_t dump_path_len, sentry_value_t event, int remove_dump_on_send); +SENTRY_API void sentry_capture_minidump(const char *dump_path); +SENTRY_API void sentry_capture_minidump_n( + const char *dump_path, size_t dump_path_len); /** * Captures an exception to be handled by the backend. diff --git a/src/sentry_core.c b/src/sentry_core.c index 6bce69237..d16ac1aed 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -18,6 +18,7 @@ #include "sentry_tracing.h" #include "sentry_transport.h" #include "sentry_value.h" +#include "transports/sentry_disk_transport.h" #ifdef SENTRY_INTEGRATION_QT # include "integrations/sentry_integration_qt.h" @@ -1176,55 +1177,37 @@ sentry_clear_crashed_last_run(void) } void -sentry_capture_minidump( - const char *dump_path, sentry_value_t event, int remove_dump_on_send) +sentry_capture_minidump(const char *dump_path) { - sentry_capture_minidump_n(dump_path, sentry__guarded_strlen(dump_path), - event, remove_dump_on_send); + sentry_capture_minidump_n(dump_path, sentry__guarded_strlen(dump_path)); } void -sentry_capture_minidump_n(const char *dump_path, size_t dump_path_len, - sentry_value_t event, int remove_dump_on_send) +sentry_capture_minidump_n(const char *dump_path_str, size_t dump_path_len) { - sentry_path_t *sentry_dump_path - = sentry__path_from_str_n(dump_path, dump_path_len); + sentry_path_t *dump_path + = sentry__path_from_str_n(dump_path_str, dump_path_len); - if (sentry_dump_path == NULL) { + if (dump_path == NULL) { SENTRY_WARN( "sentry_capture_minidump() failed due to null path to minidump"); return; } - SENTRY_WITH_OPTIONS (options) { - sentry__ensure_event_id(event, NULL); - sentry_envelope_t *envelope = sentry__envelope_new(); - if (!envelope || !sentry__envelope_add_event(envelope, event)) { - sentry_envelope_free(envelope); - sentry_value_decref(event); - sentry__path_free(sentry_dump_path); - return; - } + SENTRY_DEBUGF( + "Capturing minidump \"%" SENTRY_PATH_PRI "\"", dump_path->path); - SENTRY_TRACE("adding attachments to envelope"); - for (sentry_attachment_t *attachment = options->attachments; attachment; - attachment = attachment->next) { - sentry_envelope_item_t *item = sentry__envelope_add_from_path( - envelope, attachment->path, "attachment"); - if (!item) { - continue; - } - 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(attachment->path))); - } + sentry_value_t event = sentry_value_new_event(); + sentry_value_set_by_key( + event, "level", sentry__value_new_level(SENTRY_LEVEL_FATAL)); - sentry_envelope_item_t *item = sentry__envelope_add_from_path( - envelope, sentry_dump_path, "attachment"); + SENTRY_WITH_OPTIONS (options) { + sentry_envelope_t *envelope + = sentry__prepare_event(options, event, NULL, true); + + // 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")); @@ -1235,15 +1218,14 @@ sentry_capture_minidump_n(const char *dump_path, size_t dump_path_len, #else sentry_value_new_string( #endif - sentry__path_filename(sentry_dump_path))); + sentry__path_filename(dump_path))); } sentry__capture_envelope(options->transport, envelope); + } - if (remove_dump_on_send) { - sentry__path_remove(sentry_dump_path); - } + SENTRY_DEBUGF("Minidump has been captured: \"%" SENTRY_PATH_PRI "\"", + dump_path->path); - sentry__path_free(sentry_dump_path); - } + sentry__path_free(dump_path); } diff --git a/tests/test_capture_minidump.py b/tests/test_capture_minidump.py index 8b13648c7..00ae1ffab 100644 --- a/tests/test_capture_minidump.py +++ b/tests/test_capture_minidump.py @@ -1,64 +1,52 @@ -import itertools -import json import os -import time -import uuid +import shutil import pytest from . import make_dsn, run, Envelope from .assertions import ( assert_attachment, - assert_meta, assert_breadcrumb, - assert_stacktrace, - assert_event, - assert_exception, - assert_inproc_crash, - assert_session, - assert_user_feedback, assert_minidump, - assert_breakpad_crash, - assert_gzip_content_encoding, - assert_gzip_file_header, ) -from .conditions import has_http, has_breakpad, has_files +from .conditions import has_http pytestmark = pytest.mark.skipif(not has_http, reason="tests need http") # fmt: off auth_header = ( - "Sentry sentry_key=uiaeosnrtdy, sentry_version=7, sentry_client=sentry.native/0.7.10" + "Sentry sentry_key=uiaeosnrtdy, sentry_version=7, sentry_client=sentry.native/0.7.11" ) # fmt: on -def test_capture_minidump(cmake, httpserver, build_args): - build_args.update({"SENTRY_BACKEND": "none"}) - tmp_path = cmake(["sentry_example"], build_args) + +def test_capture_minidump(cmake, httpserver): + tmp_path = cmake(["sentry_example"], {"SENTRY_BACKEND": "none"}) + + # make sure we are isolated from previous runs + shutil.rmtree(tmp_path / ".sentry-native", ignore_errors=True) httpserver.expect_oneshot_request( "/api/123456/envelope/", headers={"x-sentry-auth": auth_header}, ).respond_with_data("OK") - env = dict(os.environ, SENTRY_DSN=make_dsn(httpserver), SENTRY_RELEASE="🤮🚀") run( tmp_path, "sentry_example", - ["log", "release-env", "capture-minidump"], + ["log", "attachment", "capture-minidump"], check=True, - env=env, + env=dict(os.environ, SENTRY_DSN=make_dsn(httpserver)), ) assert len(httpserver.log) == 1 + req = httpserver.log[0][0] body = req.get_data() envelope = Envelope.deserialize(body) - assert_meta(envelope, "🤮🚀") assert_breadcrumb(envelope) - assert_stacktrace(envelope) + assert_attachment(envelope) - assert_event(envelope) - + assert_minidump(envelope) From 4195343402ed50a1d0ebb2987d6defe5cf75c1b3 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Thu, 31 Oct 2024 20:13:37 +0100 Subject: [PATCH 19/24] chore: update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 46cddeffb..1847d5e4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ **Features**: -- Add ability to capture independently created minidumps ([#1052](https://github.com/getsentry/sentry-native/pull/1052)) +- Add `sentry_capture_minidump()` to capture independently created minidumps ([#1067](https://github.com/getsentry/sentry-native/pull/1067)) ## 0.7.11 From cd75387f7695e06586d8d093073b2a2b538dbe32 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Thu, 31 Oct 2024 22:01:45 +0100 Subject: [PATCH 20/24] cleanup --- include/sentry.h | 5 ++--- src/sentry_core.c | 11 +++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/include/sentry.h b/include/sentry.h index 0f936f0c0..ac00770c8 100644 --- a/include/sentry.h +++ b/include/sentry.h @@ -1365,9 +1365,8 @@ SENTRY_API sentry_uuid_t sentry_capture_event(sentry_value_t event); /** * Allows capturing independently created minidumps. */ -SENTRY_API void sentry_capture_minidump(const char *dump_path); -SENTRY_API void sentry_capture_minidump_n( - const char *dump_path, size_t dump_path_len); +SENTRY_API void sentry_capture_minidump(const char *path); +SENTRY_API void sentry_capture_minidump_n(const char *path, size_t path_len); /** * Captures an exception to be handled by the backend. diff --git a/src/sentry_core.c b/src/sentry_core.c index d16ac1aed..43666a0fb 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -1177,18 +1177,17 @@ sentry_clear_crashed_last_run(void) } void -sentry_capture_minidump(const char *dump_path) +sentry_capture_minidump(const char *path) { - sentry_capture_minidump_n(dump_path, sentry__guarded_strlen(dump_path)); + sentry_capture_minidump_n(path, sentry__guarded_strlen(path)); } void -sentry_capture_minidump_n(const char *dump_path_str, size_t dump_path_len) +sentry_capture_minidump_n(const char *path, size_t path_len) { - sentry_path_t *dump_path - = sentry__path_from_str_n(dump_path_str, dump_path_len); + sentry_path_t *dump_path = sentry__path_from_str_n(path, path_len); - if (dump_path == NULL) { + if (!dump_path) { SENTRY_WARN( "sentry_capture_minidump() failed due to null path to minidump"); return; From a57f84964ee1d6f0e0a9a5fe748be050c55d7529 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Fri, 1 Nov 2024 07:20:45 +0100 Subject: [PATCH 21/24] linter issues From fd97f0c94c43ca0fabc5513ecbb9c02c4dc9e9e4 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Sun, 3 Nov 2024 16:00:48 +0100 Subject: [PATCH 22/24] cleanup, review changes, docs --- include/sentry.h | 6 +++- src/sentry_core.c | 37 +++++++++++++----------- tests/test_capture_minidump.py | 52 ---------------------------------- tests/test_integration_http.py | 33 +++++++++++++++++++++ 4 files changed, 58 insertions(+), 70 deletions(-) delete mode 100644 tests/test_capture_minidump.py diff --git a/include/sentry.h b/include/sentry.h index ac00770c8..b10895ff4 100644 --- a/include/sentry.h +++ b/include/sentry.h @@ -1363,7 +1363,11 @@ SENTRY_API sentry_user_consent_t sentry_user_consent_get(void); SENTRY_API sentry_uuid_t sentry_capture_event(sentry_value_t event); /** - * Allows capturing independently created minidumps. + * Allows capturing independently created minidumps. + * + * This generates a fatal error event, includes the scope and attachments. + * If the event isn't dropped by the before-send hook, the minidump is attached + * and event is sent. */ SENTRY_API void sentry_capture_minidump(const char *path); SENTRY_API void sentry_capture_minidump_n(const char *path, size_t path_len); diff --git a/src/sentry_core.c b/src/sentry_core.c index 43666a0fb..d8f8c0e26 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -18,7 +18,6 @@ #include "sentry_tracing.h" #include "sentry_transport.h" #include "sentry_value.h" -#include "transports/sentry_disk_transport.h" #ifdef SENTRY_INTEGRATION_QT # include "integrations/sentry_integration_qt.h" @@ -1204,27 +1203,31 @@ sentry_capture_minidump_n(const char *path, size_t path_len) sentry_envelope_t *envelope = sentry__prepare_event(options, event, NULL, true); - // 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", + if (envelope) { + // 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( + sentry__value_new_string_from_wstr( #else - sentry_value_new_string( + sentry_value_new_string( #endif - sentry__path_filename(dump_path))); - } + sentry__path_filename(dump_path))); + } - sentry__capture_envelope(options->transport, envelope); - } + sentry__capture_envelope(options->transport, envelope); - SENTRY_DEBUGF("Minidump has been captured: \"%" SENTRY_PATH_PRI "\"", - dump_path->path); + SENTRY_DEBUGF("Minidump has been captured: \"%" SENTRY_PATH_PRI + "\"", + dump_path->path); + } + } sentry__path_free(dump_path); } diff --git a/tests/test_capture_minidump.py b/tests/test_capture_minidump.py deleted file mode 100644 index 00ae1ffab..000000000 --- a/tests/test_capture_minidump.py +++ /dev/null @@ -1,52 +0,0 @@ -import os -import shutil - -import pytest - -from . import make_dsn, run, Envelope -from .assertions import ( - assert_attachment, - assert_breadcrumb, - assert_minidump, -) -from .conditions import has_http - -pytestmark = pytest.mark.skipif(not has_http, reason="tests need http") - -# fmt: off -auth_header = ( - "Sentry sentry_key=uiaeosnrtdy, sentry_version=7, sentry_client=sentry.native/0.7.11" -) -# fmt: on - - -def test_capture_minidump(cmake, httpserver): - tmp_path = cmake(["sentry_example"], {"SENTRY_BACKEND": "none"}) - - # make sure we are isolated from previous runs - shutil.rmtree(tmp_path / ".sentry-native", ignore_errors=True) - - httpserver.expect_oneshot_request( - "/api/123456/envelope/", - headers={"x-sentry-auth": auth_header}, - ).respond_with_data("OK") - - run( - tmp_path, - "sentry_example", - ["log", "attachment", "capture-minidump"], - check=True, - env=dict(os.environ, SENTRY_DSN=make_dsn(httpserver)), - ) - - assert len(httpserver.log) == 1 - - req = httpserver.log[0][0] - body = req.get_data() - - envelope = Envelope.deserialize(body) - - assert_breadcrumb(envelope) - assert_attachment(envelope) - - assert_minidump(envelope) diff --git a/tests/test_integration_http.py b/tests/test_integration_http.py index 6bb34fbe4..ad75ab9b6 100644 --- a/tests/test_integration_http.py +++ b/tests/test_integration_http.py @@ -1,6 +1,7 @@ import itertools import json import os +import shutil import time import uuid @@ -573,3 +574,35 @@ def test_transaction_only(cmake, httpserver, build_args): assert start_timestamp timestamp = time.strptime(payload["timestamp"], RFC3339_FORMAT) assert timestamp >= start_timestamp + + +def test_capture_minidump(cmake, httpserver): + tmp_path = cmake(["sentry_example"], {"SENTRY_BACKEND": "none"}) + + # make sure we are isolated from previous runs + shutil.rmtree(tmp_path / ".sentry-native", ignore_errors=True) + + httpserver.expect_oneshot_request( + "/api/123456/envelope/", + headers={"x-sentry-auth": auth_header}, + ).respond_with_data("OK") + + run( + tmp_path, + "sentry_example", + ["log", "attachment", "capture-minidump"], + check=True, + env=dict(os.environ, SENTRY_DSN=make_dsn(httpserver)), + ) + + assert len(httpserver.log) == 1 + + req = httpserver.log[0][0] + body = req.get_data() + + envelope = Envelope.deserialize(body) + + assert_breadcrumb(envelope) + assert_attachment(envelope) + + assert_minidump(envelope) From abbf110aa33082e2a311b5d0dfc5a1110731f60f Mon Sep 17 00:00:00 2001 From: Ivan Dlugos Date: Sun, 3 Nov 2024 16:04:49 +0100 Subject: [PATCH 23/24] chore: fixup doc --- include/sentry.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/sentry.h b/include/sentry.h index b10895ff4..85baf2ac1 100644 --- a/include/sentry.h +++ b/include/sentry.h @@ -1366,8 +1366,8 @@ SENTRY_API sentry_uuid_t sentry_capture_event(sentry_value_t event); * Allows capturing independently created minidumps. * * This generates a fatal error event, includes the scope and attachments. - * If the event isn't dropped by the before-send hook, the minidump is attached - * and event is sent. + * If the event isn't dropped by a before-send hook, the minidump is attached + * and the event is sent. */ SENTRY_API void sentry_capture_minidump(const char *path); SENTRY_API void sentry_capture_minidump_n(const char *path, size_t path_len); From 40ec96e89617f3bd89965d55274f273cb6590ab3 Mon Sep 17 00:00:00 2001 From: Ivan Dlugos <6349682+vaind@users.noreply.github.com> Date: Mon, 4 Nov 2024 09:00:33 +0100 Subject: [PATCH 24/24] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00c6b0e2c..044b15050 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## Unrelaased +## Unreleased **Features**: