| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/app/breakpad_win.h" | 5 #include "chrome/app/breakpad_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 #include <tchar.h> | 9 #include <tchar.h> |
| 10 | 10 |
| 11 #include <algorithm> | 11 #include <algorithm> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/base_switches.h" | 14 #include "base/base_switches.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/environment.h" |
| 16 #include "base/file_util.h" | 17 #include "base/file_util.h" |
| 17 #include "base/file_version_info.h" | 18 #include "base/file_version_info.h" |
| 18 #include "base/registry.h" | 19 #include "base/registry.h" |
| 20 #include "base/scoped_ptr.h" |
| 19 #include "base/string_util.h" | 21 #include "base/string_util.h" |
| 20 #include "base/utf_string_conversions.h" | 22 #include "base/utf_string_conversions.h" |
| 21 #include "base/win_util.h" | 23 #include "base/win_util.h" |
| 22 #include "breakpad/src/client/windows/handler/exception_handler.h" | 24 #include "breakpad/src/client/windows/handler/exception_handler.h" |
| 23 #include "chrome/app/hard_error_handler_win.h" | 25 #include "chrome/app/hard_error_handler_win.h" |
| 24 #include "chrome/common/child_process_logging.h" | 26 #include "chrome/common/child_process_logging.h" |
| 25 #include "chrome/common/env_vars.h" | 27 #include "chrome/common/env_vars.h" |
| 26 #include "chrome/common/result_codes.h" | 28 #include "chrome/common/result_codes.h" |
| 27 #include "chrome/common/policy_constants.h" | 29 #include "chrome/common/policy_constants.h" |
| 28 #include "chrome/installer/util/google_chrome_sxs_distribution.h" | 30 #include "chrome/installer/util/google_chrome_sxs_distribution.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 bool DumpDoneCallback(const wchar_t*, const wchar_t*, void*, | 198 bool DumpDoneCallback(const wchar_t*, const wchar_t*, void*, |
| 197 EXCEPTION_POINTERS* ex_info, | 199 EXCEPTION_POINTERS* ex_info, |
| 198 MDRawAssertionInfo*, bool) { | 200 MDRawAssertionInfo*, bool) { |
| 199 // If the exception is because there was a problem loading a delay-loaded | 201 // If the exception is because there was a problem loading a delay-loaded |
| 200 // module, then show the user a dialog explaining the problem and then exit. | 202 // module, then show the user a dialog explaining the problem and then exit. |
| 201 if (DelayLoadFailureExceptionMessageBox(ex_info)) | 203 if (DelayLoadFailureExceptionMessageBox(ex_info)) |
| 202 return true; | 204 return true; |
| 203 | 205 |
| 204 // We set CHROME_CRASHED env var. If the CHROME_RESTART is present. | 206 // We set CHROME_CRASHED env var. If the CHROME_RESTART is present. |
| 205 // This signals the child process to show the 'chrome has crashed' dialog. | 207 // This signals the child process to show the 'chrome has crashed' dialog. |
| 206 if (!::GetEnvironmentVariableW(ASCIIToWide(env_vars::kRestartInfo).c_str(), | 208 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 207 NULL, 0)) { | 209 if (!env->HasVar(env_vars::kRestartInfo)) { |
| 208 return true; | 210 return true; |
| 209 } | 211 } |
| 210 ::SetEnvironmentVariableW(ASCIIToWide(env_vars::kShowRestart).c_str(), L"1"); | 212 env->SetVar(env_vars::kShowRestart, "1"); |
| 211 // Now we just start chrome browser with the same command line. | 213 // Now we just start chrome browser with the same command line. |
| 212 STARTUPINFOW si = {sizeof(si)}; | 214 STARTUPINFOW si = {sizeof(si)}; |
| 213 PROCESS_INFORMATION pi; | 215 PROCESS_INFORMATION pi; |
| 214 if (::CreateProcessW(NULL, ::GetCommandLineW(), NULL, NULL, FALSE, | 216 if (::CreateProcessW(NULL, ::GetCommandLineW(), NULL, NULL, FALSE, |
| 215 CREATE_UNICODE_ENVIRONMENT, NULL, NULL, &si, &pi)) { | 217 CREATE_UNICODE_ENVIRONMENT, NULL, NULL, &si, &pi)) { |
| 216 ::CloseHandle(pi.hProcess); | 218 ::CloseHandle(pi.hProcess); |
| 217 ::CloseHandle(pi.hThread); | 219 ::CloseHandle(pi.hThread); |
| 218 } | 220 } |
| 219 // After this return we will be terminated. The actual return value is | 221 // After this return we will be terminated. The actual return value is |
| 220 // not used at all. | 222 // not used at all. |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 dump_type = kLargerDumpType; | 496 dump_type = kLargerDumpType; |
| 495 } | 497 } |
| 496 | 498 |
| 497 g_breakpad = new google_breakpad::ExceptionHandler(temp_dir, &FilterCallback, | 499 g_breakpad = new google_breakpad::ExceptionHandler(temp_dir, &FilterCallback, |
| 498 callback, NULL, | 500 callback, NULL, |
| 499 google_breakpad::ExceptionHandler::HANDLER_ALL, | 501 google_breakpad::ExceptionHandler::HANDLER_ALL, |
| 500 dump_type, pipe_name.c_str(), info->custom_info); | 502 dump_type, pipe_name.c_str(), info->custom_info); |
| 501 | 503 |
| 502 if (!g_breakpad->IsOutOfProcess()) { | 504 if (!g_breakpad->IsOutOfProcess()) { |
| 503 // The out-of-process handler is unavailable. | 505 // The out-of-process handler is unavailable. |
| 504 ::SetEnvironmentVariable(ASCIIToWide(env_vars::kNoOOBreakpad).c_str(), | 506 scoped_ptr<base::Environment> env(base::Environment::Create()); |
| 505 info->process_type.c_str()); | 507 env->SetVar(env_vars::kNoOOBreakpad, WideToUTF8(info->process_type)); |
| 506 } else { | 508 } else { |
| 507 // Tells breakpad to handle breakpoint and single step exceptions. | 509 // Tells breakpad to handle breakpoint and single step exceptions. |
| 508 // This might break JIT debuggers, but at least it will always | 510 // This might break JIT debuggers, but at least it will always |
| 509 // generate a crashdump for these exceptions. | 511 // generate a crashdump for these exceptions. |
| 510 g_breakpad->set_handle_debug_exceptions(true); | 512 g_breakpad->set_handle_debug_exceptions(true); |
| 511 } | 513 } |
| 512 | 514 |
| 513 return 0; | 515 return 0; |
| 514 } | 516 } |
| 515 | 517 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 543 if (QueueUserWorkItem( | 545 if (QueueUserWorkItem( |
| 544 &InitCrashReporterThread, | 546 &InitCrashReporterThread, |
| 545 info, | 547 info, |
| 546 WT_EXECUTELONGFUNCTION) == 0) { | 548 WT_EXECUTELONGFUNCTION) == 0) { |
| 547 // We failed to queue to the worker pool, initialize in this thread. | 549 // We failed to queue to the worker pool, initialize in this thread. |
| 548 InitCrashReporterThread(info); | 550 InitCrashReporterThread(info); |
| 549 } | 551 } |
| 550 } | 552 } |
| 551 } | 553 } |
| 552 } | 554 } |
| OLD | NEW |