259 Commits

Author SHA1 Message Date
Scott Graham
47c7c03f9e clang-format: don't bin pack arguments
Prefer

  function(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
           bbbbbbbbbbbbb,
           ccccccccccccccccccccccccccccccccccccccccccc);

over

  function(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbb,
           ccccccccccccccccccccccccccccccccccccccccccc);

R=mark@chromium.org

Review URL: https://codereview.chromium.org/805333006
2014-12-19 15:44:05 -08: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
Scott Graham
4e8a78c182 Roll mini_chromium to 4d84318dbcdf46b543ab4556736cf8a9ae3ced18
Includes:
4d84318dbcdf46b543ab4556736cf8a9ae3ced18 win: Disable C4201, nameless struct/union warning
864f44f98bb8e6869b1243de9b2ebd3f50a03a21 Exclude _test suffixed files too

TBR=mark@chromium.org

Review URL: https://codereview.chromium.org/817093002
2014-12-19 15:02:54 -08:00
Scott Graham
8d7681752d win: Avoid signed/unsigned warning
d:\src\crashpad\crashpad\snapshot\cpu_context.cc(96) : warning C4245: 'return' : conversion from 'int' to 'uint64_t', signed/unsigned mismatch

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

Review URL: https://codereview.chromium.org/819703002
2014-12-19 14:53:23 -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
26c6f19927 Roll mini_chromium to 43b7cd397e5f239e59700831430b703d9a4a3b4f
Includes:
43b7cd397e5f239e59700831430b703d9a4a3b4f win: Fix for logging.h ERROR, again
a83f160101c6b054bdcfe81dea62340c7d933778 win: implement sys_byteorder.h

TBR=mark@chromium.org

Review URL: https://codereview.chromium.org/817443002
2014-12-18 09:29:46 -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
3d84a738d0 Update GYP to svn r2015 (32ca1cd8e010).
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/813873002
2014-12-17 16:03:58 -05:00
Mark Mentovai
9d2c1cffa2 Update mini_chromium to 222feaf3d302.
This picks up:

222feaf3d302 Update README
e38cddb83571 Lock: don’t require NativeThreadType to be a pointer type
8c599712d10c Include What You Use: <string.h> for memmove() and memcpy()
ef991f44ed63 Linux: always build in C++11 mode

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

Review URL: https://codereview.chromium.org/812133002
2014-12-17 16:01:35 -05:00
Mark Mentovai
39f69c862a tools: Move Mac-specific tools to tools/mac.
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/804913003
2014-12-17 15:26:23 -05: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
Mark Mentovai
86cf286350 Update mini_chromium to 158694255c7a.
This picks up:

158694255c7a win: undef ERROR, causing failing LOGs
3a981db6e6df MSVC: Disable “warning C4702: unreachable code”.
e87cd9d4dff5 Tidy string16.h after
             https://codereview.chromium.org/809563003/

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/812683002
2014-12-16 17:12:30 -05: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
b0cf01978d win: Get client/crashpad_info.cc to compile
Just avoid the Mac-specific __attribute__ tagging for now. There will need
to be some Windows-specific pragmas added here once the reader has been
written.

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

Review URL: https://codereview.chromium.org/808623002
2014-12-16 10:22:41 -08:00
Scott Graham
086714261a Roll mini_chromium to 2ef83a609517f284096f7e8296b0915d634c3ca7
Pick up build fix.

TBR=mark@chromium.org

Review URL: https://codereview.chromium.org/804853004
2014-12-15 16:46:46 -08:00
Scott Graham
7941e7f955 Roll mini_chromium to 463f840...
To pull in string16 changes.

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

Review URL: https://codereview.chromium.org/811613002
2014-12-15 16:31:15 -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
e8ab9afd82 win: Avoid 'warning C4068: unknown pragma'
I could also add COMPILER_CLANG to build_config.h, but that doesn't
appear in Chromium, apparently in preference to using __clang__
directly. I'm not sure if there's any good reason for that.

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

Review URL: https://codereview.chromium.org/803283002
2014-12-15 16:01:16 -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
Mark Mentovai
554e75422c MachMessageServer::Interface implementations: minor cleanups.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/799463003
2014-12-15 14:47:47 -05:00
Mark Mentovai
dc22dc405d Fix run_tests to always run from the crashpad directory.
BUG=4
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/799073002
2014-12-12 17:16:11 -05:00
Scott Graham
5c59a1fa18 Roll mini_chromium to 001bf11...
And another roll to get to mini_chromium to HEAD.

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

Review URL: https://codereview.chromium.org/799923005
2014-12-12 12:23:42 -08:00
Scott Graham
8d0e213213 Add test runner script for integration with the waterfall
R=mark@chromium.org

Review URL: https://codereview.chromium.org/800983002
2014-12-12 11:48:42 -08:00
Scott Graham
af07f4022b Move string16 and char16 in to base::
Needs to include roll with https://codereview.chromium.org/803593002/ included.

R=mark@chromium.org

Review URL: https://codereview.chromium.org/804593002
2014-12-12 11:06:09 -08:00
Scott Graham
1c4084fc2d Roll mini_chromium to 9427a67...
To pick up progress on compiling base on Windows.

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

Review URL: https://codereview.chromium.org/790343004
2014-12-11 16:31:40 -08:00
Scott Graham
f721df692e Revert 'Roll mini_chromium DEPS to a1fa3c5...'
mini_chromium rev broken, will fix and re-roll.

TBR=mark@chromium.org

Review URL: https://codereview.chromium.org/797553003
2014-12-11 14:41:51 -08:00
Scott Graham
c46dd63762 Roll mini_chromium DEPS to a1fa3c5...
Want to roll the mini_chromium changes in little chunks as the bot
doesn't otherwise build them, to avoid leaving something broken
for a while.

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

Review URL: https://codereview.chromium.org/796113002
2014-12-11 14:33:34 -08:00
Mark Mentovai
508a33dc7a exc_server_variants: Templatize and use CompositeMachMessageServer.
The implementations for the exc and mach_exc subsystems were nearly
identical, and were a good target for templatization. The existing
split between exc and mach_exc was a good candidate for unification
based on CompositeMachMessageServer instead of the custom unification
previously done in UniversalMachMessageServer.

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

Review URL: https://codereview.chromium.org/766193006
2014-12-11 14:29:42 -05:00
Mark Mentovai
302c87c6e5 Use GYP rules instead of actions to run mig.
TEST=util_test
R=rsesek@chromium.org

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

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

Review URL: https://codereview.chromium.org/793013002
2014-12-10 11:39:50 -08:00
Mark Mentovai
c874958fd0 MachMessageServer: eliminate argument redundancy.
MachMessageServer::Run()’s distinct |nonblocking| parameter is removed.
The information it formerly conveyed is now implied by the |timeout_ms|
parameter, which can accept two special values,
kMachMessageTimeoutNonblocking and kMachMessageTimeoutWaitIndefinitely.

TEST=client_test, snapshot_test, util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/777993002
2014-12-10 11:11:21 -05:00
Mark Mentovai
22b2f0cad7 tools: Use hyphens instead of underscores for multi-word option names.
Option names like --mach-service are easier to type than --mach_service.
Command-line tools don’t necessarily have the most ergonomic interfaces
anyway, but this is an improvement.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/774763006
2014-12-04 16:46:12 -05:00
Mark Mentovai
c83e773c33 Add CompositeMachMessageServer and its test.
TEST=util_test CompositeMachMessageServer*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/781823002
2014-12-04 16:45:02 -05:00
Mark Mentovai
821ed8fe0f UniversalMachExcServer: eliminate multiple implementation inheritance.
UniversalMachExcServer provided both an interface and an implementation,
contrary to the other classes in the exc_server_variants family. This
was mostly done for reasons of economy in an already-large class family.
Unfortunately, this decision meant that it was impossible for other code
to use UniversalMachExcServer, which required that CatchMachException()
be implemented, and also extend another class without violating the
style guide’s prohibition of multiple implementation inheritance. This
became a problem in a lot of test code, which extended MachMultiprocess
and UniversalMachExcServer.

UniversalMachExcServer is now given its own nested Interface class,
which is a pure interface. All users of UniversalMachExcServer are
changed from “is-a” UniversalMachExcServer to “has-a”
UniversalMachExcServer and “is-a” UniversalMachExcServer::Interface.

TEST=client_test, snapshot_test, util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/775943005
2014-12-04 10:18:24 -05:00