OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // For linux_syscall_support.h. This makes it safe to call embedded system | 5 // For linux_syscall_support.h. This makes it safe to call embedded system |
6 // calls when in seccomp mode. | 6 // calls when in seccomp mode. |
7 #define SYS_SYSCALL_ENTRYPOINT "playground$syscallEntryPoint" | 7 #define SYS_SYSCALL_ENTRYPOINT "playground$syscallEntryPoint" |
8 | 8 |
9 #include "chrome/app/breakpad_linux.h" | 9 #include "chrome/app/breakpad_linux.h" |
10 | 10 |
11 #include <fcntl.h> | 11 #include <fcntl.h> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
43 // where we either a) know the call cannot fail, or b) there is nothing we | 43 // where we either a) know the call cannot fail, or b) there is nothing we |
44 // can do when a call fails, we mark the return code as ignored. This avoids | 44 // can do when a call fails, we mark the return code as ignored. This avoids |
45 // spurious compiler warnings. | 45 // spurious compiler warnings. |
46 #define IGNORE_RET(x) do { if (x); } while (0) | 46 #define IGNORE_RET(x) do { if (x); } while (0) |
47 | 47 |
48 static const char kUploadURL[] = | 48 static const char kUploadURL[] = |
49 "https://clients2.google.com/cr/report"; | 49 "https://clients2.google.com/cr/report"; |
50 | 50 |
51 static bool is_crash_reporter_enabled = false; | 51 static bool is_crash_reporter_enabled = false; |
52 static uint64_t process_start_time = 0; | 52 static uint64_t process_start_time = 0; |
53 static char* crash_log_path = NULL; | |
53 | 54 |
54 // Writes the value |v| as 16 hex characters to the memory pointed at by | 55 // Writes the value |v| as 16 hex characters to the memory pointed at by |
55 // |output|. | 56 // |output|. |
56 static void write_uint64_hex(char* output, uint64_t v) { | 57 static void write_uint64_hex(char* output, uint64_t v) { |
57 static const char hextable[] = "0123456789abcdef"; | 58 static const char hextable[] = "0123456789abcdef"; |
58 | 59 |
59 for (int i = 15; i >= 0; --i) { | 60 for (int i = 15; i >= 0; --i) { |
60 output[i] = hextable[v & 15]; | 61 output[i] = hextable[v & 15]; |
61 v >>= 4; | 62 v >>= 4; |
62 } | 63 } |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
534 int fds[2]; | 535 int fds[2]; |
535 IGNORE_RET(sys_pipe(fds)); | 536 IGNORE_RET(sys_pipe(fds)); |
536 | 537 |
537 const pid_t child = sys_fork(); | 538 const pid_t child = sys_fork(); |
538 if (child) { | 539 if (child) { |
539 IGNORE_RET(sys_close(fds[1])); | 540 IGNORE_RET(sys_close(fds[1])); |
540 char id_buf[17]; | 541 char id_buf[17]; |
541 const int len = HANDLE_EINTR(sys_read(fds[0], id_buf, | 542 const int len = HANDLE_EINTR(sys_read(fds[0], id_buf, |
542 sizeof(id_buf) - 1)); | 543 sizeof(id_buf) - 1)); |
543 if (len > 0) { | 544 if (len > 0) { |
545 // Write crash dump id to stderr. | |
544 id_buf[len] = 0; | 546 id_buf[len] = 0; |
545 static const char msg[] = "\nCrash dump id: "; | 547 static const char msg[] = "\nCrash dump id: "; |
546 sys_write(2, msg, sizeof(msg) - 1); | 548 sys_write(2, msg, sizeof(msg) - 1); |
547 sys_write(2, id_buf, my_strlen(id_buf)); | 549 sys_write(2, id_buf, my_strlen(id_buf)); |
548 sys_write(2, "\n", 1); | 550 sys_write(2, "\n", 1); |
551 | |
552 // Write crash dump id to crash log as: seconds_since_epoch,crash_id | |
553 struct kernel_timeval tv; | |
554 if (!sys_gettimeofday(&tv, NULL)) { | |
555 uint64_t time = kernel_timeval_to_ms(&tv); | |
556 char time_str[21]; | |
557 const unsigned time_len = my_uint64_len(time); | |
558 my_uint64tos(time_str, time, time_len); | |
559 | |
560 int log_fd = sys_open(crash_log_path, O_CREAT | O_WRONLY | O_APPEND, | |
561 0600); | |
562 if (log_fd > 0) { | |
563 sys_write(log_fd, time_str, time_len); | |
564 sys_write(log_fd, ",", 1); | |
565 sys_write(log_fd, id_buf, my_strlen(id_buf)); | |
566 sys_write(log_fd, "\n", 1); | |
567 IGNORE_RET(sys_close(log_fd)); | |
568 } | |
569 } | |
549 } | 570 } |
550 IGNORE_RET(sys_unlink(info.filename)); | 571 IGNORE_RET(sys_unlink(info.filename)); |
551 IGNORE_RET(sys_unlink(temp_file)); | 572 IGNORE_RET(sys_unlink(temp_file)); |
552 sys__exit(0); | 573 sys__exit(0); |
553 } | 574 } |
554 | 575 |
555 IGNORE_RET(sys_close(fds[0])); | 576 IGNORE_RET(sys_close(fds[0])); |
556 IGNORE_RET(sys_dup2(fds[1], 3)); | 577 IGNORE_RET(sys_dup2(fds[1], 3)); |
557 static const char* const kWgetBinary = "/usr/bin/wget"; | 578 static const char* const kWgetBinary = "/usr/bin/wget"; |
558 const char* args[] = { | 579 const char* args[] = { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
627 // Wrapper script, do not add more code here. | 648 // Wrapper script, do not add more code here. |
628 static bool CrashDoneUpload(const char* dump_path, | 649 static bool CrashDoneUpload(const char* dump_path, |
629 const char* minidump_id, | 650 const char* minidump_id, |
630 void* context, | 651 void* context, |
631 bool succeeded) { | 652 bool succeeded) { |
632 return CrashDone(dump_path, minidump_id, true, succeeded); | 653 return CrashDone(dump_path, minidump_id, true, succeeded); |
633 } | 654 } |
634 | 655 |
635 void EnableCrashDumping(const bool unattended) { | 656 void EnableCrashDumping(const bool unattended) { |
636 is_crash_reporter_enabled = true; | 657 is_crash_reporter_enabled = true; |
658 | |
659 FilePath tmp_path("/tmp"); | |
agl
2011/02/15 14:33:52
We certainly can't write files like this into /tmp
Lei Zhang
2011/02/15 20:29:48
DIR_CRASH_DUMPS is relative to DIR_USER_DATA. If a
agl
2011/02/15 20:34:14
In the case that we can't get DIR_CRASH_DUMPS, I t
| |
660 PathService::Get(base::DIR_TEMP, &tmp_path); | |
661 | |
662 FilePath dumps_path(tmp_path); | |
663 PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path); | |
664 | |
665 FilePath logfile = dumps_path.AppendASCII("uploads.log"); | |
666 std::string logfile_str = logfile.value(); | |
667 const size_t crash_log_path_len = logfile_str.size() + 1; | |
668 crash_log_path = new char[crash_log_path_len]; | |
669 strncpy(crash_log_path, logfile_str.c_str(), crash_log_path_len); | |
670 | |
637 if (unattended) { | 671 if (unattended) { |
638 FilePath dumps_path("/tmp"); | |
639 PathService::Get(chrome::DIR_CRASH_DUMPS, &dumps_path); | |
640 new google_breakpad::ExceptionHandler(dumps_path.value().c_str(), NULL, | 672 new google_breakpad::ExceptionHandler(dumps_path.value().c_str(), NULL, |
641 CrashDoneNoUpload, NULL, | 673 CrashDoneNoUpload, NULL, |
642 true /* install handlers */); | 674 true /* install handlers */); |
643 } else { | 675 } else { |
644 new google_breakpad::ExceptionHandler("/tmp", NULL, CrashDoneUpload, NULL, | 676 new google_breakpad::ExceptionHandler(tmp_path.value().c_str(), NULL, |
677 CrashDoneUpload, NULL, | |
645 true /* install handlers */); | 678 true /* install handlers */); |
646 } | 679 } |
647 } | 680 } |
648 | 681 |
649 // Currently Non-Browser = Renderer, Plugins, Native Client and Gpu | 682 // Currently Non-Browser = Renderer, Plugins, Native Client and Gpu |
650 static bool | 683 static bool |
651 NonBrowserCrashHandler(const void* crash_context, size_t crash_context_size, | 684 NonBrowserCrashHandler(const void* crash_context, size_t crash_context_size, |
652 void* context) { | 685 void* context) { |
653 const int fd = reinterpret_cast<intptr_t>(context); | 686 const int fd = reinterpret_cast<intptr_t>(context); |
654 int fds[2] = { -1, -1 }; | 687 int fds[2] = { -1, -1 }; |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
774 struct timeval tv; | 807 struct timeval tv; |
775 if (!gettimeofday(&tv, NULL)) | 808 if (!gettimeofday(&tv, NULL)) |
776 process_start_time = timeval_to_ms(&tv); | 809 process_start_time = timeval_to_ms(&tv); |
777 else | 810 else |
778 process_start_time = 0; | 811 process_start_time = 0; |
779 } | 812 } |
780 | 813 |
781 bool IsCrashReporterEnabled() { | 814 bool IsCrashReporterEnabled() { |
782 return is_crash_reporter_enabled; | 815 return is_crash_reporter_enabled; |
783 } | 816 } |
OLD | NEW |