Skip to content
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
**Features**

- Android: Expose app-hang detection through the NDK bindings via `NdkOptions.setEnableAppHangTracking()` and `NdkOptions.setAppHangTimeoutMillis()`. ([#1823](https://github.com/getsentry/sentry-native/pull/1823))
- Windows: add wide-char versions of `sentry_capture_minidump` and `sentry_capture_minidump_n`. ([#1827](https://github.com/getsentry/sentry-native/pull/1827))

## 0.15.2

Expand Down
10 changes: 10 additions & 0 deletions include/sentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -2158,6 +2158,16 @@ SENTRY_API sentry_uuid_t sentry_capture_minidump(const char *path);
SENTRY_API sentry_uuid_t sentry_capture_minidump_n(
const char *path, size_t path_len);

#ifdef SENTRY_PLATFORM_WINDOWS
/**
* Wide char versions of `sentry_capture_minidump` and
* `sentry_capture_minidump_n`.
*/
SENTRY_API sentry_uuid_t sentry_capture_minidumpw(const wchar_t *path);
SENTRY_API sentry_uuid_t sentry_capture_minidumpw_n(
const wchar_t *path, size_t path_len);
#endif

/**
* Captures a system-native exception that you retrieve when you manually handle
* `POSIX` signals or `SEH` exceptions and want to keep using that handling
Expand Down
27 changes: 23 additions & 4 deletions src/sentry_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1798,11 +1798,9 @@ sentry_capture_minidump(const char *path)
return sentry_capture_minidump_n(path, sentry__guarded_strlen(path));
}

sentry_uuid_t
sentry_capture_minidump_n(const char *path, size_t path_len)
static sentry_uuid_t
capture_minidump(sentry_path_t *dump_path)
{
sentry_path_t *dump_path = sentry__path_from_str_n(path, path_len);

if (!dump_path) {
SENTRY_WARN(
"sentry_capture_minidump() failed due to null path to minidump");
Expand Down Expand Up @@ -1879,6 +1877,13 @@ sentry_capture_minidump_n(const char *path, size_t path_len)
return sentry_uuid_nil();
}

sentry_uuid_t
sentry_capture_minidump_n(const char *path, size_t path_len)
{
sentry_path_t *dump_path = sentry__path_from_str_n(path, path_len);
return capture_minidump(dump_path);
}

static sentry_attachment_t *
add_attachment(sentry_attachment_t *attachment)
{
Expand Down Expand Up @@ -1982,4 +1987,18 @@ sentry_attach_bytesw_n(const char *buf, size_t buf_len, const wchar_t *filename,
return add_attachment(sentry__attachment_from_buffer(
buf, buf_len, sentry__path_from_wstr_n(filename, filename_len)));
}

sentry_uuid_t
sentry_capture_minidumpw(const wchar_t *path)
{
size_t path_len = path ? wcslen(path) : 0;
return sentry_capture_minidumpw_n(path, path_len);
}

sentry_uuid_t
sentry_capture_minidumpw_n(const wchar_t *path, size_t path_len)
{
sentry_path_t *dump_path = sentry__path_from_wstr_n(path, path_len);
return capture_minidump(dump_path);
}
#endif
26 changes: 26 additions & 0 deletions tests/unit/test_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,32 @@ SENTRY_TEST(capture_minidump_basic)
#endif
}

SENTRY_TEST(capture_minidump_wide)
{
#if !defined(SENTRY_PLATFORM_WINDOWS) || defined(SENTRY_PLATFORM_XBOX)
SKIP_TEST();
#else
SENTRY_TEST_OPTIONS_NEW(options);
sentry_init(options);

const wchar_t *minidump_rel_path = L"../fixtures/minidump.dmp";
sentry_path_t *path = sentry__path_from_str(__FILE__);
sentry_path_t *dir = sentry__path_dir(path);
sentry_path_t *minidump_path
= sentry__path_join_wstr(dir, minidump_rel_path);

const sentry_uuid_t event_id
= sentry_capture_minidumpw(minidump_path->path_w);
TEST_CHECK(!sentry_uuid_is_nil(&event_id));

sentry__path_free(minidump_path);
sentry__path_free(dir);
sentry__path_free(path);

sentry_close();
#endif
}

SENTRY_TEST(capture_minidump_null_path)
{
// a NULL path will activate the path check at the beginning of the function
Expand Down
1 change: 1 addition & 0 deletions tests/unit/tests.inc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ XX(capture_minidump_basic)
XX(capture_minidump_discard)
XX(capture_minidump_invalid_path)
XX(capture_minidump_null_path)
XX(capture_minidump_wide)
XX(capture_minidump_without_sentry_init)
XX(check_version)
XX(child_spans)
Expand Down
Loading