Skip to content

Commit

Permalink
A simple minidump writer for postmortem stability reports.
Browse files Browse the repository at this point in the history
Enables writing a minimal minidump for wrapping a StabilityReport protocol buffer. The minidump is meant to be valid for registration with the Crashpad reporter (includes the Crashpad info stream).

BUG=620813

Review-Url: https://codereview.chromium.org/2327043002
Cr-Commit-Position: refs/heads/master@{#418863}
  • Loading branch information
manzagop authored and Commit bot committed Sep 15, 2016
1 parent 6f86fda commit a28851c
Show file tree
Hide file tree
Showing 6 changed files with 711 additions and 1 deletion.
33 changes: 33 additions & 0 deletions components/browser_watcher/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//third_party/protobuf/proto_library.gni")

proto_library("stability_report_proto") {
sources = [
"stability_report.proto",
]
}

static_library("browser_watcher") {
# This is a separate lib to minimize the dependencies for its
# hosting binary "chrome_watcher.dll".
Expand Down Expand Up @@ -33,12 +41,28 @@ static_library("browser_watcher_client") {
]
}

static_library("postmortem_minidump_writer") {
# TODO(manzagop): remove this lib once Crashpad writes the minidumps.
sources = [
"postmortem_minidump_writer.h",
"postmortem_minidump_writer_win.cc",
]
deps = [
":stability_report_proto",
"//base",
"//third_party/crashpad/crashpad/client",
"//third_party/crashpad/crashpad/minidump",
"//third_party/crashpad/crashpad/util",
]
}

source_set("unit_tests") {
testonly = true
sources = [
"endsession_watcher_window_win_unittest.cc",
"exit_code_watcher_win_unittest.cc",
"exit_funnel_win_unittest.cc",
"postmortem_minidump_writer_win_unittest.cc",
"watcher_client_win_unittest.cc",
"watcher_metrics_provider_win_unittest.cc",
"window_hang_monitor_win_unittest.cc",
Expand All @@ -47,8 +71,17 @@ source_set("unit_tests") {
deps = [
":browser_watcher",
":browser_watcher_client",
":postmortem_minidump_writer",
":stability_report_proto",
"//base",
"//base/test:test_support",
"//testing/gtest",
"//third_party/crashpad/crashpad/client",

# TODO(manzagop): remove this lib once Crashpad writes the minidumps.
"//third_party/crashpad/crashpad/compat",
"//third_party/crashpad/crashpad/minidump",
"//third_party/crashpad/crashpad/snapshot",
"//third_party/crashpad/crashpad/util",
]
}
3 changes: 2 additions & 1 deletion components/browser_watcher/DEPS
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include_rules = [
"+components/metrics"
"+components/metrics",
"+third_party/crashpad/crashpad",
]
37 changes: 37 additions & 0 deletions components/browser_watcher/postmortem_minidump_writer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_BROWSER_WATCHER_POSTMORTEM_MINIDUMP_WRITER_H_
#define COMPONENTS_BROWSER_WATCHER_POSTMORTEM_MINIDUMP_WRITER_H_

#include <stdint.h>

#include <string>

#include "base/files/file.h"
#include "components/browser_watcher/stability_report.pb.h"
#include "third_party/crashpad/crashpad/util/misc/uuid.h"

namespace browser_watcher {

// Minidump information required by the Crashpad reporter.
struct MinidumpInfo {
crashpad::UUID client_id; // The client's identifier.
crashpad::UUID report_id; // The report's identifier.
std::string product_name; // The product name to be used by the reporter.
std::string version_number; // The product's version number.
};

// Write to |minidump_file| a minimal minidump that wraps |report|. Returns
// true on success, false otherwise.
// Note: the caller owns |minidump_file| and is responsible for keeping it valid
// for this function's duration. |minidump_file| is expected to be empty
// and a binary stream.
bool WritePostmortemDump(base::PlatformFile minidump_file,
const StabilityReport& report,
const MinidumpInfo& minidump_info);

} // namespace browser_watcher

#endif // COMPONENTS_BROWSER_WATCHER_POSTMORTEM_MINIDUMP_WRITER_H_
Loading

0 comments on commit a28851c

Please sign in to comment.