478 Commits

Author SHA1 Message Date
Mark Mentovai
79177046d3 Mac 10.6 SDK compatibility.
A couple of the problems related to not having a C++11 library:

 - You can’t put const elements into a std::vector<>, so
   CrashReportDatabase::GetPendingReports() and
   CrashReportDatabase::GetCompletedReports() need to change. There was
   no data-safety benefit to const elements.
 - std::string::pop_back() does not exist, another mechanism must be
   used to trim strings in BreakpadHTTPFormParametersFromMinidump().

One relates to a feature that does not exist in 10.6:

 - The O_CLOEXEC flag to open() was introduced in 10.7. Although it
   would be possible to use fcntl(..., F_SETFD, FD_CLOEXEC) on 10.6, the
   O_CLOEXEC behavior is just removed from
   CrashReportDatabaseMac::ObtainReportLock(), in line with other open()
   calls in Crashpad.

And one was a real bug:

 - #define __STDC_FORMAT_MACROS before #including <inttypes.h> to get
   format macros like SCNx32, used in UUID::InitializeFromString().

TEST=* (gyp_crashpad.py -Dmac_sdk=10.6 -Dmac_deployment_target=10.6)
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/987693004
2015-03-06 18:43:28 -05:00
Scott Graham
bd77b3034f win: Implementation of CrashReportDatabase for Windows (for C++ Windows readability review)
Original CL (review, misc support code changes) at https://codereview.chromium.org/867363003/.

Crashpad is a component of Chrome used for capturing crashes in the field and uploading them to crash/ for analysis: https://code.google.com/p/crashpad/.

BUG=crashpad:1, b/19354950
R=mark@chromium.org, pkasting@chromium.org

Review URL: https://codereview.chromium.org/913273002
2015-02-17 12:05:29 -08:00
Scott Graham
0849154aed win: Implementation of CrashReportDatabase for Windows
As there are no extended file attributes available on all Windows file
systems (NTFS supports alternate data streams, but Chrome still supports
running on FAT), instead of using metadata attached to the file, metadata
is stored separately in a simple record-based file and keyed by UUID.

Initially, I attempted a metadata file beside each report, each locked
separately more closely mirroring the Mac implementation. But given the
expected number of of active reports (in the 10s to 100s range?) and the
size of the metadata for each, simply storing it all in one file is much
less complicated when considering error situations.

If the serialization/deserialization becomes a measurable problem, it
could be optimized at some complexity by reading/writing only as
necessary, or optimizing the storage.

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

Review URL: https://codereview.chromium.org/867363003
2015-02-11 12:17:05 -08:00
Mark Mentovai
5d0050dee7 Add CrashReportDatabase::ErrorWritingCrashReport().
A crash handler needs a way to clean up after itself it it calls
CrashReportDatabase::PrepareCrashReport() to begin writing a new crash
report, but then encounters an error that renders the crash report
unusable. The new ErrorWritingCrashReport() method allows it to
communicate to the database that a previously-prepared crash report
should be removed without ever being promoted to a completed report
pending upload.

TEST=client_test CrashReportDatabaseTest.ErrorWritingCrashReport
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/904533002
2015-02-04 16:33:15 -05:00
Scott Graham
7cd1639990 win: Partial fixes for client_test after CrashReportDatabase added
- Dependency on compat required for sys/types.h inclusion for ssize_t.
- Test impl of stat to avoid #error
- FileHandle isn't int on Windows.

client_test no longer links though, as it's still lacking an
implementation of CrashReportDatabase of course.

R=rsesek@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/875043004
2015-01-26 13:56:20 -08:00
Robert Sesek
ee98449755 Create CrashReportDatabase interface, a test, and a Mac implementation.
R=mark@chromium.org
TEST=client_test --gtest_filter=CrashReportDatabase\*

Review URL: https://codereview.chromium.org/842513002
2015-01-26 15:59:01 -05:00
Mark Mentovai
2602e9d5d0 Add CrashpadClient.
CrashpadClient is the primary interface for an application to have
Crashpad monitor it for crashes. It contains StartHandler(), which
starts a Crashpad handler process, and UseHandler(), which configures
the process to direct its crashes to a handler process.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/785233011
2014-12-30 14:24:52 -05:00
Scott Graham
b0cf01978d win: Get client/crashpad_info.cc to compile
Just avoid the Mac-specific __attribute__ tagging for now. There will need
to be some Windows-specific pragmas added here once the reader has been
written.

R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/808623002
2014-12-16 10:22:41 -08:00
Scott Graham
e8ab9afd82 win: Avoid 'warning C4068: unknown pragma'
I could also add COMPILER_CLANG to build_config.h, but that doesn't
appear in Chromium, apparently in preference to using __clang__
directly. I'm not sure if there's any good reason for that.

R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/803283002
2014-12-15 16:01:16 -08:00
Mark Mentovai
c874958fd0 MachMessageServer: eliminate argument redundancy.
MachMessageServer::Run()’s distinct |nonblocking| parameter is removed.
The information it formerly conveyed is now implied by the |timeout_ms|
parameter, which can accept two special values,
kMachMessageTimeoutNonblocking and kMachMessageTimeoutWaitIndefinitely.

TEST=client_test, snapshot_test, util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/777993002
2014-12-10 11:11:21 -05:00
Mark Mentovai
821ed8fe0f UniversalMachExcServer: eliminate multiple implementation inheritance.
UniversalMachExcServer provided both an interface and an implementation,
contrary to the other classes in the exc_server_variants family. This
was mostly done for reasons of economy in an already-large class family.
Unfortunately, this decision meant that it was impossible for other code
to use UniversalMachExcServer, which required that CatchMachException()
be implemented, and also extend another class without violating the
style guide’s prohibition of multiple implementation inheritance. This
became a problem in a lot of test code, which extended MachMultiprocess
and UniversalMachExcServer.

UniversalMachExcServer is now given its own nested Interface class,
which is a pure interface. All users of UniversalMachExcServer are
changed from “is-a” UniversalMachExcServer to “has-a”
UniversalMachExcServer and “is-a” UniversalMachExcServer::Interface.

TEST=client_test, snapshot_test, util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/775943005
2014-12-04 10:18:24 -05:00
Mark Mentovai
0437bc53b6 Pass Mach message trailers to server handler functions.
TEST=util_test ChildPortServer.*:ExcServerVariants.*:MachMessageUtil.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/755313004
2014-12-01 16:06:56 -05:00
Mark Mentovai
79b4434c81 Add a ReceiveLarge parameter to MachMessageServer::Run().
Previously, MachMessageServer::Run() only provided two strategies for
dealing with large messages, indicated by mach_msg() returning
MACH_RCV_TOO_LARGE: the receive buffer could be reallocated and the
message received, or the entire function could return MACH_RCV_TOO_LARGE
to the caller. There are situations where an intermediate behavior might
be desirable. This intermediate behavior would allow the function to
continue waiting for another message without returning an error to the
caller or attempting to receive the large message. This is desirable
when dealing with fixed-sized messages and a receiver that might be sent
messages by unknown, possibly-malicious callers. This can happen when
the corresponding send right is published with the bootstrap server, for
example.

Existing users continue to request their existing behavior, typically
receiving an error when encountering a large message.
catch_exception_tool will use the new “ignore” behavior when running in
persistent mode.

TEST=util_test MachMessageServer.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/756803002
2014-11-25 14:48:44 -05:00
Mark Mentovai
48b1964d1b Use implicit_cast<> instead of static_cast<> whenever possible.
implicit_cast<> only performs a cast in cases where an implicit
conversion would be possible. It’s even safer than static_cast<> It’s an
“explicit implicit” cast, which is not normally necsesary, but is
frequently required when working with the ?: operator, functions like
std::min() and std::max(), and logging and testing macros.

The public style guide does not mention implicit_cast<> only because it
is not part of the standard library, but would otherwise require it in
these situations. Since base does provide implicit_cast<>, it should be
used whenever possible.

The only uses of static_cast<> not converted to implicit_cast<> are
those that require static_cast<>, such as those that assign an integer
constant to a variable of an enum type.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/700383007
2014-11-06 16:44:38 -05:00
Mark Mentovai
de0979b930 C++11: Use type aliases instead of typedefs.
This replaces all occurrences of “typedef Y X;” with “using X = Y;”.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/700143004
2014-11-05 14:09:01 -05:00
Mark Mentovai
7f30a9ebef Fix a few documentation problems.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/688643002
2014-10-29 11:33:34 -04:00
Mark Mentovai
b9db7543a3 client.gyp: Sort.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/657303003
2014-10-17 14:38:30 -04:00
Mark Mentovai
7d84d6512b include "util/stdlib/cxx.h" before checking CXX_LIBRARY_VERSION.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/662813003
2014-10-17 14:24:12 -04:00
Mark Mentovai
b43f510a52 Add crashpad_info, MachOImageAnnotationsReader, and its test.
TEST=snapshot_test MachOImageAnnotationsReader.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/651283003
2014-10-17 13:47:02 -04:00
Mark Mentovai
dd9cf1b367 Add CRASHPAD_SIMULATE_CRASH() and supporting client code.
TEST=client_test SimulateCrash.SimulateCrash
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/658853002
2014-10-17 12:30:55 -04:00
Mark Mentovai
5d74f120fc Convert NULL to nullptr.
This change was generated mechanically by running:

  find . \( -name \*.cc -or -name \*.mm -or -name \*.h \) \
      -and -not -path ./third_party/\* -and -not -path ./out/\* \
      -exec sed -i '' -E -e 's/(^|[^_])NULL/\1nullptr/g' {} +

Further manual fix-ups were applied to remove casts of nullptr to other
pointer types where possible, to preserve the intentional use of NULL
(as a short form of MACH_PORT_NULL) in exception_port_tool, and to fix
80-column violations.

https://groups.google.com/a/chromium.org/d/topic/chromium-dev/4mijeJHzxLg/discussion

TEST=*_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/656703002
2014-10-14 11:10:45 -04:00
Mark Mentovai
22350bd676 In tests, use ASSERT_NO_FATAL_FAILURE() instead of checking
testing::Test::HasFatalFailure() after calling functions that could fail
fatally.

Inspired by
https://codereview.chromium.org/637503006/diff/20001/minidump/minidump_thread_writer_test.cc#newcode437

TEST=client_test, minidump_test, util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/640383002
2014-10-09 15:08:54 -04:00
Mark Mentovai
6d1af6922f Don’t use using directives (“using namespace”) in tests.
The contents of tests are moved into the namespace
crashpad::test::(anonymous namespace).

https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Namespaces

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/635883002
2014-10-07 17:28:50 -04:00
Scott Graham
d198c50abe Convert COMPILE_ASSERT to static_assert
(Perhaps I should have just left it in mini_chromium, but anyway.)

R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/615923004
2014-10-01 12:29:01 -07:00
Mark Mentovai
0d59a76735 Fix AMD64 APM revision number in a comment.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/597263002
2014-09-24 13:34:12 -04:00
Mark Mentovai
d0fcfa42e4 Convert SimpleStringDictionary interface documentation to Doxygen.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/499643002
2014-08-22 17:09:03 -04:00
Mark Mentovai
b980a5984b Add SimpleStringDictionary and its test.
TEST=client_test SimpleStringDictionary*.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/489993002
2014-08-22 13:52:28 -04:00
Mark Mentovai
be5d0ab39c Add CaptureContext and its test.
TEST=client_test CaptureContextMac.CaptureContext
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/493563002
2014-08-20 18:30:19 -04:00