Граф коммитов

399 Коммитов

Автор SHA1 Сообщение Дата
Mark Mentovai 809ea8158d test: Move util/test to its own top-level directory, test.
After 9e79ea1da7, it no longer makes sense for crashpad_util_test_lib
to “hide” in util/util_test.gyp. All of util/test is moved to its own
top-level directory, test, which all other test code is allowed to
depend on. test, too, is allowed to depend on all other non-test code.

In a future change, when crashpad_util_test_lib gains a dependency on
crashpad_client, it won’t look so weird for something in util (even
though it’s in util/test) to depend on something in client, because the
thing that needs to depend on client will live in test, not util.

BUG=crashpad:33
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1051533002
2015-03-31 17:44:14 -04:00
Mark Mentovai 9e79ea1da7 Split *_test.gyp from *.gyp.
In a future change, crashpad_util_test_lib will gain a dependency on
crashpad_client. This would violate GYP’s prohibition on circular
dependencies between .gyp files, although there would be no circular
relationship between the targets themselves. To overcome this problem,
all test-related targets are moved into their own first-class .gyp
files.

BUG=crashpad:33
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1045173004
2015-03-31 17:06:28 -04:00
Mark Mentovai d5ddd14ee1 Improve map insertion operations.
Add MapInsertOrReplace<>() to insert a key-value pair into a map if the
key is not already present, or replace the existing value for key if the
key is present. The original value can optionally be returned to the
caller in this case.

Map insertions now use either MapInsertOrReplace<>() or
std::map<>::insert() directly.

Use MapInsertOrReplace<>() when the map should be updated to contain a
mapping from a key to a value regardless of whether the key is already
present.

Use std::map<>::insert() to insert a mapping from a key to a value
without replacing any existing mapping from a key, if present. If it is
important to know whether an existing mapping from a key was present,
use the returned std::pair<>.second. If it is important to know the
existing value, use the returned std::pair<>.first->second.

This change has a slight positive impact on performance.

TEST=crashpad_util_test MapInsert.MapInsertOrReplace and others
BUG=
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1044273002
2015-03-31 14:29:32 -04:00
Mark Mentovai 2e64c73330 Fix ThreadLogMessages’ test.
The test wasn’t strictly broken, but an <= written where a < was
intended caused some threads to log more messages than intended.

BUG=crashpad:26
TEST=crashpad_util_test ThreadLogMessages.Multithreaded
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1047813002
2015-03-30 17:58:12 -04:00
Mark Mentovai e95224bbe7 Add ThreadLogMessages and its test.
This updates mini_chromium to 91ea4908ffd74d9c886bd2f8ccbfae6d31c499af.
The last five commits listed here are required to support this change.
The mini_chromium update includes:

c1745a924c5c Fix paths to atomicops files in base.gyp from 2f02dcc73536
108e9247189c Add #include of <unistd.h> to close_nocancel.cc
6e4f98a9edf8 Add logging::SetLogMessageHandler()
4063fcb8f460 Add base::ThreadLocalStorage
4870f18a33a6 Add base::LazyInstance
0d31b1f3a289 Fix base/memory/aligned_memory.h for MSVC
91ea4908ffd7 base/logging.h: DCHECK() should always reference its
             condition

BUG=crashpad:26
TEST=crashpad_util_test ThreadLogMessages.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1041643003
2015-03-30 14:51:34 -04:00
Mark Mentovai 5d0a133ecd Tolerate weird cl_kernels modules.
cl_kernels modules (OpenCL kernels) are not structured as correct Mach-O
images on Mac OS X 10.10, but they’re present frequently enough that
it’s worth detecting and tolerating their quirks.

As discussed in
https://groups.google.com/a/chromium.org/d/msg/crashpad-dev/NaB7PrfW04g/FanqNJkVBfUJ

Apple bug: https://openradar.appspot.com/20239912

TEST=crashpad_snapshot_test ProcessReader.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1019243006
2015-03-23 16:27:42 -04:00
Scott Graham 0c704745dd Followup to https://codereview.chromium.org/1001673002/.
- Add parens around conditional operator expression
- Fix Thread::Join ASSERT.

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

Review URL: https://codereview.chromium.org/1022203002
2015-03-23 08:15:53 -07:00
Mark Mentovai 71deedee44 doxygen: Prevent the word Thread with a capital T from automatically
linking to test::Thread.

I noticed in the doxygen diffs that the documentation for
test::TestThreadSnapshot::ThreadID() grew a link now that we have
test::Thread.

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1027923002
2015-03-20 19:18:00 -04:00
Scott Graham 79ae055e50 Add Locking calls to file_io.h plus implementations and test
Towards removing use of open() with O_EXLOCK/O_SHLOCK in code
used on non-BSD.

Adds simple Thread abstraction to util/test.

Includes mini_chromium roll with:
56dd2883170d0df0ec89af0e7862af3f9aaa9be6 Fix import of atomicops for Windows
886592fd6677615c54c4156bb2f2edb5d547ba6c Export SystemErrorCodeToString

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

Review URL: https://codereview.chromium.org/1001673002
2015-03-20 15:45:54 -07:00
Mark Mentovai 8b4932e560 Update mini_chromium to 31e989ac0b03d50ebe71bfa13417c7f8b66db1b8.
cbbdc1b965ec  Fix include guards in base/atomicops*
8f3fade515f6  Clean up -Wunused-parameter warnings reachable by Crashpad
              clients
31e989ac0b03  Declare string16 traits’ move() correctly

TBR=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1021363002
2015-03-20 15:24:54 -04:00
Scott Graham 7fa250c9a2 Roll mini_chromium to 2f02dcc735362f33618655ebe663b8abdf85e8bc
Includes
2f02dcc735362f33618655ebe663b8abdf85e8bc Pull in base/atomicops.h from chromium

TBR=mark@chromium.org

Review URL: https://codereview.chromium.org/1005383003
2015-03-19 16:08:39 -07:00
Mark Mentovai 6f4e6aacc8 Add crashpad_database_util and its man page.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1022663002
2015-03-19 18:41:01 -04:00
Mark Mentovai 4bd97bb6db Document CrashpadInfo::set_simple_annotations().
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1016613003
2015-03-19 18:04:38 -04:00
Mark Mentovai af9e78940e Allow man pages to link to each other
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1018023002
2015-03-18 17:13:22 -04:00
Mark Mentovai c052c97c7e Update crashpad_handler man page to document all options.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1009743004
2015-03-18 17:10:55 -04:00
Mark Mentovai c2502f45c9 doc: Add documentation-generating scripts to the Crashpad tree.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1009223003
2015-03-18 17:10:12 -04:00
Mark Mentovai 1e12b471e3 Update mini_chromium to 6c49a5924dea1e0bd71d568f371c08d754d8aeb8.
c503b8bc1e03  Suppress unused Debug_x64 and Release_x64 configurations
              on non-Windows
6c49a5924dea  Switch between x86 and x86_64 with the target_arch GYP
              variable

TBR=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1022493002
2015-03-18 11:27:36 -04:00
Mark Mentovai d516689641 Update crashpad.doxy to Doxygen 1.8.9.1.
The updated configuration was generated by running “doxygen -u
crashpad.doxy”.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1012123002
2015-03-17 15:31:55 -04:00
Mark Mentovai 82bebb11de Update man pages.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1013783002
2015-03-16 13:47: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 1d022a86db handler/mac: Support the in-Chromium component=shared_library
configuration.

When depending on shared libraries such as libbase.dylib,
crashpad_handler must have an LC_RPATH pointing to the
out/{Debug,Release} directory relative to its home deep within
Chromium.app.

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

Review URL: https://codereview.chromium.org/1009633002
2015-03-13 18:23:17 -04:00
Mark Mentovai e7b80a52f5 win: Add UUID::InitializeFromSystemUUID().
The new call is also used in
CrashReportDatabaseWin::PrepareNewCrashReport(). Previously, that method
used the UUID::InitializeFromBytes() constructor. That actually caused
various fields of the UUID to be byte-swapped so that the ::UUID and
crashpad::UUID would be different UUIDs. Although a UUID is mostly
random, the version field in data_3 is used as a namespace and should be
4 for random UUIDs, and this was not the case under swapping.

TEST=crashpad_util_test UUID.FromSystem
BUG=crashpad:1
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1004913004
2015-03-13 13:53:38 -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 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 94471409a1 handler/mac: Increase the upload timeout from the default 15s to 60s.
R=mark@chromium.org

Review URL: https://codereview.chromium.org/1008623002
2015-03-12 18:51:00 -04:00
Mark Mentovai 7edad7c412 client/simulate_crash_mac.h: Qualify NativeCPUContext with the crashpad
namespace when used in the CRASHPAD_SIMULATE_CRASH() macro.

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

Review URL: https://codereview.chromium.org/1001163002
2015-03-12 17:54:07 -04:00
Mark Mentovai fd14ae6450 crashpad_client: expose the crashpad root as an include_dir to
dependents.

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

Review URL: https://codereview.chromium.org/997303005
2015-03-12 17:21:43 -04:00
Mark Mentovai 29cdc74579 CrashpadClient::StartHandler(): accept database, url, and annotations arguments.
This makes it easier for clients to start the Crashpad handler, instead
of requiring them to know how to construct arguments for the handler
themselves. Note in the TEST that -a is no longer required.

TEST=run_with_crashpad --handler crashpad_handler \
         --database=/tmp/crashpad_db \
         --url=https://clients2.google.com/cr/staging_report \
         --annotation=prod=crashpad \
         --annotation=ver=0.7.0 \
         crashy_program

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1001993002
2015-03-12 14:28:19 -04:00
Mark Mentovai 5f19d639e1 handler/mac: Log a warning when an exception message has a suspicious
origin.

This adds AuditPIDFromMachMessageTrailer() to get the process ID of a
Mach message’s sender. Exception messages are considered suspicious when
not sent by the kernel or the exception process.

TEST=crashpad_util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1001943002
2015-03-12 14:00:38 -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 94f7f9eeb2 MinidumpCrashpadInfo: the default constructor should zero-initialize.
This regressed in 359bdd8622 when a non-POD UUID data member was added
to MinidumpCrashpadInfo, which made MinidumpCrashpadInfo non-POD. This
problem seems to have affected MinidumpModuleCodeViewRecordPDB70 since
it was added, but it is not likely to have caused any problems there
because that structure never appears without having all of its members
populated. By comparison, MinidumpCrashpadInfo may be sparsely
populated.

This caused 4 of the 5 MinidumpCrashpadInfoWriter tests to fail on
Windows.

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

Review URL: https://codereview.chromium.org/1001683002
2015-03-11 17:43:46 -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
Robert Sesek f0ee5f0efe Remove NSInputStream used in HTTPTransportMac and use a CFReadStream instead.
NSInputStream requires overriding and implementing private methods in order to
use it with NSURLConnection [1]. It is cleaner to use the private but stable
and open source CFStreamAbstract.h header from CF-Lite to implement a
CFReadStream. Since CFReadStream is toll-free bridged to NSInputStream, the
remainder of the HTTPTransport code can remain unchanged.

[1] http://lists.apple.com/archives/macnetworkprog/2007/May/msg00055.html

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

Review URL: https://codereview.chromium.org/993413003
2015-03-11 16:59:59 -04:00
Robert Sesek 36ad2d0ee5 Roll mini_chromium to b3d221e85747.
BUG=crashpad:14
R=mark@chromium.org

Review URL: https://codereview.chromium.org/997993002
2015-03-11 14:08:33 -04:00
Mark Mentovai b8cbfff0d3 test::Multiprocess: exit cleanly from children with _exit().
Child exits were using exit(), which caused crashes on 10.10 for
Multiprocess-based tests that ran after HTTPTransport tests. The crashes
occurred while running exit-time destructors. exit() was never correct
in this situation, this should have used _exit() all along.

TEST=crashpad_util_test
BUG=crashpad:17
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1000653002
2015-03-11 13:59:46 -04:00
Mark Mentovai b8d2129bc1 handler/mac: Forward exceptions to the system crash reporter.
TEST=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/998733002
2015-03-10 17:09:59 -04:00
Mark Mentovai a829f67f81 Don’t const_cast<char*> the service name parameter to
bootstrap_look_up().

This hasn’t been required since the 10.5 SDK, which is no longer
supported.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/999533002
2015-03-10 17:01:12 -04:00
Mark Mentovai 42db629ee3 handler/mac: Respect the uploads-enabled user preference and rate-limit
upload attempts to no more than 1 per hour.

The rate limiting is simplistic but duplicates the existing Breakpad
client’s behavior, and is suitable for the time being.

TEST=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/992303002
2015-03-10 15:31:25 -04:00
Mark Mentovai 6c82c23a0d package.h: update version number to 0.7.0.
I don’t want to call it 1.0 yet because the Windows client isn’t done
and there’s no processor yet, but I do want to bump the number at around
the time of the initial Mac client Chromium integration (now).

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/998653002
2015-03-10 14:29:20 -04:00
Mark Mentovai 0b103946a2 Add contributors to CONTRIBUTORS.
These people have contributed and reviewed significant and non-trivial
code.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/995893002
2015-03-10 14:28:41 -04:00
Mark Mentovai 7d5e17cd2e CrashReportDatabase::Initialize(): use the database path.
Rather than accepting the path to the database’s parent directory, this
now accepts the path to the database itself. Using the parent directory
proved cumbersome in practice. When testing crashpad_handler with a
variety of databases, it is useful to be able to specify
--database=/tmp/crashpad_database, --database=/tmp/crashpad_database_2,
etc. The old interface required that these directories be created as a
separate step, and would put the actual database at
/tmp/crashpad_database/Crashpad. This was contrary to the operation of
most tools and interfaces, which would only require that /tmp exist and
would put the database at /tmp/crashpad_database.

TEST=crashpad_client_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/991393002
2015-03-10 14:27:54 -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
Mark Mentovai 7979d9db4e CrashReportDatabase: use InitializationStateDcheck to guard against API
abuses and misuses.

TEST=crashpad_client_test CrashReportDatabaseTest.*
R=rsesek@chromium.org, scottmg@chromium.org

Review URL: https://codereview.chromium.org/987313003
2015-03-10 13:24:44 -04:00
Mark Mentovai 4ef649d189 CrashReportDatabse: set the last upload attempt time from RecordUploadAttempt().
This is only implemented for CrashReportDatabaseMac, because
CrashReportDatabaseWin does not currently have a Settings object. See
bug crashpad:13.

TEST=crashpad_client_test CrashReportDatabaseTest.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/995853003
2015-03-10 12:22:31 -04:00
Mark Mentovai c4a8b32495 Fix ExceptionPorts.TaskAndThreadExceptionPorts under better compiler
optimization.

Newer versions of clang (in this case, trunk r231191) can see through
the pointless division by zero and optimize it away. This caused the
test to hang in release mode.

A 50ms timeout is added to each test to transform the hang into a
failure. The test was split into 12 tests to provide better feedback and
control.

To fix the bug, the division by zero is replaced by __builtin_trap().

TEST=crashpad_util_test ExceptionPorts.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/993613004
2015-03-10 11:16:24 -04:00
Scott Graham ab6cdb6bc1 win: Support reading process info cross-bitness
This only works 64->64, 32->32, and 64->32. We shouldn't have a
need for 32->64. It will also currently not work if the crash service
is running on Wow64 itself (that is, 32->32, but on an x64 OS). We
should also be able to avoid needing that.

Primarily, this change templatizes the winternl.h process structure
types on word size, so the PEB can be read in a foreign bitsize process.

This also happens to resolve using void* as pointer values into foreign
processes, as they're now all either DWORD or DWORD64 depending on which
traits class is used.

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

Review URL: https://codereview.chromium.org/981393003
2015-03-09 16:37:43 -07: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
Mark Mentovai 26804a0be1 Add ASSERT_DEATH_CHECK() to do ASSERT_DEATH() of CHECK() failures.
Likewise for EXPECT_DEATH_CHECK() and EXPECT_DEATH().

In the in-Chromium build configured for official builds in Release mode,
CHECK() throws away its condition string and stream parameters without
ever printing them, although it still evaluates the condition and
triggers death appropriately. {ASSERT,EXPECT}_DEATH(statement, regex)
will not work correctly for any regex that attempts to match what
CHECK() prints. In these build configurations,
{ASSERT,EXPECT}_DEATH_CHECK() use a match-all regex (""). In other build
configurations, they transparently wrap {ASSERT,EXPECT}_DEATH().

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

Review URL: https://codereview.chromium.org/992693003
2015-03-09 18:02:14 -04:00