Skip to content

Commit

Permalink
Add a cross-platform database implementation
Browse files Browse the repository at this point in the history
This CL, based on
https://chromium-review.googlesource.com/c/crashpad/crashpad/+/689745
adds a cross-platform database implementation side-by-side with the
existing macOS and Windows implementations. The generic implementation
is used for Linux, Android and Fuchsia.

The database uses the directory structure from the macOS
implementation, but stores report metadata in companion files for each
report, rather than using filesystem attributes. The database uses
lockfiles (companion files opened with O_EXCL) to protect report access
because they are widely supported across filesystems. Lost lockfiles
are removed after 3 days, along with any reports or metadata they were
protecting.

Bug: crashpad:206
Change-Id: I086e9001350e4446dd2f8c12fd3817377f509d3e
Reviewed-on: https://chromium-review.googlesource.com/919527
Commit-Queue: Joshua Peraza <[email protected]>
Reviewed-by: Mark Mentovai <[email protected]>
  • Loading branch information
Joshua Peraza authored and Commit Bot committed Feb 15, 2018
1 parent 7faa2ef commit 8d0d999
Show file tree
Hide file tree
Showing 8 changed files with 935 additions and 37 deletions.
5 changes: 4 additions & 1 deletion client/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@ static_library("client") {

if (crashpad_is_fuchsia) {
sources += [
"crash_report_database_fuchsia.cc",
"crashpad_client_fuchsia.cc",
]
}

if (crashpad_is_linux || crashpad_is_android || crashpad_is_fuchsia) {
sources += [ "crash_report_database_generic.cc" ]
}

public_configs = [ "..:crashpad_config" ]

deps = [
Expand Down
1 change: 1 addition & 0 deletions client/client.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
'annotation_list.h',
'crash_report_database.cc',
'crash_report_database.h',
'crash_report_database_generic.cc',
'crash_report_database_mac.mm',
'crash_report_database_win.cc',
'crashpad_client.h',
Expand Down
3 changes: 3 additions & 0 deletions client/client_test.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
'../handler/handler.gyp:crashpad_handler_console',
],
}],
['OS=="linux" or OS=="android"',
{'dependencies!': ['../handler/handler.gyp:crashpad_handler']},
],
],
},
],
Expand Down
14 changes: 13 additions & 1 deletion client/crash_report_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class CrashReportDatabase {
const UUID& ReportID() { return uuid_; }

private:
friend class CrashReportDatabase;
friend class CrashReportDatabaseGeneric;
friend class CrashReportDatabaseMac;
friend class CrashReportDatabaseWin;

Expand All @@ -142,6 +142,7 @@ class CrashReportDatabase {

private:
friend class CrashReportDatabase;
friend class CrashReportDatabaseGeneric;
friend class CrashReportDatabaseMac;
friend class CrashReportDatabaseWin;

Expand Down Expand Up @@ -348,6 +349,17 @@ class CrashReportDatabase {
//! \return The operation status code.
virtual OperationStatus RequestUpload(const UUID& uuid) = 0;

//! \brief Cleans the database of expired lockfiles, metadata without report
//! files, and report files without metadata.
//!
//! This method does nothing on the macOS and Windows implementations of the
//! database.
//!
//! \param[in] lockfile_ttl The number of seconds at which lockfiles or new
//! report files are considered expired.
//! \return The number of reports cleaned.
virtual int CleanDatabase(time_t lockfile_ttl) { return 0; }

protected:
CrashReportDatabase() {}

Expand Down
35 changes: 0 additions & 35 deletions client/crash_report_database_fuchsia.cc

This file was deleted.

Loading

0 comments on commit 8d0d999

Please sign in to comment.