26 Commits

Author SHA1 Message Date
Mark Mentovai
6278690abe Update copyright boilerplate, 2022 edition (Crashpad)
sed -i '' -E -e 's/Copyright (.+) The Crashpad Authors\. All rights reserved\.$/Copyright \1 The Crashpad Authors/' $(git grep -El 'Copyright (.+) The Crashpad Authors\. All rights reserved\.$')

Bug: chromium:1098010
Change-Id: I8d6138469ddbe3d281a5d83f64cf918ec2491611
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3878262
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2022-09-06 23:54:07 +00:00
Justin Cohen
bc138fc01c Initialize process snapshot client ids to zero.
Change-Id: If6e1902d62e6364114a75d8ebc4d260e4239d58b
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3296266
Commit-Queue: Justin Cohen <justincohen@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-11-23 20:59:19 +00:00
Vlad Tsyrklevich
fccd9c09c0 Implement ProcessSnapshotMac::Memory()
Plumb ProcessReaderMac::Memory() through to ProcessSnapshotMac::Memory()
and add consts where necessary to accomodate the type signature of
ProcessSnapshot::Memory().

Bug: crashpad:263
Change-Id: I2608979918bc201ae3561483ea52ed2092cbc1e2
Reviewed-on: https://chromium-review.googlesource.com/c/1387924
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
2018-12-20 22:01:27 +00:00
Vlad Tsyrklevich
1c4c1277e8 Add a ProcessSnapshot::Memory method
Add a method to the ProcessSnapshot to expose a ProcessMemory object to
allow reading memory directly from the underlying process.

CQ-DEPEND=CL:1278830

BUG=crashpad:262

Change-Id: Ied2a5510a9b051c7ac8c41cdd060e8daa531086e
Reviewed-on: https://chromium-review.googlesource.com/c/1315428
Commit-Queue: Vlad Tsyrklevich <vtsyrklevich@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-11-14 19:13:39 +00:00
Scott Graham
2b05eb522f Rename ProcessReader to platform-suffixed versions
Mac's ProcessReader becomes ProcessReaderMac.
Linux/Android's ProcessReader becomes ProcessReaderLinux.
Fuchsia's ProcessReader becomes ProcessReaderFuchsia.

No intended change in behavior.

Bug: crashpad:196, crashpad:30
Change-Id: I7ec8d72f79533bd78189173261ade2ad99010bad
Reviewed-on: https://chromium-review.googlesource.com/930321
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2018-02-22 21:33:39 +00:00
Mark Mentovai
419f25eac8 Remove PointerVector<> and replace with std::vector<std::unique_ptr<>>
As mentioned at
https://chromium-review.googlesource.com/c/crashpad/crashpad/+/721978/13/tools/crashpad_http_upload.cc#90
Change-Id: I4820346cc0b0bf26633e1de598c884af8af19983
Reviewed-on: https://chromium-review.googlesource.com/724744
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-10-19 04:53:36 +00:00
Mark Mentovai
7a849482ea Switch the language standard to C++14 and use std::make_unique
Update mini_chromium to 7d6697ceb5cb5ca02fde3813496f48b9b1d76d0c

47ff9691450e Switch the language standard to C++14
7d6697ceb5cb Remove base/memory/ptr_util.h and base::WrapUnique

base::WrapUnique and std::make_unique are similar, but the latter is
standardized and preferred.

Most of the mechanical changes were made with this sed:

for f in $(git grep -l base::WrapUnique | uniq); do
  sed -E \
      -e 's%base::WrapUnique\(new ([^(]+)\((.*)\)\);%std::make_unique<\1>(\2);%g' \
      -e 's%base::WrapUnique\(new ([^(]+)\);%std::make_unique<\1>();%g' \
      -e 's%^#include "base/memory/ptr_util.h"$%#include <memory>%' \
      -i '' "${f}"
done

Several uses of base::WrapUnique that did not fit on a single line and
were not matched by this sed were adjusted manually. All #include
changes were audited manually, to at least move <memory> into the
correct section. Where <memory> was already #included by a file (or its
corresponding header), the extra #include was removed. Where <memory>
should have been #included by a header, it was added. Other similar
adjustments to other #includes were also made.

Change-Id: Id4e0baad8b3652646bede4c3f30f41fcabfdbd4f
Reviewed-on: https://chromium-review.googlesource.com/714658
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
2017-10-12 19:07:13 +00:00
Scott Graham
a02ba24006 Convert from scoped_ptr to std::unique_ptr
Follows https://codereview.chromium.org/1911823002/ but fixes includes
that were messed up there.

Change-Id: Ic4bad7d095ee6f5a1c9f8ca2d11ac9e67d55a626
Reviewed-on: https://chromium-review.googlesource.com/340497
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-04-25 19:16:26 +00:00
Scott Graham
dbfcb5d032 win: Cap indirect memory gathering
Add a user-configurable cap on the amount of memory that is gathered by
dereferencing thread stacks. (SyzyAsan stores a tremendously large
number of pointers on the stack, so the dumps were ending up in the ~25M
range.)

Also reduce the range around pointers somewhat.

Change-Id: I6bce57d86bd2f6a796e1580c530909e089ec00ed
Reviewed-on: https://chromium-review.googlesource.com/338463
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-04-22 17:04:33 +00:00
Scott Graham
badfacccee win: Add support for capturing unloaded modules
R=mark@chromium.org
BUG=crashpad:89

Change-Id: Ib6a67147e538811168d68f14a457fdceab30c02e
Reviewed-on: https://chromium-review.googlesource.com/327231
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-02-18 00:55:38 +00:00
Scott Graham
83247fda60 Fix Mac after af3dc54f
CrashpadInfo not being initialized/propagated properly on Mac.

Change-Id: I5f33a16e4e18bb1b068e0d4aeb7f2032a6cb6278
Reviewed-on: https://chromium-review.googlesource.com/324500
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-01-28 21:16:16 +00:00
Scott Graham
af3dc54f2a Add a field to CrashpadInfo to control indirect memory capture
Change-Id: I6467aafba5d20f8a199bab0e2476f98a5318f84a
Reviewed-on: https://chromium-review.googlesource.com/322245
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-01-28 20:16:01 +00:00
Scott Graham
30678f1e82 Fix Mac build after https://codereview.chromium.org/1407643004
Oops.

R=mark@chromium.org
BUG=crashpad:21, crashpad:52

Review URL: https://codereview.chromium.org/1409823003 .
2015-10-16 16:33:40 -07:00
Scott Graham
937d3d710c Mostly-boilerplate to add MemoryMapSnapshot
Follows https://codereview.chromium.org/1375313005.

Adds MINIDUMP_MEMORY_INFO for non-win in dbghelp.h.

R=mark@chromium.org
BUG=crashpad:20, crashpad:46

Review URL: https://codereview.chromium.org/1377133006 .
2015-10-13 12:37:44 -07:00
Scott Graham
0758dbde9a win: Save contents of PEB to minidump to start making !peb work
This makes the basics of !peb work in windbg, however, pointed-to things
are not yet retrieved. For full functionality, a variety of pointers in
the PEB also needs to be walked and captured.

e.g.

Previously:

0:000> .ecxr
eax=00000007 ebx=7e383000 ecx=c3f9a943 edx=00000000 esi=006d62d0 edi=003c9280
eip=00384828 esp=005bf634 ebp=005bf638 iopl=0         nv up ei pl zr na pe nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00010246
crashy_program!crashpad::`anonymous namespace'::SomeCrashyFunction+0x28:
00384828 c7002a000000    mov     dword ptr [eax],2Ah  ds:002b:00000007=????????
0:000> !peb
PEB at 7e383000
error 1 InitTypeRead( nt!_PEB at 7e383000)...

Now:

0:000> .ecxr
eax=00000007 ebx=7f958000 ecx=02102f4d edx=00000000 esi=00e162d0 edi=01389280
eip=01344828 esp=00c2fb64 ebp=00c2fb68 iopl=0         nv up ei pl zr na pe nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00010246
crashy_program!crashpad::`anonymous namespace'::SomeCrashyFunction+0x28:
01344828 c7002a000000    mov     dword ptr [eax],2Ah  ds:002b:00000007=????????
0:000> !peb
PEB at 7f958000
    InheritedAddressSpace:    No
    ReadImageFileExecOptions: No
    BeingDebugged:            No
    ImageBaseAddress:         01340000
    Ldr                       77ec8b40
    *** unable to read Ldr table at 77ec8b40
    SubSystemData:     00000000
    ProcessHeap:       00e10000
    ProcessParameters: 00e114e0
    CurrentDirectory:  '< Name not readable >'
    WindowTitle:  '< Name not readable >'
    ImageFile:    '< Name not readable >'
    CommandLine:  '< Name not readable >'
    DllPath:      '< Name not readable >'
    Environment:  00000000
       Unable to read Environment string.

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

Review URL: https://codereview.chromium.org/1364053002 .
2015-09-25 10:31:02 -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
Scott Graham
7b7205fe52 Fix typo in ProcessSnapshotMac::ParentProcessID
R=mark@chromium.org

Review URL: https://codereview.chromium.org/1095403002
2015-04-21 13:06:41 -07: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
40b1d7cb1d Add ConstThreadState to mach_extensions.h and use it everywhere.
TEST=everything
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1058523002
2015-04-02 15:28:28 -04:00
Mark Mentovai
6bf80c3e48 Add MinidumpCrashpadInfo::report_id.
Now that Chrome’s about:crashes displays the crash report UUID, I wanted
to add it to the minidump. In the future, we may be able to index these
on the server. This will also help identify dumps that correspond to the
same event once we’re equipped to convert between different formats.

Ideally, this new field is populated with the same UUID used locally in
the crash report database. To make this work,
CrashReportDatabase::NewReport must carry the UUID. This was actually
part of CrashReportDatabaseWin’s private extension to NewReport, so that
extension subclass can now be cleaned up.

TEST=crashpad_minidump_test MinidumpCrashpadInfoWriter.*,
     crashpad_client_test CrashReportDatabaseTest.NewCrashReport

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1000263003
2015-03-13 13:00:56 -04:00
Mark Mentovai
359bdd8622 Carry the client ID from the database all the way through upload.
The client ID is added to a new field, MinidumpCrashpadInfo::client_id,
in each minidump file that is written. The ProcessSnapshot::ClientID()
gives access to value at the snapshot level. In the upload thread,
client IDs are retrieved from minidump files and used to populate the
“guid” HTTP form parameter.

The Breakpad client supplies these values at upload without hyphens and
with all capital letters. Currently, the Crashpad client uses hyphens
and lowercase letters when communicating with a Breakpad server.

TEST=crashpad_minidump_test MinidumpCrashpadInfoWriter.*,
     crashpad_snapshot_test ProcessSnapshotMinidump.*,
     run_with_crashpad --handler crashpad_handler \
         -a --database=/tmp/crashpad_db \
         -a --url=https://clients2.google.com/cr/staging_report \
         -a --annotation=prod=crashpad \
         -a --annotation=ver=0.7.0 \
         crashy_program

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/998033002
2015-03-11 17:10:50 -04:00
Mark Mentovai
9b7ff0ea5a Allow exception forwarding to the system’s native crash reporter to be
disabled.

ClientInfo::set_system_crash_reporter_forwarding() can be used to
disable forwarding. The first module that is found with a non-default
value in this field will dictate whether forwarding is enabled or
disabled. It is possible to enable or disable reporting with this call,
as well as reset it to default, which will allow later modules a chance
to influence the behavior.

ClientInfo::set_crashpad_handler_behavior() is also provided, which can
be used to disable Crashpad’s handling of the exception. Most users
should not call this, but should use Settings::SetUploadsEnabled()
instead.

TEST=crashpad_snapshot_test \
         CrashpadInfoClientOptions.*:MachOImageReader.Self_DyldImages; \
     run_with_crashpad --handler crashpad_handler \
         -a --database=/tmp/crashpad_db \
         -a --url=https://clients2.google.com/cr/staging_report \
         -a --annotation=prod=crashpad \
         -a --annotation=ver=0.7.0 \
         crashy_program

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/997713002
2015-03-11 17:07:11 -04:00
Mark Mentovai
445c0eae7c snapshot: Add a minimal ModuleSnapshotMinidump and accessor from
ProcessSnapshotMinidump.

ModuleSnapshotMinidump is currently only capable of reading module
annotations, in both vector and simple-dictionary forms. It does not
read any other module information from minidump files. These annotations
are all that are necessary to be able to upload Crashpad-produced
minidumps to Breakpad crash processor servers, because Breakpad accepts
them as HTTP POST parameters, while Crashpad places them in the minidump
file itself.

TEST=snapshot_test ProcessSnapshotMinidump.Modules
BUG=crashpad:10
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/972383002
2015-03-04 12:29:01 -05:00
Mark Mentovai
40b931bd8e Add ProcessSnapshotMinidump, the beginning of the minidump variant of
the Snapshot family.

For the time being, only ProcessSnapshotMinidump::AnnotationsSimpleMap()
is implemented. In order to complete the initial uploader for Crashpad,
ModuleSnapshotMinidump::AnnotationsSimpleMap() is also needed, to be
accessed by ProcessSnapshotMinidump::Modules().

TEST=snapshot_test ProcessSnapshotMinidump.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/932153003
2015-02-26 14:43:10 -05:00
Mark Mentovai
a0f5dc62a4 Add MinidumpCrashpadInfo::simple_annotations.
Some annotations will exist at a broader scope than per-module, which is
the only place that annotations can currently be stored. The product
name and version are not under the control of any module, but are
established when the first Crashpad client establishes a handler. These
annotations will be stored in a minidump’s MinidumpCrashpadInfo
structure, which applies to the entire minidump.

Within the snapshot interface, this data is carried within the
“process” snapshot because it is the top-level structure in that family.
Note that the data may not correspond directly with a process, however.

TEST=minidump_test MinidumpCrashpadInfoWriter.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/924673003
2015-02-17 17:38:02 -05:00
Mark Mentovai
279ca87e68 Add ProcessSnapshotMac.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/650223007
2014-10-17 14:00:58 -04:00