232 Commits

Author SHA1 Message Date
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
4539fd1553 minidump: Reorganize MinidumpModuleCrashpadInfo to improve linking
between classic and extension structures.

Previosly, each MinidumpModuleCrashpadInfo structure contained a
minidump_module_list_index field referencing a module in the
MINIDUMP_MODULE_LIST stream by index. This layout was discovered to
cause a problem for the new minidump reader in ModuleSnapshotMinidump.
Instead, the module list index for linkage should be contained in the
MinidumpModuleCrashpadInfoList alongside the LOCATION_DESCRIPTORs
pointing to each MinidumpModuleCrashpadInfo.

The organizational difference is small, but this enables a better design
for ModuleSnapshotMinidump. When initializing a ModuleSnapshotMinidump
with the new layout, it is possible for the caller to have access to the
location descriptor for the MinidumpModuleCrashpadInfo corresponding to
a MINIDUMP_MODULE_LIST. Previously, the caller would not have had this
data without interpreting each MinidumpModuleCrashpadInfo, which
ModuleSnapshotMinidump would have to do anyway.

MinidumpModuleCrashpadInfoListWriter was the only user of
MinidumpLocationDescriptorListWriter, which is obsoleted and removed in
this change. Its functionality is moving directly into
MinidumpModuleCrashpadInfoListWriter, but it is no longer generic enough
to maintain as a distinct class.

TEST=minidump_test \
     MinidumpModuleCrashpadInfoWriter.*,MinidumpCrashpadInfoWriter.*

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/978463003
2015-03-04 10:53:34 -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
Mark Mentovai
a0f5dc62a4 Add MinidumpCrashpadInfo::simple_annotations.
Some annotations will exist at a broader scope than per-module, which is
the only place that annotations can currently be stored. The product
name and version are not under the control of any module, but are
established when the first Crashpad client establishes a handler. These
annotations will be stored in a minidump’s MinidumpCrashpadInfo
structure, which applies to the entire minidump.

Within the snapshot interface, this data is carried within the
“process” snapshot because it is the top-level structure in that family.
Note that the data may not correspond directly with a process, however.

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

Review URL: https://codereview.chromium.org/924673003
2015-02-17 17:38:02 -05:00
Scott Graham
06b89552af %zu to PRIuS in minidump
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/900323003
2015-02-05 15:04:49 -08:00
Scott Graham
22c82f0c6c Use recently imported MSVC warning macros
The PUSH/POP are less noisy for sure. SUPPRESS is a little more
subtle -- it's correctly documented as "for this line and the next"
but that doesn't work well with our coding style.

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

Review URL: https://codereview.chromium.org/898133002
2015-02-05 11:30:29 -08:00
Scott Graham
b7d214e741 win: warning fixes in minidump_thread_writer_test.cc
- unaligned due to heap allocation
- potentially uninitialized local
- truncation of uint64_t -> DWORD

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

Review URL: https://codereview.chromium.org/903603002
2015-02-05 09:52:24 -08:00
Scott Graham
e67b87ef02 win: Fixes for minidump_string_writer_test.cc
- More references to sizeof(Struct::Member)
- Complaints about not being able to generate
  constructor, etc. on initialized struct.

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

Review URL: https://codereview.chromium.org/896423002
2015-02-05 09:42:16 -08:00
Scott Graham
38a026ffc7 win: fix various warnings in minidump_system_info_writer_test.cc
- Stack object instantiated for sizeof to avoid

d:\src\crashpad\crashpad\minidump\minidump_system_info_writer_test.cc(43) : error C2597: illegal reference to non-static member '_MINIDUMP_STRING::Buffer'

Could also just be sizeof(WCHAR) if that feels less ugly.

- narrowing cast
- potentially uninitialize variable warning

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

Review URL: https://codereview.chromium.org/886143004
2015-02-05 09:39:54 -08:00
Scott Graham
2d2ad633ea win: Fixes for minidump_misc_info_writer_test.cc
MINIDUMP_MISC_INFO and MINIDUMP_MISC_INFO_2, etc. are not
derived from each other in Windows' dbghelp.h, so need
a reinterpret_cast.

arraysize fails on Struct::Member with a big mess (below)
but works ok on a local stack instance.

d:\src\crashpad\crashpad\minidump\minidump_misc_info_writer_test.cc(405) : error C2664: 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>::basic_string(std::initializer_list<_Elem>,const std::allocator<char> &)' : cannot convert argument 1 from 'char' to 'const std::basic_string<char,std::char_traits<char>,std::allocator<char>> &'
        with
        [
            _Elem=char
        ]
        Reason: cannot convert from 'char' to 'const std::basic_string<char,std::char_traits<char>,std::allocator<char>>'
        No constructor could take the source type, or constructor overload resolution was ambiguous
d:\src\crashpad\crashpad\minidump\minidump_misc_info_writer_test.cc(408) : error C2784: 'char (&ArraySizeHelper(const T (&)[N]))[N]' : could not deduce template argument for 'const T (&)[N]' from 'unknown'
        d:\src\crashpad\crashpad\third_party\mini_chromium\mini_chromium\base\basictypes.h(39) : see declaration of 'ArraySizeHelper'

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

Review URL: https://codereview.chromium.org/899163004
2015-02-05 09:35:54 -08:00
Scott Graham
a813dd2e1b win: Fixes for minidump_misc_info_writer_test.cc
test_process_snapshot.h apparently requires the full inclusion,
not a forward declaration otherwise it claims to be deleting
undefined types.

And, some more potentially uninitialized variables.

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

Review URL: https://codereview.chromium.org/902803002
2015-02-05 09:25:14 -08:00
Scott Graham
9574e94b3d win: minidump_writeable_test_util from constexpr to enum
No constexpr on VS2013. :(

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

Review URL: https://codereview.chromium.org/897173005
2015-02-05 09:13:13 -08:00
Scott Graham
842bbdeb97 win: potentially uninitialized variables in minidump_crashpad_info_writer_test.cc
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/902793003
2015-02-05 08:48:24 -08:00
Scott Graham
743b778468 win: truncation warnings in minidump_context_test_util.cc
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/897233002
2015-02-05 08:46:06 -08:00
Scott Graham
55cd6a2714 win: potentially uninitialized locals in minidump_exception_writer_test.cc
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/897863004
2015-02-05 08:45:34 -08:00
Scott Graham
8c74948ae5 win: Fixes for minidump_file_writer_test
- implicit conversion from time_t -> long
- "exception_info" is a pseudo-keyword on MSVC related to SEH
- disable warning about expected truncation

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

Review URL: https://codereview.chromium.org/898013002
2015-02-05 08:43:38 -08:00
Scott Graham
3162f1259c win: convert MinidumpSimpleStringDictionaryWriter to scoped_ptr
Had to move this one out to a scoped_ptr too, otherwise when
it's instantiated in test code on the stack,

d:\src\crashpad\crashpad\minidump\minidump_simple_string_dictionary_writer_test.cc(45) : warning C4815: 'dictionary_writer' : zero-sized array in stack object will have no elements (unless the object is an aggregate that has been aggregate initialized)

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

Review URL: https://codereview.chromium.org/895313004
2015-02-05 08:41:16 -08:00
Scott Graham
75e6df2382 win: various warnings in minidump_module_writer_test
- time_t -> uint32_t warning
- mixing bool and BOOLEAN
- potentially unintialized variable warnings

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

Review URL: https://codereview.chromium.org/902513003
2015-02-04 20:47:16 -08:00
Scott Graham
658d70efb3 win: fix 'potentially uninitialized local variable' warnings
e.g.

d:\src\crashpad\crashpad\minidump\minidump_memory_writer_test.cc(347) : error C2220: warning treated as error - no 'object' file generated
d:\src\crashpad\crashpad\minidump\minidump_memory_writer_test.cc(347) : warning C4701: potentially uninitialized local variable 'memory_list' used
d:\src\crashpad\crashpad\minidump\minidump_memory_writer_test.cc(347) : warning C4703: potentially uninitialized local pointer variable 'memory_list' used

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

Review URL: https://codereview.chromium.org/899793002
2015-02-04 20:46:44 -08:00
Scott Graham
2b46aaabda win: Locally disable allocation alignment warning
A (somewhat cursory) inspection leads me to believe that there's
no particular alignment requirements for this object at this location,
so this warning can be ignored.

d:\src\crashpad\crashpad\minidump\minidump_context_writer.cc(43) : error C2220: warning treated as error - no 'object' file generated
d:\src\crashpad\crashpad\minidump\minidump_context_writer.cc(43) : warning C4316: 'crashpad::MinidumpContextAMD64Writer' : object allocated on the heap may not be aligned 16

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

Review URL: https://codereview.chromium.org/893393002
2015-02-04 17:36:38 -08:00
Scott Graham
74a34e9c4b win: Resolve zero-length array errors on MSVC
In some cases, it's sufficient to move the zero-length array to the end of the
structure. When the struct is used inside a class that is derived from however,
this fails. In that case, switch to holding the object in a scoped_ptr.

Longer winded version: https://groups.google.com/a/chromium.org/d/msg/crashpad-dev/NGZ6LwRMORM/nKcXKQ7inIEJ

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

Review URL: https://codereview.chromium.org/896663006
2015-02-04 17:34:43 -08:00
Scott Graham
429a3368d4 win: Work towards getting 'minidump' to compile
- dbghelp.h requires windows.h to be included before it (ick!).
  Add a stub one for non_win to make this work.
- convert __attribute__ -> macro that can work work with MSVC;
- a handful of narrowing casts.

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

Review URL: https://codereview.chromium.org/883773005
2015-02-04 17:30:03 -08: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
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
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
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
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
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
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
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
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
c9db1b1d19 Add MinidumpSimpleStringDictionaryWriter and its test.
TEST=minidump_test MinidumpSimpleStringDictionaryWriter.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/656173003
2014-10-16 18:09:18 -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
c182be95a2 Rename minidump_test_util.* to minidump_file_writer_test_util.*.
This is in line with the other new minidump_*_test_util files, namely,
the “context” and “memory” ones. minidump_file_writer_test_util.*
provides VerifyMinidumpHeader(), which is used to validate the
MINIDUMP_HEADER at the beginning of a minidump file, as written by
MinidumpFileWriter.

TEST=minidump_test
R=rsesek@chromium.org

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

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

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

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

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

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

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

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

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

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

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

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

R=rsesek@chromium.org

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

Review URL: https://codereview.chromium.org/628153004
2014-10-07 17:27:11 -04:00
Scott Graham
d198c50abe Convert COMPILE_ASSERT to static_assert
(Perhaps I should have just left it in mini_chromium, but anyway.)

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

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

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

R=rsesek@chromium.org

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

R=rsesek@chromium.org

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

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

BUG=
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/491023005
2014-08-20 18:32:06 -04:00
Mark Mentovai
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
e0a79bec5e MinidumpMemoryWriter test: Don’t suffix uint64_t constants.
It’s not necessary.

TEST=minidump_test MinidumpMemoryWriter
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/467323003
2014-08-13 15:27:33 -07:00
Mark Mentovai
0ba9d2b065 Add MinidumpModuleWriter, MinidumpModuleListWriter, related classes, and
their test.

TEST=minidump_test MinidumpModuleTest
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/460933004
2014-08-13 15:26:21 -07:00
Mark Mentovai
3b2c6d32f4 Add MinidumpMemoryWriter, MinidumpMemoryListWriter, and their test.
TEST=minidump_test MinidumpMemoryWriter
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/459973002
2014-08-12 10:26:40 -07:00
Mark Mentovai
c73a97d4e3 Add MinidumpMiscInfoWriter and its test.
TEST=minidump_test MinidumpMiscInfoWriter
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/454073002
2014-08-11 11:42:12 -07:00
Mark Mentovai
aa3adf2c5b Add MinidumpSystemInfoWriter and its test.
TEST=minidump_test MinidumpSystemInfoWriter
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/435243002
2014-08-07 14:58:26 -04:00
Mark Mentovai
859560f70d Add MinidumpFileWriter and its test.
MinidumpFileWriter writes the top-level object to a minidump file. This
consists of a MINIDUMP_HEADER and a list of MINIDUMP_DIRECTORY entries
that point to streams, which are second-level objects in minidump files.
This change also adds the base class for stream writers,
MinidumpStreamWriter.

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

Review URL: https://codereview.chromium.org/432863006
2014-08-03 18:47:34 -04:00
Mark Mentovai
d2675ce50b Introduce MinidumpStringWriter and its test.
MinidumpStringWriter is responsible for writing variable-length UTF-16
(MINIDUMP_STRING) and UTF-8 (MinidumpUTF8String) strings to minidump
files.

This change depends on https://codereview.chromium.org/430003003/ and
https://codereview.chromium.org/435013002/.

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

Review URL: https://codereview.chromium.org/431363002
2014-08-01 14:44:57 -04:00
Mark Mentovai
5ba343ccf1 Add minidump_extensions.h, which defines Crashpad/Breakpad extensions to
the standard minidump format defined in dbghelp.h.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/435013002
2014-08-01 14:37:20 -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