| 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 // 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 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 #include <sys/stat.h> | 49 #include <sys/stat.h> |
| 50 | 50 |
| 51 #include "base/android/build_info.h" | 51 #include "base/android/build_info.h" |
| 52 #include "base/android/path_utils.h" | 52 #include "base/android/path_utils.h" |
| 53 #include "third_party/lss/linux_syscall_support.h" | 53 #include "third_party/lss/linux_syscall_support.h" |
| 54 #else | 54 #else |
| 55 #include "sandbox/linux/seccomp-legacy/linux_syscall_support.h" | 55 #include "sandbox/linux/seccomp-legacy/linux_syscall_support.h" |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 #if defined(ADDRESS_SANITIZER) | 58 #if defined(ADDRESS_SANITIZER) |
| 59 #include <ucontext.h> // for getcontext(). | 59 #include <ucontext.h> // for getcontext(). |
| 60 #endif | 60 #endif |
| 61 | 61 |
| 62 #if defined(OS_ANDROID) | 62 #if defined(OS_ANDROID) |
| 63 #define STAT_STRUCT struct stat | 63 #define STAT_STRUCT struct stat |
| 64 #define FSTAT_FUNC fstat | 64 #define FSTAT_FUNC fstat |
| 65 #else | 65 #else |
| 66 #define STAT_STRUCT struct kernel_stat | 66 #define STAT_STRUCT struct kernel_stat |
| 67 #define FSTAT_FUNC sys_fstat | 67 #define FSTAT_FUNC sys_fstat |
| 68 #endif | 68 #endif |
| 69 | 69 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 | 135 |
| 136 unsigned len = 0; | 136 unsigned len = 0; |
| 137 while (i) { | 137 while (i) { |
| 138 len++; | 138 len++; |
| 139 i /= 10; | 139 i /= 10; |
| 140 } | 140 } |
| 141 | 141 |
| 142 return len; | 142 return len; |
| 143 } | 143 } |
| 144 | 144 |
| 145 // uint64_t version of my_itos() from | 145 // uint64_t version of my_uitos() from |
| 146 // breakpad/src/common/linux/linux_libc_support.h. Convert a non-negative | 146 // breakpad/src/common/linux/linux_libc_support.h. Convert a non-negative |
| 147 // integer to a string (not null-terminated). | 147 // integer to a string (not null-terminated). |
| 148 void my_uint64tos(char* output, uint64_t i, unsigned i_len) { | 148 void my_uint64tos(char* output, uint64_t i, unsigned i_len) { |
| 149 for (unsigned index = i_len; index; --index, i /= 10) | 149 for (unsigned index = i_len; index; --index, i /= 10) |
| 150 output[index - 1] = '0' + (i % 10); | 150 output[index - 1] = '0' + (i % 10); |
| 151 } | 151 } |
| 152 | 152 |
| 153 #if defined(OS_ANDROID) | 153 #if defined(OS_ANDROID) |
| 154 char* my_strncpy(char* dst, const char* src, size_t len) { | 154 char* my_strncpy(char* dst, const char* src, size_t len) { |
| 155 int i = len; | 155 int i = len; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 size_t chunk_size, | 297 size_t chunk_size, |
| 298 bool strip_trailing_spaces) { | 298 bool strip_trailing_spaces) { |
| 299 if (chunk_size > kMaxCrashChunkSize) | 299 if (chunk_size > kMaxCrashChunkSize) |
| 300 return; | 300 return; |
| 301 | 301 |
| 302 unsigned i = 0; | 302 unsigned i = 0; |
| 303 size_t done = 0, msg_length = msg_data_size; | 303 size_t done = 0, msg_length = msg_data_size; |
| 304 | 304 |
| 305 while (msg_length) { | 305 while (msg_length) { |
| 306 char num[16]; | 306 char num[16]; |
| 307 const unsigned num_len = my_int_len(++i); | 307 const unsigned num_len = my_uint_len(++i); |
| 308 my_itos(num, i, num_len); | 308 my_uitos(num, i, num_len); |
| 309 | 309 |
| 310 size_t chunk_len = std::min(chunk_size, msg_length); | 310 size_t chunk_len = std::min(chunk_size, msg_length); |
| 311 | 311 |
| 312 AddString(g_form_data_msg); | 312 AddString(g_form_data_msg); |
| 313 AddItem(msg_type, msg_type_size); | 313 AddItem(msg_type, msg_type_size); |
| 314 AddItem(num, num_len); | 314 AddItem(num, num_len); |
| 315 AddString(g_quote_msg); | 315 AddString(g_quote_msg); |
| 316 AddString(g_rn); | 316 AddString(g_rn); |
| 317 AddString(g_rn); | 317 AddString(g_rn); |
| 318 if (strip_trailing_spaces) { | 318 if (strip_trailing_spaces) { |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 my_memset(*file_data, 0xf, st.st_size); | 678 my_memset(*file_data, 0xf, st.st_size); |
| 679 | 679 |
| 680 *size = st.st_size; | 680 *size = st.st_size; |
| 681 sys_read(*fd, *file_data, *size); | 681 sys_read(*fd, *file_data, *size); |
| 682 IGNORE_RET(sys_close(*fd)); | 682 IGNORE_RET(sys_close(*fd)); |
| 683 } | 683 } |
| 684 | 684 |
| 685 void HandleCrashDump(const BreakpadInfo& info) { | 685 void HandleCrashDump(const BreakpadInfo& info) { |
| 686 int dumpfd; | 686 int dumpfd; |
| 687 size_t dump_size; | 687 size_t dump_size; |
| 688 uint8_t *dump_data; | 688 uint8_t* dump_data; |
| 689 google_breakpad::PageAllocator allocator; | 689 google_breakpad::PageAllocator allocator; |
| 690 LoadDataFromFile(allocator, info, info.filename, | 690 LoadDataFromFile(allocator, info, info.filename, |
| 691 &dumpfd, &dump_data, &dump_size); | 691 &dumpfd, &dump_data, &dump_size); |
| 692 #if defined(ADDRESS_SANITIZER) | 692 #if defined(ADDRESS_SANITIZER) |
| 693 int logfd; | 693 int logfd; |
| 694 size_t log_size; | 694 size_t log_size; |
| 695 uint8_t *log_data; | 695 uint8_t* log_data; |
| 696 // Load the AddressSanitizer log into log_data. | 696 // Load the AddressSanitizer log into log_data. |
| 697 LoadDataFromFile(allocator, info, info.log_filename, | 697 LoadDataFromFile(allocator, info, info.log_filename, |
| 698 &logfd, &log_data, &log_size); | 698 &logfd, &log_data, &log_size); |
| 699 #endif | 699 #endif |
| 700 | 700 |
| 701 // We need to build a MIME block for uploading to the server. Since we are | 701 // We need to build a MIME block for uploading to the server. Since we are |
| 702 // going to fork and run wget, it needs to be written to a temp file. | 702 // going to fork and run wget, it needs to be written to a temp file. |
| 703 const int ufd = sys_open("/dev/urandom", O_RDONLY, 0); | 703 const int ufd = sys_open("/dev/urandom", O_RDONLY, 0); |
| 704 if (ufd < 0) { | 704 if (ufd < 0) { |
| 705 static const char msg[] = "Cannot upload crash dump because /dev/urandom" | 705 static const char msg[] = "Cannot upload crash dump because /dev/urandom" |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1302 logging::SetDumpWithoutCrashingFunction(&DumpProcess); | 1302 logging::SetDumpWithoutCrashingFunction(&DumpProcess); |
| 1303 #if defined(ADDRESS_SANITIZER) | 1303 #if defined(ADDRESS_SANITIZER) |
| 1304 // Register the callback for AddressSanitizer error reporting. | 1304 // Register the callback for AddressSanitizer error reporting. |
| 1305 __asan_set_error_report_callback(AsanLinuxBreakpadCallback); | 1305 __asan_set_error_report_callback(AsanLinuxBreakpadCallback); |
| 1306 #endif | 1306 #endif |
| 1307 } | 1307 } |
| 1308 | 1308 |
| 1309 bool IsCrashReporterEnabled() { | 1309 bool IsCrashReporterEnabled() { |
| 1310 return g_is_crash_reporter_enabled; | 1310 return g_is_crash_reporter_enabled; |
| 1311 } | 1311 } |
| OLD | NEW |