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

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

Issue 9838033: Upstream native crash handling changes for Android. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Chrome Android native crash support Created 8 years, 9 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) 2011 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 #include "chrome/browser/crash_handler_host_linux.h" 5 #include "chrome/browser/crash_handler_host_linux.h"
Yaron 2012/03/26 18:51:16 Fix include
carlosvaldivia 2012/04/03 06:24:47 Done.
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_linux.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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 info->process_type = process_type_str; 311 info->process_type = process_type_str;
306 312
307 info->crash_url_length = strlen(crash_url); 313 info->crash_url_length = strlen(crash_url);
308 info->crash_url = crash_url; 314 info->crash_url = crash_url;
309 315
310 info->guid_length = strlen(guid); 316 info->guid_length = strlen(guid);
311 info->guid = guid; 317 info->guid = guid;
312 318
313 info->distro_length = strlen(distro); 319 info->distro_length = strlen(distro);
314 info->distro = distro; 320 info->distro = distro;
315 321 #if defined(OS_ANDROID)
322 // Nothing gets uploaded in android.
323 info->upload = false;
324 #else
316 info->upload = (getenv(env_vars::kHeadless) == NULL); 325 info->upload = (getenv(env_vars::kHeadless) == NULL);
326 #endif
317 info->process_start_time = uptime; 327 info->process_start_time = uptime;
318 328
319 BrowserThread::PostTask( 329 BrowserThread::PostTask(
320 BrowserThread::FILE, FROM_HERE, 330 BrowserThread::FILE, FROM_HERE,
321 base::Bind(&CrashHandlerHostLinux::WriteDumpFile, 331 base::Bind(&CrashHandlerHostLinux::WriteDumpFile,
322 base::Unretained(this), 332 base::Unretained(this),
323 info, 333 info,
324 crashing_pid, 334 crashing_pid,
325 crash_context, 335 crash_context,
326 signal_fd)); 336 signal_fd));
(...skipping 16 matching lines...) Expand all
343 process_type_.c_str(), 353 process_type_.c_str(),
344 rand); 354 rand);
345 if (!google_breakpad::WriteMinidump(minidump_filename.c_str(), 355 if (!google_breakpad::WriteMinidump(minidump_filename.c_str(),
346 crashing_pid, crash_context, 356 crashing_pid, crash_context,
347 kCrashContextSize)) { 357 kCrashContextSize)) {
348 LOG(ERROR) << "Failed to write crash dump for pid " << crashing_pid; 358 LOG(ERROR) << "Failed to write crash dump for pid " << crashing_pid;
349 } 359 }
350 delete[] crash_context; 360 delete[] crash_context;
351 361
352 // Freed in CrashDumpTask(); 362 // Freed in CrashDumpTask();
353 char* minidump_filename_str = new char[minidump_filename.length() + 1]; 363 unsigned minidump_filename_str_len = minidump_filename.length() + 1;
364 char* minidump_filename_str = new char[minidump_filename_str_len];
354 minidump_filename.copy(minidump_filename_str, minidump_filename.length()); 365 minidump_filename.copy(minidump_filename_str, minidump_filename.length());
355 minidump_filename_str[minidump_filename.length()] = '\0'; 366 minidump_filename_str[minidump_filename.length()] = '\0';
356 info->filename = minidump_filename_str; 367 info->filename = minidump_filename_str;
368 info->filename_length = minidump_filename_str_len;
369 info->pid = crashing_pid;
357 370
358 BrowserThread::PostTask( 371 BrowserThread::PostTask(
359 BrowserThread::IO, FROM_HERE, 372 BrowserThread::IO, FROM_HERE,
360 base::Bind(&CrashHandlerHostLinux::QueueCrashDumpTask, 373 base::Bind(&CrashHandlerHostLinux::QueueCrashDumpTask,
361 base::Unretained(this), 374 base::Unretained(this),
362 info, 375 info,
363 signal_fd)); 376 signal_fd));
364 } 377 }
365 378
366 void CrashHandlerHostLinux::QueueCrashDumpTask(BreakpadInfo* info, 379 void CrashHandlerHostLinux::QueueCrashDumpTask(BreakpadInfo* info,
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 } 481 }
469 482
470 void RendererCrashHandlerHostLinux::SetProcessType() { 483 void RendererCrashHandlerHostLinux::SetProcessType() {
471 process_type_ = "renderer"; 484 process_type_ = "renderer";
472 } 485 }
473 486
474 // static 487 // static
475 RendererCrashHandlerHostLinux* RendererCrashHandlerHostLinux::GetInstance() { 488 RendererCrashHandlerHostLinux* RendererCrashHandlerHostLinux::GetInstance() {
476 return Singleton<RendererCrashHandlerHostLinux>::get(); 489 return Singleton<RendererCrashHandlerHostLinux>::get();
477 } 490 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698