| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/crash_handler_host_linux.h" | 5 #include "chrome/browser/crash_handler_host_linuxish.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <stdlib.h> | 8 #include <stdlib.h> |
| 9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
| 10 #include <sys/syscall.h> | 10 #include <sys/syscall.h> |
| 11 #include <unistd.h> | 11 #include <unistd.h> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
| 15 #include "base/eintr_wrapper.h" | 15 #include "base/eintr_wrapper.h" |
| 16 #include "base/file_path.h" | 16 #include "base/file_path.h" |
| 17 #include "base/format_macros.h" | 17 #include "base/format_macros.h" |
| 18 #include "base/linux_util.h" | 18 #include "base/linux_util.h" |
| 19 #include "base/logging.h" | 19 #include "base/logging.h" |
| 20 #include "base/memory/singleton.h" | 20 #include "base/memory/singleton.h" |
| 21 #include "base/message_loop.h" | 21 #include "base/message_loop.h" |
| 22 #include "base/path_service.h" | 22 #include "base/path_service.h" |
| 23 #include "base/rand_util.h" | 23 #include "base/rand_util.h" |
| 24 #include "base/string_util.h" | 24 #include "base/string_util.h" |
| 25 #include "base/stringprintf.h" | 25 #include "base/stringprintf.h" |
| 26 #include "base/threading/thread.h" | 26 #include "base/threading/thread.h" |
| 27 #include "breakpad/src/client/linux/handler/exception_handler.h" | 27 #include "breakpad/src/client/linux/handler/exception_handler.h" |
| 28 #include "breakpad/src/client/linux/minidump_writer/linux_dumper.h" | 28 #include "breakpad/src/client/linux/minidump_writer/linux_dumper.h" |
| 29 #include "breakpad/src/client/linux/minidump_writer/minidump_writer.h" | 29 #include "breakpad/src/client/linux/minidump_writer/minidump_writer.h" |
| 30 #include "chrome/app/breakpad_linux.h" | 30 #include "chrome/app/breakpad_linuxish.h" |
| 31 #include "chrome/common/chrome_paths.h" | 31 #include "chrome/common/chrome_paths.h" |
| 32 #include "chrome/common/env_vars.h" | 32 #include "chrome/common/env_vars.h" |
| 33 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 34 | 34 |
| 35 #if defined(OS_ANDROID) |
| 36 #include <sys/linux-syscalls.h> |
| 37 |
| 38 #define SYS_read __NR_read |
| 39 #endif |
| 40 |
| 35 using content::BrowserThread; | 41 using content::BrowserThread; |
| 36 using google_breakpad::ExceptionHandler; | 42 using google_breakpad::ExceptionHandler; |
| 37 | 43 |
| 38 namespace { | 44 namespace { |
| 39 | 45 |
| 40 // The length of the control message: | 46 // The length of the control message: |
| 41 const unsigned kControlMsgSize = | 47 const unsigned kControlMsgSize = |
| 42 CMSG_SPACE(2*sizeof(int)) + CMSG_SPACE(sizeof(struct ucred)); | 48 CMSG_SPACE(2*sizeof(int)) + CMSG_SPACE(sizeof(struct ucred)); |
| 43 // The length of the regular payload: | 49 // The length of the regular payload: |
| 44 const unsigned kCrashContextSize = sizeof(ExceptionHandler::CrashContext); | 50 const unsigned kCrashContextSize = sizeof(ExceptionHandler::CrashContext); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 info->process_type = process_type_str; | 317 info->process_type = process_type_str; |
| 312 | 318 |
| 313 info->crash_url_length = strlen(crash_url); | 319 info->crash_url_length = strlen(crash_url); |
| 314 info->crash_url = crash_url; | 320 info->crash_url = crash_url; |
| 315 | 321 |
| 316 info->guid_length = strlen(guid); | 322 info->guid_length = strlen(guid); |
| 317 info->guid = guid; | 323 info->guid = guid; |
| 318 | 324 |
| 319 info->distro_length = strlen(distro); | 325 info->distro_length = strlen(distro); |
| 320 info->distro = distro; | 326 info->distro = distro; |
| 321 | 327 #if defined(OS_ANDROID) |
| 328 // Nothing gets uploaded in android. |
| 329 info->upload = false; |
| 330 #else |
| 322 info->upload = (getenv(env_vars::kHeadless) == NULL); | 331 info->upload = (getenv(env_vars::kHeadless) == NULL); |
| 332 #endif |
| 323 info->process_start_time = uptime; | 333 info->process_start_time = uptime; |
| 324 info->oom_size = oom_size; | 334 info->oom_size = oom_size; |
| 325 | 335 |
| 326 BrowserThread::PostTask( | 336 BrowserThread::PostTask( |
| 327 BrowserThread::FILE, FROM_HERE, | 337 BrowserThread::FILE, FROM_HERE, |
| 328 base::Bind(&CrashHandlerHostLinux::WriteDumpFile, | 338 base::Bind(&CrashHandlerHostLinux::WriteDumpFile, |
| 329 base::Unretained(this), | 339 base::Unretained(this), |
| 330 info, | 340 info, |
| 331 crashing_pid, | 341 crashing_pid, |
| 332 crash_context, | 342 crash_context, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 354 kCrashContextSize)) { | 364 kCrashContextSize)) { |
| 355 LOG(ERROR) << "Failed to write crash dump for pid " << crashing_pid; | 365 LOG(ERROR) << "Failed to write crash dump for pid " << crashing_pid; |
| 356 } | 366 } |
| 357 delete[] crash_context; | 367 delete[] crash_context; |
| 358 | 368 |
| 359 // Freed in CrashDumpTask(); | 369 // Freed in CrashDumpTask(); |
| 360 char* minidump_filename_str = new char[minidump_filename.length() + 1]; | 370 char* minidump_filename_str = new char[minidump_filename.length() + 1]; |
| 361 minidump_filename.copy(minidump_filename_str, minidump_filename.length()); | 371 minidump_filename.copy(minidump_filename_str, minidump_filename.length()); |
| 362 minidump_filename_str[minidump_filename.length()] = '\0'; | 372 minidump_filename_str[minidump_filename.length()] = '\0'; |
| 363 info->filename = minidump_filename_str; | 373 info->filename = minidump_filename_str; |
| 374 info->pid = crashing_pid; |
| 364 | 375 |
| 365 BrowserThread::PostTask( | 376 BrowserThread::PostTask( |
| 366 BrowserThread::IO, FROM_HERE, | 377 BrowserThread::IO, FROM_HERE, |
| 367 base::Bind(&CrashHandlerHostLinux::QueueCrashDumpTask, | 378 base::Bind(&CrashHandlerHostLinux::QueueCrashDumpTask, |
| 368 base::Unretained(this), | 379 base::Unretained(this), |
| 369 info, | 380 info, |
| 370 signal_fd)); | 381 signal_fd)); |
| 371 } | 382 } |
| 372 | 383 |
| 373 void CrashHandlerHostLinux::QueueCrashDumpTask(BreakpadInfo* info, | 384 void CrashHandlerHostLinux::QueueCrashDumpTask(BreakpadInfo* info, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 } | 486 } |
| 476 | 487 |
| 477 void RendererCrashHandlerHostLinux::SetProcessType() { | 488 void RendererCrashHandlerHostLinux::SetProcessType() { |
| 478 process_type_ = "renderer"; | 489 process_type_ = "renderer"; |
| 479 } | 490 } |
| 480 | 491 |
| 481 // static | 492 // static |
| 482 RendererCrashHandlerHostLinux* RendererCrashHandlerHostLinux::GetInstance() { | 493 RendererCrashHandlerHostLinux* RendererCrashHandlerHostLinux::GetInstance() { |
| 483 return Singleton<RendererCrashHandlerHostLinux>::get(); | 494 return Singleton<RendererCrashHandlerHostLinux>::get(); |
| 484 } | 495 } |
| OLD | NEW |