130 Commits

Author SHA1 Message Date
Mark Mentovai
525de2c35a Use exactly one of final, override, and virtual.
This change was generated mechanically by running:

  find . \
      \( -name \*.cc -or -name \*.mm -or -name \*.h \) \
      -and -not -path ./third_party/\* -and -not -path ./out/\* -exec \
      sed -i '' -E -e 's/virtual (.*) override final/\1 final/' {} +

  find . \
      \( -name \*.cc -or -name \*.mm -or -name \*.h \) \
      -and -not -path ./third_party/\* -and -not -path ./out/\* -exec \
      sed -i '' -E -e 's/virtual (.*) override/\1 override/' {} +

Additional changes were made manually based on:

  git grep -E '^ {3,}.*override[;{]'

http://google-styleguide.googlecode.com/svn/trunk/cppguide.html?showone=The__define_Guard#Inheritance

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

Review URL: https://codereview.chromium.org/654933002
2014-10-14 11:11:57 -04:00
Mark Mentovai
5d74f120fc Convert NULL to nullptr.
This change was generated mechanically by running:

  find . \( -name \*.cc -or -name \*.mm -or -name \*.h \) \
      -and -not -path ./third_party/\* -and -not -path ./out/\* \
      -exec sed -i '' -E -e 's/(^|[^_])NULL/\1nullptr/g' {} +

Further manual fix-ups were applied to remove casts of nullptr to other
pointer types where possible, to preserve the intentional use of NULL
(as a short form of MACH_PORT_NULL) in exception_port_tool, and to fix
80-column violations.

https://groups.google.com/a/chromium.org/d/topic/chromium-dev/4mijeJHzxLg/discussion

TEST=*_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/656703002
2014-10-14 11:10:45 -04:00
Mark Mentovai
d90ce10e1f ProcessReader: Fix comment about TASK_BASIC_INFO_64.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/650993003
2014-10-13 18:09:53 -04:00
Mark Mentovai
d7eb23c93e Add ExceptionSnapshotMac.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/650303002
2014-10-13 18:09:07 -04:00
Mark Mentovai
356a2db147 Add ThreadSnapshotMac.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/652003002
2014-10-13 18:06:43 -04:00
Mark Mentovai
2bd5e23ea4 Add ScopedTaskSuspend and its test.
This also introduces ScopedFcntlFlags.

TEST=util_test ScopedTaskSuspend.*:ScopedFcntlFlags.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/649693002
2014-10-13 18:05:21 -04:00
Mark Mentovai
8c7872e9e0 Use the correct null constants for Mach threads, tasks, and hosts.
This uses THREAD_NULL, TASK_NULL, and HOST_NULL in preference to
MACH_PORT_NULL and kMachPortNull. These constants are correctly-typed
(thread_t, task_t, and host_t) and result in more readable source code,
especially where thread and task parameters appear together as they do
in exc_*_variants.

TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/649713002
2014-10-13 12:59:21 -04:00
Mark Mentovai
8f23d3e475 util_test Clock.SleepNanoseconds: don’t set an upper bound for the
amount of time spent sleeping.

Even with the slop, this wound up being flaky, specifically on virtual
machines. And guess what our automated test infrastructure runs on?

TEST=util_test Clock.SleepNanoseconds
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/640373003
2014-10-10 14:00:43 -04:00
Mark Mentovai
7669b33010 ServiceManagement test: reduce test flake.
ExpectProcessIsRunning() goes to a lot of trouble to deal with the flaky
{CTL_KERN, KERN_PROCARGS2} API exposed by ProcessArgumentsForPID(). It
retries that call inside an inner loop until it succeeds, because it may
fail while a process is mid-exec(). Once it succeeds, it should use the
argv it obtained. Waiting for success and then attempting to call
ProcessArgumentsForPID() again to get argv can be flaky when the first
attempt succeeds because it’s pre-exec(), and the second one catches the
process in the middle of the exec() and fails.

The existence of the inner loop was intended to protect against this
problem, and the subsequent call outside of the inner loop appears to be
left behind from before the inner loop existed. It should have been
removed when the inner loop was added.

TEST=util_test ServiceManagement.SubmitRemoveJob
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/644473005
2014-10-09 17:26:50 -04:00
Mark Mentovai
c182be95a2 Rename minidump_test_util.* to minidump_file_writer_test_util.*.
This is in line with the other new minidump_*_test_util files, namely,
the “context” and “memory” ones. minidump_file_writer_test_util.*
provides VerifyMinidumpHeader(), which is used to validate the
MINIDUMP_HEADER at the beginning of a minidump file, as written by
MinidumpFileWriter.

TEST=minidump_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/643643003
2014-10-09 17:07:59 -04:00
Mark Mentovai
b8684a8a3c Add MinidumpThreadWriter, MinidumpThreadListWriter, and their test.
TEST=minidump_test MinidumpThreadWriter*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/637503006
2014-10-09 15:31:29 -04:00
Mark Mentovai
8d36e3581c minidump: Use variable names in tests that match parallel array indices.
Inspired by
https://codereview.chromium.org/637503006/diff/20001/minidump/minidump_thread_writer_test.cc#newcode409

TEST=minidump_test MinidumpMemoryWriter.*:MinidumpModuleWriter.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/643683003
2014-10-09 15:21:05 -04:00
Mark Mentovai
9d115e2391 Add MinidumpExceptionWriter and its test.
TEST=minidump_test MinidumpExceptionWriter*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/639573002
2014-10-09 15:13:13 -04:00
Mark Mentovai
22350bd676 In tests, use ASSERT_NO_FATAL_FAILURE() instead of checking
testing::Test::HasFatalFailure() after calling functions that could fail
fatally.

Inspired by
https://codereview.chromium.org/637503006/diff/20001/minidump/minidump_thread_writer_test.cc#newcode437

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

Review URL: https://codereview.chromium.org/640383002
2014-10-09 15:08:54 -04:00
Mark Mentovai
9c76cc60db Pull test utilities from MinidumpMemoryWriter’s test out into their own file.
These utilities are also useful to MinidumpThreadWriter’s test.

TEST=minidump_test MinidumpMemoryWriter.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/639513002
2014-10-07 17:58:43 -04:00
Mark Mentovai
b677bc4ec0 Simplify MinidumpModuleWriter’s module name requirement implementation.
TEST=minidump_test MinidumpModuleWriter*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/633163002
2014-10-07 17:31:43 -04:00
Mark Mentovai
40602fab1f Don’t use using directives (“using namespace”) in tools.
The contents of tools are moved into the namespace
crashpad::(anonymous namespace).

https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Namespaces

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/627273004
2014-10-07 17:30:09 -04:00
Mark Mentovai
6d1af6922f Don’t use using directives (“using namespace”) in tests.
The contents of tests are moved into the namespace
crashpad::test::(anonymous namespace).

https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Namespaces

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/635883002
2014-10-07 17:28:50 -04:00
Mark Mentovai
e74a272ab5 Add MinidumpContextWriter test.
TEST=minidump_test MinidumpContextWriter.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/628153004
2014-10-07 17:27:11 -04:00
Mark Mentovai
d0294f3bb8 Fix collision between 49c03db12965 and 56503fef865d.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/628403002
2014-10-06 19:02:57 -04:00
Mark Mentovai
49c03db129 Add snapshot/cpu_context_mac*, including InitializeCPUContextX86() and
InitializeCPUContextX86_64(), and their tests.

TEST=snapshot_test CPUContextMac.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/630513003
2014-10-06 18:46:04 -04:00
Mark Mentovai
56503fef86 Use the correct fxsave type for x86_64.
No functional change.

TEST=snapshot_test SystemSnapshotMacTest.CPUX86SupportsDAZ
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/623343004
2014-10-06 13:47:10 -04:00
Mark Mentovai
0ff46a4e60 Improve SystemSnapshotMac::TimeZone()’s computation of UTC offsets.
In locations that observe daylight saving time, this method now probes
different times to determine the offset when DST observance is (or is
not) in effect. This replaces a hard-coded one-hour offset, accounting
for Lord Howe Island, Australia, which is at a 30-minute offset.

TEST=snapshot_test SystemSnapshotMacTest.TimeZone
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/626093005
2014-10-03 18:40:09 -04:00
Mark Mentovai
6b451ea32a Add MemorySnapshotMac.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/623163004
2014-10-03 14:57:07 -04:00
Mark Mentovai
3f81599848 Add SystemSnapshotMac and its test.
TEST=snapshot_test SystemSnapshotMac.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/626013002
2014-10-03 14:55:54 -04:00
Mark Mentovai
bc8626f898 Use the correct type for ProcessReader::Thread::port.
It is a thread_t, not a task_t.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/627683002
2014-10-03 12:05:56 -04:00
Mark Mentovai
47f17926e4 util_test: specify libbsm link dependency properly.
7dda7b322881 accidentally moved the libbsm.dylib dependency from
util_test_lib to util_test. It is only used by
test/mac/mach_multiprocess.cc in util_test_lib.

Meanwhile, util_test should link against Foundation.framework, which is
used by three tests in util/mac: launchd_test.mm, mac_util_test.mm, and
service_management_test.mm.

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/612923004
2014-10-02 18:32:33 -04:00
Mark Mentovai
7b2e7efcc2 Add the Snapshot interface.
These are all of the abstract base classes used in the Snapshot series,
discussed in the thread at
https://groups.google.com/a/chromium.org/d/topic/crashpad-dev/4pACgjhIz-I.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/597673004
2014-10-02 17:09:37 -04:00
Mark Mentovai
ae7ad05090 int128_test.cc: Add missing #include after d198c50abe9b.
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/620793003
2014-10-01 16:56:56 -04:00
Scott Graham
d198c50abe Convert COMPILE_ASSERT to static_assert
(Perhaps I should have just left it in mini_chromium, but anyway.)

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

Review URL: https://codereview.chromium.org/615923004
2014-10-01 12:29:01 -07:00
Mark Mentovai
5906513e30 MinidumpContext: fix some problems in AMD64 (x86_64) context enums.
This fixes a sloppy compliation error: “Redefinition of enumerator
'kMinidumpContextX86Xstate'”. It also fixes CONTEXT_FULL, which should
contain floating-point registers but not segment registers unlike the
its 32-bit x86 equivalent.

Some comments are revised to provide better, um, context.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/620663002
2014-09-30 17:22:35 -04:00
Scott Graham
7dda7b3228 Superficial gyp changes to not immediately error out on Windows
Just guarding the usage of $SDKROOT so that ninja doesn't error out
on invalid $ escape on parsing.

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

Review URL: https://codereview.chromium.org/620553004
2014-09-30 13:11:04 -07:00
Mark Mentovai
8decf86db8 Add, test, and use clock utilities.
This includes ClockMonotonicNanoseconds() and SleepNanoseconds().

SleepNanoseconds() is like base::PlatformThread::Sleep(), but
PlatformThread is not in mini_chromium and I’m not keen on adding it
because I’m not sold on the interface. I’m not convinced Sleep() belongs
there, and I don’t want to have to bring all of base::Time* along for
the ride.

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

Review URL: https://codereview.chromium.org/597533002
2014-09-24 14:08:48 -04:00
Mark Mentovai
cb2288d174 Add MinidumpContext (X86 and AMD64 variants) and their writers.
These are fairly simple classes and it’s not valuable to test them
individually. They will be tested as part of MinidumpThreadWriter and
MinidumpExceptionWriter.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/593583004
2014-09-24 13:34:45 -04:00
Mark Mentovai
0d59a76735 Fix AMD64 APM revision number in a comment.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/597263002
2014-09-24 13:34:12 -04:00
Mark Mentovai
b7a1070335 Add Semaphore and its test, and use it where semaphores are needed.
TEST=util_test Semaphore.*:ProcessReader.*:ExceptionPorts.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/589243003
2014-09-24 13:32:31 -04:00
Erik Chen
7e5c11f59a Add a missing null pointer check.
R=mark@chromium.org

Review URL: https://codereview.chromium.org/593183003/
2014-09-23 14:54:41 -04:00
Mark Mentovai
fec869992f uint128_struct: address misunderstood review feedback.
TEST=util_test Int128.UInt128
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/590283002
2014-09-22 17:16:03 -04:00
Mark Mentovai
fee5d8aea9 Add uint128_struct and its test.
This will be used in the upcoming Minidump context structures.

This also updates mini_chromium to ba9b15f1b6a7 to pick up:

ba9b15f1b6a7 Make bit_cast available in C++11 mode.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/583283003
2014-09-22 15:46:00 -04:00
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