| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/app/breakpad_linux.h" | 5 #include "chrome/app/breakpad_linux.h" |
| 6 | 6 |
| 7 #include <arpa/inet.h> | 7 #include <arpa/inet.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <netinet/in.h> | 9 #include <netinet/in.h> |
| 10 #include <sys/sendfile.h> | 10 #include <sys/sendfile.h> |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 sys__exit(1); | 465 sys__exit(1); |
| 466 } | 466 } |
| 467 | 467 |
| 468 return child; | 468 return child; |
| 469 } | 469 } |
| 470 | 470 |
| 471 // This is defined in chrome/browser/google_update_settings_linux.cc, it's the | 471 // This is defined in chrome/browser/google_update_settings_linux.cc, it's the |
| 472 // static string containing the user's unique GUID. We send this in the crash | 472 // static string containing the user's unique GUID. We send this in the crash |
| 473 // report. | 473 // report. |
| 474 namespace google_update { | 474 namespace google_update { |
| 475 extern std::string linux_guid; | 475 extern std::string posix_guid; |
| 476 } | 476 } |
| 477 | 477 |
| 478 // This is defined in base/linux_util.cc, it's the static string containing the | 478 // This is defined in base/linux_util.cc, it's the static string containing the |
| 479 // user's distro info. We send this in the crash report. | 479 // user's distro info. We send this in the crash report. |
| 480 namespace base { | 480 namespace base { |
| 481 extern std::string linux_distro; | 481 extern std::string linux_distro; |
| 482 } | 482 } |
| 483 | 483 |
| 484 static bool CrashDone(const char* dump_path, | 484 static bool CrashDone(const char* dump_path, |
| 485 const char* minidump_id, | 485 const char* minidump_id, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 501 memcpy(path + dump_path_len + 1, minidump_id, minidump_id_len); | 501 memcpy(path + dump_path_len + 1, minidump_id, minidump_id_len); |
| 502 memcpy(path + dump_path_len + 1 + minidump_id_len, ".dmp", 4); | 502 memcpy(path + dump_path_len + 1 + minidump_id_len, ".dmp", 4); |
| 503 path[dump_path_len + 1 + minidump_id_len + 4] = 0; | 503 path[dump_path_len + 1 + minidump_id_len + 4] = 0; |
| 504 | 504 |
| 505 BreakpadInfo info; | 505 BreakpadInfo info; |
| 506 info.filename = path; | 506 info.filename = path; |
| 507 info.process_type = "browser"; | 507 info.process_type = "browser"; |
| 508 info.process_type_length = 7; | 508 info.process_type_length = 7; |
| 509 info.crash_url = NULL; | 509 info.crash_url = NULL; |
| 510 info.crash_url_length = 0; | 510 info.crash_url_length = 0; |
| 511 info.guid = google_update::linux_guid.data(); | 511 info.guid = google_update::posix_guid.data(); |
| 512 info.guid_length = google_update::linux_guid.length(); | 512 info.guid_length = google_update::posix_guid.length(); |
| 513 info.distro = base::linux_distro.data(); | 513 info.distro = base::linux_distro.data(); |
| 514 info.distro_length = base::linux_distro.length(); | 514 info.distro_length = base::linux_distro.length(); |
| 515 UploadCrashDump(info); | 515 UploadCrashDump(info); |
| 516 | 516 |
| 517 return true; | 517 return true; |
| 518 } | 518 } |
| 519 | 519 |
| 520 void EnableCrashDumping() { | 520 void EnableCrashDumping() { |
| 521 // We leak this object. | 521 // We leak this object. |
| 522 | 522 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 533 | 533 |
| 534 static bool | 534 static bool |
| 535 RendererCrashHandler(const void* crash_context, size_t crash_context_size, | 535 RendererCrashHandler(const void* crash_context, size_t crash_context_size, |
| 536 void* context) { | 536 void* context) { |
| 537 const int fd = reinterpret_cast<intptr_t>(context); | 537 const int fd = reinterpret_cast<intptr_t>(context); |
| 538 int fds[2]; | 538 int fds[2]; |
| 539 socketpair(AF_UNIX, SOCK_STREAM, 0, fds); | 539 socketpair(AF_UNIX, SOCK_STREAM, 0, fds); |
| 540 char guid[kGuidSize] = {0}; | 540 char guid[kGuidSize] = {0}; |
| 541 char crash_url[kMaxActiveURLSize + 1] = {0}; | 541 char crash_url[kMaxActiveURLSize + 1] = {0}; |
| 542 char distro[kDistroSize + 1] = {0}; | 542 char distro[kDistroSize + 1] = {0}; |
| 543 const size_t guid_len = std::min(google_update::linux_guid.size(), | 543 const size_t guid_len = std::min(google_update::posix_guid.size(), |
| 544 kGuidSize); | 544 kGuidSize); |
| 545 const size_t crash_url_len = | 545 const size_t crash_url_len = |
| 546 std::min(child_process_logging::active_url.size(), kMaxActiveURLSize); | 546 std::min(child_process_logging::active_url.size(), kMaxActiveURLSize); |
| 547 const size_t distro_len = | 547 const size_t distro_len = |
| 548 std::min(base::linux_distro.size(), kDistroSize); | 548 std::min(base::linux_distro.size(), kDistroSize); |
| 549 memcpy(guid, google_update::linux_guid.data(), guid_len); | 549 memcpy(guid, google_update::posix_guid.data(), guid_len); |
| 550 memcpy(crash_url, child_process_logging::active_url.data(), crash_url_len); | 550 memcpy(crash_url, child_process_logging::active_url.data(), crash_url_len); |
| 551 memcpy(distro, base::linux_distro.data(), distro_len); | 551 memcpy(distro, base::linux_distro.data(), distro_len); |
| 552 | 552 |
| 553 // The length of the control message: | 553 // The length of the control message: |
| 554 static const unsigned kControlMsgSize = CMSG_SPACE(sizeof(int)); | 554 static const unsigned kControlMsgSize = CMSG_SPACE(sizeof(int)); |
| 555 | 555 |
| 556 struct kernel_msghdr msg; | 556 struct kernel_msghdr msg; |
| 557 my_memset(&msg, 0, sizeof(struct kernel_msghdr)); | 557 my_memset(&msg, 0, sizeof(struct kernel_msghdr)); |
| 558 struct kernel_iovec iov[4]; | 558 struct kernel_iovec iov[4]; |
| 559 iov[0].iov_base = const_cast<void*>(crash_context); | 559 iov[0].iov_base = const_cast<void*>(crash_context); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 // We might be chrooted in a zygote or renderer process so we cannot call | 611 // We might be chrooted in a zygote or renderer process so we cannot call |
| 612 // GetCollectStatsConsent because that needs access the the user's home | 612 // GetCollectStatsConsent because that needs access the the user's home |
| 613 // dir. Instead, we set a command line flag for these processes. | 613 // dir. Instead, we set a command line flag for these processes. |
| 614 if (!parsed_command_line.HasSwitch(switches::kEnableCrashReporter)) | 614 if (!parsed_command_line.HasSwitch(switches::kEnableCrashReporter)) |
| 615 return; | 615 return; |
| 616 // Get the guid and linux distro from the command line switch. | 616 // Get the guid and linux distro from the command line switch. |
| 617 std::string switch_value = WideToASCII( | 617 std::string switch_value = WideToASCII( |
| 618 parsed_command_line.GetSwitchValue(switches::kEnableCrashReporter)); | 618 parsed_command_line.GetSwitchValue(switches::kEnableCrashReporter)); |
| 619 size_t separator = switch_value.find(","); | 619 size_t separator = switch_value.find(","); |
| 620 if (separator != std::string::npos) { | 620 if (separator != std::string::npos) { |
| 621 google_update::linux_guid = switch_value.substr(0, separator); | 621 google_update::posix_guid = switch_value.substr(0, separator); |
| 622 base::linux_distro = switch_value.substr(separator + 1); | 622 base::linux_distro = switch_value.substr(separator + 1); |
| 623 } else { | 623 } else { |
| 624 google_update::linux_guid = switch_value; | 624 google_update::posix_guid = switch_value; |
| 625 } | 625 } |
| 626 EnableRendererCrashDumping(); | 626 EnableRendererCrashDumping(); |
| 627 } | 627 } |
| 628 } | 628 } |
| 629 | 629 |
| 630 // ----------------------------------------------------------------------------- | 630 // ----------------------------------------------------------------------------- |
| 631 | 631 |
| 632 bool EnableCoreDumping(std::string* core_dump_directory) { | 632 bool EnableCoreDumping(std::string* core_dump_directory) { |
| 633 // First we check that the core files will get dumped to the | 633 // First we check that the core files will get dumped to the |
| 634 // current-directory in a file called 'core'. We could try to support other | 634 // current-directory in a file called 'core'. We could try to support other |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 } | 780 } |
| 781 | 781 |
| 782 if (WIFSIGNALED(status) && WCOREDUMP(status)) { | 782 if (WIFSIGNALED(status) && WCOREDUMP(status)) { |
| 783 std::string core_filename; | 783 std::string core_filename; |
| 784 UploadCoreFile(child, &core_filename); | 784 UploadCoreFile(child, &core_filename); |
| 785 unlink(core_filename.c_str()); | 785 unlink(core_filename.c_str()); |
| 786 } | 786 } |
| 787 | 787 |
| 788 rmdir(core_dump_directory.c_str()); | 788 rmdir(core_dump_directory.c_str()); |
| 789 } | 789 } |
| OLD | NEW |