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

427 Коммитов

Автор SHA1 Сообщение Дата
Robert Sesek 6d829e9af7 Create WorkerThread, an abstraction to perform some work on an interval.
This was extracted from CrashReportUploadThread and will be re-used for the
database pruning thread.

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

Review URL: https://codereview.chromium.org/1526563003 .
2016-01-04 17:10:58 -05:00
Bruce Dawson b0394744cc Fix some VS 2015 warnings
Fix some warnings when compiling crashpad with VC++ 2015 Update 1.

Warning 4302 occurs if you convert from a pointer to a <sizeof(void*)
integer in one cast, because this often indicates an accidental pointer
truncation which can be a bug in 64-bit builds.

Warning 4577 warns that noexcept will not be enforced, but we don't want
it to be enforced anyway, so I disabled it. The full warning is:

warning C4577: 'noexcept' used with no exception handling mode specified
termination on exception is not guaranteed. Specify /EHsc

BUG=440500
R=mark@chromium.org

Review URL: https://codereview.chromium.org/1527803002 .

Patch from Bruce Dawson <brucedawson@chromium.org>.
2015-12-14 20:01:05 -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
Mark Mentovai a33736dd0d Fix AlignedAllocator for pre-C++11 libraries
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1511233002 .
2015-12-09 17:25:05 -05:00
Scott Graham b9e732d318 win: Fix a few sign mismatch warnings in crashpad.
BUG=chromium:567877
R=mark@chromium.org, scottmg@chromium.org

Review URL: https://codereview.chromium.org/1503403003 .
2015-12-08 14:21:29 -08:00
Mark Mentovai f55d18ade6 Add AlignedVector and use it for vector<MEMORY_BASIC_INFORMATION64>
MEMORY_BASIC_INFORMATION64 specifies an alignment of 16, but the
standard allocator used by containers doesn't honor this. Although 16
is the default alignment size used on Windows for x86_64, it's not for
32-bit x86. clang assumed that the alignment of the structure was as
declared, and used an SSE load sequence that required this alignment.

AlignedAllocator is a replacement for std::allocator that allows the
alignment to be specified. AlignedVector is an std::vector<> that uses
AlignedAllocator instead of std::allocator.

BUG=chromium:564691
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1498133002 .
2015-12-08 15:38:17 -05:00
Scott Graham 894a06070e win: Fix some warnings reported by /analyze
Reported by brucedawson@chromium.org.

R=mark@chromium.org
BUG=chromium:427616

Review URL: https://codereview.chromium.org/1489293004 .
2015-12-02 13:52:03 -08:00
Mark Mentovai 5be8ce4ea0 Get module versions and types from in-memory images
Don't call GetFileVersionInfo(), which calls LoadLibrary() to be able to
access the module's resources. Loading modules from the crashy process
into the handler process can cause trouble. The Crashpad handler
definitely doesn't want to run arbitrary modules' module initializer
code.

Since the VS_FIXEDFILEINFO needed is already in memory in the remote
process' address space, just access it from there.

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

Review URL: https://codereview.chromium.org/1475023004 .
2015-12-01 17:06:37 -05:00
Mark Mentovai 7764fa1144 Remove errant double-semicolons
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1489063002 .
2015-12-01 12:56:03 -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 116e1087f0 win: Don't warn when no VERSIONINFO resource is present in a module
Modules will work without a VERSIONINFO resource. This happens in some
of Crashpad's tests.

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1467993003 .
2015-11-23 16:17:50 -05:00
Scott Graham 74e69ed555 win: Avoid some more clang complaints
R=mark@chromium.org
BUG=chromium:82385

Review URL: https://codereview.chromium.org/1463633002 .
2015-11-19 15:09:59 -08:00
Scott Graham 0a717f0d27 win: class VM_COUNTERS -> struct
The fields aren't accessed anyway, but clang warns that they're
completely inaccessible. Also, matches all the other definitions in this
file.

R=mark@chromium.org

Review URL: https://codereview.chromium.org/1462203002 .
2015-11-19 14:26:36 -08:00
Mark Mentovai 4f09b58d1f Add RandomString() and its test, and use it everywhere it makes sense
This unifies several things that used a 16-character random string, and
a few other users of random identifiers where it also made sense to use
a 16-character random string.

TEST=crashpad_util_test RandomString.RandomString
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1451793002 .
2015-11-16 13:39:01 -05:00
Mark Mentovai 6e89d45d7d Switch googletest and googlemock to pull from the GitHub git repository
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1404033002 .
2015-11-11 11:13:37 -05:00
Mark Mentovai 7413569ea6 win: Explain the CreateFile() client-side pipe-opening loop
The bug and linked code review has more of the history, but we’ve been
tempted to remove the loop outright a couple of times already before
realizing that it serves an important purpose. Hopefully this comment
will protect our future selves from going on the same fool’s errand.

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

Review URL: https://codereview.chromium.org/1427643010 .
2015-11-10 16:43:13 -05: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 ff274507dc win: Only retry in UseHandler() loop on ERROR_PIPE_BUSY
This is better because now end_to_end_test.py fails immediately with

[1180:9020:20151106,145204.830:ERROR registration_protocol_win.cc:39] CreateFile: The system cannot find the file specified.  (0x2)

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

Review URL: https://codereview.chromium.org/1409693011 .
2015-11-06 15:54:48 -08:00
Mark Mentovai b666bcbe98 win: Use signed int as the integer representation of HANDLEs
HandleToInt() and IntToHandle() use int, a signed type, for the 32-bit
integer representation of HANDLE values. For opaque values, an unsigned
type would normally be used, but in this case, signed was chosen for
sign extension to work correctly. INVALID_HANDLE_VALUE is defined as
((HANDLE)(LONG_PTR)-1), and this needs to round-trip through the chosen
integer representation back to the same HANDLE value. Sign extension is
also recommended by
https://msdn.microsoft.com/en-us/library/windows/desktop/aa384203.

As suggested in
https://codereview.chromium.org/1422503015/diff/1/util/win/handle.cc#newcode24

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1422023010 .
2015-11-06 15:03:13 -05:00
Scott Graham e75e8c800f win: Lower integrity level of connection pipe
This is necessary to be able to connect to crashpad_handler from a
Chrome renderer.

R=jschuh@chromium.org, mark@chromium.org
BUG=chromium:546288

Review URL: https://codereview.chromium.org/1405093013 .
2015-11-06 10:43:39 -08:00
Mark Mentovai 9a9076656f win: Fix ClockMonotonicNanoseconds()
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1419533014 .
2015-11-06 10:15:58 -05:00
Mark Mentovai 82ffeaa0f0 win: crashpad_util_test ProcessInfo.Handles doesn't work with CONOUT$
In 2eeaa3ac54, I added a check to make sure that the expected CONOUT$
handle was found. Its omission seemed to be unintentional. The tests
passed for me on Windows 10, but failed on the bots. I can reproduce
the failures locally on Windows 7.

Doing the inheritance test with a file other than CONOUT$ fixes the
immediate problem, but we should find out why this CONOUT$ handle isn't
showing up in the handles list on Windows 7, fix it, and add back a
test.

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1428753009 .
2015-11-05 15:08:28 -05:00
Mark Mentovai 2eeaa3ac54 win: Add HandleToInt() and IntToHandle()
This consolidates all of the twisted casts and comments that discuss how
HANDLEs are really only 32 bits wide even in 64-bit processes on 64-bit
operating systems into a single location.

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1422503015 .
2015-11-05 14:00:26 -05:00
Mark Mentovai 3e988865ad win: crashpad_handler should create its own pipe name in ephemeral mode
Allowing the client to create its own pipe name string caused a race
between client and server. Instead, in this mode, the server now creates
the pipe name along with a pipe, and returns it to its client via a
--handshake-handle. This guarantees that by the time the client gets the
pipe name, the server has already created it.

Ephemeral mode is now implied by --handshake-handle. The --persistent
option is gone. --persistent mode is enabled when using --pipe-name.

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

Review URL: https://codereview.chromium.org/1432563003 .
2015-11-03 19:26:18 -05:00
Mark Mentovai 7f939285de win: Rename CrashpadClient::SetHandler() to SetHandlerIPCPipe()
In https://codereview.chromium.org/1414533006/, I'm adding a few
Mac-specific SetHandler() variants, so it makes sense to name each
SetHandler() variant for what it does.

I'm also making it take a wstring argument, which seems like a more
natural fit for what it does. There should be fewer string conversions
this way.

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1406993008 .
2015-11-02 17:00:06 -05:00
Mark Mentovai 740c668e87 win: Implement CrashpadClient::StartHandler()
BUG=crashpad:69
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1428803006 .
2015-11-02 13:59:36 -05:00
Scott Graham 4860f64923 win: Handle binary with embedded CodeView debug record
I considered writing the CodeView records to the minidump, but I didn't
find a ton of docs and debugging is only lightly supported (e.g.
http://www.debuginfo.com/articles/gendebuginfo.html#debuggersandformats
and it doesn't attempt to load at all on more recent Visual Studios).

As we won't be generating symbols in this format, and we don't expect to
have symbols for any weird modules that get injected into us in the
wild, it seems like we don't lose anything by just ignoring them.

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

Review URL: https://codereview.chromium.org/1430773003 .
2015-10-31 11:45:39 -07:00
Mark Mentovai c1b841442f mac: Add NotifyServer::DefaultInterface, a default no-op implementation
Each routine in this implementation returns MIG_BAD_ID. These routines
may be overridden.

Most things that implement NotifyServer::Interface will only need to
implement one of the interface routines. Since another user of
NotifyServer will be added soon, it makes sense to provide a default
no-op implementation rather than forcing everyone to write the same
no-op boilerplate repeatedly.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1414413006 .
2015-10-30 15:44:40 -04:00
Mark Mentovai cd0e25f1ba Update all URLs to point to https://crashpad.chromium.org/
All other links to code.google.com and googlecode.com are fixed to point
to their proper new homes as well.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1414243005 .
2015-10-29 18:31:20 -04:00
Mark Mentovai 06ad194571 win: Construct ExceptionHandlerServer() with its pipe argument (again)
This re-lands 9d03d54d0b, which was partially un-done by an apparent
bad rebase leading up to fc7d8b3a27.

Review URL: https://codereview.chromium.org/1424213005 .
2015-10-29 18:19:37 -04:00
Mark Mentovai fc7d8b3a27 mac: Make crashpad_handler get its receive right from its client
Previously, crashpad_handler made its own receive right, and transferred
a corresponding send right to its client. There are two advantages to
making the receive right in the client:

 - It is possible to monitor the receive right for a port-destroyed
   notificaiton in the client, allowing the handler to be restarted if
   it dies.
 - For the future run-from-launchd mode (bug crashpad:25), the handler
   will obtain its receive right from the bootstrap server instead of
   making its own. Having the handler get its receive right from
   different sources allows more code to be shared than if it were to
   sometimes get a receive right and sometimes make a receive right and
   transfer a send right.

This includes a restructuring in crashpad_client_mac.cc that will make
it easier to give it an option to restart crashpad_handler if it dies.
The handler starting logic should all behave the same as before.

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

Review URL: https://codereview.chromium.org/1409073013 .
2015-10-29 18:09:03 -04:00
Mark Mentovai 9d03d54d0b win: Construct ExceptionHandlerServer() with its pipe argument
This allows better code sharing in crashpad_handler’s main(). It doesn’t
look like much of an improvement now, but a separate change will cause
the Mac ExceptionHandlerServer() to be constructed with an argument. It
will be beneficial for Mac and Windows to be able to share the Run()
call.

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1402333004 .
2015-10-29 15:12:23 -04:00
Mark Mentovai 062138106c mac: ChildPortHandshake: allow receive rights to be sent
The intended use is to flip the client-server relationship in
CrashpadClient so that the initial client (parent process) furnishes the
handler process with a receive right. The parent can optionally receive
a port-destroyed notification allowing it to restart the handler if it
exits prematurely.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1408473002 .
2015-10-29 14:14:15 -04:00
Scott Graham 03d8be4a15 win: Fix NTSTATUS_LOG for no-function arg version of COMPACT_GOOGLE_LOG_EX_
R=mark@chromium.org
BUG=crashpad:1, chromium:546288

Review URL: https://codereview.chromium.org/1426493002 .
2015-10-23 14:32:17 -07:00
Scott Graham 1a9c8b0e9d win: Disable C4201 in util.gyp for building without crashpad common.gypi
R=mark@chromium.org
BUG=crashpad:1, crashpad:526488

Review URL: https://codereview.chromium.org/1421173002 .
2015-10-23 14:07:59 -07:00
Scott Graham 4b8b42be6c win: Implement c16lcpy without base:c16*
Chromium base doesn't have base::c16len, c16memcpy, etc. when
WCHAR_T_IS_UTF16, so implement c16lcpy without using those.

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

Review URL: https://codereview.chromium.org/1417403004 .
2015-10-23 13:38:46 -07:00
Scott Graham 3d598cdbcd Change file op |ssize_t|s to FileOperationResult
R=mark@chromium.org

Review URL: https://codereview.chromium.org/1416493006 .
2015-10-22 16:14:18 -07: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
Scott Graham 80f50467c3 Fix Mac after FileOperationResult change
Oops, forgot to test Mac, sorry.

R=mark@chromium.org

Review URL: https://codereview.chromium.org/1409973004 .
2015-10-22 14:17:03 -07:00
Scott Graham a43323a1bf Remove usage of compat from client
When used in client headers, the downstream dependency on compat
is unpleasant, so avoid that.

This is another alternative rather than
https://codereview.chromium.org/1424443002/.

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

Review URL: https://codereview.chromium.org/1419673007 .
2015-10-22 14:01:33 -07:00
Scott Graham 90ef7475cd win: Validate readability of memory ranges added to minidump
R=mark@chromium.org
BUG=crashpad:59

Review URL: https://codereview.chromium.org/1412243005 .
2015-10-21 16:07:03 -07:00
Mark Mentovai 6c0d42ce9d Mach port scopers should use get() instead of type conversion operators
In https://codereview.chromium.org/1411523006, the Mach port scopers are
becoming better ScopedGenerics and are losing the type conversion
operators in the process. This is needed to adapt to that change. get()
is ugly, but being explicit about conversion isn’t a bad thing, and
these scopers will gain functionality such as Pass() as part of the
switch.

As a bonus, some would-be uses of get() to check for valid port rights
are becoming a more descriptive is_valid().

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1405273002 .
2015-10-20 11:03:25 -04:00
Mark Mentovai d075a9eb2e win: Add and use GET_FUNCTION() and GET_FUNCTION_REQUIRED()
These wrap the GetProcAddress(LoadLibrary(), …) idiom into macros that
are much less wordy.

TEST=crashpad_util_test GetFunction.GetFunction and all others
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1405323003 .
2015-10-19 14:32:07 -04:00
Mark Mentovai 1818dbbb08 win: Fix crashpad_util_test ProcessInfo.Handles
This new test from 7de04b02f8 was failing on Windows 10. I started by
adding the hint, which produced “CreateFileMapping: Access is denied.
(0x5)”. Switching the “Global\” to “Local\” fixes the test for me.

TEST=crashpad_util_test ProcessInfo.Handles
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1407993003 .
2015-10-19 13:40:50 -04:00
Scott Graham 4600643a78 Some plumbing for the beginning of getting handles into snapshot/minidump
Follows https://codereview.chromium.org/1400413002/.

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

Review URL: https://codereview.chromium.org/1407643004 .
2015-10-16 15:58:40 -07:00
Scott Graham 7de04b02f8 win: Add Handles() to ProcessInfo
To eventually be used to fill out MINIDUMP_HANDLE_DESCRIPTOR.

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

Review URL: https://codereview.chromium.org/1400413002 .
2015-10-16 15:31:32 -07:00
Scott Graham d1e49bd221 Fix CRITICAL_SECTION test
I thought I had confirmed that this still allocated and ignored the flag
on older OSs, but I must have not had the PLOG active yet? I'm not sure
what I did. (I might try to blame VMware as it has an annoying habit of
caching old binaries when you use it's "Shared Folders" feature to point
at the dev machine's build dir.)

I confirmed that it does work on Win8 and Win10 but doesn't on Win XP
and Win 7.

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

Review URL: https://codereview.chromium.org/1405243002 .
2015-10-16 14:55:14 -07:00
Scott Graham 4893a9b76d win: Capture some CRITICAL_SECTION debugging data
Capture the memory for the loader lock (can be inspected by !cs), as
well as all locks that were created with .DebugInfo which can be viewed
with !locks.

e.g.

0:000> !cs ntdll!LdrpLoaderLock
-----------------------------------------
Critical section   = 0x778d6410 (ntdll!LdrpLoaderLock+0x0)
DebugInfo          = 0x778d6b6c
NOT LOCKED
LockSemaphore      = 0x0
SpinCount          = 0x04000000

0:000> !locks -v

CritSec ntdll!RtlpProcessHeapsListLock+0 at 778d7620
LockCount          NOT LOCKED
RecursionCount     0
OwningThread       0
EntryCount         0
ContentionCount    0

CritSec +7a0248 at 007a0248
LockCount          NOT LOCKED
RecursionCount     0
OwningThread       0
EntryCount         0
ContentionCount    0

CritSec crashy_program!g_critical_section_with_debug_info+0 at 01342c48
LockCount          NOT LOCKED
RecursionCount     0
OwningThread       0
EntryCount         0
ContentionCount    0

CritSec crashy_program!crashpad::`anonymous namespace'::g_test_critical_section+0 at 01342be0
WaiterWoken        No
LockCount          0
RecursionCount     1
OwningThread       34b8
EntryCount         0
ContentionCount    0
*** Locked

Scanned 4 critical sections

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

Review URL: https://codereview.chromium.org/1392093003 .
2015-10-15 13:18:08 -07:00
Mark Mentovai 9fdb70738b mac: 10.11 SDK compatibility
This doesn’t really provide compatibility, it just ignores the
deprecation warning for +[NSURLConnection
sendSynchronousRequest:returningResponse:error:].

The suggested replacement, NSURLSession, was new in 10.9, and this code
needs to run on 10.6, so it’s not usable here, at least not without a
runtime check.

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

Review URL: https://codereview.chromium.org/1395673002 .
2015-10-07 16:16:53 -04:00
Scott Graham d3bdb23ffe Use MEMORY_BASIC_INFORMATION64 rather than a custom MemoryInfo
We already use all the shared constants for page protection and type,
so rather than making various incompatible structures, just use
the MEMORY_BASIC_INFORMATION64 one directly, so that it can be directly
used.

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

Review URL: https://codereview.chromium.org/1375313005 .
2015-10-07 12:23:08 -07:00
Mark Mentovai 78592537bc Add non-logging OpenFileForWrite() and OpenFileForReadAndWrite()
BUG=crashpad:63
TEST=crashpad_util_test FileIO.*OpenFileFor*
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1395543002 .
2015-10-07 11:40:02 -04:00
Mark Mentovai 2d8a0498ab Add FileWriteMode::kCreateOrFail
BUG=crashpad:63
TEST=crashpad_util_test FileIO.OpenFileForWrite
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1390023002 .
2015-10-07 08:20:55 -04:00
Mark Mentovai 5f7eda87a6 mac: Don’t leak send rights from ExceptionPorts::GetExceptionPorts()
ExceptionPorts::GetExceptionPorts() returned a
std::vector<ExceptionPorts::ExceptionHandler>, which contained send
rights to Mach ports. The interface required callers to assume ownership
of each send right contained within the vector. This was cumbersome and
error-prone, and despite the care taken in Crashpad, port right leaks
did occur:

 - SimulateCrash() didn’t make any attempt to release these resources at
   all.
 - Neither did crashpad_util_test ExceptionPorts.HostExceptionPorts,
   which also reused a vector.

This replaces the vector with the interface-compatible (as far as
necessary) ExceptionPorts::ExceptionHandlerVector, which deallocates
collected port rights on destruction or clear().

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1381023007 .
2015-10-06 16:14:29 -04:00
Mark Mentovai bb13efbda7 Add and use scoped-right-returning wrappers for Mach bootstrap routines
This wraps bootstrap_check_in() in BootstrapCheckIn(), and
bootstrap_look_up() in BootstrapLookUp(). The wrappers make it more
difficult to accidentally leak a returned right. They’re easier to use,
encapsulating common error checking and logging, simplifying all call
sites.

TEST=crashpad_util_test MachExtensions.BootstrapCheckInAndLookUp
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1383283003 .
2015-10-05 17:07:15 -04:00
Mark Mentovai cd85c9f700 mac: Add CrashpadClient::UseSystemDefaultHandler()
Chrome’s relauncher process needs a way to sever ties with the
crashpad_handler instance running from the disk image in order to cause
that instance to exit so that the disk image may be unmounted. This new
function is otherwise not thought to be interesting, and its use is not
recommended.

This comes with a small refactoring to create a
SystemCrashReporterHandler() function, and a fix for a minor port leak
in CrashReportExceptionHandler::CatchMachException().

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

Review URL: https://codereview.chromium.org/1375573005 .
2015-10-02 14:40:38 -04:00
Scott Graham ccd5ec6404 MEM_RESERVE regions are not accessible by ReadProcessMemory()
Sadly this code did not survive a collision with the real world. In
probing for the environment block there's a MEM_COMMIT region followed
directly by a MEM_RESERVE region (past the end of the environment
block).

Update region checker to correctly treat MEM_RESERVE as inaccessible.

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

Review URL: https://codereview.chromium.org/1370063005 .
2015-10-01 15:28:40 -07:00
Scott Graham ecf3b37863 win: Save contents of TEBs allowing !teb and !gle to work in windbg
crashy_program's log looks something like this now:

0:000> .ecxr
eax=00000007 ebx=7f24e000 ecx=7f24d000 edx=00000000 esi=00497ec8 edi=00d39ca0
eip=00cf5d12 esp=001ffcd8 ebp=001ffcdc iopl=0         nv up ei ng nz ac po cy
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00010293
crashy_program+0x5d12:
00cf5d12 ??              ???
0:000> !teb
TEB at 7f24d000
    ExceptionList:        001ff548
    StackBase:            00200000
    StackLimit:           001fd000
    SubSystemTib:         00000000
    FiberData:            00001e00
    ArbitraryUserPointer: 00000000
    Self:                 7f24d000
    EnvironmentPointer:   00000000
    ClientId:             00003658 . 00004630
    RpcHandle:            00000000
    Tls Storage:          7f24d02c
    PEB Address:          7f24e000
    LastErrorValue:       2
    LastStatusValue:      c000000f
    Count Owned Locks:    0
    HardErrorMode:        0
0:000> !gle
LastErrorValue: (Win32) 0x2 (2) - The system cannot find the file specified.
LastStatusValue: (NTSTATUS) 0xc000000f - {File Not Found}  The file %hs does not exist.

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

Review URL: https://codereview.chromium.org/1364803004 .
2015-10-01 14:04:49 -07:00
Scott Graham 4df538f283 win: Add memory map range intersection helper
To be used for improved version of ReadMemory() that is memory-map
aware, in particular for reading the environment block in
https://codereview.chromium.org/1360863006/.

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

Review URL: https://codereview.chromium.org/1372183002 .
2015-10-01 11:47:32 -07:00
Scott Graham 1e3ca26f16 win: Disable ASLR on test binary that uses fixed base
This causes a link error on msvs builds which we don't care about, but
in general if build/common.gypi forced RandomizedBaseAddress (e.g. in
Chrome), it makes sense to be explicit about disabling it for this
binary.

R=mark@chromium.org
BUG=https://groups.google.com/a/chromium.org/d/msg/crashpad-dev/jMtnDldRnJI/kNx7ZDxMAwAJ

Review URL: https://codereview.chromium.org/1376913004 .
2015-10-01 11:13:50 -07:00
Scott Graham 9d9302bb02 win: fix VirtualQueryEx on < win10
On Win10, VirtualQueryEx supports querying the x64 part of WOW64
processes. However, on lower OSs it errors past 2/3G. There's no direct
way to retrieve to maximum memory address for processes other than
yourself, but fortunately, VirtualQueryEx sets a distinct error code
when `lpAddress` exceeds the maximum accessible address, so we can just
terminate successfully in that case.

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

Review URL: https://codereview.chromium.org/1376353002 .
2015-09-30 17:20:23 -07:00
Mark Mentovai c8592b847b win: Add and use a custom CaptureContext() implementation
RtlCaptureContext() is buggy and limited.

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

Review URL: https://codereview.chromium.org/1377963002 .
2015-09-30 14:10:08 -04:00
Scott Graham 56c8359b27 win: Gather memory information
Not yet written as MINIDUMP_MEMORY_INFO_LIST to minidump.

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

Review URL: https://codereview.chromium.org/1369833002 .
2015-09-25 21:11:04 -07:00
Scott Graham 475ac81cce win: Implement CRASHPAD_SIMULATE_CRASH()
Windows requires the connection to the handler to do anything, so it
can't really be implemented or tested without CrashpadClient and the
connection machinery.

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

Review URL: https://codereview.chromium.org/1356383002 .
2015-09-25 13:45:32 -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 5165c48b3a Use argument escaping function in util/win/process_info_test.cc
R=mark@chromium.org

Review URL: https://codereview.chromium.org/1356753004 .
2015-09-22 09:20:23 -07: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 4a34a3dd89 win: Make reading NT_IMAGE_HEADERS work cross-bitness
Factor out some test launching code used in cross-bitness tests.

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

Review URL: https://codereview.chromium.org/1352323002 .
2015-09-20 11:16:31 -07:00
Scott Graham bf556829d9 win: support x64 reading x86 (wow64)
Removes the bitness-specific targets in favour of pulling binaries from
the other build directory. This is to avoid the added complexity of
duplicating all the targets for the x86 in x64 build.

Overall, mostly templatizing more functions to support the
wow64-flavoured structures. The only additional functionality required
is reading the x86 TEB that's chained from the x64 TEB when running
as WOW64.

The crashing child test was switched to a manual CreateProcess because
it needs to launch a binary other than itself.

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

Review URL: https://codereview.chromium.org/1349313003 .
2015-09-18 16:06:05 -07:00
Mark Mentovai 9b9e49d0d9 Remove unnecessary crashpad:: qualification from implicit_cast<>
This undoes 595803e1be, a workaround that should no longer be
necessary now that base no longer provides implicit_cast<> in the global
namespace.

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1356673003 .
2015-09-17 13:11:23 -04:00
Mark Mentovai 4ff6c2d71f Remove #include "base/basictypes.h" as appropriate
These files were only using basictypes.h for implicit_cast, which moved
to util/misc/implicit_cast.h in 0b022d72a2.

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1352873002 .
2015-09-17 12:32:38 -04:00
Scott Graham 8ce88d8953 win x86: Grab bag of restructuring to get tests working on x86-on-x86
A few function implementations that were missing, various switches
for functions/functionality that didn't exist on XP, and far too long
figuring out what exactly was wrong with SYSTEM_PROCESS_INFORMATION
on x86 (the "alignment_for_x86" fields).

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

Review URL: https://codereview.chromium.org/1336823002 .
2015-09-16 12:42:20 -07:00
Scott Graham bc55c7916e win: Add (currently unused) NTSTATUS_LOG
Split out of https://codereview.chromium.org/1336823002/, I'll go and
adapt various places to use it as I need to touch them.

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

Review URL: https://codereview.chromium.org/1343873003 .
2015-09-15 09:22:29 -07:00
Scott Graham 595803e1be In the launch.mm file use the crashpad::implicit_cast .. explicitly.
Until the base one goes away this complains of it being ambiguous.

R=mark@chromium.org, scottmg@chromium.org
BUG=529769, 472900, crashpad:51

Review URL: https://codereview.chromium.org/1336413003 .
2015-09-14 15:17:51 -07:00
Scott Graham 0b022d72a2 Include implicit_cast.h at all users of it.
The implicit_cast in base will be no more, make sure we have a reference
to the crashpad version at all callsites.

BUG=529769, 472900, crashpad:51
R=mark@chromium.org, scottmg@chromium.org

Review URL: https://codereview.chromium.org/1344683002 .
2015-09-14 14:51:05 -07:00
Scott Graham 5069c2903a Replace implicit_cast usage with static_cast.
chromium's implicit_cast is going to be removed so stop using it.

BUG=529769,472900
R=mark@chromium.org

Review URL: https://codereview.chromium.org/1335353002 .
2015-09-14 11:09:46 -07:00
Scott Graham 6c23e37ee9 win: Fix ProcessInfo test when running on x86 host OS
R=mark@chromium.org
BUG=crashpad:50

Review URL: https://codereview.chromium.org/1339813002 .
2015-09-14 11:07:59 -07:00
Scott Graham c3cc1d19c1 win: Fix use of THREAD_ALL_ACCESS on XP
OpenThread(THREAD_ALL_ACCESS, ...) fails on XP with the uplevel value of
THREAD_ALL_ACCESS, so use the XP value.

Similar to the PROCESS_ALL_ACCESS in
https://codereview.chromium.org/1337133002/ but I mistakenly only
grepped for PROCESS_ALL_ACCESS at that point.

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

Review URL: https://codereview.chromium.org/1337653005 .
2015-09-11 16:45:44 -07:00
Scott Graham d62866f734 win: Don't run x64 specific test unless built for x64
R=mark@chromium.org
BUG=crashpad:50

Review URL: https://codereview.chromium.org/1343433003 .
2015-09-11 16:11:00 -07:00
Scott Graham 81269ee676 win: Fix pipe leak on connection
The pipe handle was being leaked on connections (oops!). On XP this
resulted in the next test's CreateNamedPipe to fail, because the
previous one still existed (because all handles were not closed). More
recent OSs are more forgiving so I got away with the buggy code.

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

Review URL: https://codereview.chromium.org/1337953003 .
2015-09-11 15:34:35 -07:00
Scott Graham ccf9f98519 win xp: Don't use ICU_REJECT_USERPWD with WinHttpCrackUrl
Fails on XP with ERROR_INVALID_PARAMETER (undocumented). Not overly
important that we reject embedded user/passwords in the URL for this
use case.

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

Review URL: https://codereview.chromium.org/1339793002 .
2015-09-11 13:23:59 -07:00
Scott Graham 3a886267aa win: Fix OpenProcess(PROCESS_ALL_ACCESS, ...) on XP
PROCESS_ALL_ACCESS was changed in later SDKs and the newer value fails
when run on XP with ERROR_ACCESS_DENIED. Use the old value to maintain
compatibility with XP.

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

Review URL: https://codereview.chromium.org/1337133002 .
2015-09-11 13:16:06 -07:00
Scott Graham 5111a1823f win: Implement and use ScopedProcessSuspend
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/1303173011 .
2015-09-08 10:09:26 -07:00
Scott Graham 28c5da9080 win: Add version to client registration request
Follow up after suggestion in https://codereview.chromium.org/1301853002/.

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

Review URL: https://codereview.chromium.org/1314683008 .
2015-09-04 11:52:07 -07:00
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 5de461e8c8 Refactor handler/main for Windows, implement CrashHandlerExceptionServer
BUG=crashpad:1
R=mark@chromium.org

Review URL: https://codereview.chromium.org/1314093002 .
2015-09-03 13:31:19 -07:00
Scott Graham 6978bf7646 win: Crash handler server
This replaces the registration server, and adds dispatch to a delegate
on crash requests.

(As you are already aware) we went around in circles on trying to come
up with a slightly-too-fancy threading design. All of them seemed to
have problems when it comes to out of order events, and orderly
shutdown, so I've gone back to something not-too-fancy.

Two named pipe instances (that clients connect to) are created. These
are used only for registration (which should take <1ms), so 2 should be
sufficient to avoid any waits. When a client registers, we duplicate
an event to it, which is used to signal when it wants a dump taken.

The server registers threadpool waits on that event, and also on the
process handle (which will be signalled when the client process exits).
These requests (in particular the taking of the dump) are serviced
on the threadpool, which avoids us needing to manage those threads,
but still allows parallelism in taking dumps. On process termination,
we use an IO Completion Port to post a message back to the main thread
to request cleanup. This complexity is necessary so that we can
unregister the threadpool waits without being on the threadpool, which
we need to do synchronously so that we can be sure that no further
callbacks will execute (and expect to have the client data around
still).

In a followup, I will readd support for DumpWithoutCrashing -- I don't
think it will be too difficult now that we have an orderly way to
clean up client records in the server.

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

Review URL: https://codereview.chromium.org/1301853002 .
2015-09-03 11:06:17 -07: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 78bba8808b win: Pass WINHTTP_FLAG_SECURE when necessary
Otherwise the server drops us when connecting to an https endpoint,
and WinHttpReceiveResponse fails with an obscure error.

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

Review URL: https://codereview.chromium.org/1317023003 .
2015-08-31 13:29:00 -07:00
Mark Mentovai b70d302987 Add a few more expectations to crashpad_util_test InRangeCast
TEST=crashpad_util_test InRangeCast.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1300403002 .
2015-08-20 12:13:46 -04:00
Mark Mentovai 34aef02cc7 ubsan: Don’t call v[0] on empty vectors
Calling std::vector<>::operator[]() with an out-of-range index argument
is undefined behavior. In two cases, Crashpad used &v[0] in situations
where it was known that the address would not be used. These calls were
wrapped in conditions guarding against vector emptiness.

While s[0] is valid on an empty string, in two cases, Crashpad used
&s[0] as an argument to a system call that would be a no-op. These calls
were wrapped in similar conditions to avoid the system call.

The two uses of vector with undefined behavior were caught by the
following tests in crashpad_snapshot_test with
UndefinedBehaviorSanitizer:

[ RUN      ] CrashpadInfoClientOptions.OneModule
/Users/mark/compilatorium/llvm.build/bin/../include/c++/v1/vector:1493:12:
runtime error: reference binding to null pointer of type
'crashpad::process_types::section'
[       OK ] CrashpadInfoClientOptions.OneModule (72 ms)

[ RUN      ] ProcessSnapshotMinidump.Empty
/Users/mark/compilatorium/llvm.build/bin/../include/c++/v1/vector:1493:12:
runtime error: reference binding to null pointer of type
'MINIDUMP_DIRECTORY'
[       OK ] ProcessSnapshotMinidump.Empty (1 ms)

The Crashpad codebase was audited by searching for resize() calls and
analyzing how resized strings and vectors are used.

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

Review URL: https://codereview.chromium.org/1283243004 .
2015-08-20 11:50:19 -04:00
Mark Mentovai 5064aeb784 Use -[NSNumber numberWithDouble:] for doubles
Found by -fsanitize=undefined:
[ RUN      ] Launchd.CFPropertyToLaunchData_FloatingPoint
../../../util/mac/launchd_test.mm:82:33: runtime error: value
1.79769e+308 is outside the range of representable values of type
'float'
[       OK ] Launchd.CFPropertyToLaunchData_FloatingPoint (2 ms)

TEST=crashpad_util_test Launchd.CFPropertyToLaunchData_FloatingPoint
BUG=
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1302843004 .
2015-08-20 09:29:23 -04:00
Mark Mentovai b1d7833600 Use EXPECT_STREQ(a, b) when a and b are both const char*
While not strictly asan-related, this bug was found while running tests
under asan. Evidently, strings are pooled differently in that build
configuration.

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

Review URL: https://codereview.chromium.org/1291573004 .
2015-08-19 18:47:51 -04:00
Mark Mentovai 6645a69240 asan: Fix invalid memory access in UniversalExceptionRaise()
TEST=crashpad_util_test ExcClientVariants.UniversalExceptionRaise
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1283323010 .
2015-08-19 18:47:02 -04:00
Mark Mentovai 14a2241274 HTTPTransport test: Deal with limited-size pipe buffers
HTTPTransport.Upload33k failed on Windows due to WinHTTP timing out. The
test server, http_transport_test_server.py, writes the entire request to
a stdout pipe, to be received by crashpad_util_test. crashpad_util_test
is also the HTTP client, and it does not attempt to read from this pipe
until the HTTP transaction is complete. http_transport_test_server.py
must not write to stdout until the transaction is complete, otherwise,
there is a risk of deadlock if the pipe buffer fills up. The new
Upload33k test sends a large request, which was filling up the pipe
buffer on Windows.

This also adds an Upload33k_LengthUnknown test variant to exercise a
large POST when the length is not known ahead of time. This more closely
matches how Crashpad crash uploads are done on OS X.

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

Review URL: https://codereview.chromium.org/1286173007 .
2015-08-18 17:52:12 -04:00
Mark Mentovai f496130fd5 HTTPTransportMac: CFStream Read() must always set at_eof
CFStream’s CFReadStreamGetBuffer() calls the Read() callback without
initializing at_eof. The callback function is responsible for setting it
on any successful read operation. See 10.10.2 CF-1152.14/CFStream.c.

By chance, at_eof seems to always have an initial value of false on
x86_64, but true on 32-bit x86. Crashpad’s Read() callback assumed that
the initial value was always false. The discrepancy caused truncation
and possibly hangs when a 32-bit process attempted to upload a request
body larger than 32kB, the buffer size used by NSMutableURLRequest or
something between it and CFReadStream.

A new test with more than 32kB of data is added.

As discussed in:
https://groups.google.com/a/chromium.org/d/topic/crashpad-dev/Vz--qMZJRPU

TEST=crashpad_util_test HTTPTransport.Upload33k
BUG=
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1304433004 .
2015-08-18 15:42:34 -04: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
Nick Carter ad09fd1bc8 DCHECK_IS_ON needs ()
Found in the course of reintroducing this bug elsewhere

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

Review URL: https://codereview.chromium.org/1287043005 .

Patch from Nick Carter <nick@chromium.org>.
2015-08-12 20:47:36 -04:00
Mark Mentovai eb7ca8c374 Fix a few pieces of documentation
These problems were noticed while perusing
http://docs.crashpad.googlecode.com/git/doxygen/namespacecrashpad.html

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1278423002 .
2015-08-10 12:23:50 -04:00
Mark Mentovai 124ace19bd crashpad_database_util: Accept --new-report=- to read a new report from
standard input.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1023943003 .
2015-08-07 13:57:05 -04:00
Scott Graham 8171e6f765 win: Fix module timestamp test
This test was added in https://codereview.chromium.org/1052813002. It
was previously checking the timestamp from in-memory module traversal
vs. the disk mtime. This is flaky (of course) because it depends on
the linker writing the header and closing the file during the same time
quantum. So the bots occasionally failed with:

[ RUN      ] ProcessInfo.Self
e:\b\build\slave\chromium_win_dbg\build\crashpad\util\win\process_info_test.cc(86): error: Value of: GetTimestampForModule(GetModuleHandleW(nullptr))
  Actual: 1431650338
Expected: modules[0].timestamp
Which is: 1431650337

Instead, use imagehlp to pull the timestamp out of the header so that
it matches the header value that will be the in-memory timestamp.

R=cpu@chromium.org
TBR=mark@chromium.org

Review URL: https://codereview.chromium.org/1139103003
2015-05-14 18:45:28 -07:00
Scott Graham b0889f61ee win: Retrieve module version/type information
Refactor version retrieval from system snapshot to use when
retrieving the module version information.

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

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

Review URL: https://codereview.chromium.org/1126273003
2015-05-14 17:43:49 -07:00
Scott Graham 5a21de6a1b win: Retrieve thread context for x64
Retrieve context and save to thread context. NtQueryInformationThread
is no longer required (right now?) because to retrieve the CONTEXT, the
thread needs to be Suspend/ResumeThread'd anyway, and the return value
of SuspendThread is the previous SuspendCount.

I haven't handle the x86 case yet -- that would ideally be via
Wow64GetThreadContext (I think) but unfortunately that's Vista+, so I'll
likely need to to a bit of fiddling to get that sorted out. (It's actually
likely going to be NtQueryInformationThread again, but one thing at a
time for now.)

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

Review URL: https://codereview.chromium.org/1133203002
2015-05-14 17:37:02 -07:00
Erik Wright f357afc43e Move thread from test/ to util/thread/.
BUG=
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1134943003
2015-05-13 14:05:57 -04:00
Scott Graham 658cd3e1a7 win: Add thread snapshot and memory snapshot for stacks
The next big piece of functionality in snapshot. There's a bit more
grubbing around in the NT internals than would be nice, and it has
made me start to question the value avoiding MinidumpWriteDump. But
this seems to extract most of the data we need (I haven't pulled
the cpu context yet, but I hope that won't be too hard.)

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

Review URL: https://codereview.chromium.org/1131473005
2015-05-11 13:29:52 -07:00
Mark Mentovai 00c42ae7bd file_io_test: Use NoBarrier_Load() instead of Release_Load().
BUG=chromium:420970
TEST=util_test FileIO.*Exclusive*
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1130403002
2015-05-08 14:15:11 -04:00
Mark Mentovai e8e19ac29d util/win/time.cc: Add and use FiletimeToMicroseconds().
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1137503002
2015-05-07 15:08:02 -04:00
Mark Mentovai 7d454ae713 ThreadLogMessages: don’t check TLS slot initialization return value.
This updates Crashpad for https://codereview.chromium.org/1124493002/.

The mini_chromium update includes:

98264cf63f22 ThreadLocalStorage: remove the return value from slot
             initialization

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1129793004
2015-05-06 17:04:44 -04:00
Scott Graham 06db728457 win: Add support for CPUTimes and StartTime to snapshot
Follows https://codereview.chromium.org/1120383003/.

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

Review URL: https://codereview.chromium.org/1119393003
2015-05-06 11:13:44 -07: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 d8713a576b win: Don't log wide strings via path.value().c_str()
At the moment the LOGs print something unhelpful like:

[19912:21888:20150501,145958.098:ERROR file_io_win.cc:122] CreateFile 000000C9F8FDE7F0: The system cannot find the file specified.  (0x2)

(where the hex string ought to be a file name)

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

Review URL: https://codereview.chromium.org/1117393002
2015-05-01 15:49:35 -07:00
Scott Graham 69d135acda win: make CrashpadInfo retrievable
The main goal was to get the beginnings of module iteration and retrieval
of CrashpadInfo in snapshot. The main change for that is to move
crashpad_info_client_options[_test] down out of mac/.

This also requires adding some of the supporting code of snapshot in
ProcessReaderWin, ProcessSnapshotWin, and ModuleSnapshotWin. These are
partially copied from Mac or stubbed out with lots of TODO annotations.
This is a bit unfortunate, but seemed like the most productive way to
make progress incrementally. That is, it's mostly placeholder at the
moment, but hopefully has the right shape for things to come.

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

Review URL: https://codereview.chromium.org/1052813002
2015-05-01 13:48:23 -07:00
Erik Chen 3d216f5516 mac: Suppress partial availability warnings.
The warnings are emitted when a translation unit attempts to reference
a function whose availability is newer than the deployment target.

BUG=471823
R=mark@chromium.org

Review URL: https://codereview.chromium.org/1109273002

Patch from Erik Chen <erikchen@chromium.org>.
2015-05-01 14:16:58 -04: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 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 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 352160906b Add ExcServerCopyState().
ExcServerCopyState() properly sets the new_state and new_state_count
out-parameters for exception handler routines that may deal with
state-carrying exceptions.

This used to exist inline in catch_exception_tool, but that
implementation had a bug caught by the new test.

TEST=crashpad_util_test ExcServerVariants.ExcServerCopyState and others
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1049023003
2015-04-01 12:16:22 -04:00
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
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
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 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 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 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
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 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
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
Mark Mentovai b665a0db07 Allow Crashpad to build in the Chromium tree.
When building in the Chromium tree, this swaps out Crashpad’s copies of
mini_chromium, gtest, and gmock for the equivalents provided by
Chromium. A GYP variable, crashpad_in_chromium, is used to determine the
behavior.

gclient doesn’t sync sub-DEPS, so when doing an in-Chromium build,
Crashpad’s copies of mini_chromium, gtest, and gmock are not available.

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

Review URL: https://codereview.chromium.org/986033002
2015-03-09 15:25:42 -04:00
Mark Mentovai 32a9d410ca Locate test data more robustly.
Test code that requires test data should call Paths::TestDataRoot() to
obtain the test data root. This will use the CRASHPAD_TEST_DATA_ROOT
environment variable if set. Otherwise, it will look for test data at
known locations relative to the executable path. If the test data is not
found in any of these locations, it falls back to using the working
directory, the same as the current behavior.

BUG=crashpad:4
TEST=crashpad_util_test Paths.TestDataRoot and others
R=rsesek@chromium.org, scottmg@chromium.org

Review URL: https://codereview.chromium.org/992503002
2015-03-09 15:13:13 -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
Mark Mentovai 55861e88ce util/mach/exc_server_variants.cc: Remove unused typedefs.
BUG=crashpad:12
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/989023002
2015-03-08 15:15:53 -04:00
Mark Mentovai 88690cece3 util/mac: Provide wrappers for <launch.h> functions deprecated in 10.10.
A few stragglers were missing from bc401f6aac. I really don’t know how
that’s possible, since I thought I was testing it with the correct SDK.
I guess I wasn’t.

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

Review URL: https://codereview.chromium.org/978883007
2015-03-08 15:12:40 -04:00
Mark Mentovai bc401f6aac util/mac: Provide wrappers for <launch.h> functions deprecated in 10.10.
The 10.10 SDK deprecates <launch.h>, but this file is still useful and
is used by util/mac/launchd.* and util/mac/service_management.*. Wrap
the <launch.h> functions in versions that ignore the deprecation
warnings.

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

Review URL: https://codereview.chromium.org/989733003
2015-03-06 22:27:25 -05: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
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 bed7a543c0 win: Add implementation of ProcessInfo
This is as a precursor to ProcessReader. Some basic functionality
is included for now, with more to be added later as necessary.

The PEB code is pretty icky -- walking the doubly-linked list
in the target's address space is cumbersome. The alternative
is to use EnumProcessModules. That would work but:
1) needs different APIs for XP and Vista 64+
2) retrieves modules in memory-location order, rather than
initialization order. I felt retrieving them in initialization order
might be useful when detecting third party DLL injections. In the
end, we may want to make both orders available.

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

Review URL: https://codereview.chromium.org/977003003
2015-03-05 22:07:38 -08:00
Mark Mentovai ae1ccf621b handler: Add report upload.
The handler is now capable of uploading crash reports from the database.
At present, only one upload attempt is made, and the report will be
moved to “completed” in the database after the attempt, regardless of
whether it succeeded or failed.

The handler also has support to push annotations from its command line
into the process annotations map of each crash report it writes. This is
intended to set basic information about each crash report, such as the
product ID and version. Each potentially crashy process can’t be relied
on to maintain this information on their own.

With this change, Crashpad is now 100% capable of running a handler that
maintains a database and uploads crash reports to a Breakpad-type server
such that Breakpad properly interprets the reports. This is all possible
from the command line.

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.6.0 \
         crashy_program

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/982613002
2015-03-05 15:40:47 -05:00
Scott Graham 583314184a win: add equivalent of gettimeofday
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/940793002
2015-02-20 11:35:04 -08:00
Mark Mentovai 89ca2fbba7 Add FileReaderInterface::ReadExactly() and
FileSeekerInterface::SeekSet().

These methods perform common error checking.

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

Review URL: https://codereview.chromium.org/913223008
2015-02-18 18:22:39 -05:00
Mark Mentovai 583233cf78 Add FileReaderInterface. Move StringFileWriter to StringFile and
implement the new interface.

The upcoming minidump reader will get minidump data from a
FileReaderInterface. For ease of testing, a string-based implementation
is provided. There wasn’t a good reason to have a separate
StringFileReader and StringFileWriter, so I combined them into a single
StringFile.

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

Review URL: https://codereview.chromium.org/936153002
2015-02-18 14:15:38 -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 e774a63dbc win: Fix InitializationStateDcheck in Release build
e:\b\build\slave\crashpad_win_rel\build\crashpad\util\misc\initialization_state_dcheck_test.cc(25) : error C2133: 'initialization_state_dcheck' : unknown size

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

Review URL: https://codereview.chromium.org/915023003
2015-02-11 13:39:38 -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