2389 Commits

Author SHA1 Message Date
Mark Mentovai
d0212ebaee Update gtest and gmock to the latest versions.
In b6a0183ccec7, gtest and gmock were held back at older versions with
limited C++11 support, because the then-current heads of each did not
work well in environments with C++11 language support but pre-C++11
library support. This is the environment that Chrome code for Mac builds
in. All necessary patches for this have been merged upstream, and this
has been corrected in the current released versions of gtest and gmock.

TEST=*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/731473007
2014-11-19 11:37:26 -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
09d3a6c695 Add the generate_dump tool.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/727983002
2014-11-14 19:21:43 -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
Mark Mentovai
360e441c53 Add MinidumpFileWriter::InitializeFromSnapshot() and its tests.
TEST=minidump_test MinidumpFileWriter.InitializeFromSnapshot*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/703223003
2014-11-07 14:47:08 -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
9386a054e2 minidump: Use the crashpad::internal namespace more appropriately.
MinidumpLocationDescriptorListWriter and MinidumpRVAListWriter are
implementation details and should be in the crashpad::internal
namespace.

MinidumpUTF16StringListWriter and MinidumpUTF8StringListWriter are
accessible to outside code and should not be in this namespace.

TEST=minidump_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/699313007
2014-11-07 11:45:44 -05:00
Mark Mentovai
4a22225fc0 Add MinidumpCrashpadInfoWriter::InitializeFromSnapshot() and its test.
TEST=minidump_test MinidumpCrashpadInfoWriter.InitializeFromSnapshot
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/703353002
2014-11-07 11:38:13 -05:00
Mark Mentovai
3b1c5bd3b9 Doxygen: only generate documentation for [Objective-]C[++] files.
Doxygen was generating some pretty bogus-looking documentation for
the Python http_transport_test_server, making it look like a C++
namespace and generating mostly useless documentation:

http://docs.crashpad.googlecode.com/git/doxygen/annotated.html

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/706233003
2014-11-07 11:36:40 -05:00
Mark Mentovai
408262d58f Fix MinidumpMiscInfoWriter test compilation with 32-bit time_t.
This produced errors such as:
minidump_misc_info_writer_test.cc:665:32: error: non-constant-expression
cannot be narrowed from type 'uint32_t' (aka 'unsigned int') to
'__darwin_time_t' (aka 'long') in initializer list [-Wc++11-narrowing]
  const timeval kStartTime = { expect_misc_info.ProcessCreateTime, 0 };
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
minidump_misc_info_writer_test.cc:665:32: note: override this message by
inserting an explicit cast
  const timeval kStartTime = { expect_misc_info.ProcessCreateTime, 0 };
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                               static_cast<__darwin_time_t>(     )

TEST=minidump_test MinidumpMiscInfoWriter.InitializeFromSnapshot
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/711603002
2014-11-07 10:02:21 -05:00
Mark Mentovai
1d440d36d6 Add list_annotations to MinidumpModuleCrashpadInfo.
TEST=MinidumpModuleCrashpadInfoWriter.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/705153002
2014-11-07 10:01:17 -05:00
Mark Mentovai
6e97189d27 Add MinidumpStringListWriter and test.
TEST=minidump_test MinidumpStringWriter.*List
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/707003002
2014-11-07 09:57:07 -05:00
Mark Mentovai
a980409288 Add MinidumpRVAListWriter and test.
This will be used as the foundation for writing a list of
MinidumpUTF8String objects. MinidumpUTF8String (and UTF-16
MINIDUMP_STRING) objects are never referenced by
MINIDUMP_LOCATION_DESCRIPTOR because they carry their own lengths.
Instead, they are always referenced by RVA.

The list of MinidumpUTF8String objects will be used for the module
annotations vector.

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

Review URL: https://codereview.chromium.org/704333002
2014-11-07 09:44:09 -05:00
Mark Mentovai
20032b5ddf minidump: Refactor MinidumpCrashpadInfoListWriter into a base class,
MinidumpLocationDescriptorListWriter. This allows easier construction of
minidump structures that are lists of MINIDUMP_LOCATION_DESCRIPTOR
structures in the future.

TEST=minidump_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/707543002
2014-11-06 16:58:37 -05:00
Mark Mentovai
8ad3beccdb minidump: stronger checking for MinidumpWritableAtRVA<>().
MinidumpWritableAtRVA<>() now checks that the object of the requested
type is actually in the range of the minidump file’s size, rather than
just checking that the beginning of the object is in range.

TEST=minidump_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/708803002
2014-11-06 16:47:57 -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
bdfd147a47 Add MinidumpMiscInfoWriter::InitializeFromSnapshot() and its test.
TEST=minidump_test MinidumpMiscInfoWriter.InitializeFromSnapshot
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/701783004
2014-11-05 18:15:19 -05:00
Mark Mentovai
8609cdb60d Add MinidumpSystemInfoWriter::InitializeFromSnapshot() and its test.
TEST=minidump_test MinidumpSystemInfo*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/694063003
2014-11-05 18:10: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
62b0976290 Add MinidumpExceptionWriter::InitializeFromSnapshot() and test.
TEST=minidump_test MinidumpExceptionWriter.InitializeFromSnapshot
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/698673002
2014-11-04 12:41:01 -05:00
Mark Mentovai
8248c030e2 Add MinidumpThreadListWriter::InitializeFromSnapshot(), everything
downstream, and tests.

TEST=minidump_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/693933002
2014-11-04 12:36:29 -05:00
Mark Mentovai
52c2f6edfc Add MinidumpContextWriter::CreateFromSnapshot(), everything downstream,
and its test.

Minidump context structures now interoperate more easily with snapshot
CPUContext structures, while maintaining identical layout to before.
This is facilitated by reusing the Fxsave types for the substructures
which were completely identical, and by using compatible logic to
initialize the minidump and snapshot structures for testing.

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

Review URL: https://codereview.chromium.org/686353004
2014-11-03 17:43:39 -05:00
Mark Mentovai
f3bdc972f9 Fix comment for MinidumpUTF8StringAtRVAAsString().
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/689193003
2014-11-03 15:08:00 -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
Mark Mentovai
45993a6959 minidump: Fix InitializeFromSnapshot() comments for module lists.
These classes don’t really have “mutators” other than their singular
AddModule() methods, and the documentation is clearer when revised in
this way.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/691853002
2014-10-30 17:26:56 -04:00
Mark Mentovai
4299ab3c4c Add MinidumpMemoryListWriter::AddFromSnapshot(), everything downstream,
and its test.

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

Review URL: https://codereview.chromium.org/641603006
2014-10-30 17:15:49 -04:00
Mark Mentovai
f7b38a9dd9 minidump: Fix InitializeFromSnapshot() comments for module lists.
These classes don’t really have “mutators” other than their singular
AddModule() methods, and the documentation is clearer when revised in
this way.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/691853002
2014-10-30 14:51:40 -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
4ee00568b7 snapshot: Make destructors of interface classes public and virtual.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/689483003
2014-10-29 17:31:23 -04:00
Mark Mentovai
84b44610cf minidump: Add InitializeFromSnapshot() for MinidumpModuleWriter and
MinidumpModuleListWriter.

TEST=minidump_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/682263002
2014-10-29 11:38:49 -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
Mark Mentovai
78bec65b27 minidump: Use decltype(object) instead of typeof(object).
TEST=minidump_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/681313005
2014-10-28 17:28:31 -04:00
Mark Mentovai
765e428321 minidump: Add InitializeFromSnapshot() for
MinidumpModuleCrashpadInfoListWriter and everything downstream.

TEST=minidump_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/683143003
2014-10-28 17:00:46 -04:00
Mark Mentovai
0a4ea0b52d minidump: Change the ownership model.
All minidump objects now own their all of their children, rather than
having them maintain weak pointers and requiring callers to maintain
ownership.

The only weak object in the entire tree now is the “extra memory” added
to a MinidumpMemoryListWriter by its AddExtraMemory() method. Extra
memory aliases objects owned elsewhere in the tree, typically by a
MinidumpThreadWriter as stack memory. Non-“extra” memory added to a
MinidumpMemoryListWriter by its AddMemory() method is strongly owned.

Many objects are now deleted through base pointers, and in those cases,
the base classes now have public virtual destructors. The ultimate base,
MinidumpWritable, is still protected to guard against direct
instantiation and deletion, and thus its destructor does not need to be
virtual.

This updates mini_chromium to eeb3b6a4f020 specifically for that
revision, which includes necessary updates to scoped_ptr. It also picks
up:

eeb3b6a4f020 Update base/move.h and base/memory/scoped_ptr.h to match
67ad2efafaba More porting to Windows
be27a006421e AUTHORS: Fix link post-git migration flag day.
05f5b1503230 Add codereview.settings to mini_chromium.
a32c2b199811 Beginnings of Windows support in mini_chromium

TEST=minidump_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/674153002
2014-10-27 15:01:39 -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
3f48f6d798 minidump: Rename MinidumpCrashpadModuleInfoWriter files.
The classes were renamed in response to
https://codereview.chromium.org/675803002/diff/1/minidump/minidump_extensions.h#newcode334,
but the files were not.

TEST=minidump_test \
     MinidumpCrashpadInfoWriter.*:MinidumpModuleCrashpadInfoWriter.*

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/645393005
2014-10-24 14:58:53 -04:00
Mark Mentovai
61af24848f Add MinidumpModuleCrashpadInfo, its list form, their writers, and their
test.

Move SimpleAnnotations from being a property of the minidump to being a
property of the module, matching the Snapshot interface.

TEST=minidump_test MinidumpCrashpadInfo.*:MinidumpCrashpadModule.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/675803002
2014-10-24 14:44:55 -04:00
Mark Mentovai
38aeadc1c1 minidump: Use forward declarations in more places.
TEST=minidump_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/679443002
2014-10-23 18:47:27 -04:00
Mark Mentovai
44a839614b minidump: Annotate existing virtual destructors that override a base
class virtual destructor with “override”.

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

Review URL: https://codereview.chromium.org/675783006
2014-10-23 18:42:26 -04:00
Mark Mentovai
dcdbd2098f minidump: Be consistent about setting the fields of WritableIoVec.
The iov_base field appears before the iov_len field, but for some
reason, sometimes the fields were being set in the reverse order.

TEST=minidump_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/678473003
2014-10-23 17:25:20 -04:00
Mark Mentovai
20f95a2f5b minidump: Migrate the rest of the tests to
MinidumpWritableAtLocationDescriptor<>().

TEST=minidump_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/670853002
2014-10-22 18:35:18 -04:00
Mark Mentovai
8a6a4c68e4 Refactor minidump test utilities for MinidumpWritable,
MinidumpFileWriter, and Minidump*StringWriter.

TEST=minidump_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/664283002
2014-10-21 14:15:07 -04:00
Mark Mentovai
01c535b001 Move minidump/*_test_util.* to minidump/test.
Suggested at
https://codereview.chromium.org/654573003/diff/1/minidump/minidump_string_writer_test_util.h#newcode22

TEST=minidump_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/663093003
2014-10-20 12:11:14 -04:00
Mark Mentovai
b8a2f41156 Add MinidumpCrashpadInfoWriter and its test.
TEST=minidump_test MinidumpCrashpadInfoWriter.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/654573003
2014-10-17 18:00:41 -04:00
Mark Mentovai
b9db7543a3 client.gyp: Sort.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/657303003
2014-10-17 14:38:30 -04:00