125 Commits

Author SHA1 Message Date
Mark Mentovai
9086d25ce8 Don’t trigger EXC_CORPSE_NOTIFY on OS X 10.11
CrashReportExceptionHandler::CatchMachException() must always set a
valid new_state. Failing to do so appears to trigger corpse generation
on OS X 10.11. This is addressed by calling ExcServerCopyState().
Previously, this was not done for exceptions forwarded to the user
ReportCrash, under the apparent mistaken assumption that ReportCrash
would do it. However, ReportCrash is given copies of out-parameters like
new_state to explicitly prevent it from influencing Crashpad’s returned
state.

ExcServerSuccessfulReturnValue() must not return MACH_RCV_PORT_DIED for
an EXC_CRASH handler on OS X 10.11. This appears to trigger corpse
generation. This is addressed by always returning KERN_SUCCESS from
EXC_CRASH handlers on OS X 10.11.

This also adds generic EXC_CORPSE_NOTIFY support throughout Crashpad.
The crashpad_handler does not listen for this exception type, but it is
now possible to work with this exception type using tools like
exception_port_tool and catch_exception_tool.

BUG=crashpad:48
TEST=Crashes handled by crashpad_handler do not result in the generation
     of reports in the root /Library/Logs/DiagnosticReports.

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

Review URL: https://codereview.chromium.org/1305893010 .
2015-09-04 14:29:12 -04:00
Scott Graham
3ef04d14f2 Implement ModuleSnapshotWin::UUID
Reads CodeView PDB GUID from Debug Directory of PE header.

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

Review URL: https://codereview.chromium.org/1311003003 .
2015-09-01 09:32:09 -07:00
Scott Graham
a691448ffb win: Implement exception snapshot
Refactor some of the NT internals helpers and cpu_context to share
between the thread and exception snapshot code.

Add test that runs crashing child and validates the exception in the
snapshot.

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

Review URL: https://codereview.chromium.org/1126413008 .
2015-08-18 12:25:19 -07:00
Mark Mentovai
0366307615 win: Provide strcasecmp() in <strings.h> in compat.
base::strcasecmp() has been deprecated since upstream 8a800901b78a2.

BUG=chromium:472900
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1275633002 .
2015-08-05 16:34:50 -04:00
Scott Graham
ff52791faf Get generate_dump compiling on Windows
Sort of works in that the process is opened, modules retrieved, etc.
but eventually CHECKs due to missing functionality in snapshot.

Follows https://codereview.chromium.org/1119783005/.

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

Review URL: https://codereview.chromium.org/1120383003
2015-05-06 11:09:31 -07:00
Scott Graham
17b770ece4 win: get tools/crashpad_database_util mostly working
- Add public domain getopt implementation to third_party.
- Add timegm to compat/win.
- Add stub of strptime to compat/win.

Requires https://codereview.chromium.org/1119173003/ and
https://codereview.chromium.org/1117013006/.

Rather than working in wchar_t everywhere on Windows, convert
UTF16 command line arguments in wmain to UTF8, work primarily
in UTF8, and convert back when necessary to UTF16 for base::FilePath.
This avoids the need to genericize over all the standard C string
functions, getopt, etc. while still handling non-ASCII properly.

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

Review URL: https://codereview.chromium.org/1119783005
2015-05-06 10:28:07 -07:00
Mark Mentovai
1baff4ff92 Accept non-fatal resource exceptions without generating crash reports.
This adds IsExceptionNonfatalResource() and its test, and uses it in
crashpad_handler. When non-fatal resource exceptions are encountered, no
crash report is generated. crashpad_handler swallows these exceptions.
Alternatively, it could allow them to be sent to the system’s host-level
resource exception handler, normally com.apple.ReportCrash.root, which
would allow them to be processed in the same way as when Crashpad is not
in use. I’m not sure which option is better. I chose to swallow them
because there doesn’t appear to be much value in letting
com.apple.ReportCrash.root and spindump look at them.

This also moves ExcCrashRecoverOriginalException() to the new file as a
sibling of IsExceptionNonfatalResource(). This provides better
organization.

BUG=crashpad:35, chromium:474163, chromium:474326
TEST=crashpad_util_test ExceptionTypes.IsExceptionNonfatalResource
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1066243002
2015-04-08 17:46:09 -04:00
Mark Mentovai
e1347a740c Handle EXC_RESOURCE and EXC_GUARD exceptions properly.
These two exception types use all 64 bits of the code[0] field.  The
ExceptionSnapshot was unprepared to stuff this into a 32-bit field.  To
resolve the discrepancy, the more-significant data is taken from the
high 32 bits of code[0]. No information is lost because the full code[0]
is made available as part of the Codes() vector.

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

Review URL: https://codereview.chromium.org/1050313003
2015-04-02 15:49:51 -04:00
Mark Mentovai
98cca0e5fc compat/mac: 10.6 SDK compatibility for pre-Xcode 4.2 10.6 SDK.
Some definitions were added to the 10.6 SDK during its lifetime, and
aren’t present in older versions of the SDK. The AVX definitions are in
this group.

Apparently, not all of Chrome’s builders use the same version of this
SDK. A try bot failure was encountered for
https://codereview.chromium.org/1011503002/ in
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_compile_dbg_ng/builds/33868/steps/compile%20%28with%20patch%29/logs/stdio.

This provides definitions in compat for when they aren’t available from
the SDK.

TEST=compile
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1001733003
2015-03-16 13:41:48 -04:00
Mark Mentovai
b256df0534 Set target_name on many targets to use a crashpad_ prefix.
In Chromium, many targets are built, sharing a single output directory.
Collisions are likely. When integrating Crashpad into Chromium, the
ui/snapshot library and Crashpad’s snapshot library were found to
conflict.

This change gives most Crashpad targets a “crashpad_” prefix to avoid
conflicts. All library and test targets are given a target_name with
this prefix. Existing tools are not likely to conflict with anything
else and are not given a prefix.

BUG=crashpad:12
R=rsesek@chromium.org, scottmg@chromium.org

Review URL: https://codereview.chromium.org/990553003
2015-03-08 16:25:34 -04:00
Mark Mentovai
b770a51f2b Set the chromium_code GYP variable.
When building in the Chromium tree, chromium_code is necessary to apply
Chromium’s build/filename_rules.gypi. Crashpad’s build depends on these
rules. chromium_code also enables a high warning level, which is
desirable for Crashpad.

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

Review URL: https://codereview.chromium.org/986873002
2015-03-08 15:17:22 -04:00
Scott Graham
07fcf63c21 win: fixes for Windows x64
Mostly size_t <-> unsigned int warnings, but I also had a mistake in
PROCESS_BASIC_INFORMATION, the pids are 32-on-32 and 64-on-64.

The Windows build is still x86 until https://codereview.chromium.org/981333002/.
I don't think I'll bother maintaining the x86 build for now, though we will probably
need it for x86 OSs in the future. It should be straightforward to revive it once we
need it, and have bots to support it.

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

Review URL: https://codereview.chromium.org/983103004
2015-03-06 16:05:34 -08:00
Scott Graham
bcc580e561 win: Add implementation of system_snapshot for Windows
ProcessReaderWin only a stub for now.

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

Review URL: https://codereview.chromium.org/936333004
2015-03-02 13:06:34 -08:00
Scott Graham
429a3368d4 win: Work towards getting 'minidump' to compile
- dbghelp.h requires windows.h to be included before it (ick!).
  Add a stub one for non_win to make this work.
- convert __attribute__ -> macro that can work work with MSVC;
- a handful of narrowing casts.

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

Review URL: https://codereview.chromium.org/883773005
2015-02-04 17:30:03 -08:00
Scott Graham
af07f4022b Move string16 and char16 in to base::
Needs to include roll with https://codereview.chromium.org/803593002/ included.

R=mark@chromium.org

Review URL: https://codereview.chromium.org/804593002
2014-12-12 11:06:09 -08:00
Scott Graham
012ddc9752 win: Add compat header for sys/types.h
To add definition of ssize_t. Uses #include <../include/...> to
emulate #include_next, similar to the mac headers.

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

Review URL: https://codereview.chromium.org/793013002
2014-12-10 11:39:50 -08: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
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
850ec0657d Drop 10.5 support.
TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/575823002
2014-09-16 11:55:55 -04:00
Mark Mentovai
ab4978b51e 10.6 SDK compatibility.
TEST=util_test MachOImageReader.* (and all others with a 10.6 SDK build)
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/561933004
2014-09-12 12:13:27 -04:00
Mark Mentovai
c73a97d4e3 Add MinidumpMiscInfoWriter and its test.
TEST=minidump_test MinidumpMiscInfoWriter
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/454073002
2014-08-11 11:42:12 -07:00
Mark Mentovai
aa3adf2c5b Add MinidumpSystemInfoWriter and its test.
TEST=minidump_test MinidumpSystemInfoWriter
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/435243002
2014-08-07 14:58:26 -04:00
Mark Mentovai
5ba343ccf1 Add minidump_extensions.h, which defines Crashpad/Breakpad extensions to
the standard minidump format defined in dbghelp.h.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/435013002
2014-08-01 14:37:20 -04:00
Mark Mentovai
dfe81014f7 Add compat to Crashpad.
compat includes headers providing definitions normally provided by the
system, in cases where the system SDK does not always provide the
correct or up-to-date definitions, and cases where code on different
platforms needs to access definitions normally only available on one
platform.

To provide definitions on a single platform, where the system SDK may
not provide the definitions correctly, use subdirectories named for the
platform, such as “mac”.

To provide definitions normally available on only one platform to
others, use subdirectories that identify that they are to be used on
platforms other than the one that originated their definitions, such as
“non_win”.

In all cases, headers should be named as they are natively in their
respective SDKs, so that it’s possible to #include them according to
their usual names.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/432843002
2014-07-31 13:45:51 -04:00