2424 Commits

Author SHA1 Message Date
Mark Mentovai
57eb311528 Add ExcServerSuccessfulReturnValue() and its test.
There’s also some light reformatting in here. Should save a few lines.

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

Review URL: https://codereview.chromium.org/574753003
2014-09-17 12:08:18 -04:00
Mark Mentovai
63fd3ae47d Drop 10.5 support: use ServiceManagement.framework directly.
TEST=util_test ServiceManagement.SubmitRemoveJob
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/572323002
2014-09-16 17:45:12 -04:00
Mark Mentovai
84d9952ebf Use backticks more uniformly in MachOImage*Reader Doxygen
documentation.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/574723002
2014-09-16 17:37:41 -04:00
Mark Mentovai
8c8089dc77 Add ExceptionPorts and its test.
This is a unified interface to
{thread,task,host}_{get,set}_exception_ports().

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

Review URL: https://codereview.chromium.org/549023005
2014-09-16 17:36:33 -04:00
Mark Mentovai
06d48e4b0a Add exception_behaviors and its test.
This includes the functions ExceptionBehaviorHasState(),
ExceptionBehaviorHasIdentity(),
ExceptionBehaviorHasMachExceptionCodes(), and ExceptionBehaviorBasic().

TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/565793005
2014-09-16 17:32:35 -04:00
Mark Mentovai
850ec0657d Drop 10.5 support.
TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/575823002
2014-09-16 11:55:55 -04:00
Mark Mentovai
e49510ab7c Add SymbolicConstantsMach and its test.
TEST=util_test SymbolicConstantsMach.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/563383002
2014-09-16 11:00:51 -04:00
Mark Mentovai
1e7cdb30a0 Add exc_client_variants (UniversalExceptionRaise()) and its test.
This also puts kMachExceptionCodes into mach_extensions.h, because a
form of MACH_EXCEPTION_CODES that’s the right type
(exception_behavior_t) has now shown its use in more than one file.

TEST=util_test ExcClientVariants.UniversalExceptionRaise
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/567283002
2014-09-16 09:48:01 -04:00
Mark Mentovai
b6a0183cce gtest, gmock: pull older versions via DEPS that don’t require C++11
library support.

When building with support for Mac OS X 10.6, C++11 library support is
not available, because Mac OS X uses libc++ for C++11 support, and Mac
OS X 10.6 does not provide libc++ as a runtime library. gtest and gmock
have a hard time distinguishing between C++11 language and library
support (which is not really their fault, having one but not the other
is an odd situation). The currently-released trunk versions of gtest and
gmock do not work in this configuration. I’ve submitted patches upstream
to fix this, but they may take a while to make it to the released
verions. For now, it’s fine to roll gtest and gmock back to versions
from December 2013 that do work cleanly with C++11 language support but
only C++03 library support.

TEST=Compile and run all tests in both 10.6 and native builds
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/572613002
2014-09-15 15:09:42 -04:00
Mark Mentovai
b77c788543 util_test MachMessageServer.ReturnCodeNoReply: keep the child alive
until the server is done handling its request.

In most tests, this is handled automatically because the client expects
a reply from the server, and waits for this reply. This test is
different because the server does handle the message, but does not send
a reply, so the client does not wait for one. When the child process
exits before the parent has had a chance to inspect the message it
received, the parent will find a dead name where it expects the remote
port to be, causing this test to be flaky based on the outcome of this
race.

The potential for a similar race existed in the
MachMessageServer.ComplexNotDestroyedNoReply test because it also
involved a request without a reply. In that test, the situation was
handled by not allowing the child to exit until signaled to do so by the
parent. The same logic should be used for both no-reply tests.

TEST=util_test MachMessageServer.ReturnCodeNoReply
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/569953002
2014-09-15 15:08:28 -04:00
Mark Mentovai
1990a6ca2a ExcServerVariants test: don’t test debug thread state flavors.
Kernel bugs prevent debug thread state flavors from being delivered to
exception handlers properly. Through luck, things work out for
x86_DEBUG_STATE and x86_DEBUG_STATE64, but a handler registered to
receive the x86_DEBUG_STATE32 thread state flavor will never be called.
For the x86 family, the only thread state flavors that can be delivered
to exception handlers are the thread, float, and exception flavors.

Radar 18312067 is filed.

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

Review URL: https://codereview.chromium.org/558503006
2014-09-12 12:14:08 -04:00
Mark Mentovai
ab4978b51e 10.6 SDK compatibility.
TEST=util_test MachOImageReader.* (and all others with a 10.6 SDK build)
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/561933004
2014-09-12 12:13:27 -04:00
Mark Mentovai
24fc801715 Add third_party/apple_cctools containing virgin upstream code.
getsectionbyname() and getsegmentbyname() do not exist prior to Mac OS X
10.7. These functions are used by util_test MachOImageReader.*. For 10.6
SDK and runtime compatibility, Crashpad needs its own implementations of
these functions.

This checkin contains unmodified copies of the upstream code. A
subsequent checkin will contain the local modifications, which will trim
out all unnecessary portions. This is being committed in two parts to
make it easier to see what changes are being made to the upstream files.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/564853002
2014-09-11 15:11:50 -04:00
Mark Mentovai
0869b3e86d Add a MappedMemory interface to TaskMemory and use it in
MachOImageSymbolTableReader.

This results in a speed boost for MachOImageSymbolTableReader because
it’s able to read the entire string table in one operation, rather than
reading each string from the remote process individually. Copying is
also reduced. In a debug-mode build on my laptop, util_test
MachOImageReader.* has improved from ~1400ms to ~1000ms.

TEST=util_test TaskMemory.*:MachOImageReader.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/558313002
2014-09-11 15:10:12 -04:00
Mark Mentovai
fbf12950fe MachMessageServer: Make request messages const.
There’s no reason that “in” or “request” messages should be non-const.
This makes them const, bridges the const gap left by the MIG-generated
“check” functions with wrappers, and uses non-const fields in
“out” messages instead of const fields in “in” messages for in-out
parameters.

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

Review URL: https://codereview.chromium.org/564533002
2014-09-10 18:57:14 -04:00
Mark Mentovai
a01c87059b Add symbolic_constants_posix and its test.
This includes the functions SignalToString() and StringToSignal().

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

Review URL: https://codereview.chromium.org/565453002
2014-09-10 17:30:21 -04:00
Mark Mentovai
177f5dcddc Add exc_server_variants including UniversalMachExcServer and its test.
TEST=util_test ExcServerVariants.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/545053003
2014-09-10 17:29:07 -04:00
Mark Mentovai
10d1b76b90 Add string_number_conversion and its test.
This includes the StringToNumber() function, both int and unsigned int variants.

Similar functionality is available in base, but it is unsuitable for
applications where a number’s base may be determined based on an "0x" or
"0X" prefix (hexadecimal) or an "0" prefix (octal).

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

Review URL: https://codereview.chromium.org/557033002
2014-09-10 15:30:11 -04:00
Mark Mentovai
7fdc7f277e Add Multiprocess::SetExpectedChildTermination().
An expectation of the child’s termination reason can now be specified.
It is now possible to test with children that do not exit cleanly, if
they are not expected to exit cleanly.

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

Review URL: https://codereview.chromium.org/553153002
2014-09-09 17:04:47 -04:00
Mark Mentovai
f1202a0814 Enhance the MachMessageServer test to cover large messages
(MACH_RCV_LARGE).

This also adds a COMPILE_ASSERT to check that the
PersistentNonblockingFourMessages test case is not exceeding the value
of MACH_PORT_QLIMIT_DEFAULT.

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

Review URL: https://codereview.chromium.org/557793002
2014-09-09 12:28:31 -04:00
Mark Mentovai
88a681e747 Enhance the MachMessageServer test to cover port right ownership
management.

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

Review URL: https://codereview.chromium.org/555663002
2014-09-09 09:59:05 -04:00
Mark Mentovai
67082c93b9 Add MachMessageServer and its test.
MachMessageServer is much like mach_msg_server() and
mach_msg_server_once(), but with a C++ interface and with a number of
deficiencies corrected.

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

Review URL: https://codereview.chromium.org/544393002
2014-09-08 21:06:34 -04:00
Mark Mentovai
2cae118b60 Add MachOImageSymbolTableReader and hook it up to MachOImageReader.
TEST=util_test MachOImageReader.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/539263003
2014-09-05 16:53:18 -04:00
Mark Mentovai
3d4eeae864 Make ProcessReaderModule and ProcessReaderThread nested classes.
This change is being made in response to the suggestion at
https://codereview.chromium.org/539263003/diff/20001/util/mac/mach_o_image_symbol_table_reader.h#newcode45

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

Review URL: https://codereview.chromium.org/543193002
2014-09-05 16:35:16 -04:00
Mark Mentovai
9dd0ac943a Implement (and test) ProcessReader::Modules().
This depended on MachOImageReader, which recently landed, so it can now
be added.

TEST=util_test ProcessReader.*Modules
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/546573002
2014-09-05 13:43:51 -04:00
Mark Mentovai
5a0b7827ff Run mig to generate the exc and mach_exc interfaces.
mach_exc is necessary because libSystem doesn’t contain this at all. exc
is necessary too, however: the copy in libSystem relies on the server
callbacks being externally defined symbols, which is cheesey.
Additionally, some Crashpad code wants to call internal validation
(“check”) routines that are not normally accessible to outside callers
via the copy of exc in libSystem, but they are made accessible here by
processing mig’s output in this Python script.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/541213002
2014-09-05 13:27:06 -04:00
Mark Mentovai
2f425e744b Add missing dependency on util_test_multiprocess_exec_test_child to
util_test.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/542993002
2014-09-05 12:40:05 -04:00
Mark Mentovai
35865a00d5 Fix problems discovered with gcc 4.9.1.
BUG=
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/538233002
2014-09-05 12:39:09 -04:00
Mark Mentovai
4f74716f6d Add MachOImageReader and its test, which also tests
MachOImageSegmentReader.

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

Review URL: https://codereview.chromium.org/535343004
2014-09-04 11:45:40 -04:00
Mark Mentovai
52064fdd1b Add the MultiprocessExec test and its test.
TEST=util_test MultiprocessExec.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/531203002
2014-09-03 18:24:29 -04:00
Mark Mentovai
d492df404c Add CloseMultipleNowOrOnExec().
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/534703003
2014-09-02 16:21:46 -04:00
Mark Mentovai
1460c47d6a Add MachOImageSegmentReader.
This is part of a family of classes whose chief entry point is
MachOImageReader. MachOImageReader depends on this class to read
segments, so this one is landing first. The bulk of this class will be
tested as part of MachOImageReader.

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

Review URL: https://codereview.chromium.org/516983003
2014-09-02 15:50:11 -04:00
Mark Mentovai
af0cfd5a57 Add strnlen() wrapper and its test.
TEST=util_test strnlen.strnlen
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/514253002
2014-08-28 14:38:27 -04:00
Mark Mentovai
04842e0ca4 Add CheckedMachAddressRange and its test.
TEST=util_test CheckedMachAddressRange.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/513453002
2014-08-28 13:47:28 -04:00
Mark Mentovai
ff26ea6db9 Refactor MachMultiprocess into a Multiprocess base class without any
knowledge of Mach. MachMultiprocess builds on this new base class.

TEST=util_test MachMultiprocess.*:Multiprocess.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/506143002
2014-08-26 17:10:19 -04:00
Mark Mentovai
30589d87a9 Add ProcessTypes, its test, and many proctype definition files.
TEST=util_test ProcessTypes.DyldImagesSelf
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/501203002
2014-08-26 17:08:18 -04:00
Mark Mentovai
0cc86a24f9 Add ScopedForbidReturn and its test.
Use ScopedForbidReturn in ProcessReader::InitializeThreads().

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

Review URL: https://codereview.chromium.org/493203005
2014-08-26 16:50:08 -04:00
Mark Mentovai
8256f9fc23 Add most of ProcessReader and its test.
TEST=util_test ProcessReader.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/491963002
2014-08-25 17:51:09 -04:00
Mark Mentovai
d0fcfa42e4 Convert SimpleStringDictionary interface documentation to Doxygen.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/499643002
2014-08-22 17:09:03 -04:00
Mark Mentovai
4004e77ee9 Improvements for MachMultiprocess.
This adds a pipe going in the other direction (parent to child).
Initially, I didn’t think this was necessary, but it turned out to be
needed for ProcessReader. Having the child wait on a pipe read is the
easiest way to keep it alive until the parent is done with it.

This also tests MachMultiprocess::ChildPID() in
mach_multiprocess_test.cc.

Both of these fell out of https://codereview.chromium.org/491963002/.

TEST=util_test MachMultiprocess.MachMultiprocess
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/491363002
2014-08-22 14:00:10 -04:00
Mark Mentovai
b980a5984b Add SimpleStringDictionary and its test.
TEST=client_test SimpleStringDictionary*.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/489993002
2014-08-22 13:52:28 -04:00
Mark Mentovai
9168ba47ac Fix minidump_module_writer_test 32-bit x86 build.
time_t is a typedef for long on Mac OS X. In 32-bit x86 (ILP32), long is
a signed 32-bit quantity, and its range does not contain the range of
uint32_t, used to store times in time_t fashion in minidump files. A
cast is necessary to make these EXPECT_* macros do the right thing. This
is not a problem in x86_64 (LP64) where long is a signed 64-bit
quantity, which does contain the range of uint32_t.

clang’s error was “error: comparison of integers of different signs:
'const long' and 'const unsigned int' [-Werror,-Wsign-compare]”

BUG=
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/491023005
2014-08-20 18:32:06 -04:00
Mark Mentovai
be5d0ab39c Add CaptureContext and its test.
TEST=client_test CaptureContextMac.CaptureContext
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/493563002
2014-08-20 18:30:19 -04:00
Mark Mentovai
0b7f86a650 Add on_demand_service_tool.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/477353002
2014-08-20 15:18:55 -04:00
Mark Mentovai
bbe4d85935 Add MachMultiprocess and its test.
TEST=util_test MachMultiprocess.MachMultiprocess
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/482483002
2014-08-20 13:58:42 -04:00
Mark Mentovai
280c4345c5 Add BootstrapCheckIn and its test.
TEST=util_test Bootstrap.BootstrapCheckIn
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/478713003
2014-08-18 20:41:00 -07:00
Mark Mentovai
8fe32b7b9c Add mac_util, including MacOSXMinorVersion(), MacOSXVersion(), and
MacModelAndBoard(), along with their tests.

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

Review URL: https://codereview.chromium.org/473023002
2014-08-15 22:33:14 -07:00
Mark Mentovai
a70edb3b7f Add ServiceManagement*() and their tests.
TEST=util_test ServiceManagement
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/467923003
2014-08-15 22:30:24 -07:00
Mark Mentovai
d05166c26c Add CheckedRange<> and its test.
TEST=util_test CheckedRange
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/467113002
2014-08-15 10:22:37 -07:00
Mark Mentovai
6997418cd4 Add InRangeCast<> and its test.
InRangeCast<> is similar to base::saturated_cast<>, but it allows the
caller to specify the value to be returned in the event that the source
value can’t be converted to the destination data type without data loss.

TEST=util_test InRangeCast
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/467103002
2014-08-14 16:00:44 -07:00