14 Commits

Author SHA1 Message Date
Mark Mentovai
f09d0cde00 Improve time handling and error checking
The database settings object’s last_upload_attempt_time (time_t) field
is switched from uint64_t to int64_t, for better compatibility with
time_t, which is normally a signed type. This change should be
transparent, as there should be no valid high-bit-set 64-bit timestamps
in this field in the wild.

A number of improvements are made to crashpad_database_util’s time
handling. Errors are checked during time conversion.
--set-last-upload-attempt-time=now is a new supported (and documented)
option.

A StringToNumber() overload for int64_t, along with a test, is added to
aid in crashpad_database_util’s time conversions from numeric strings. A
test is also added for the previously-untested uint64_t implementation.

TEST=crashpad_util_test StringNumberConversion.*

Change-Id: I089c4bf7b95f5df0982bdbb3c27b4f6a89db966e
Reviewed-on: https://chromium-review.googlesource.com/410068
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-11-15 18:53:11 +00:00
Mark Mentovai
6d2d31d2d1 Use base/macros.h instead of base/basictypes.h
This was done in Chromium’s local copy of Crashpad in 562827afb599. This
change is similar to that one, except more care was taken to avoid
including headers from a .cc or _test.cc when already included by the
associated .h. Rather than using <stddef.h> for size_t, Crashpad has
always used <sys/types.h>, so that’s used here as well.

This updates mini_chromium to 8a2363f486e3a0dc562a68884832d06d28d38dcc,
which removes base/basictypes.h.

e128dcf10122 Remove base/move.h; use std::move() instead of Pass()
8a2363f486e3 Move basictypes.h to macros.h

R=avi@chromium.org

Review URL: https://codereview.chromium.org/1566713002 .
2016-01-06 12:22:50 -05:00
Mark Mentovai
583d1dc3ef Provide std::move() in compat instead of using crashpad::move()
This more-natural spelling doesn’t require Crashpad developers to have
to remember anything special when writing code in Crashpad. It’s easier
to grep for and it’s easier to remove the “compat” part when pre-C++11
libraries are no longer relevant.

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1513573005 .
2015-12-09 17:36:32 -05:00
Dana Jansens
6bebb10829 Replace use of .Pass() with crashpad::move().
Since C++11 library support isn't available everywhere crashpad is
compiled, add our own move() method in the crashpad namespace to replace
std::move() for now. Replace uses of .Pass() with this method.

R=mark@chromium.org, scottmg@chromium.org
BUG=chromium:557422

Review URL: https://codereview.chromium.org/1483073004 .
2015-11-30 14:20:54 -08:00
Mark Mentovai
81ece89d6a Make ScopedGeneric uses slightly more consistent
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1426533008 .
2015-11-09 15:33:36 -05:00
Scott Graham
4b780ba040 Tidy up to enable C4800 on Windows
Fixes two incorrect usages of ssize_t/off_t being implicitly converted
to bool. As such, I think it's worth the cost of the additional !! on
BOOL returning Win32 functions.

R=mark@chromium.org

Review URL: https://codereview.chromium.org/1408123006 .
2015-10-22 14:32:13 -07:00
Mark Mentovai
0884d4d3a8 Don’t log an error when creating a new crash report database
Previously, any attempt to create a new crash report database would
result in this message being logged:

[p:t:yyyymmdd,hhmmss.uuuuuu:ERROR file_io.cc:30] read: expected 40,
observed 0

This would be the first thing that a developer embedding Crashpad into
their application would see after getting everything right. It doesn’t
exactly seem like everything’s right with that being logged. It would
also be the first thing that a user would see on stderr or in logs upon
launching a Crashpad-enabled application, which also seems kind of
dodgy.

The crash report database settings creation logic is restructured to
avoid logging this error when definitely creating a new database, while
retaining all other error logging.

BUG=crashpad:63
TEST=crashpad_database_util --database $new_db --show-client-id
     (should not show any errors)

R=rsesek@chromium.org, scottmg@chromium.org

Review URL: https://codereview.chromium.org/1392953002 .
2015-10-07 16:20:29 -04:00
Scott Graham
6082aed2f2 win: Get Crashpad compiling under VS2015
R=mark@chromium.org
BUG=crashpad:1, chromium:440500

Review URL: https://codereview.chromium.org/1357833002 .
2015-09-21 10:51:15 -07:00
Scott Graham
8272a4cefe Use LockFile/UnlockFile for Settings to port to Windows
Adds LoggingOpenFileForReadAndWrite, LoggingTruncateFile, and UUID::GenerateFromSystem
in support.

R=mark@chromium.org, rsesek@chromium.org
BUG=crashpad:13

Review URL: https://codereview.chromium.org/999953002
2015-04-20 14:21:48 -07:00
Mark Mentovai
58c7519598 Add a magic number to settings.dat for better identification.
“1” is probably one of the more common things for files to begin with.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1007433003
2015-03-12 19:34:05 -04:00
Robert Sesek
995e762a45 Use new ScopedGeneric move support.
BUG=crashpad:14
R=mark@chromium.org

Review URL: https://codereview.chromium.org/1001713002
2015-03-12 09:47:55 -04:00
Mark Mentovai
bdcc1e7625 Return a FilePath from Settings::file_path().
This makes it possible to #include "client/settings.h" for the interface
even on Windows. Although Settings is not currently implemented on
Windows (bug crashpad:13), it’s easier to have the interface declaration
available without having to have it be guarded.

TEST=crashpad_client_test SettingsTest.*
BUG=
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/987383002
2015-03-10 14:26:24 -04:00
Robert Sesek
e4c8b6cc72 Fix Settings::OpenForReadingAndWriting using O_CREAT with no mode.
R=mark@chromium.org

Review URL: https://codereview.chromium.org/997613002
2015-03-10 13:52:19 -04:00
Robert Sesek
1a635e3a79 Define the Settings interface for a CrashReportDatabase and provide a Mac implementation.
R=mark@chromium.org

Review URL: https://codereview.chromium.org/988063003
2015-03-09 18:47:52 -04:00