| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/breakpad/browser/crash_handler_host_linux.h" | 5 #include "components/breakpad/browser/crash_handler_host_linux.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> |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 scoped_ptr<BreakpadInfo> info(new BreakpadInfo); | 293 scoped_ptr<BreakpadInfo> info(new BreakpadInfo); |
| 294 | 294 |
| 295 info->fd = -1; | 295 info->fd = -1; |
| 296 info->process_type_length = process_type_.length(); | 296 info->process_type_length = process_type_.length(); |
| 297 // Freed in CrashDumpTask(). | 297 // Freed in CrashDumpTask(). |
| 298 char* process_type_str = new char[info->process_type_length + 1]; | 298 char* process_type_str = new char[info->process_type_length + 1]; |
| 299 process_type_.copy(process_type_str, info->process_type_length); | 299 process_type_.copy(process_type_str, info->process_type_length); |
| 300 process_type_str[info->process_type_length] = '\0'; | 300 process_type_str[info->process_type_length] = '\0'; |
| 301 info->process_type = process_type_str; | 301 info->process_type = process_type_str; |
| 302 | 302 |
| 303 std::string distro = base::GetLinuxDistro(); | |
| 304 info->distro_length = distro.length(); | |
| 305 // Freed in CrashDumpTask(). | |
| 306 char* distro_str = new char[info->distro_length + 1]; | |
| 307 distro.copy(distro_str, info->distro_length); | |
| 308 distro_str[info->distro_length] = '\0'; | |
| 309 info->distro = distro_str; | |
| 310 | |
| 311 // Memory released from scoped_ptrs below are also freed in CrashDumpTask(). | 303 // Memory released from scoped_ptrs below are also freed in CrashDumpTask(). |
| 312 info->crash_keys = crash_keys.release(); | 304 info->crash_keys = crash_keys.release(); |
| 313 #if defined(ADDRESS_SANITIZER) | 305 #if defined(ADDRESS_SANITIZER) |
| 314 asan_report[kMaxAsanReportSize] = '\0'; | 306 asan_report[kMaxAsanReportSize] = '\0'; |
| 315 info->asan_report_str = asan_report.release(); | 307 info->asan_report_str = asan_report.release(); |
| 316 info->asan_report_length = strlen(info->asan_report_str); | 308 info->asan_report_length = strlen(info->asan_report_str); |
| 317 #endif | 309 #endif |
| 318 | 310 |
| 319 info->process_start_time = uptime; | 311 info->process_start_time = uptime; |
| 320 info->oom_size = oom_size; | 312 info->oom_size = oom_size; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 337 signal_fd)); | 329 signal_fd)); |
| 338 } | 330 } |
| 339 | 331 |
| 340 void CrashHandlerHostLinux::WriteDumpFile(scoped_ptr<BreakpadInfo> info, | 332 void CrashHandlerHostLinux::WriteDumpFile(scoped_ptr<BreakpadInfo> info, |
| 341 scoped_ptr<char[]> crash_context, | 333 scoped_ptr<char[]> crash_context, |
| 342 pid_t crashing_pid, | 334 pid_t crashing_pid, |
| 343 int signal_fd) { | 335 int signal_fd) { |
| 344 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( | 336 DCHECK(BrowserThread::GetBlockingPool()->IsRunningSequenceOnCurrentThread( |
| 345 worker_pool_token_)); | 337 worker_pool_token_)); |
| 346 | 338 |
| 339 // Set |info->distro| here because base::GetLinuxDistro() needs to run on a |
| 340 // blocking thread. |
| 341 std::string distro = base::GetLinuxDistro(); |
| 342 info->distro_length = distro.length(); |
| 343 // Freed in CrashDumpTask(). |
| 344 char* distro_str = new char[info->distro_length + 1]; |
| 345 distro.copy(distro_str, info->distro_length); |
| 346 distro_str[info->distro_length] = '\0'; |
| 347 info->distro = distro_str; |
| 348 |
| 347 base::FilePath dumps_path("/tmp"); | 349 base::FilePath dumps_path("/tmp"); |
| 348 PathService::Get(base::DIR_TEMP, &dumps_path); | 350 PathService::Get(base::DIR_TEMP, &dumps_path); |
| 349 if (!info->upload) | 351 if (!info->upload) |
| 350 dumps_path = dumps_path_; | 352 dumps_path = dumps_path_; |
| 351 const std::string minidump_filename = | 353 const std::string minidump_filename = |
| 352 base::StringPrintf("%s/chromium-%s-minidump-%016" PRIx64 ".dmp", | 354 base::StringPrintf("%s/chromium-%s-minidump-%016" PRIx64 ".dmp", |
| 353 dumps_path.value().c_str(), | 355 dumps_path.value().c_str(), |
| 354 process_type_.c_str(), | 356 process_type_.c_str(), |
| 355 base::RandUint64()); | 357 base::RandUint64()); |
| 356 | 358 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 // no-ops. | 422 // no-ops. |
| 421 shutting_down_ = true; | 423 shutting_down_ = true; |
| 422 uploader_thread_->Stop(); | 424 uploader_thread_->Stop(); |
| 423 } | 425 } |
| 424 | 426 |
| 425 bool CrashHandlerHostLinux::IsShuttingDown() const { | 427 bool CrashHandlerHostLinux::IsShuttingDown() const { |
| 426 return shutting_down_; | 428 return shutting_down_; |
| 427 } | 429 } |
| 428 | 430 |
| 429 } // namespace breakpad | 431 } // namespace breakpad |
| OLD | NEW |