Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/backends/sentry_backend_crashpad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ preload_scope_breadcrumbs(
{
sentry_value_t breadcrumbs = sentry_value_new_null();
SENTRY_WITH_SCOPE (scope) {
breadcrumbs = sentry__ringbuffer_to_list(scope->breadcrumbs);
breadcrumbs = sentry__scope_breadcrumbs_to_list(scope);
}

size_t breadcrumb_count = sentry_value_get_length(breadcrumbs);
Expand Down Expand Up @@ -597,7 +597,7 @@ crashpad_handler(int signum, siginfo_t *info, ucontext_t *user_context)
// written above and stays breadcrumb-free
SENTRY_WITH_SCOPE (scope) {
sentry_value_set_by_key(crash_event, "breadcrumbs",
sentry__ringbuffer_to_list(scope->breadcrumbs));
sentry__scope_breadcrumbs_to_list(scope));
}

sentry__session_replay_flush_pending(
Expand Down Expand Up @@ -941,17 +941,20 @@ crashpad_backend_startup(

// register attachments from the finalized initial scope
SENTRY_WITH_SCOPE (scope) {
size_t num_attachments = sentry_value_get_length(scope->attachments);
sentry_value_t scope_attachments
= sentry__scope_load_attachments(scope);
size_t num_attachments = sentry_value_get_length(scope_attachments);
for (size_t i = 0; i < num_attachments; i++) {
sentry_value_t attachment
= sentry_value_get_by_index(scope->attachments, i);
= sentry_value_get_by_index(scope_attachments, i);
sentry_path_t *path
= prepare_initial_attachment(attachment, current_run_folder);
if (path) {
attachments.emplace_back(SENTRY_PATH_PLATFORM_STR(path));
sentry__path_free(path);
}
}
sentry_value_decref(scope_attachments);
}

// and add the serialized event, and two rotating breadcrumb files
Expand Down
15 changes: 10 additions & 5 deletions src/backends/sentry_backend_native.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,14 @@ native_backend_preload_scope(
{
sentry_value_t breadcrumbs = sentry_value_new_null();
SENTRY_WITH_SCOPE (scope) {
size_t attachment_count = sentry_value_get_length(scope->attachments);
sentry_value_t attachments = sentry__scope_load_attachments(scope);
size_t attachment_count = sentry_value_get_length(attachments);
for (size_t i = 0; i < attachment_count; i++) {
native_backend_add_attachment(backend,
sentry_value_get_by_index(scope->attachments, i), options);
native_backend_add_attachment(
backend, sentry_value_get_by_index(attachments, i), options);
}
breadcrumbs = sentry__ringbuffer_to_list(scope->breadcrumbs);
sentry_value_decref(attachments);
breadcrumbs = sentry__scope_breadcrumbs_to_list(scope);
}

size_t breadcrumb_count = sentry_value_get_length(breadcrumbs);
Expand Down Expand Up @@ -1144,12 +1146,14 @@ native_backend_write_attachments(const sentry_path_t *event_path)
return;
}
SENTRY_WITH_SCOPE (scope) {
sentry_value_t attachments = scope->attachments;
sentry_value_t attachments = sentry__scope_load_attachments(scope);
if (sentry_value_get_length(attachments) == 0) {
sentry_value_decref(attachments);
continue;
}
sentry_path_t *run_path = sentry__path_dir(event_path);
if (!run_path) {
sentry_value_decref(attachments);
continue;
}
sentry_path_t *attach_list_path
Expand Down Expand Up @@ -1205,6 +1209,7 @@ native_backend_write_attachments(const sentry_path_t *event_path)
sentry__path_free(attach_list_path);
}
sentry__path_free(run_path);
sentry_value_decref(attachments);
}
}

Expand Down
42 changes: 24 additions & 18 deletions src/integrations/sentry_integration_wer.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,18 @@ wer_remove_attachment(void *UNUSED(data), sentry_value_t attachment)
}
}

static void
wer_for_each_attachment(
sentry_scope_t *scope, void *data, void (*callback)(void *, sentry_value_t))
{
sentry_value_t attachments = sentry__scope_load_attachments(scope);
size_t len = sentry_value_get_length(attachments);
for (size_t i = 0; i < len; i++) {
callback(data, sentry_value_get_by_index(attachments, i));
}
sentry_value_decref(attachments);
}

static int
wer_cleanup_tag(const char *key, sentry_value_t UNUSED(value), void *data)
{
Expand All @@ -217,13 +229,11 @@ wer_clear(void *data)
return;
}

sentry_value_foreach_key_value(scope->tags, wer_cleanup_tag, wer_data);
sentry_value_t tags = sentry__scope_load_tags(scope);
sentry_value_foreach_key_value(tags, wer_cleanup_tag, wer_data);
sentry_value_decref(tags);

size_t len = sentry_value_get_length(scope->attachments);
for (size_t i = 0; i < len; i++) {
wer_remove_attachment(
wer_data, sentry_value_get_by_index(scope->attachments, i));
}
wer_for_each_attachment(scope, wer_data, wer_remove_attachment);
}

static void
Expand All @@ -248,12 +258,10 @@ register_wer(
if (sentry__scope_add_observer(scope, observer)) {
wer_data->scope = scope;
wer_data->observer = observer;
sentry_value_foreach_key_value(scope->tags, wer_sync_tag, wer_data);
size_t len = sentry_value_get_length(scope->attachments);
for (size_t i = 0; i < len; i++) {
wer_add_attachment(
wer_data, sentry_value_get_by_index(scope->attachments, i));
}
sentry_value_t tags = sentry__scope_load_tags(scope);
sentry_value_foreach_key_value(tags, wer_sync_tag, wer_data);
sentry_value_decref(tags);
wer_for_each_attachment(scope, wer_data, wer_add_attachment);
}
}

Expand All @@ -267,13 +275,11 @@ unregister_wer(
return;
}

sentry_value_foreach_key_value(scope->tags, wer_cleanup_tag, wer_data);
sentry_value_t tags = sentry__scope_load_tags(scope);
sentry_value_foreach_key_value(tags, wer_cleanup_tag, wer_data);
sentry_value_decref(tags);

size_t len = sentry_value_get_length(scope->attachments);
for (size_t i = 0; i < len; i++) {
wer_remove_attachment(
wer_data, sentry_value_get_by_index(scope->attachments, i));
}
wer_for_each_attachment(scope, wer_data, wer_remove_attachment);

sentry__scope_remove_observer(scope, wer_data->observer);
wer_data->scope = NULL;
Expand Down
Loading
Loading