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
9 changes: 8 additions & 1 deletion client/crashpad_client_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ struct BackgroundHandlerStartThreadData {
const std::vector<std::string>& arguments,
const std::vector<base::FilePath>& attachments,
const base::FilePath& screenshot,
const bool wait_for_upload,
const std::wstring& ipc_pipe,
ScopedFileHANDLE ipc_pipe_handle)
: handler(handler),
Expand All @@ -367,6 +368,7 @@ struct BackgroundHandlerStartThreadData {
arguments(arguments),
attachments(attachments),
screenshot(screenshot),
wait_for_upload(wait_for_upload),
ipc_pipe(ipc_pipe),
ipc_pipe_handle(std::move(ipc_pipe_handle)) {}

Expand All @@ -379,6 +381,7 @@ struct BackgroundHandlerStartThreadData {
std::vector<std::string> arguments;
std::vector<base::FilePath> attachments;
base::FilePath screenshot;
bool wait_for_upload;
std::wstring ipc_pipe;
ScopedFileHANDLE ipc_pipe_handle;
};
Expand Down Expand Up @@ -452,6 +455,10 @@ bool StartHandlerProcess(
&command_line);
}

if (data->wait_for_upload) {
AppendCommandLineArgument(L"--wait-for-upload", &command_line);
}

ScopedKernelHANDLE this_process(
OpenProcess(kXPProcessLimitedAccess, true, GetCurrentProcessId()));
if (!this_process.is_valid()) {
Expand Down Expand Up @@ -648,7 +655,6 @@ bool CrashpadClient::StartHandler(
const std::vector<base::FilePath>& attachments,
const base::FilePath& screenshot,
bool wait_for_upload) {
(void) wait_for_upload; // unused in win (for now)
DCHECK(ipc_pipe_.empty());

// Both the pipe and the signalling events have to be created on the main
Expand Down Expand Up @@ -681,6 +687,7 @@ bool CrashpadClient::StartHandler(
arguments,
attachments,
screenshot,
wait_for_upload,
ipc_pipe_,
std::move(ipc_pipe_handle));

Expand Down
5 changes: 5 additions & 0 deletions handler/crash_report_upload_thread.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ void CrashReportUploadThread::ReportPending(const UUID& report_uuid) {
thread_.DoWorkNow();
}

void CrashReportUploadThread::ReportPendingSync(const UUID& report_uuid) {
known_pending_report_uuids_.PushBack(report_uuid);
DoWork(nullptr);
}

void CrashReportUploadThread::Start() {
thread_.Start(
options_.watch_pending_reports ? 0.0 : WorkerThread::kIndefiniteWait);
Expand Down
10 changes: 10 additions & 0 deletions handler/crash_report_upload_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ class CrashReportUploadThread : public WorkerThread::Delegate,
//! This method may be called from any thread.
void ReportPending(const UUID& report_uuid);

//! \brief Runs the upload on the calling thread rather than in the upload
//! thread. This is only used from the exception handler to block the
//! termination of the crashed process until the upload is completed.
//!
//! \param[in] report_uuid The unique identifier of the newly added pending
//! report.
//!
//! This method will run on the pool thread executing the OnCrashDumpEvent
void ReportPendingSync(const UUID& report_uuid);

// Stoppable:

//! \brief Starts a dedicated upload thread, which executes ThreadMain().
Expand Down
12 changes: 6 additions & 6 deletions handler/handler_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ struct Options {
#if defined(SCREENSHOT_SUPPORTED)
base::FilePath screenshot;
#endif // SCREENSHOT_SUPPORTED
#if BUILDFLAG(IS_LINUX)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN)
bool wait_for_upload = false;
#endif
};
Expand Down Expand Up @@ -650,7 +650,7 @@ int HandlerMain(int argc,
#if BUILDFLAG(IS_ANDROID)
kOptionWriteMinidumpToLog,
#endif // BUILDFLAG(IS_ANDROID)
#if BUILDFLAG(IS_LINUX)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN)
kOptionWaitForUpload,
#endif

Expand Down Expand Up @@ -747,8 +747,8 @@ int HandlerMain(int argc,
#if BUILDFLAG(IS_ANDROID)
{"write-minidump-to-log", no_argument, nullptr, kOptionWriteMinidumpToLog},
#endif // BUILDFLAG(IS_ANDROID)
#if BUILDFLAG(IS_LINUX)
{"wait-for-upload", optional_argument, nullptr, kOptionWaitForUpload},
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN)
{"wait-for-upload", no_argument, nullptr, kOptionWaitForUpload},
#endif
{"help", no_argument, nullptr, kOptionHelp},
{"version", no_argument, nullptr, kOptionVersion},
Expand Down Expand Up @@ -941,7 +941,7 @@ int HandlerMain(int argc,
break;
}
#endif // BUILDFLAG(IS_ANDROID)
#if BUILDFLAG(IS_LINUX)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN)
case kOptionWaitForUpload : {
options.wait_for_upload = true;
break;
Expand Down Expand Up @@ -1136,7 +1136,7 @@ int HandlerMain(int argc,
false,
#endif // BUILDFLAG(IS_LINUX)
user_stream_sources
#if BUILDFLAG(IS_LINUX)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN)
,options.wait_for_upload
#endif
);
Expand Down
11 changes: 9 additions & 2 deletions handler/win/crash_report_exception_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ CrashReportExceptionHandler::CrashReportExceptionHandler(
const std::map<std::string, std::string>* process_annotations,
const std::vector<base::FilePath>* attachments,
const base::FilePath* screenshot,
const UserStreamDataSources* user_stream_data_sources)
const UserStreamDataSources* user_stream_data_sources,
const bool wait_for_upload)
: database_(database),
upload_thread_(upload_thread),
process_annotations_(process_annotations),
attachments_(attachments),
screenshot_(screenshot),
wait_for_upload_(wait_for_upload),
user_stream_data_sources_(user_stream_data_sources) {}

CrashReportExceptionHandler::~CrashReportExceptionHandler() {}
Expand Down Expand Up @@ -160,7 +162,12 @@ unsigned int CrashReportExceptionHandler::ExceptionHandlerServerException(
}

if (upload_thread_) {
upload_thread_->ReportPending(uuid);
if (wait_for_upload_) {
upload_thread_->ReportPendingSync(uuid);
}
else {
upload_thread_->ReportPending(uuid);
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion handler/win/crash_report_exception_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class CrashReportExceptionHandler final
const std::map<std::string, std::string>* process_annotations,
const std::vector<base::FilePath>* attachments,
const base::FilePath* screenshot,
const UserStreamDataSources* user_stream_data_sources);
const UserStreamDataSources* user_stream_data_sources,
bool wait_for_upload);

CrashReportExceptionHandler(const CrashReportExceptionHandler&) = delete;
CrashReportExceptionHandler& operator=(const CrashReportExceptionHandler&) =
Expand All @@ -85,6 +86,7 @@ class CrashReportExceptionHandler final
const std::map<std::string, std::string>* process_annotations_; // weak
const std::vector<base::FilePath>* attachments_; // weak
const base::FilePath* screenshot_; // weak
const bool wait_for_upload_;
const UserStreamDataSources* user_stream_data_sources_; // weak
};

Expand Down
2 changes: 1 addition & 1 deletion third_party/mini_chromium/mini_chromium