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
13 changes: 13 additions & 0 deletions include/sentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,19 @@ SENTRY_API void sentry_options_set_database_pathw(
sentry_options_t *opts, const wchar_t *path);
SENTRY_API void sentry_options_set_database_pathw_n(
sentry_options_t *opts, const wchar_t *path, size_t path_len);

/**
* Sets the args passed to the process when relaunching after a crash.
* Args must be in 1 single string separated by |
*/
SENTRY_API void sentry_options_set_relaunch_argvw(
sentry_options_t *opts, const wchar_t *relaunch_argv);

/**
* Gets the args passsed to the process when relaunching after a crash.
*/
SENTRY_API const wchar_t *sentry_options_get_relaunch_argvw(
const sentry_options_t *opts);
#endif

/**
Expand Down
27 changes: 15 additions & 12 deletions src/backends/sentry_backend_crashpad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,25 +420,28 @@ crashpad_backend_startup(
std::vector<base::FilePath> attachments;

sentry_path_t *current_exe = sentry__path_current_exe();
if (current_exe && options->relaunch_argv) {
annotations["__td-crashed-pid"] = std::to_string(td__getpid());
annotations["__td-relaunch-argv"] = std::string(options->relaunch_argv);
if (current_exe) {
if (options->relaunch_argv) {
annotations["__td-relaunch-argv"]
= std::string(options->relaunch_argv);
annotations["__td-relaunch-path"] = std::string(current_exe->path);
}
#ifdef SENTRY_PLATFORM_WINDOWS
std::wstring wstrPath(current_exe->path);
std::string strPath;
std::transform(wstrPath.begin(), wstrPath.end(),
std::back_inserter(strPath), [](wchar_t c) { return (char)c; });

annotations["__td-relaunch-path"] = strPath;
#else
annotations["__td-relaunch-path"] = std::string(current_exe->path);
if (options->relaunch_argvw) {
annotations["__td-relaunch-argv"] = std::string {
sentry__string_from_wstr(options->relaunch_argvw)
};
annotations["__td-relaunch-path"]
= std::string { sentry__string_from_wstr(current_exe->path) };
}
#endif
annotations["__td-crashed-pid"] = std::to_string(td__getpid());
sentry__path_free(current_exe);
}

// register attachments
for (sentry_attachment_t *attachment = options->attachments; attachment;
attachment = attachment->next) {
attachment = attachment->next) {
attachments.emplace_back(attachment->path->path);
}

Expand Down
19 changes: 19 additions & 0 deletions src/sentry_options.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ sentry_options_free(sentry_options_t *opts)
}
sentry__dsn_decref(opts->dsn);
sentry_free(opts->release);
#ifdef SENTRY_PLATFORM_WINDOWS
sentry_free(opts->relaunch_argvw);
#endif
sentry_free(opts->relaunch_argv);
sentry_free(opts->sdk_name);
sentry_free(opts->user_agent);
Expand Down Expand Up @@ -550,6 +553,22 @@ sentry_options_set_database_pathw(sentry_options_t *opts, const wchar_t *path)
size_t path_len = path ? wcslen(path) : 0;
sentry_options_set_database_pathw_n(opts, path, path_len);
}

void
sentry_options_set_relaunch_argvw(
sentry_options_t *opts, const wchar_t *relaunch_argvw)
{
sentry_free(opts->relaunch_argvw);
size_t len = relaunch_argvw ? wcslen(relaunch_argvw) : 0;
const auto clonedPath = sentry__path_from_wstr_n(relaunch_argvw, len);
opts->relaunch_argvw = clonedPath->path;
}

const wchar_t *
sentry_options_get_relaunch_argvw(const sentry_options_t *opts)
{
return opts->relaunch_argvw;
}
#endif

/**
Expand Down
3 changes: 3 additions & 0 deletions src/sentry_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ typedef struct sentry_options_s {
char *http_proxy;
char *ca_certs;
char *transport_thread_name;
#ifdef SENTRY_PLATFORM_WINDOWS
wchar_t *relaunch_argvw;
#endif
char *relaunch_argv;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we use relaunch_argv on Windows ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sentry implementation is not #ifdef SENTRY_PLATFORM_WINDOWS #else but rather than adding wchar_t overload as an additional method. So, I'm keeping the same functionality and yes I'll use relaunch_argv on appmanager windows

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok. I think there was earlier impl where relaunch_argv is in else part.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes but I changed it at the recent commits

char *sdk_name;
char *user_agent;
Expand Down