Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: chrome/browser/crash_handler_host_linuxish.cc

Issue 9838033: Upstream native crash handling changes for Android. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Revert of Revert with fixes. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 17 matching lines...) Expand all
350 process_type_.c_str(), 360 process_type_.c_str(),
351 rand); 361 rand);
352 if (!google_breakpad::WriteMinidump(minidump_filename.c_str(), 362 if (!google_breakpad::WriteMinidump(minidump_filename.c_str(),
353 crashing_pid, crash_context, 363 crashing_pid, crash_context,
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 unsigned minidump_filename_str_len = minidump_filename.length() + 1;
371 char* minidump_filename_str = new char[minidump_filename_str_len];
361 minidump_filename.copy(minidump_filename_str, minidump_filename.length()); 372 minidump_filename.copy(minidump_filename_str, minidump_filename.length());
362 minidump_filename_str[minidump_filename.length()] = '\0'; 373 minidump_filename_str[minidump_filename.length()] = '\0';
363 info->filename = minidump_filename_str; 374 info->filename = minidump_filename_str;
375 info->pid = crashing_pid;
364 376
365 BrowserThread::PostTask( 377 BrowserThread::PostTask(
366 BrowserThread::IO, FROM_HERE, 378 BrowserThread::IO, FROM_HERE,
367 base::Bind(&CrashHandlerHostLinux::QueueCrashDumpTask, 379 base::Bind(&CrashHandlerHostLinux::QueueCrashDumpTask,
368 base::Unretained(this), 380 base::Unretained(this),
369 info, 381 info,
370 signal_fd)); 382 signal_fd));
371 } 383 }
372 384
373 void CrashHandlerHostLinux::QueueCrashDumpTask(BreakpadInfo* info, 385 void CrashHandlerHostLinux::QueueCrashDumpTask(BreakpadInfo* info,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 } 487 }
476 488
477 void RendererCrashHandlerHostLinux::SetProcessType() { 489 void RendererCrashHandlerHostLinux::SetProcessType() {
478 process_type_ = "renderer"; 490 process_type_ = "renderer";
479 } 491 }
480 492
481 // static 493 // static
482 RendererCrashHandlerHostLinux* RendererCrashHandlerHostLinux::GetInstance() { 494 RendererCrashHandlerHostLinux* RendererCrashHandlerHostLinux::GetInstance() {
483 return Singleton<RendererCrashHandlerHostLinux>::get(); 495 return Singleton<RendererCrashHandlerHostLinux>::get();
484 } 496 }
OLDNEW
« no previous file with comments | « chrome/browser/crash_handler_host_linuxish.h ('k') | chrome/browser/crash_handler_host_linuxish_stub.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698