Commit 23cf12b1 authored by Tao Bai's avatar Tao Bai Committed by Commit Bot

[log minidump] Enable for WebView

- This patch added command line to write the minidump to log
- and enable it by default for WebView.

Bug: 979082
Change-Id: I9dd7fc282261356ec6d26b030333c0e86e92ea93
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2037083Reviewed-by: default avatarJoshua Peraza <jperaza@chromium.org>
Reviewed-by: default avatarMark Mentovai <mark@chromium.org>
Commit-Queue: Tao Bai <michaelbai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738686}
parent e2775e18
...@@ -92,6 +92,8 @@ class AwCrashReporterClient : public crash_reporter::CrashReporterClient { ...@@ -92,6 +92,8 @@ class AwCrashReporterClient : public crash_reporter::CrashReporterClient {
return true; return true;
} }
bool ShouldWriteMinidumpToLog() override { return true; }
bool JavaExceptionFilter( bool JavaExceptionFilter(
const base::android::JavaRef<jthrowable>& java_exception) { const base::android::JavaRef<jthrowable>& java_exception) {
return Java_AwCrashReporterClient_stackTraceContainsWebViewCode( return Java_AwCrashReporterClient_stackTraceContainsWebViewCode(
......
...@@ -178,6 +178,11 @@ bool CrashReporterClient::ShouldEnableBreakpadMicrodumps() { ...@@ -178,6 +178,11 @@ bool CrashReporterClient::ShouldEnableBreakpadMicrodumps() {
return false; return false;
#endif #endif
} }
bool CrashReporterClient::ShouldWriteMinidumpToLog() {
return false;
}
#endif #endif
#if defined(OS_ANDROID) || defined(OS_LINUX) #if defined(OS_ANDROID) || defined(OS_LINUX)
......
...@@ -173,6 +173,9 @@ class CrashReporterClient { ...@@ -173,6 +173,9 @@ class CrashReporterClient {
// Returns true if breakpad microdumps should be enabled. This orthogonal to // Returns true if breakpad microdumps should be enabled. This orthogonal to
// the standard minidump uploader (which depends on the user consent). // the standard minidump uploader (which depends on the user consent).
virtual bool ShouldEnableBreakpadMicrodumps(); virtual bool ShouldEnableBreakpadMicrodumps();
// Returns true if minudump should be written to android log.
virtual bool ShouldWriteMinidumpToLog();
#endif #endif
#if defined(OS_ANDROID) || defined(OS_LINUX) #if defined(OS_ANDROID) || defined(OS_LINUX)
......
...@@ -212,11 +212,13 @@ DWORD WINAPI DumpProcessForHungInputThread(void* param); ...@@ -212,11 +212,13 @@ DWORD WINAPI DumpProcessForHungInputThread(void* param);
#endif // defined(OS_WIN) #endif // defined(OS_WIN)
#if defined(OS_LINUX) || defined(OS_ANDROID) #if defined(OS_ANDROID)
// Starts the handler process with an initial client connected on fd. // Starts the handler process with an initial client connected on fd,
// the handler will write minidump to database if write_minidump_to_database is
// true.
// Returns `true` on success. // Returns `true` on success.
bool StartHandlerForClient(int fd); bool StartHandlerForClient(int fd, bool write_minidump_to_database);
#endif // OS_LINUX || OS_ANDROID #endif // OS_ANDROID
// The platform-specific portion of InitializeCrashpad(). On Windows, if // The platform-specific portion of InitializeCrashpad(). On Windows, if
// |user_data_dir| is non-empty, the user data directory will be passed to the // |user_data_dir| is non-empty, the user data directory will be passed to the
......
...@@ -403,7 +403,7 @@ void BuildHandlerArgs(CrashReporterClient* crash_reporter_client, ...@@ -403,7 +403,7 @@ void BuildHandlerArgs(CrashReporterClient* crash_reporter_client,
crash_reporter_client->GetCrashDumpLocation(database_path); crash_reporter_client->GetCrashDumpLocation(database_path);
crash_reporter_client->GetCrashMetricsLocation(metrics_path); crash_reporter_client->GetCrashMetricsLocation(metrics_path);
// TODO(jperaza): Set URL for Android when Crashpad takes over report upload. // TODO(jperaza): Set URL for Android when Crashpad takes over report upload.
*url = std::string(); *url = std::string();
std::string product_name; std::string product_name;
...@@ -429,6 +429,16 @@ void BuildHandlerArgs(CrashReporterClient* crash_reporter_client, ...@@ -429,6 +429,16 @@ void BuildHandlerArgs(CrashReporterClient* crash_reporter_client,
(*process_annotations)["plat"] = std::string("Android"); (*process_annotations)["plat"] = std::string("Android");
} }
bool ShouldHandleCrashAndUpdateArguments(bool write_minidump_to_database,
bool write_minidump_to_log,
std::vector<std::string>* arguments) {
if (!write_minidump_to_database)
arguments->push_back("--no-write-minidump-to-database");
if (write_minidump_to_log)
arguments->push_back("--write-minidump-to-log");
return write_minidump_to_database || write_minidump_to_log;
}
bool GetHandlerPath(base::FilePath* exe_dir, base::FilePath* handler_path) { bool GetHandlerPath(base::FilePath* exe_dir, base::FilePath* handler_path) {
// There is not any normal way to package native executables in an Android // There is not any normal way to package native executables in an Android
// APK. The Crashpad handler is packaged like a loadable module, which // APK. The Crashpad handler is packaged like a loadable module, which
...@@ -510,7 +520,9 @@ class HandlerStarter { ...@@ -510,7 +520,9 @@ class HandlerStarter {
!GetHandlerTrampoline(&handler_trampoline_, &handler_library_); !GetHandlerTrampoline(&handler_trampoline_, &handler_library_);
} }
if (!dump_at_crash) { if (!ShouldHandleCrashAndUpdateArguments(
dump_at_crash, GetCrashReporterClient()->ShouldWriteMinidumpToLog(),
&arguments)) {
return database_path; return database_path;
} }
...@@ -543,7 +555,9 @@ class HandlerStarter { ...@@ -543,7 +555,9 @@ class HandlerStarter {
return database_path; return database_path;
} }
bool StartHandlerForClient(CrashReporterClient* client, int fd) { bool StartHandlerForClient(CrashReporterClient* client,
int fd,
bool write_minidump_to_database) {
base::FilePath database_path; base::FilePath database_path;
base::FilePath metrics_path; base::FilePath metrics_path;
std::string url; std::string url;
...@@ -558,6 +572,12 @@ class HandlerStarter { ...@@ -558,6 +572,12 @@ class HandlerStarter {
return false; return false;
} }
if (!ShouldHandleCrashAndUpdateArguments(write_minidump_to_database,
client->ShouldWriteMinidumpToLog(),
&arguments)) {
return true;
}
if (use_java_handler_ || !handler_trampoline_.empty()) { if (use_java_handler_ || !handler_trampoline_.empty()) {
std::vector<std::string> env; std::vector<std::string> env;
if (!BuildEnvironmentWithApk(kUse64Bit, &env)) { if (!BuildEnvironmentWithApk(kUse64Bit, &env)) {
...@@ -606,8 +626,9 @@ bool ConnectToHandler(CrashReporterClient* client, base::ScopedFD* connection) { ...@@ -606,8 +626,9 @@ bool ConnectToHandler(CrashReporterClient* client, base::ScopedFD* connection) {
base::ScopedFD local_connection(fds[0]); base::ScopedFD local_connection(fds[0]);
base::ScopedFD handlers_socket(fds[1]); base::ScopedFD handlers_socket(fds[1]);
if (!HandlerStarter::Get()->StartHandlerForClient(client, if (!HandlerStarter::Get()->StartHandlerForClient(
handlers_socket.get())) { client, handlers_socket.get(),
true /* write_minidump_to_database */)) {
return false; return false;
} }
...@@ -676,9 +697,9 @@ void WhitelistMemoryRange(void* begin, size_t length) { ...@@ -676,9 +697,9 @@ void WhitelistMemoryRange(void* begin, size_t length) {
namespace internal { namespace internal {
bool StartHandlerForClient(int fd) { bool StartHandlerForClient(int fd, bool write_minidump_to_database) {
return HandlerStarter::Get()->StartHandlerForClient(GetCrashReporterClient(), return HandlerStarter::Get()->StartHandlerForClient(
fd); GetCrashReporterClient(), fd, write_minidump_to_database);
} }
base::FilePath PlatformCrashpadInitialization( base::FilePath PlatformCrashpadInitialization(
......
...@@ -567,7 +567,8 @@ void CrashHandlerHost::Init() { ...@@ -567,7 +567,8 @@ void CrashHandlerHost::Init() {
} }
bool CrashHandlerHost::ReceiveClientMessage(int client_fd, bool CrashHandlerHost::ReceiveClientMessage(int client_fd,
base::ScopedFD* handler_fd) { base::ScopedFD* handler_fd,
bool* write_minidump_to_database) {
int signo; int signo;
unsigned char request_dump; unsigned char request_dump;
iovec iov[2]; iovec iov[2];
...@@ -622,11 +623,8 @@ bool CrashHandlerHost::ReceiveClientMessage(int client_fd, ...@@ -622,11 +623,8 @@ bool CrashHandlerHost::ReceiveClientMessage(int client_fd,
NotifyCrashSignalObservers(child_pid, signo); NotifyCrashSignalObservers(child_pid, signo);
} }
if (!request_dump) {
return false;
}
handler_fd->reset(child_fd.release()); handler_fd->reset(child_fd.release());
*write_minidump_to_database = request_dump;
return true; return true;
} }
...@@ -646,12 +644,13 @@ void CrashHandlerHost::OnFileCanReadWithoutBlocking(int fd) { ...@@ -646,12 +644,13 @@ void CrashHandlerHost::OnFileCanReadWithoutBlocking(int fd) {
DCHECK_EQ(browser_socket_.get(), fd); DCHECK_EQ(browser_socket_.get(), fd);
base::ScopedFD handler_fd; base::ScopedFD handler_fd;
if (!ReceiveClientMessage(fd, &handler_fd)) { bool write_minidump_to_database = false;
if (!ReceiveClientMessage(fd, &handler_fd, &write_minidump_to_database)) {
return; return;
} }
bool result = bool result = crash_reporter::internal::StartHandlerForClient(
crash_reporter::internal::StartHandlerForClient(handler_fd.get()); handler_fd.get(), write_minidump_to_database);
DCHECK(result); DCHECK(result);
} }
......
...@@ -156,7 +156,9 @@ class CrashHandlerHost : public base::MessagePumpForIO::FdWatcher, ...@@ -156,7 +156,9 @@ class CrashHandlerHost : public base::MessagePumpForIO::FdWatcher,
CrashHandlerHost(); CrashHandlerHost();
void Init(); void Init();
bool ReceiveClientMessage(int client_fd, base::ScopedFD* handler_fd); bool ReceiveClientMessage(int client_fd,
base::ScopedFD* handler_fd,
bool* write_minidump_to_database);
void NotifyCrashSignalObservers(base::ProcessId pid, int signo); void NotifyCrashSignalObservers(base::ProcessId pid, int signo);
// MessagePumbLibevent::Watcher impl: // MessagePumbLibevent::Watcher impl:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment