1091 Commits

Author SHA1 Message Date
Mark Mentovai
0d8f67c1f5 Specify system framework dependencies properly in .gyp files.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/588073004
2014-09-22 14:06:06 -04:00
Mark Mentovai
4517d7c866 Update mini_chromium to get close$NOCANCEL, and update GYP to keep up.
Update mini_chromium to 313bd83d6d9d, picking up:

313bd83d6d9d Use close$NOCANCEL on Mac, as in Chrome r23369.
15a69caf735f Add some things from base/synchronization:
             ConditionVariable and Lock.

Also, udpate GYP to 46282cedf40f (r1977), picking up:

r1977 android: Add a way to override build system variables.
r1976 android: Don't emit useless info into generated makefiles.
r1975 Fix indentation for emacs and add missing keyword.
r1974 Changes ninja generator to only output empty names if not already
      output
r1973 Changes the ninja generator to output phony targets for
      uninteresting targets
r1972 Makes matching of build files work when absolute
r1971 Support for custom NM/readelf binaries in your toolchain.
r1970 android: Support host multilib builds.
r1969 Makes analyzer output names of all executable target types
r1968 android: Make buildbot able to use a custom manifest.
r1967 ninja win: don't expect pdb to be generated when
      GenerateDebugInformation: false
r1966 Makes the analyzer output the set of targets needing a build
r1965 Removes old way to specify files to look for
r1964 Provide a way to suppress implicit MIDL generation rules for
      actions
r1963 Style changes for analyzer __ -> _ and lots of single newlines to
      double newlines.
r1962 Changes for analyzer
r1961 Pull in relevant targets when using xcode-ninja
r1960 Guard against configurations without 'xcode_settings'
r1959 Updates analyzer to output to a file

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/590033002
2014-09-22 13:18:38 -04:00
Mark Mentovai
7b85d6d372 Multiprocess: wrap waitpid() in HANDLE_EINTR().
TEST=util_test Multiprocess.Multiprocess
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/592633002
2014-09-22 13:17:17 -04:00
Mark Mentovai
8eec7874fd MachMessageServer test: deal with short receive queue lengths on 10.10.
The queue length of a new receive port appears to be 2 on Mac OS X 10.10
DP8 14A361c. The value of MACH_PORT_QLIMIT_DEFAULT in the 10.10 SDK is
still 5, so a read of the kernel source should be interesting, if we
ever get to see it.

In the meantime, mach_port_set_attributes() can be used to set a
traditional queue length.

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

Review URL: https://codereview.chromium.org/584293003
2014-09-22 13:15:14 -04:00
Mark Mentovai
75988925f9 Revert "Drop 10.5 support: use ServiceManagement.framework directly."
This reverts commit 63fd3ae47d2513ef4390c3d8c0dde3fa95152480.

SMJobRemove() still performs a 1-second sleep() when its |wait|
parameter is true. Radar 18398683 is filed. In the mean time, the
launchd-based implementation of these functions does not have this
undesirable property.

The comments have been revised to not reflect operating systems before
Mac OS X 10.6. Comments describing bugs in earlier 10.10 seeds that have
since been fixed have been removed.

TEST=util_test Launchd.*:ServiceManagement.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/579083003
2014-09-22 13:11:40 -04:00
Mark Mentovai
32ed4b367d 10.6 runtime compatibility for MachOImageReader test.
Don’t require a __TEXT, __text section in every module. Some system
modules on 10.6, including ApplicationServices, do not have this
section. This change does not consider the runtime OS version.

Split from https://codereview.chromium.org/586123002/.

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

Review URL: https://codereview.chromium.org/586393003
2014-09-22 13:10:14 -04:00
Mark Mentovai
8e70083aa0 10.6 runtime compatibility for ProcessReader.
On 10.6, the main executable does not show up at index 0, but appears
elsewhere in the list. Modules are now scanned to ensure that the
MH_EXECUTE one is first in the list. This means that ProcessReader is
now responsible for creating a MachOImageReader object for each module,
rather than having its callers perform that task.

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

Review URL: https://codereview.chromium.org/586123002
2014-09-22 13:08:57 -04:00
Mark Mentovai
51e696ade9 ExceptionPorts::GetExceptionPorts(): don’t return ExceptionHandler
elements whose handler port would be MACH_PORT_NULL.

For most exception targets, *_get_exception_ports() will normally return
an exception port of MACH_PORT_NULL when no handler is registered.
However, as of Mac OS X 10.9, thread_get_exception_ports() will return
an empty list when no handler is registered for any exception type on a
thread.

Consequently, a caller would have to do additional processing to
determine whether a specific exception port is registered: an
unregistered port will either appear but have a handler port of
MACH_PORT_NULL, or it will not appear at all. This is confusing for
callers. The behaviors are unified, and when a handler port of
MACH_PORT_NULL is found, it will not be returned to the caller. This is
expected to be the simpler of the two possible behaviors for callers to
make use of.

The change in the kernel can be seen by comparing 10.8.5
xnu-2050.48.11/osfmk/kern/ipc_tt.c thread_get_exception_ports() to the
same function in 10.9.4 xnu-2422.110.17. The 10.9 version has a special
check for thread->exc_actions being NULL, which short-circuits the rest
of the function without returning any exception ports. In 10.8.5,
thread->exc_actions can never be NULL. This new check is only present
for thread targets, presumably because it’s very common for threads to
not have any exception ports set, and not having to initialize this data
is an optimization. Typical user-level tasks in Mac OS X always have at
least some exception ports set at the task level.

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

Review URL: https://codereview.chromium.org/584223002
2014-09-22 13:07:43 -04:00
Mark Mentovai
c93fcf8278 In MachMultiprocess-based tests, the child must wait for the parent to
finish.

It was possible for the child process to exit before the parent had a
chance to complete the pid_for_task() portion of its verification.

TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/586053002
2014-09-22 13:06:12 -04:00
Mark Mentovai
eeaf460f82 Add and use CheckedReadFD(), CheckedWriteFD(), and CheckedReadFDAtEOF().
TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/577333002
2014-09-18 15:03:49 -04:00
Mark Mentovai
12b67422f9 catch_exception_tool: Show the thread ID, state flavor, and state count.
For identity-carrying exceptions, the system-wide thread ID is shown.

For state-carrying exceptions, the flavor and old_state_count are shown.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/581153002
2014-09-18 13:55:03 -04:00
Mark Mentovai
4d35ffa80e Use more-specific typedefs for send rights to task, thread, and
exception handler ports.

task_t, thread_t, and exception_handler_t are typedefs for mach_port_t.
They are more descriptive than mach_port_t, and are already in use in
exc_server_variants.

TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/577293002
2014-09-18 13:53:43 -04:00
Mark Mentovai
1b61c90e7c Add exception_port_tool.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/575033004
2014-09-18 12:09:00 -04:00
Mark Mentovai
021c93c2e0 Use a more specific type, mach_exception_code_t, when possible.
mach_exception_data_type_t is more generic and is used for any element
of a codes[] array. For individual elements, the typedefs
mach_exception_code_t and mach_exception_subcode_t are available. Using
mach_exception_code_t when possible gives slightly more descriptive
code.

No functional change.

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

Review URL: https://codereview.chromium.org/585473003
2014-09-18 11:56:03 -04:00
Mark Mentovai
3f2ba965f5 Use ExcServerSuccessfulReturnValue() in one spot that was missed in
57eb311528f2.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/575243002
2014-09-17 18:09:05 -04:00
Mark Mentovai
b4fe6dfae0 Refactor EXC_CRASH code[0] processing into a new function,
ExcCrashRecoverOriginalException(), and use it where sensible.

TEST=util_test ExcVariantsTest.ExcCrashRecoverOriginalException …
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/566693003
2014-09-17 17:59:35 -04:00
Mark Mentovai
f764db270f Add catch_exception_tool.
catch_exception_tool catches Mach exceptions. Currenlty, it simply
prints a message with some information about each exception it handles.
In the future, it will be tied to the minidump generator as well.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/579443005
2014-09-17 15:40:09 -04:00
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