179 Commits

Author SHA1 Message Date
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
Mark Mentovai
10c264cd57 Add Semaphore::TimedWait().
This also splits the per-OS Semaphore methods into their own files.

TEST=util_test Semaphore.*
R=rsesek@chromium.org, scottmg@chromium.org

Review URL: https://codereview.chromium.org/909263002
2015-02-10 17:01:58 -05:00
Scott Graham
b16b89c89d Make HTTPTransportWin respect user timeout
Uses solution suggested in linked bug. No test as it'd be flaky, slow,
or both.

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

Review URL: https://codereview.chromium.org/897393002
2015-02-06 10:10:55 -08:00
Mark Mentovai
242619d958 HTTPTransport: callers should be able to obtain the HTTP response body.
This adds a new optional out-parameter to
HTTPTransport::ExecuteSynchronously() and provides Mac and Windows
implementations.

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

Review URL: https://codereview.chromium.org/885183004
2015-02-05 18:05:40 -05:00
Mark Mentovai
222f91f5c6 Add WeakFileHandleFileWriter, a FileWriterInterface implementation that
deals solely with a weak FileHandle.

CrashReportDatabase::PrepareNewCrashReport() provides its caller with
both a FileHandle and a FilePath. While it’s possible to create a
FileWriter from the FilePath, it’s not necessary to have two FileHandles
open to the same file. Also, there’s no FileWriteMode::kReuseOrFail
option because it didn’t seem necessary[1], and although it would
actually be the most desirable option for a FileWriter here, allowing
the FileHandle to be used directly without reopening the file sidesteps
the problem entirely.

FileWriter is adapted to use WeakFileHandleFileWriter to minimize
duplication.

[1] https://codereview.chromium.org/818433002/diff/80001/util/file/file_io.h#newcode138

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

Review URL: https://codereview.chromium.org/871193010
2015-02-04 17:26:16 -05:00
Scott Graham
d77461acd0 Missed change in http://crrev.com/880763002, remove const from info()
Oops, forgot to do this before landing.

R=mark@chromium.org
TBR=mark@chromium.org
BUG=crashpad:7

Review URL: https://codereview.chromium.org/885663004
2015-01-28 15:00:46 -08:00
Scott Graham
892c29e8ba Reorganize Multiprocess and implement for Windows
- Various "FD" to "Handle"
- Existing Multiprocess implementation moves to _posix.
- Stub implementation for _win.

At the moment, multiprocess_exec_win.cc contains implementations of both
Multiprocess methods and MultiprocessExec functions. This will need more
work in the future, but reflects the idea that all tests should be in
terms of MultiprocessExec eventually.

Currently, this works sufficiently to have util_test succeed (including
multiprocess_exec_test, and the recently ported HTTPTransport tests.)

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

Review URL: https://codereview.chromium.org/880763002
2015-01-28 14:49:42 -08:00
Scott Graham
7c9bd944ae win: Add implementation of HTTPTransport based on WinHTTP
(There's also https://codereview.chromium.org/854363006/ based on
WinInet, I'm still a little uncertain which is preferable here.)

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

Review URL: https://codereview.chromium.org/852213004
2015-01-26 13:31:35 -08:00
Scott Graham
ac6a7455fd win: use FileOffset, not off_t in string_file_writer_test
off_t exists on Windows, but Seek is implemented in terms of
SetFilePointerEx which expects a LONGLONG, so FileOffset is LONGLONG.

So, use FileOffset in the test code so that it wraps at the expected
value.

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

Review URL: https://codereview.chromium.org/854883002
2015-01-15 11:24:28 -08:00
Scott Graham
92d5c41964 win: implement ErrnoMessage
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/816223007
2015-01-15 10:40:18 -08:00
Scott Graham
cb8c01f410 win: Some %zu to PRIuS
%zu aborts in system printf functions on Windows, so use PRIuS instead.

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

Review URL: https://codereview.chromium.org/849193002
2015-01-15 10:00:43 -08:00
Scott Graham
7e7b65da1b win: Add implementation of ExecutablePath
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/852773004
2015-01-15 10:00:09 -08:00
Scott Graham
7115130043 win: Add implementation of ScopedTempDir
Also fix implementation of CreateFile which aborted at runtime
when provided POSIX-style permissions.

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

Review URL: https://codereview.chromium.org/837123005
2015-01-13 13:51:32 -08:00
Robert Sesek
f0b9dcba25 Add a tri-state enum to return the result of Xattr operations.
R=mark@chromium.org
TEST=util_test --gtest_filter=Xattr\*

Review URL: https://codereview.chromium.org/842223003
2015-01-09 13:04:36 -05:00
Scott Graham
a277e14c9e Fix function name in error message of scoped_temp_dir_test
After https://codereview.chromium.org/826003003/.

R=mark@chromium.org

Review URL: https://codereview.chromium.org/836833003
2015-01-08 11:08:32 -08:00
Scott Graham
f9c487b1e1 win: port multiprocess_exec_test_child.cc
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/808493003
2015-01-08 11:08:11 -08:00
Scott Graham
c6bcbfb042 win: port semaphore test
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/840933004
2015-01-08 09:32:12 -08:00
Scott Graham
b1d2beb724 win: Disable Clock tests that require SleepNanoseconds
As it was left unimplemented on Windows per previous discussion.

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

Review URL: https://codereview.chromium.org/838833004
2015-01-07 21:04:52 -08:00
Scott Graham
b0545c2627 win: porting for scoped_temp_dir_test
Uses the posix-y CRT functions rather than Win32 API for consistency/similarity
to the POSIX code path as it's localized test code anyway.

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

Review URL: https://codereview.chromium.org/826003003
2015-01-07 16:16:18 -08:00
Scott Graham
7b161de65c win: FILE_PATH_LITERAL in executable_path_test.cc
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/838023002
2015-01-07 15:08:37 -08:00
Scott Graham
9b05b910d4 win: FILE_PATH_LITERALs in http_multipart_builder_test.cc
clang-format wanted to rewrap this way.

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

Review URL: https://codereview.chromium.org/814683003
2015-01-07 15:07:40 -08:00
Scott Graham
119c4fdd93 win: various porting for http_body_test.cc
- Wrap constants in FILE_PATH_LITERAL for L"".
- dynamic allocation, as VS otherwise complains about lack of constant
expression:

d:\src\crashpad\crashpad\util\net\http_body_test.cc(182) : error C2057: expected constant expression
d:\src\crashpad\crashpad\util\net\http_body_test.cc(182) : error C2466: cannot allocate an array of constant size 0
d:\src\crashpad\crashpad\util\net\http_body_test.cc(182) : error C2133: 'buf' : unknown size
d:\src\crashpad\crashpad\util\net\http_body_test.cc(183) : error C2070: 'uint8_t []': illegal sizeof operand
d:\src\crashpad\crashpad\util\net\http_body_test.cc(196) : error C2070: 'uint8_t []': illegal sizeof operand

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

Review URL: https://codereview.chromium.org/837293002
2015-01-07 15:05:38 -08:00
Scott Graham
4ec5405135 win: avoid warning in StringFileWriter.SeekInvalid test
d:\src\crashpad\crashpad\util\file\string_file_writer_test.cc(367) : warning C4244: 'initializing' : conversion from 'const uint64_t' to 'const off_t', possible loss of data

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

Review URL: https://codereview.chromium.org/836413004
2015-01-07 14:42:52 -08:00
Robert Sesek
c75dc46b17 Add UUID::InitializeFromString().
R=mark@chromium.org
TEST=util_test --gtest_filter=UUID.FromString

Review URL: https://codereview.chromium.org/820783004
2015-01-02 18:46:10 -05:00
Robert Sesek
1cdb7c1d04 Create ScopedTempDir, implement it on POSIX, and use it where appropriate.
R=mark@chromium.org
TEST=util_test --gtest_filter=ScopedTempDir.*

Review URL: https://codereview.chromium.org/834693002
2015-01-02 13:51:47 -05:00
Robert Sesek
8e98c9251a Add wrappers around getxattr() and setxattr().
R=mark@chromium.org
TEST=util_test --gtest_filter=Xattr.*

Review URL: https://codereview.chromium.org/791493009
2014-12-30 17:39:27 -05:00
Scott Graham
6865865773 Change 'bool world_readable' to an enum
More clear at callsites, and relatively important not to accidentally choose the wrong one.

R=mark@chromium.org

Review URL: https://codereview.chromium.org/821483002
2014-12-19 15:35:30 -08:00
Scott Graham
9cfd2c515e Make http_body cross-platform
'util' builds on Windows after this.

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

Review URL: https://codereview.chromium.org/791493007
2014-12-19 15:21:19 -08:00
Mark Mentovai
110eafe9a1 CloseMultipleNowOrOnExec(): promote out of test.
This function will be useful in upcoming non-test code. Because the
first Crashpad client that wants a Crashpad handler will now be
responsible for starting the handler process, this will prevent file
descriptors from leaking to the handler process.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/819483002
2014-12-19 16:42:34 -05:00
Scott Graham
5f5e342584 Switch [String]FileWriter to use new file_io.h functions/types
Also add ScopedFileHandle as cross-platform version of ScopedFD/ScopedFileHANDLE.

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

Review URL: https://codereview.chromium.org/815053004
2014-12-19 13:33:01 -08:00
Mark Mentovai
25c3afaac5 Add CloseStdinAndStdout().
There will be no reason to leave the handler process connected to its
invoker’s stdin or stdout.

On the other hand, I’m currently leaving it connected to the original
and stderr, as these may be useful for diagnostics.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/818573002
2014-12-19 14:20:20 -05:00
Scott Graham
384497475a Add LoggingSeekFile
As the whence values are "helpfully" available in windows.h as well
( http://msdn.microsoft.com/en-us/library/windows/desktop/dd757336(v=vs.85).aspx )
don't bother inventing a new enum. Add implementations for POSIX and Win32.

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

Review URL: https://codereview.chromium.org/812593005
2014-12-19 10:45:22 -08:00
Scott Graham
4034d30023 Add LoggingOpenFileFor{Read|Write}
I started (https://codereview.chromium.org/812403002/) emulating oflag values
on Windows in FileWriter, but it seemed awkward. On the assumption that we're
only likely to need "read a file" and "write a file" this seemed simpler, and
sufficient (but I don't know if that's necessarily true).

Users of open are not yet switched.

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

Review URL: https://codereview.chromium.org/818433002
2014-12-18 16:29:33 -08:00
Scott Graham
4a9b858fbd win: Add Scoped...Handle
Intended for future use to implement util/file/file_writer.

There's a similar class in base:
https://code.google.com/p/chromium/codesearch#chromium/src/base/win/scoped_handle.h&l=28

However (perhaps for historical reasons) it does not distinguish between
the possible types of HANDLEs which have different invalid values,
resulting in a need to copy a bunch of code rather than simply using
ScopedGeneric.

Instead, distinguish between the types so the caller can use the
correct one.

Refs:
http://blogs.msdn.com/b/oldnewthing/archive/2004/03/02/82639.aspx
http://msdn.microsoft.com/en-us/magazine/cc302328.aspx (Figure 2)

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

Review URL: https://codereview.chromium.org/813873004
2014-12-18 09:51:20 -08:00
Scott Graham
d1fdcf99e0 win: implement Semaphore
Ref:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms686946%28v=vs.85%29.aspx

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

Review URL: https://codereview.chromium.org/797173003
2014-12-18 09:08:57 -08:00
Scott Graham
ec38bf152d win: Add static_cast to AssignIfInRange
Otherwise, when assigning to a smaller type, MSVC warns e.g.

d:\src\crashpad\crashpad\util\numeric\safe_assignment.h(38) : error C2220: warning treated as error - no 'object' file generated
        d:\src\crashpad\crashpad\util\file\string_file_writer.cc(127) : see reference to function template instantiation 'bool crashpad::AssignIfInRange<size_t,FileOffset>(Destination *,Source)' being compiled
        with
        [
            Destination=size_t
,            Source=FileOffset
        ]
d:\src\crashpad\crashpad\util\numeric\safe_assignment.h(38) : warning C4244: '=' : conversion from 'FileOffset' to 'size_t', possible loss of data

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

Review URL: https://codereview.chromium.org/809303003
2014-12-18 08:42:26 -08:00
Scott Graham
10165ce449 Cross platform low level file IO wrappers
Rename fd_io to file_io, and ReadFD to ReadFile, etc.

file_io.cc is the higher level versions that call the basic ReadFile/WriteFile
and then file_io_posix.cc and file_io_win.cc are the implementations of
those functions.

The Windows path is as yet untested, lacking the ability to link the test binary.

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

Review URL: https://codereview.chromium.org/811823003
2014-12-17 14:35:18 -08:00
Mark Mentovai
a02f721637 Add NewMachPort() and its test, and switch call sites to use it.
There were many call sites that wasted a few lines on
mach_port_allocate() and sticking the result into a scoper. I was about
to add three more, so I took the opportunity to simplify things.

TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/809103002
2014-12-17 15:10:38 -05:00
Mark Mentovai
439532bd0b MachMessageServer::Run(): correct documentation.
The comment referred to the old form of the |persistent| argument, which
was a bool.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/806953004
2014-12-17 15:09:22 -05:00
Scott Graham
3eeae10ebe win: avoid warning on return of base::RandGenerator
Else,

d:\src\crashpad\crashpad\util\net\http_multipart_builder.cc(50) : warning C4244: 'initializing' : conversion from 'uint64_t' to 'int', possible loss of data

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

Review URL: https://codereview.chromium.org/796643006
2014-12-17 10:50:05 -08:00
Scott Graham
db6492e154 win: clock implementation
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/807973002
2014-12-17 10:45:43 -08:00
Scott Graham
4a5d21528e DCHECK_LE for cr_ngroups vs arraysize(cr_groups)
This DCHECK fails for me locally as

[----------] 3 tests from ProcessInfo
[ RUN      ] ProcessInfo.Self
[70989:10546846:20141216,112509.948519:FATAL process_info_mac.cc:114] Check failed: static_cast<size_t>(ngroups) < (sizeof(ArraySizeHelper(kern_proc_info_.kp_eproc.e_ucred.cr_groups))) (16 vs. 16).
Abort trap: 6

It doesn't seem to happen on the waterfall, so maybe I'm building against
an incorrect header? I don't particularly understand the code, but assuming
it's normal 0-based array, perhaps it should be a DCHECK_LE in any case.

R=mark@chromium.org

Review URL: https://codereview.chromium.org/813473002
2014-12-16 12:18:32 -08:00
Mark Mentovai
5adfa5039e string_number_conversions: only check CXX_LIBRARY_HAS_CONSTEXPR.
CXX_LIBRARY_VERSION is irrelevant, because the only C++11 library
feature of any concern is whether numeric_limits’ min() and max() are
declared constexpr.

Crashpad is C++11-only as far as the language is concerned, and the
comment doesn’t need to call it out explicitly because static_assert()
is always available.

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/809833002
2014-12-16 14:55:28 -05:00
Mark Mentovai
d78b003ef1 Add NotifyServer and its test.
TEST=util_test NotifyServerTest.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/804633002
2014-12-16 14:10:16 -05:00
Scott Graham
4263334db8 win: avoid warnings in string_number_conversion_test.cc
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/807463004
2014-12-16 11:00:20 -08:00
Scott Graham
9d38069f13 win: static_cast to uint64_t rather than implicit_cast, to avoid warnings
e.g.

FAILED: ninja -t msvc -e environment.x86 -- "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\util\misc\util_test.clock_test.obj.rsp /c ..\..\util\misc\clock_test.cc /Foobj\util\misc\util_test.clock_test.obj /Fdobj\util\util_test.cc.pdb
d:\src\crashpad\crashpad\third_party\mini_chromium\mini_chromium\base\basictypes.h(49) : error C2220: warning treated as error - no 'object' file generated
        d:\src\crashpad\crashpad\util\misc\clock_test.cc(72) : see reference to function template instantiation 'To implicit_cast<uint64_t,double>(const From &)' being compiled
        with
        [
            To=uint64_t
,            From=double
        ]
d:\src\crashpad\crashpad\third_party\mini_chromium\mini_chromium\base\basictypes.h(49) : warning C4244: 'return' : conversion from 'const double' to 'uint64_t', possible loss of data

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

Review URL: https://codereview.chromium.org/807653002
2014-12-15 16:21:12 -08:00
Scott Graham
1a17e7e643 win: Avoid warnings about conversion to smaller integer types
e.g.

d:\src\crashpad\crashpad\util\numeric\in_range_cast.h(35) : warning C4244: 'return' : conversion from 'unsigned __int64' to 'uint32_t', possible loss of data
d:\src\crashpad\crashpad\util\numeric\in_range_cast.h(35) : warning C4244: 'return' : conversion from '__int64' to 'int32_t', possible loss of data
        d:\src\crashpad\crashpad\util\numeric\in_range_cast_test.cc(54) : see reference to function template instantiation 'Destination crashpad::InRangeCast<int32_t,__int64>(Source,Destination)' being compiled
        with
        [
            Destination=int32_t
,            Source=__int64
        ]

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

Review URL: https://codereview.chromium.org/800073003
2014-12-15 16:19:33 -08:00
Scott Graham
c23dcdc88a win: set CXX_LIBRARY_VERSION to 2011
Unfortunately VS2013's support of C++11 is partial. It supports the
extended union definition, but does not fully support constexpr.

So, update some locations where CXX_LIBRARY_VERSION is used where
toolchain support is lacking. It works correctly in the locations
where std::is_standard_layout is used.

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

Review URL: https://codereview.chromium.org/803273002
2014-12-15 15:55:41 -08:00
Mark Mentovai
22cf9e28d5 util_test: Don’t crash when run from the wrong location.
When run from the wrong location and test data or other test programs
can’t be found, the tests should fail with gtest assertions. The test
executable should not crash.

BUG=crashpad:4
TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/799083003
2014-12-15 16:40:16 -05:00