diff options
author | erikwright <erikwright@chromium.org> | 2015-02-20 12:22:28 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-20 20:23:29 +0000 |
commit | d2349e504d60c9fd0b99420a10e8a83df0f7d8fe (patch) | |
tree | 4c4a84f5136e8499250624f82c159280c421c585 /chrome/chrome_watcher | |
parent | 66af5887986c6e397eb502be312a98dc6e7d6d9b (diff) | |
download | chromium_src-d2349e504d60c9fd0b99420a10e8a83df0f7d8fe.zip chromium_src-d2349e504d60c9fd0b99420a10e8a83df0f7d8fe.tar.gz chromium_src-d2349e504d60c9fd0b99420a10e8a83df0f7d8fe.tar.bz2 |
Instantiate a Kasko reporter inside the Chrome watcher process, when SyzyASAN instrumented.
BUG=460512
Review URL: https://codereview.chromium.org/901673002
Cr-Commit-Position: refs/heads/master@{#317385}
Diffstat (limited to 'chrome/chrome_watcher')
-rw-r--r-- | chrome/chrome_watcher/BUILD.gn | 1 | ||||
-rw-r--r-- | chrome/chrome_watcher/DEPS | 1 | ||||
-rw-r--r-- | chrome/chrome_watcher/chrome_watcher.gypi | 8 | ||||
-rw-r--r-- | chrome/chrome_watcher/chrome_watcher_main.cc | 28 | ||||
-rw-r--r-- | chrome/chrome_watcher/chrome_watcher_main_api.cc | 7 | ||||
-rw-r--r-- | chrome/chrome_watcher/chrome_watcher_main_api.h | 19 |
6 files changed, 60 insertions, 4 deletions
diff --git a/chrome/chrome_watcher/BUILD.gn b/chrome/chrome_watcher/BUILD.gn index 32d73d9..376daaa 100644 --- a/chrome/chrome_watcher/BUILD.gn +++ b/chrome/chrome_watcher/BUILD.gn @@ -33,6 +33,7 @@ shared_library("chrome_watcher") { ] deps = [ ":chrome_watcher_resources", + ":client", "//base", "//components/browser_watcher", ] diff --git a/chrome/chrome_watcher/DEPS b/chrome/chrome_watcher/DEPS index e805bfc..9b1e8bd 100644 --- a/chrome/chrome_watcher/DEPS +++ b/chrome/chrome_watcher/DEPS @@ -1,4 +1,5 @@ include_rules = [ "+base", "+components/browser_watcher", + "+syzygy/kasko/api", ] diff --git a/chrome/chrome_watcher/chrome_watcher.gypi b/chrome/chrome_watcher/chrome_watcher.gypi index 067dbb6..146cb86 100644 --- a/chrome/chrome_watcher/chrome_watcher.gypi +++ b/chrome/chrome_watcher/chrome_watcher.gypi @@ -59,10 +59,18 @@ 'chrome_watcher_main.cc', ], 'dependencies': [ + 'chrome_watcher_client', 'chrome_watcher_resources', '../base/base.gyp:base', '../components/components.gyp:browser_watcher', ], + 'conditions': [ + ['syzyasan==1', { + 'dependencies': [ + 'kasko_dll', + ], + }], + ], 'msvs_settings': { 'VCLinkerTool': { # Set /SUBSYSTEM:WINDOWS. diff --git a/chrome/chrome_watcher/chrome_watcher_main.cc b/chrome/chrome_watcher/chrome_watcher_main.cc index c88988f..b67f13d 100644 --- a/chrome/chrome_watcher/chrome_watcher_main.cc +++ b/chrome/chrome_watcher/chrome_watcher_main.cc @@ -8,6 +8,7 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/command_line.h" +#include "base/files/file_path.h" #include "base/logging_win.h" #include "base/macros.h" #include "base/memory/ref_counted.h" @@ -20,11 +21,16 @@ #include "base/template_util.h" #include "base/threading/thread.h" #include "base/time/time.h" +#include "base/win/scoped_handle.h" #include "chrome/chrome_watcher/chrome_watcher_main_api.h" #include "components/browser_watcher/endsession_watcher_window_win.h" #include "components/browser_watcher/exit_code_watcher_win.h" #include "components/browser_watcher/exit_funnel_win.h" +#ifdef SYZYASAN +#include "syzygy/kasko/api/reporter.h" +#endif + namespace { // Use the same log facility as Chrome for convenience. @@ -197,7 +203,8 @@ void BrowserMonitor::BrowserExited() { // mangling. extern "C" int WatcherMain(const base::char16* registry_path, HANDLE process_handle, - HANDLE on_initialized_event_handle) { + HANDLE on_initialized_event_handle, + const base::char16* browser_data_directory) { base::Process process(process_handle); base::win::ScopedHandle on_initialized_event(on_initialized_event_handle); @@ -212,6 +219,20 @@ extern "C" int WatcherMain(const base::char16* registry_path, // chrome.exe in order to report its exit status. ::SetProcessShutdownParameters(0x100, SHUTDOWN_NORETRY); +#ifdef SYZYASAN + bool launched_kasko = kasko::api::InitializeReporter( + GetKaskoEndpoint(process.Pid()).c_str(), + L"https://clients2.google.com/cr/staging_report", + base::FilePath(browser_data_directory) + .Append(L"Crash Reports") + .value() + .c_str(), + base::FilePath(browser_data_directory) + .Append(kPermanentlyFailedReportsSubdir) + .value() + .c_str()); +#endif // SYZYASAN + // Run a UI message loop on the main thread. base::MessageLoop msg_loop(base::MessageLoop::TYPE_UI); msg_loop.set_thread_name("WatcherMainThread"); @@ -225,6 +246,11 @@ extern "C" int WatcherMain(const base::char16* registry_path, run_loop.Run(); +#ifdef SYZYASAN + if (launched_kasko) + kasko::api::ShutdownReporter(); +#endif // SYZYASAN + // Wind logging down. logging::LogEventProvider::Uninitialize(); diff --git a/chrome/chrome_watcher/chrome_watcher_main_api.cc b/chrome/chrome_watcher/chrome_watcher_main_api.cc index 2c41cd5..e8b29e1 100644 --- a/chrome/chrome_watcher/chrome_watcher_main_api.cc +++ b/chrome/chrome_watcher/chrome_watcher_main_api.cc @@ -3,7 +3,14 @@ // found in the LICENSE file. #include "chrome/chrome_watcher/chrome_watcher_main_api.h" +#include "base/strings/string_number_conversions.h" const base::FilePath::CharType kChromeWatcherDll[] = FILE_PATH_LITERAL("chrome_watcher.dll"); const char kChromeWatcherDLLEntrypoint[] = "WatcherMain"; +const base::FilePath::CharType kPermanentlyFailedReportsSubdir[] = + L"Crash Reports Fallback"; + +base::string16 GetKaskoEndpoint(base::ProcessId client_process_id) { + return L"chrome_kasko_" + base::UintToString16(client_process_id); +} diff --git a/chrome/chrome_watcher/chrome_watcher_main_api.h b/chrome/chrome_watcher/chrome_watcher_main_api.h index 22dbf9b..7b48f82 100644 --- a/chrome/chrome_watcher/chrome_watcher_main_api.h +++ b/chrome/chrome_watcher/chrome_watcher_main_api.h @@ -7,20 +7,33 @@ #include <Windows.h> #include "base/files/file_path.h" +#include "base/process/process_handle.h" #include "base/strings/string16.h" // The name of the watcher DLL. extern const base::FilePath::CharType kChromeWatcherDll[]; // The name of the watcher DLLs entrypoint function. extern const char kChromeWatcherDLLEntrypoint[]; +// The subdirectory of the browser data directory where permanently failed crash +// reports will be stored. +extern const base::FilePath::CharType kPermanentlyFailedReportsSubdir[]; // The type of the watcher DLL's main entry point. // Watches |parent_process| and records its exit code under |registry_path| in -// HKCU. |on_initialized_event| will be signaled once the process is fully -// initialized. Takes ownership of |parent_process| and |on_initialized_event|. +// HKCU. If SyzyASAN is enabled, a Kasko reporter process is also instantiated, +// using |browser_data_directory| to store crash reports. |on_initialized_event| +// will be signaled once the process is fully initialized. Takes ownership of +// |parent_process| and |on_initialized_event|. typedef int (*ChromeWatcherMainFunction)( const base::char16* registry_path, HANDLE parent_process, - HANDLE on_initialized_event); + HANDLE on_initialized_event, + const base::char16* browser_data_directory); + +// Returns an RPC endpoint name for the identified client process. This method +// may be invoked in both the client and the watcher process with the PID of the +// client process to establish communication between the two using a common +// endpoint name. +base::string16 GetKaskoEndpoint(base::ProcessId client_process_id); #endif // CHROME_CHROME_WATCHER_CHROME_WATCHER_MAIN_API_H_ |