Граф коммитов

427 Коммитов

Автор SHA1 Сообщение Дата
Scott Graham b0889f61ee win: Retrieve module version/type information
Refactor version retrieval from system snapshot to use when
retrieving the module version information.

Follows https://codereview.chromium.org/1133203002/.

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

Review URL: https://codereview.chromium.org/1126273003
2015-05-14 17:43:49 -07:00
Scott Graham 5a21de6a1b win: Retrieve thread context for x64
Retrieve context and save to thread context. NtQueryInformationThread
is no longer required (right now?) because to retrieve the CONTEXT, the
thread needs to be Suspend/ResumeThread'd anyway, and the return value
of SuspendThread is the previous SuspendCount.

I haven't handle the x86 case yet -- that would ideally be via
Wow64GetThreadContext (I think) but unfortunately that's Vista+, so I'll
likely need to to a bit of fiddling to get that sorted out. (It's actually
likely going to be NtQueryInformationThread again, but one thing at a
time for now.)

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

Review URL: https://codereview.chromium.org/1133203002
2015-05-14 17:37:02 -07:00
Erik Wright f357afc43e Move thread from test/ to util/thread/.
BUG=
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1134943003
2015-05-13 14:05:57 -04:00
Scott Graham 658cd3e1a7 win: Add thread snapshot and memory snapshot for stacks
The next big piece of functionality in snapshot. There's a bit more
grubbing around in the NT internals than would be nice, and it has
made me start to question the value avoiding MinidumpWriteDump. But
this seems to extract most of the data we need (I haven't pulled
the cpu context yet, but I hope that won't be too hard.)

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

Review URL: https://codereview.chromium.org/1131473005
2015-05-11 13:29:52 -07:00
Mark Mentovai 00c42ae7bd file_io_test: Use NoBarrier_Load() instead of Release_Load().
BUG=chromium:420970
TEST=util_test FileIO.*Exclusive*
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1130403002
2015-05-08 14:15:11 -04:00
Mark Mentovai e8e19ac29d util/win/time.cc: Add and use FiletimeToMicroseconds().
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1137503002
2015-05-07 15:08:02 -04:00
Mark Mentovai 7d454ae713 ThreadLogMessages: don’t check TLS slot initialization return value.
This updates Crashpad for https://codereview.chromium.org/1124493002/.

The mini_chromium update includes:

98264cf63f22 ThreadLocalStorage: remove the return value from slot
             initialization

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1129793004
2015-05-06 17:04:44 -04:00
Scott Graham 06db728457 win: Add support for CPUTimes and StartTime to snapshot
Follows https://codereview.chromium.org/1120383003/.

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

Review URL: https://codereview.chromium.org/1119393003
2015-05-06 11:13:44 -07:00
Scott Graham ff52791faf Get generate_dump compiling on Windows
Sort of works in that the process is opened, modules retrieved, etc.
but eventually CHECKs due to missing functionality in snapshot.

Follows https://codereview.chromium.org/1119783005/.

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

Review URL: https://codereview.chromium.org/1120383003
2015-05-06 11:09:31 -07:00
Scott Graham d8713a576b win: Don't log wide strings via path.value().c_str()
At the moment the LOGs print something unhelpful like:

[19912:21888:20150501,145958.098:ERROR file_io_win.cc:122] CreateFile 000000C9F8FDE7F0: The system cannot find the file specified.  (0x2)

(where the hex string ought to be a file name)

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

Review URL: https://codereview.chromium.org/1117393002
2015-05-01 15:49:35 -07:00
Scott Graham 69d135acda win: make CrashpadInfo retrievable
The main goal was to get the beginnings of module iteration and retrieval
of CrashpadInfo in snapshot. The main change for that is to move
crashpad_info_client_options[_test] down out of mac/.

This also requires adding some of the supporting code of snapshot in
ProcessReaderWin, ProcessSnapshotWin, and ModuleSnapshotWin. These are
partially copied from Mac or stubbed out with lots of TODO annotations.
This is a bit unfortunate, but seemed like the most productive way to
make progress incrementally. That is, it's mostly placeholder at the
moment, but hopefully has the right shape for things to come.

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

Review URL: https://codereview.chromium.org/1052813002
2015-05-01 13:48:23 -07:00
Erik Chen 3d216f5516 mac: Suppress partial availability warnings.
The warnings are emitted when a translation unit attempts to reference
a function whose availability is newer than the deployment target.

BUG=471823
R=mark@chromium.org

Review URL: https://codereview.chromium.org/1109273002

Patch from Erik Chen <erikchen@chromium.org>.
2015-05-01 14:16:58 -04:00
Scott Graham 8272a4cefe Use LockFile/UnlockFile for Settings to port to Windows
Adds LoggingOpenFileForReadAndWrite, LoggingTruncateFile, and UUID::GenerateFromSystem
in support.

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

Review URL: https://codereview.chromium.org/999953002
2015-04-20 14:21:48 -07:00
Mark Mentovai 1baff4ff92 Accept non-fatal resource exceptions without generating crash reports.
This adds IsExceptionNonfatalResource() and its test, and uses it in
crashpad_handler. When non-fatal resource exceptions are encountered, no
crash report is generated. crashpad_handler swallows these exceptions.
Alternatively, it could allow them to be sent to the system’s host-level
resource exception handler, normally com.apple.ReportCrash.root, which
would allow them to be processed in the same way as when Crashpad is not
in use. I’m not sure which option is better. I chose to swallow them
because there doesn’t appear to be much value in letting
com.apple.ReportCrash.root and spindump look at them.

This also moves ExcCrashRecoverOriginalException() to the new file as a
sibling of IsExceptionNonfatalResource(). This provides better
organization.

BUG=crashpad:35, chromium:474163, chromium:474326
TEST=crashpad_util_test ExceptionTypes.IsExceptionNonfatalResource
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1066243002
2015-04-08 17:46:09 -04:00
Mark Mentovai 40b1d7cb1d Add ConstThreadState to mach_extensions.h and use it everywhere.
TEST=everything
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1058523002
2015-04-02 15:28:28 -04:00
Mark Mentovai 352160906b Add ExcServerCopyState().
ExcServerCopyState() properly sets the new_state and new_state_count
out-parameters for exception handler routines that may deal with
state-carrying exceptions.

This used to exist inline in catch_exception_tool, but that
implementation had a bug caught by the new test.

TEST=crashpad_util_test ExcServerVariants.ExcServerCopyState and others
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1049023003
2015-04-01 12:16:22 -04:00
Mark Mentovai 809ea8158d test: Move util/test to its own top-level directory, test.
After 9e79ea1da7, it no longer makes sense for crashpad_util_test_lib
to “hide” in util/util_test.gyp. All of util/test is moved to its own
top-level directory, test, which all other test code is allowed to
depend on. test, too, is allowed to depend on all other non-test code.

In a future change, when crashpad_util_test_lib gains a dependency on
crashpad_client, it won’t look so weird for something in util (even
though it’s in util/test) to depend on something in client, because the
thing that needs to depend on client will live in test, not util.

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

Review URL: https://codereview.chromium.org/1051533002
2015-03-31 17:44:14 -04:00
Mark Mentovai 9e79ea1da7 Split *_test.gyp from *.gyp.
In a future change, crashpad_util_test_lib will gain a dependency on
crashpad_client. This would violate GYP’s prohibition on circular
dependencies between .gyp files, although there would be no circular
relationship between the targets themselves. To overcome this problem,
all test-related targets are moved into their own first-class .gyp
files.

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

Review URL: https://codereview.chromium.org/1045173004
2015-03-31 17:06:28 -04:00
Mark Mentovai d5ddd14ee1 Improve map insertion operations.
Add MapInsertOrReplace<>() to insert a key-value pair into a map if the
key is not already present, or replace the existing value for key if the
key is present. The original value can optionally be returned to the
caller in this case.

Map insertions now use either MapInsertOrReplace<>() or
std::map<>::insert() directly.

Use MapInsertOrReplace<>() when the map should be updated to contain a
mapping from a key to a value regardless of whether the key is already
present.

Use std::map<>::insert() to insert a mapping from a key to a value
without replacing any existing mapping from a key, if present. If it is
important to know whether an existing mapping from a key was present,
use the returned std::pair<>.second. If it is important to know the
existing value, use the returned std::pair<>.first->second.

This change has a slight positive impact on performance.

TEST=crashpad_util_test MapInsert.MapInsertOrReplace and others
BUG=
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1044273002
2015-03-31 14:29:32 -04:00
Mark Mentovai 2e64c73330 Fix ThreadLogMessages’ test.
The test wasn’t strictly broken, but an <= written where a < was
intended caused some threads to log more messages than intended.

BUG=crashpad:26
TEST=crashpad_util_test ThreadLogMessages.Multithreaded
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1047813002
2015-03-30 17:58:12 -04:00
Mark Mentovai e95224bbe7 Add ThreadLogMessages and its test.
This updates mini_chromium to 91ea4908ffd74d9c886bd2f8ccbfae6d31c499af.
The last five commits listed here are required to support this change.
The mini_chromium update includes:

c1745a924c5c Fix paths to atomicops files in base.gyp from 2f02dcc73536
108e9247189c Add #include of <unistd.h> to close_nocancel.cc
6e4f98a9edf8 Add logging::SetLogMessageHandler()
4063fcb8f460 Add base::ThreadLocalStorage
4870f18a33a6 Add base::LazyInstance
0d31b1f3a289 Fix base/memory/aligned_memory.h for MSVC
91ea4908ffd7 base/logging.h: DCHECK() should always reference its
             condition

BUG=crashpad:26
TEST=crashpad_util_test ThreadLogMessages.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1041643003
2015-03-30 14:51:34 -04:00
Scott Graham 0c704745dd Followup to https://codereview.chromium.org/1001673002/.
- Add parens around conditional operator expression
- Fix Thread::Join ASSERT.

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

Review URL: https://codereview.chromium.org/1022203002
2015-03-23 08:15:53 -07:00
Scott Graham 79ae055e50 Add Locking calls to file_io.h plus implementations and test
Towards removing use of open() with O_EXLOCK/O_SHLOCK in code
used on non-BSD.

Adds simple Thread abstraction to util/test.

Includes mini_chromium roll with:
56dd2883170d0df0ec89af0e7862af3f9aaa9be6 Fix import of atomicops for Windows
886592fd6677615c54c4156bb2f2edb5d547ba6c Export SystemErrorCodeToString

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

Review URL: https://codereview.chromium.org/1001673002
2015-03-20 15:45:54 -07:00
Mark Mentovai e7b80a52f5 win: Add UUID::InitializeFromSystemUUID().
The new call is also used in
CrashReportDatabaseWin::PrepareNewCrashReport(). Previously, that method
used the UUID::InitializeFromBytes() constructor. That actually caused
various fields of the UUID to be byte-swapped so that the ::UUID and
crashpad::UUID would be different UUIDs. Although a UUID is mostly
random, the version field in data_3 is used as a namespace and should be
4 for random UUIDs, and this was not the case under swapping.

TEST=crashpad_util_test UUID.FromSystem
BUG=crashpad:1
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1004913004
2015-03-13 13:53:38 -04:00
Mark Mentovai 29cdc74579 CrashpadClient::StartHandler(): accept database, url, and annotations arguments.
This makes it easier for clients to start the Crashpad handler, instead
of requiring them to know how to construct arguments for the handler
themselves. Note in the TEST that -a is no longer required.

TEST=run_with_crashpad --handler crashpad_handler \
         --database=/tmp/crashpad_db \
         --url=https://clients2.google.com/cr/staging_report \
         --annotation=prod=crashpad \
         --annotation=ver=0.7.0 \
         crashy_program

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1001993002
2015-03-12 14:28:19 -04:00
Mark Mentovai 5f19d639e1 handler/mac: Log a warning when an exception message has a suspicious
origin.

This adds AuditPIDFromMachMessageTrailer() to get the process ID of a
Mach message’s sender. Exception messages are considered suspicious when
not sent by the kernel or the exception process.

TEST=crashpad_util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1001943002
2015-03-12 14:00:38 -04:00
Robert Sesek 995e762a45 Use new ScopedGeneric move support.
BUG=crashpad:14
R=mark@chromium.org

Review URL: https://codereview.chromium.org/1001713002
2015-03-12 09:47:55 -04:00
Mark Mentovai 9b7ff0ea5a Allow exception forwarding to the system’s native crash reporter to be
disabled.

ClientInfo::set_system_crash_reporter_forwarding() can be used to
disable forwarding. The first module that is found with a non-default
value in this field will dictate whether forwarding is enabled or
disabled. It is possible to enable or disable reporting with this call,
as well as reset it to default, which will allow later modules a chance
to influence the behavior.

ClientInfo::set_crashpad_handler_behavior() is also provided, which can
be used to disable Crashpad’s handling of the exception. Most users
should not call this, but should use Settings::SetUploadsEnabled()
instead.

TEST=crashpad_snapshot_test \
         CrashpadInfoClientOptions.*:MachOImageReader.Self_DyldImages; \
     run_with_crashpad --handler crashpad_handler \
         -a --database=/tmp/crashpad_db \
         -a --url=https://clients2.google.com/cr/staging_report \
         -a --annotation=prod=crashpad \
         -a --annotation=ver=0.7.0 \
         crashy_program

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/997713002
2015-03-11 17:07:11 -04:00
Robert Sesek f0ee5f0efe Remove NSInputStream used in HTTPTransportMac and use a CFReadStream instead.
NSInputStream requires overriding and implementing private methods in order to
use it with NSURLConnection [1]. It is cleaner to use the private but stable
and open source CFStreamAbstract.h header from CF-Lite to implement a
CFReadStream. Since CFReadStream is toll-free bridged to NSInputStream, the
remainder of the HTTPTransport code can remain unchanged.

[1] http://lists.apple.com/archives/macnetworkprog/2007/May/msg00055.html

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

Review URL: https://codereview.chromium.org/993413003
2015-03-11 16:59:59 -04:00
Mark Mentovai b8cbfff0d3 test::Multiprocess: exit cleanly from children with _exit().
Child exits were using exit(), which caused crashes on 10.10 for
Multiprocess-based tests that ran after HTTPTransport tests. The crashes
occurred while running exit-time destructors. exit() was never correct
in this situation, this should have used _exit() all along.

TEST=crashpad_util_test
BUG=crashpad:17
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1000653002
2015-03-11 13:59:46 -04:00
Mark Mentovai c4a8b32495 Fix ExceptionPorts.TaskAndThreadExceptionPorts under better compiler
optimization.

Newer versions of clang (in this case, trunk r231191) can see through
the pointless division by zero and optimize it away. This caused the
test to hang in release mode.

A 50ms timeout is added to each test to transform the hang into a
failure. The test was split into 12 tests to provide better feedback and
control.

To fix the bug, the division by zero is replaced by __builtin_trap().

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

Review URL: https://codereview.chromium.org/993613004
2015-03-10 11:16:24 -04:00
Scott Graham ab6cdb6bc1 win: Support reading process info cross-bitness
This only works 64->64, 32->32, and 64->32. We shouldn't have a
need for 32->64. It will also currently not work if the crash service
is running on Wow64 itself (that is, 32->32, but on an x64 OS). We
should also be able to avoid needing that.

Primarily, this change templatizes the winternl.h process structure
types on word size, so the PEB can be read in a foreign bitsize process.

This also happens to resolve using void* as pointer values into foreign
processes, as they're now all either DWORD or DWORD64 depending on which
traits class is used.

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

Review URL: https://codereview.chromium.org/981393003
2015-03-09 16:37:43 -07:00
Mark Mentovai 26804a0be1 Add ASSERT_DEATH_CHECK() to do ASSERT_DEATH() of CHECK() failures.
Likewise for EXPECT_DEATH_CHECK() and EXPECT_DEATH().

In the in-Chromium build configured for official builds in Release mode,
CHECK() throws away its condition string and stream parameters without
ever printing them, although it still evaluates the condition and
triggers death appropriately. {ASSERT,EXPECT}_DEATH(statement, regex)
will not work correctly for any regex that attempts to match what
CHECK() prints. In these build configurations,
{ASSERT,EXPECT}_DEATH_CHECK() use a match-all regex (""). In other build
configurations, they transparently wrap {ASSERT,EXPECT}_DEATH().

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

Review URL: https://codereview.chromium.org/992693003
2015-03-09 18:02:14 -04:00
Mark Mentovai b665a0db07 Allow Crashpad to build in the Chromium tree.
When building in the Chromium tree, this swaps out Crashpad’s copies of
mini_chromium, gtest, and gmock for the equivalents provided by
Chromium. A GYP variable, crashpad_in_chromium, is used to determine the
behavior.

gclient doesn’t sync sub-DEPS, so when doing an in-Chromium build,
Crashpad’s copies of mini_chromium, gtest, and gmock are not available.

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

Review URL: https://codereview.chromium.org/986033002
2015-03-09 15:25:42 -04:00
Mark Mentovai 32a9d410ca Locate test data more robustly.
Test code that requires test data should call Paths::TestDataRoot() to
obtain the test data root. This will use the CRASHPAD_TEST_DATA_ROOT
environment variable if set. Otherwise, it will look for test data at
known locations relative to the executable path. If the test data is not
found in any of these locations, it falls back to using the working
directory, the same as the current behavior.

BUG=crashpad:4
TEST=crashpad_util_test Paths.TestDataRoot and others
R=rsesek@chromium.org, scottmg@chromium.org

Review URL: https://codereview.chromium.org/992503002
2015-03-09 15:13:13 -04:00
Mark Mentovai b256df0534 Set target_name on many targets to use a crashpad_ prefix.
In Chromium, many targets are built, sharing a single output directory.
Collisions are likely. When integrating Crashpad into Chromium, the
ui/snapshot library and Crashpad’s snapshot library were found to
conflict.

This change gives most Crashpad targets a “crashpad_” prefix to avoid
conflicts. All library and test targets are given a target_name with
this prefix. Existing tools are not likely to conflict with anything
else and are not given a prefix.

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

Review URL: https://codereview.chromium.org/990553003
2015-03-08 16:25:34 -04:00
Mark Mentovai b770a51f2b Set the chromium_code GYP variable.
When building in the Chromium tree, chromium_code is necessary to apply
Chromium’s build/filename_rules.gypi. Crashpad’s build depends on these
rules. chromium_code also enables a high warning level, which is
desirable for Crashpad.

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

Review URL: https://codereview.chromium.org/986873002
2015-03-08 15:17:22 -04:00
Mark Mentovai 55861e88ce util/mach/exc_server_variants.cc: Remove unused typedefs.
BUG=crashpad:12
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/989023002
2015-03-08 15:15:53 -04:00
Mark Mentovai 88690cece3 util/mac: Provide wrappers for <launch.h> functions deprecated in 10.10.
A few stragglers were missing from bc401f6aac. I really don’t know how
that’s possible, since I thought I was testing it with the correct SDK.
I guess I wasn’t.

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

Review URL: https://codereview.chromium.org/978883007
2015-03-08 15:12:40 -04:00
Mark Mentovai bc401f6aac util/mac: Provide wrappers for <launch.h> functions deprecated in 10.10.
The 10.10 SDK deprecates <launch.h>, but this file is still useful and
is used by util/mac/launchd.* and util/mac/service_management.*. Wrap
the <launch.h> functions in versions that ignore the deprecation
warnings.

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

Review URL: https://codereview.chromium.org/989733003
2015-03-06 22:27:25 -05:00
Scott Graham 07fcf63c21 win: fixes for Windows x64
Mostly size_t <-> unsigned int warnings, but I also had a mistake in
PROCESS_BASIC_INFORMATION, the pids are 32-on-32 and 64-on-64.

The Windows build is still x86 until https://codereview.chromium.org/981333002/.
I don't think I'll bother maintaining the x86 build for now, though we will probably
need it for x86 OSs in the future. It should be straightforward to revive it once we
need it, and have bots to support it.

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

Review URL: https://codereview.chromium.org/983103004
2015-03-06 16:05:34 -08:00
Mark Mentovai 79177046d3 Mac 10.6 SDK compatibility.
A couple of the problems related to not having a C++11 library:

 - You can’t put const elements into a std::vector<>, so
   CrashReportDatabase::GetPendingReports() and
   CrashReportDatabase::GetCompletedReports() need to change. There was
   no data-safety benefit to const elements.
 - std::string::pop_back() does not exist, another mechanism must be
   used to trim strings in BreakpadHTTPFormParametersFromMinidump().

One relates to a feature that does not exist in 10.6:

 - The O_CLOEXEC flag to open() was introduced in 10.7. Although it
   would be possible to use fcntl(..., F_SETFD, FD_CLOEXEC) on 10.6, the
   O_CLOEXEC behavior is just removed from
   CrashReportDatabaseMac::ObtainReportLock(), in line with other open()
   calls in Crashpad.

And one was a real bug:

 - #define __STDC_FORMAT_MACROS before #including <inttypes.h> to get
   format macros like SCNx32, used in UUID::InitializeFromString().

TEST=* (gyp_crashpad.py -Dmac_sdk=10.6 -Dmac_deployment_target=10.6)
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/987693004
2015-03-06 18:43:28 -05:00
Scott Graham bed7a543c0 win: Add implementation of ProcessInfo
This is as a precursor to ProcessReader. Some basic functionality
is included for now, with more to be added later as necessary.

The PEB code is pretty icky -- walking the doubly-linked list
in the target's address space is cumbersome. The alternative
is to use EnumProcessModules. That would work but:
1) needs different APIs for XP and Vista 64+
2) retrieves modules in memory-location order, rather than
initialization order. I felt retrieving them in initialization order
might be useful when detecting third party DLL injections. In the
end, we may want to make both orders available.

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

Review URL: https://codereview.chromium.org/977003003
2015-03-05 22:07:38 -08:00
Mark Mentovai ae1ccf621b handler: Add report upload.
The handler is now capable of uploading crash reports from the database.
At present, only one upload attempt is made, and the report will be
moved to “completed” in the database after the attempt, regardless of
whether it succeeded or failed.

The handler also has support to push annotations from its command line
into the process annotations map of each crash report it writes. This is
intended to set basic information about each crash report, such as the
product ID and version. Each potentially crashy process can’t be relied
on to maintain this information on their own.

With this change, Crashpad is now 100% capable of running a handler that
maintains a database and uploads crash reports to a Breakpad-type server
such that Breakpad properly interprets the reports. This is all possible
from the command line.

TEST=run_with_crashpad --handler crashpad_handler \
         -a --database=/tmp/crashpad_db \
         -a --url=https://clients2.google.com/cr/staging_report \
         -a --annotation=prod=crashpad \
         -a --annotation=ver=0.6.0 \
         crashy_program

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/982613002
2015-03-05 15:40:47 -05:00
Scott Graham 583314184a win: add equivalent of gettimeofday
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/940793002
2015-02-20 11:35:04 -08:00
Mark Mentovai 89ca2fbba7 Add FileReaderInterface::ReadExactly() and
FileSeekerInterface::SeekSet().

These methods perform common error checking.

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

Review URL: https://codereview.chromium.org/913223008
2015-02-18 18:22:39 -05:00
Mark Mentovai 583233cf78 Add FileReaderInterface. Move StringFileWriter to StringFile and
implement the new interface.

The upcoming minidump reader will get minidump data from a
FileReaderInterface. For ease of testing, a string-based implementation
is provided. There wasn’t a good reason to have a separate
StringFileReader and StringFileWriter, so I combined them into a single
StringFile.

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

Review URL: https://codereview.chromium.org/936153002
2015-02-18 14:15:38 -05:00
Scott Graham bd77b3034f win: Implementation of CrashReportDatabase for Windows (for C++ Windows readability review)
Original CL (review, misc support code changes) at https://codereview.chromium.org/867363003/.

Crashpad is a component of Chrome used for capturing crashes in the field and uploading them to crash/ for analysis: https://code.google.com/p/crashpad/.

BUG=crashpad:1, b/19354950
R=mark@chromium.org, pkasting@chromium.org

Review URL: https://codereview.chromium.org/913273002
2015-02-17 12:05:29 -08:00
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
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
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
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
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 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
Mark Mentovai 86588c5526 MachMessageServer: scribble over memory allocations in debug mode.
This exposed a bug in the ExcClientVariants test, which was expecting
the memory used for new_state to be initialized with zeroes. In reality,
no guarantee of initialization is made. MIG “out” parameters are
strictly “out” and may contain garbage at function entry.

TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/779633004
2014-12-03 18:24:27 -05:00
Mark Mentovai 9f520e3fbf MachMessageServer: add some DCHECKs.
These DCHECKs make sure that buffer sizes and message sizes are as
expected.

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

Review URL: https://codereview.chromium.org/781593003
2014-12-03 18:21:00 -05:00
Mark Mentovai ef0b7cf6d5 Rewrite MachMessageServer::Run().
This method is now much more straightforward, easy to understand, and
maintainable.

There are no externally-visible changes.

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

Review URL: https://codereview.chromium.org/723853003
2014-12-03 16:45:48 -05:00
Mark Mentovai 8593b1aa55 ChildPortHandshake: 10.6 fix.
The F_SETNOSIGPIPE fcntl() command is not available on 10.6. Use
socketpair() instead of pipe(), so that the SO_NOSIGPIPE socket option
can be used.

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

Review URL: https://codereview.chromium.org/777573002
2014-12-03 13:42:06 -05:00
Mark Mentovai eee9de7361 MachMessageWithDeadline(): 10.6 SDK fix.
In the pre-C++11 10.6 SDK, std::numeric_limits<>::max() is not marked
constexpr and cannot be used to initialize enum elements.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/771183003
2014-12-02 18:37:31 -05:00
Mark Mentovai dce497446e Add MachMessageWithDeadline() and supporting characters.
MachMessageWithDeadline() is a mach_msg() wrapper that deals with
deadlines instead of timeouts. It is a slight simplification of the
mach_msg() interface because the deadline parameter implies the timeout
option bits, and because the caller does not need to specify send_size
during sends as the message itself already carries this information.

TEST=util_test MachMessage.MachMessageDeadlineFromTimeout
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/773943002
2014-12-02 17:09:08 -05:00
Mark Mentovai c0d5d87785 Move mach_message_util.* to mach_message.*.
A subsequent change will add MachMessageWithDeadline(), a mach_msg()
wrapper. Conceptually, it makes sense to include that function in this
file family. Since this file family now contains a mach_msg() wrapper,
it makes sense to rename it mach_message and lose the _util suffix.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/772133004
2014-12-02 17:02:32 -05:00
Mark Mentovai 49f170e633 MachMessageServer: handle allocations more reasonably.
MachMessageServer was wasteful with allocations for request and reply
messages. It allocated new memory for each request receive and for each
reply send, and if it needed to resize an allocation for a request, it
would maintain two request allocations simultaneously. The new behavior
allocates memory for a new request only if it needs a different size
than for the previous request, and it never maintains two request
allocations simultaneously. Memory for a reply is allocated once per
method invocation and maintained, since this never needs to be resized.

One pass of the loop is now guaranteed, even if a caller specifies a
very small timeout that expires before attempting to receive a message.

An infinite looping bug that could occur when ignoring large messages
has also been fixed.

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

Review URL: https://codereview.chromium.org/759023004
2014-12-01 16:13:40 -05:00
Mark Mentovai 50726ac8d0 Undo a685942342.
The buffer sizing logic was correct to start with. I don’t know why I
misread it. It should say “if this would resize to receive a large
message, use the entire allocation rounded up to full page size,
otherwise, only use the space expected for a message.”

TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/760573003
2014-12-01 16:12:10 -05:00
Mark Mentovai 0437bc53b6 Pass Mach message trailers to server handler functions.
TEST=util_test ChildPortServer.*:ExcServerVariants.*:MachMessageUtil.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/755313004
2014-12-01 16:06:56 -05:00
Mark Mentovai de5a6cdd6f ExcServerVariants test: use constructors to initialize test structures.
Previously, test structures were initialized with InitializeForTesting()
methods. A related code review suggested making these into constructors.

https://codereview.chromium.org/754123002/diff/40001/util/mach/child_port_server_test.cc#newcode53

This also cleans up the definitions of some structures that can simply
inherit from existing structures defined in system headers.

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

Review URL: https://codereview.chromium.org/757113002
2014-11-25 15:06:42 -05:00
Mark Mentovai d14fa0961a ExcServerVariants test: make the mock test port dispositions reflect reality.
These port dispositions were naïvely taken from excUser.c and
mach_excUser.c, but the local and remote portions were not swapped as
they would be upon receipt in a server. This swaps them to match how
they’d be visible in a server, and uses the port disposition name
aliases expected to be used in servers: MACH_MSG_TYPE_PORT_* instead of
MACH_MSG_TYPE_{MAKE,COPY,MOVE}_*.

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

Review URL: https://codereview.chromium.org/755323002
2014-11-25 15:05:29 -05:00
Mark Mentovai a685942342 MachMessageServer: invert the request buffer allocation logic.
The existing implementation used the same logic as is found in
mach_msg_server(), but that logic seems incorrect. When the caller wants
to retry a mach_msg() receive of a too-large message that returns
MACH_RCV_TOO_LARGE, there’s no harm in attempting the receive with a
larger buffer initially. On the other hand, if the caller does not want
to retry such mach_msg() receive attempts, it’s an indication that the
caller is expecting to be intolerant of too-large messages, and there’s
no need to attempt the receive with a buffer any larger than requested.

TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/753363003
2014-11-25 15:04:31 -05:00
Mark Mentovai 306625dac4 MachMessageServer: don’t deal with MACH_SEND_TRAILER.
As documented, MACH_SEND_TRAILER would allow a sender to provide its own
message trailer instead of having the kernel append its own
kernel-generated trailer. This is a Mach feature that supports a network
of multiple Mach hosts, but even in that environment, the option is
restricted to use by privileged callers. In reality, MACH_SEND_TRAILER
has never been implemented in OS X.

The system’s mach_msg_server() family does consider the value of
MACH_SEND_TRAILER, but this is pointless. Any purported trailer set by a
server function would be ignored.

Maintaining this code gives the illusion that it’s functional, so it’s
being removed.

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

Review URL: https://codereview.chromium.org/736493007
2014-11-25 15:00:13 -05:00
Mark Mentovai 85c9318597 Add ChildPortHandshake and its test.
ChildPortHandshake is the most generic system yet to allow child
processes to provide their parents with Mach rights. These are
ordinarily expected to be send rights to the children’s own task ports,
or send rights to servers that the children hold receive rights to.

This updates DEPS to pull mini_chromium 1d3523dbda93, which includes
base::mac::ScopedMachPortSet.

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

Review URL: https://codereview.chromium.org/756603003
2014-11-25 14:56:05 -05:00
Mark Mentovai 79b4434c81 Add a ReceiveLarge parameter to MachMessageServer::Run().
Previously, MachMessageServer::Run() only provided two strategies for
dealing with large messages, indicated by mach_msg() returning
MACH_RCV_TOO_LARGE: the receive buffer could be reallocated and the
message received, or the entire function could return MACH_RCV_TOO_LARGE
to the caller. There are situations where an intermediate behavior might
be desirable. This intermediate behavior would allow the function to
continue waiting for another message without returning an error to the
caller or attempting to receive the large message. This is desirable
when dealing with fixed-sized messages and a receiver that might be sent
messages by unknown, possibly-malicious callers. This can happen when
the corresponding send right is published with the bootstrap server, for
example.

Existing users continue to request their existing behavior, typically
receiving an error when encountering a large message.
catch_exception_tool will use the new “ignore” behavior when running in
persistent mode.

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

Review URL: https://codereview.chromium.org/756803002
2014-11-25 14:48:44 -05:00
Mark Mentovai 04aaa36026 Add ChildPortServer, a MachMessageServer::Interface implementation for
the child_port subsystem.

Common routines shared with the ExcServer family of classes have been
moved to a new file, where they can be shared between different
MachMessageServer::Interface implementations.

TEST=util_test ChildPortServer.*:MachMessageUtil.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/754123002
2014-11-25 14:29:46 -05:00
Mark Mentovai af1c7eb098 Add Logging{Read,Write}FD() and CheckedCloseFD().
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/756653004
2014-11-24 15:49:33 -05:00
Mark Mentovai e9482a704d Add the child_port Mach subsystem.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/752243002
2014-11-24 15:48:10 -05:00
Mark Mentovai e4551e709c exc_server_variants: use DISALLOW_COPY_AND_ASSIGN.
TEST=util_test ExcServerVariants.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/753563003
2014-11-21 14:29:42 -05:00
Mark Mentovai d5b28d6236 Add comments in DropPrivileges() explaining the kernel bug further.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/725303003
2014-11-17 12:24:38 -05:00
Mark Mentovai 49d7fdba9a Add DropPrivileges().
DropPrivileges() is used in exception_port_tool, so that when it is
installed as a setuid executable, it only uses elevated privileges to
obtain a task port for its -p option, and then relinquishes those
privileges.

It is difficult to provide a test for this function, because it must be
running setuid or setgid in order to do anything interesting. However,
the function contains its own CHECKs to verify that it behaves properly.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/727053002
2014-11-14 18:44:19 -05:00
Mark Mentovai de3c46c6b3 Add TaskForPID().
This also transitions exception_port_tool to use TaskForPID(), so that
it can be safely used as a setuid executable without giving permission
to operate on any process on the system.

It is difficult to provide a test for this function, because it must be
running setuid root in order to do anything interesting.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/728973002
2014-11-14 17:56:17 -05:00
Mark Mentovai 6812cec67e Move some parts of ProcessReader (in snapshot) to ProcessInfo (in util).
Also, move ProcessArgumentsForPID() into ProcessInfo.

This change prepares for a TaskForPID() implementation that’s capable of
operating correctly in a setuid root executable. TaskForPID() belongs in
util/mach, but for its permission checks, it must access some process
properties that were previously fetched by ProcessReader in snapshot.
util can’t depend on snapshot. The generic util-safe process information
bits (Is64Bit(), ProcessID(), ParentProcessID(), and StartTime()) are
moved from ProcessReader to ProcessInfo (in util), where the current
ProcessReader can use it (as it’s OK for snapshot to depend on util),
and the future TaskForPID() in util can also use it. ProcessInfo also
contains other methods that TaskForPID() will use, providing access to
the credentials that the target process holds. ProcessArgumentsForPID()
is related, and is also now a part of ProcessInfo.

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

Review URL: https://codereview.chromium.org/727973002
2014-11-14 17:54:42 -05:00
Robert Sesek e5048b3a80 In CompositeHTTPBodyStream, coalesce small GetBytesBuffer()s to better fill the buffer.
R=mark@chromium.org

Review URL: https://codereview.chromium.org/707223002
2014-11-07 12:08:14 -05:00
Mark Mentovai 48b1964d1b Use implicit_cast<> instead of static_cast<> whenever possible.
implicit_cast<> only performs a cast in cases where an implicit
conversion would be possible. It’s even safer than static_cast<> It’s an
“explicit implicit” cast, which is not normally necsesary, but is
frequently required when working with the ?: operator, functions like
std::min() and std::max(), and logging and testing macros.

The public style guide does not mention implicit_cast<> only because it
is not part of the standard library, but would otherwise require it in
these situations. Since base does provide implicit_cast<>, it should be
used whenever possible.

The only uses of static_cast<> not converted to implicit_cast<> are
those that require static_cast<>, such as those that assign an integer
constant to a variable of an enum type.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/700383007
2014-11-06 16:44:38 -05:00
Mark Mentovai bbeef320e0 C++11: Use template aliases instead of inheritance.
This only came up in one location, PointerVector.

A template alias is superior to inheritance, which doesn’t provide full
type equivalence and doesn’t automatically inherit non-default
constructors.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/683753005
2014-11-05 14:54:42 -05:00
Mark Mentovai de0979b930 C++11: Use type aliases instead of typedefs.
This replaces all occurrences of “typedef Y X;” with “using X = Y;”.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/700143004
2014-11-05 14:09:01 -05:00
Mark Mentovai 486429e4f4 util/net: Place death tests into a *DeathTest test case.
Not doing this causes gtest to issue these warnings:

[WARNING] ../../third_party/gtest/gtest/src/gtest-death-test.cc:825::
Death tests use fork(), which is unsafe particularly in a threaded
context. For this test, Google Test detected 4 threads.

The gtest documentation recommends giving the test case a name ending in
DeathTest. Test cases named according to this convention run before all
other tests. Other death tests in Crashpad also follow this convention.

https://code.google.com/p/googletest/wiki/AdvancedGuide#Death_Tests_And_Threads

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

Review URL: https://codereview.chromium.org/694963002
2014-10-31 15:39:16 -04:00
Robert Sesek d88711adfa Add HTTPTransport, a Mac implementation, and an end-to-end test.
BUG=https://crbug.com/415544
R=mark@chromium.org

Review URL: https://codereview.chromium.org/692963002
2014-10-31 12:17:32 -04:00
Robert Sesek 123e01f96d Treat '+' as a safe MIME type character.
This addresses a review comment from
https://codereview.chromium.org/681303003/diff/120001/util/net/http_multipart_builder.cc#newcode107

R=mark@chromium.org

Review URL: https://codereview.chromium.org/694483002
2014-10-30 09:22:39 -04:00
Robert Sesek 9db5d6f773 Add HTTPMultipartBuilder and its test.
BUG=https://crbug.com/415544
R=mark@chromium.org

Review URL: https://codereview.chromium.org/681303003
2014-10-29 19:13:24 -04:00
Mark Mentovai 7f30a9ebef Fix a few documentation problems.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/688643002
2014-10-29 11:33:34 -04:00
Robert Sesek 977a7a8052 Add HTTPBodyStream interface, three concrete implementations, and their tests.
BUG=415544
R=mark@chromium.org

Review URL: https://codereview.chromium.org/669153006
2014-10-24 15:04:25 -04:00
Mark Mentovai bcae4d94d5 Create snapshot/mac and move some files from snapshot and util to there.
TEST=snapshot_test, util_test CheckedMachAddressRange.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/666483002
2014-10-17 13:41:45 -04:00
Mark Mentovai 6c1a46f2bb ScopedTaskSuspend test: remove extraneous CheckedReadFDAtEOF().
The base class takes care of this.

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

Review URL: https://codereview.chromium.org/659493002
2014-10-14 11:14:20 -04:00
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 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 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 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 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.
7dda7b3228 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 ae7ad05090 int128_test.cc: Add missing #include after d198c50abe.
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
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 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 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 63fd3ae47d.

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 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 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
57eb311528.

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 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 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 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 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 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
Mark Mentovai 01f9e396b8 Include <limits.h> in util/file/file_writer.cc because it uses IOV_MAX.
This also updates mini_chromium to abd6e3792f4f.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/469093002
2014-08-14 09:58:31 -07:00
Mark Mentovai 5f554ff10e Add ProcessArgumentsForPID() (process_util) and its test.
TEST=util_test ProcessUtil.ProcessArgumentsForPID
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/461253002
2014-08-14 09:57:19 -07:00
Mark Mentovai 21af173940 Add InitializationStateDcheck, its base class, and their tests.
TEST=util_test InitializationState*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/465103002
2014-08-14 09:51:26 -07:00
Mark Mentovai 7090b209ad Use the gtest_main target for test executables.
There’s no need to build a separate copy of gtest_main.cc for each test
executable.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/465363004
2014-08-13 15:28:59 -07:00
Mark Mentovai 293964f69b Add CFPropertyToLaunchData() and its test.
TEST=util_test Launchd
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/438673003
2014-08-03 18:53:10 -04:00
Mark Mentovai 4ae57690fa Put back the standard-layout checks lost in 5bbb7e8abb.
TEST=util_test UUID.UUID
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/440603002
2014-08-03 18:50:09 -04:00
Mark Mentovai 9f6d86742d Add TaskMemory, which can read another Mach task’s memory, and its test.
This also adds MachErrorMessage(), a test-only function that’s a
dependency of TaskMemory’s test, and related test-only error message
functions.

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

Review URL: https://codereview.chromium.org/438993002
2014-08-03 18:48:40 -04:00
Mark Mentovai 5bbb7e8abb Fix the UUID structure to have distinct fields, as expected by
Breakpad’s minidump reader.

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

Review URL: https://codereview.chromium.org/436933002
2014-08-01 16:10:58 -04:00
Mark Mentovai 4d6b867a1f Add UUID, c16lcpy (strlcpy for char16*), and their tests to util.
These are dependencies of the upcoming MinidumpStringWriter.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/430003003
2014-08-01 14:39:55 -04:00
Mark Mentovai 6e720f1421 Fix StringFileWriter::Seek().
The final range check needs to check that the value fits in a size_t,
because that’s what StringFileWriter uses for its offset_.

TEST=util_test StringFileWriter.SeekInvalid
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/434103003
2014-08-01 13:30:27 -04:00
Mark Mentovai 995012534e Introduce MinidumpWritable, its dependencies, and their tests.
MinidumpWritable is the base class for all minidump-writing operations.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/432003005
2014-08-01 12:48:28 -04:00