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 {
return true;
}
bool ShouldWriteMinidumpToLog() override { return true; }
bool JavaExceptionFilter(
const base::android::JavaRef<jthrowable>& java_exception) {
return Java_AwCrashReporterClient_stackTraceContainsWebViewCode(
......
......@@ -178,6 +178,11 @@ bool CrashReporterClient::ShouldEnableBreakpadMicrodumps() {
return false;
#endif
}
bool CrashReporterClient::ShouldWriteMinidumpToLog() {
return false;
}
#endif
#if defined(OS_ANDROID) || defined(OS_LINUX)
......
......@@ -173,6 +173,9 @@ class CrashReporterClient {
// Returns true if breakpad microdumps should be enabled. This orthogonal to
// the standard minidump uploader (which depends on the user consent).
virtual bool ShouldEnableBreakpadMicrodumps();
// Returns true if minudump should be written to android log.
virtual bool ShouldWriteMinidumpToLog();
#endif
#if defined(OS_ANDROID) || defined(OS_LINUX)
......
......@@ -212,11 +212,13 @@ DWORD WINAPI DumpProcessForHungInputThread(void* param);
#endif // defined(OS_WIN)
#if defined(OS_LINUX) || defined(OS_ANDROID)
// Starts the handler process with an initial client connected on fd.
#if defined(OS_ANDROID)
// 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.
bool StartHandlerForClient(int fd);
#endif // OS_LINUX || OS_ANDROID
bool StartHandlerForClient(int fd, bool write_minidump_to_database);
#endif // OS_ANDROID
// The platform-specific portion of InitializeCrashpad(). On Windows, if
// |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,
crash_reporter_client->GetCrashDumpLocation(database_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();
std::string product_name;
......@@ -429,6 +429,16 @@ void BuildHandlerArgs(CrashReporterClient* crash_reporter_client,
(*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) {
// There is not any normal way to package native executables in an Android
// APK. The Crashpad handler is packaged like a loadable module, which
......@@ -510,7 +520,9 @@ class HandlerStarter {
!GetHandlerTrampoline(&handler_trampoline_, &handler_library_);
}
if (!dump_at_crash) {
if (!ShouldHandleCrashAndUpdateArguments(
dump_at_crash, GetCrashReporterClient()->ShouldWriteMinidumpToLog(),
&arguments)) {
return database_path;
}
......@@ -543,7 +555,9 @@ class HandlerStarter {
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 metrics_path;
std::string url;
......@@ -558,6 +572,12 @@ class HandlerStarter {
return false;
}
if (!ShouldHandleCrashAndUpdateArguments(write_minidump_to_database,
client->ShouldWriteMinidumpToLog(),
&arguments)) {
return true;
}
if (use_java_handler_ || !handler_trampoline_.empty()) {
std::vector<std::string> env;
if (!BuildEnvironmentWithApk(kUse64Bit, &env)) {
......@@ -606,8 +626,9 @@ bool ConnectToHandler(CrashReporterClient* client, base::ScopedFD* connection) {
base::ScopedFD local_connection(fds[0]);
base::ScopedFD handlers_socket(fds[1]);
if (!HandlerStarter::Get()->StartHandlerForClient(client,
handlers_socket.get())) {
if (!HandlerStarter::Get()->StartHandlerForClient(
client, handlers_socket.get(),
true /* write_minidump_to_database */)) {
return false;
}
......@@ -676,9 +697,9 @@ void WhitelistMemoryRange(void* begin, size_t length) {
namespace internal {
bool StartHandlerForClient(int fd) {
return HandlerStarter::Get()->StartHandlerForClient(GetCrashReporterClient(),
fd);
bool StartHandlerForClient(int fd, bool write_minidump_to_database) {
return HandlerStarter::Get()->StartHandlerForClient(
GetCrashReporterClient(), fd, write_minidump_to_database);
}
base::FilePath PlatformCrashpadInitialization(
......
......@@ -567,7 +567,8 @@ void CrashHandlerHost::Init() {
}
bool CrashHandlerHost::ReceiveClientMessage(int client_fd,
base::ScopedFD* handler_fd) {
base::ScopedFD* handler_fd,
bool* write_minidump_to_database) {
int signo;
unsigned char request_dump;
iovec iov[2];
......@@ -622,11 +623,8 @@ bool CrashHandlerHost::ReceiveClientMessage(int client_fd,
NotifyCrashSignalObservers(child_pid, signo);
}
if (!request_dump) {
return false;
}
handler_fd->reset(child_fd.release());
*write_minidump_to_database = request_dump;
return true;
}
......@@ -646,12 +644,13 @@ void CrashHandlerHost::OnFileCanReadWithoutBlocking(int fd) {
DCHECK_EQ(browser_socket_.get(), 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;
}
bool result =
crash_reporter::internal::StartHandlerForClient(handler_fd.get());
bool result = crash_reporter::internal::StartHandlerForClient(
handler_fd.get(), write_minidump_to_database);
DCHECK(result);
}
......
......@@ -156,7 +156,9 @@ class CrashHandlerHost : public base::MessagePumpForIO::FdWatcher,
CrashHandlerHost();
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);
// 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