125 Commits

Author SHA1 Message Date
Scott Graham
ab153f7e1b gn: Avoid depending on BUILDCONFIG.gn globals
Goes with https://chromium-review.googlesource.com/c/chromium/mini_chromium/+/834648.

Includes mini_chromium DEPS roll to pull in edfe51ce81

Bug: crashpad:79, crashpad:196
Change-Id: Ib45cc738aecf9ae727f8faeff81f3b71e2dc9de8
Reviewed-on: https://chromium-review.googlesource.com/834543
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-12-19 23:38:36 +00:00
Joshua Peraza
9b2ba587f6 linux: Add ExceptionHandlerServer and ExceptionHandlerClient
Bug: crashpad:30
Change-Id: I60874a26ccb281144f870df2b4d16c6970a39f6b
Reviewed-on: https://chromium-review.googlesource.com/772824
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-12-19 20:11:52 +00:00
Mark Mentovai
99b0030616 gn, linux: Build for Linux with GN
This is sufficient for a native Linux build using GN. Android is not yet
supported.

mini_chromium side: https://crrev.com/c/833407

This also updates mini_chromium to 404f6dbf9928.

c913ef97a236 gn, linux: Build for Linux with GN
404f6dbf9928 gn: Don’t use .rsp files; rationalize descriptions and
             output dirs

Bug: crashpad:79
Change-Id: I4f3b72fd02884d77812e520fb95231b35815677d
Reviewed-on: https://chromium-review.googlesource.com/833408
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-12-19 19:31:20 +00:00
Mark Mentovai
8742051c60 mac: Drop apple_cctools and getsectiondata()/getsegmentdata() wrappers
These are present on 10.7 and later, and were only provided for the
benefit of older systems that probably aren’t relevant to Crashpad any
longer.

Change-Id: If9d7222f7af05020d0ff57d5d9ed06355fa14a48
Reviewed-on: https://chromium-review.googlesource.com/827686
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-12-15 23:05:54 +00:00
Mark Mentovai
612237a032 android: Fix 32-bit test to build at API [21, 24) with unified headers
Although API 21 introduced support for 64-bit off_t in many system calls
or their wrappers, <stdio.h> support for 64-bit off_t is absent until
API 24.

This is a partial revert of 5969d6b1eb22, because with this more
targeted fix applying only to gtest, the rest of Crashpad will work with
a 64-bit off_t even at API levels lacking NDK support by going through
the mmap() shim in compat.

This includes a mini_chromium update to 96e32dd499a4.

85cbec19ffc0 fuchsia: Make EINTR macros no-ops
fbf410cd4d40 fuchsia: Use koid instead of getpid() for process field in
             logging
96e32dd499a4 Revert "android: Don’t use _FILE_OFFSET_BITS=64 until API
             21"

Bug: crashpad:211
Change-Id: I34c3c8b42eb315605e6775962b44c3c4573b7462
Reviewed-on: https://chromium-review.googlesource.com/811204
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-12-06 18:05:37 +00:00
Joshua Peraza
7a0daa6989 Enable reading notes from ELF images
Bug: crashpad:30
Change-Id: Ie6c594b05c6d39a869ed30b7a7b49e6a6301cc65
Reviewed-on: https://chromium-review.googlesource.com/792539
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-12-05 19:27:37 +00:00
Mark Mentovai
5969d6b1eb android: NDK r16 compatibility
This updates build/gyp_crashpad_android.py to define the
android_api_level GYP variable whenver unified headers are in use.
Previously, it was only set when compiling with GCC and using unified
headers. This pairs with https://crrev.com/c/804574 to allow proper
detection of when _FILE_OFFSET_BITS=64 would be inappropriate.

Since there’s no longer any possibility of using a 64-bit off_t with API
< 21, this also drops the compatibility wrapper for mmap() that allowed
this configuration to work. Too bad, I liked this, but it’s pointless to
carry now.

The development documentation is also updated to refer to NDK r16.

mini_chromium is updated to 88e056258a01450b07414642fa5fb98493c1f6ce.

f609089390cd fuchsia: Add ZX_LOG, et al. to mini_chromium
0a8c5de30c67 fuchsia: Fix RandBytes() ZX_CHECK message string
88e056258a01 android: Don’t use _FILE_OFFSET_BITS=64 until API 21

Change-Id: I932116e0c01bcddd5719f9091a070d504eae600f
Reviewed-on: https://chromium-review.googlesource.com/804555
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-12-04 16:26:00 +00:00
Mark Mentovai
d25b0242c6 gn: Fix a couple of things after 9465fc72ad90 and 2bb56fafe3bd
When I redid the Crashpad GN build a few weeks ago
(https://chromium-review.googlesource.com/c/chromium/src/+/751403), I
tried to order things according to the GN style guide
(https://chromium.googlesource.com/chromium/src/tools/gn/+/HEAD/docs/style_guide.md).
As for conditionals, I tried to stick to doing a set of conditionals
after “sources” for just “sources”, and then another one at the bottom
for everything else.

It turns out that this was a good idea because it’s an error to say
“deps += [something]” inside a conditional until you’ve already said
“deps = [something_else]” first. (Maybe that’s why I did it.)
9465fc72ad90 regressed this.

2bb56fafe3bd also left behind a couple of straggler paths that were
absolute to Chromium’s root but should have been made relative.

This also fixes a comment (about something that won’t yet work outside
of Chromium anyway, but still…)

Bug: crashpad:79
Change-Id: I8a6f84bfad368cbcdae4fbff11f1d00e2af14b93
Reviewed-on: https://chromium-review.googlesource.com/798172
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-11-29 23:40:18 +00:00
Scott Graham
2bb56fafe3 Rework GN files to start to support building standalone, and also in Chromium
- Adds a .gn and a build/BUILDCONFIG.gn that uses mini_chromium's
  build/BUILD.gn.
- Adds some stub BUILD.gn files in locations where Chromium expects them
  (in //build, //testing, //third_party) containing empty targets/configs.
  These are no-ops in standalone builds, but add functionality when
  building in Chromium.  This is in preference to having a global bool
  that conditionally does Chromium-y things in the Crashpad build files.
  These stub files are all contained in a secondary source root in
  build/chromium_compatibility, referred to by //.gn.
- Adds //base/BUILD.gn which forwards to mini_chromium/base. This is
  only used when building standalone so that both Chromium and Crashpad
  can refer to it as "//base".
- Changes references to other Crashpad targets to be relatively
  specified so that they work when the root of the project is //, and also
  when it's //third_party/crashpad/crashpad as it is in Chromium.
- Moves any error-causing Mac/Win-specific files into explicit if (is_mac)
  or if (is_win) blocks as part of removing the dependency on
  set_sources_assignment_filter().

As yet unresolved:
- CRASHPAD_IN_CHROMIUM needs to be removed when standalone; to be tackled
  in a follow up.
- Not sure what to do with zlib yet, the build file currently assumes
  "in Chromium" too, and similarly having Crashpad //third_party/zlib:zlib
  pointing at itself doesn't work.

Bug: crashpad:79
Change-Id: I6a7dda214e4b3b14a60c1ed285267ab97432a1a8
Reviewed-on: https://chromium-review.googlesource.com/777410
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2017-11-28 20:29:35 +00:00
Mark Mentovai
20e5aba1af URL cleanups: switch to HTTPS, fix dead ones, use canonical ones
Change-Id: I4b247d7fae1a212350f8ffcf2bf5ba1fa730f5c1
Reviewed-on: https://chromium-review.googlesource.com/780339
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2017-11-20 22:23:39 +00:00
Scott Graham
d5ead4d70f Upstream lightly modified Chromium BUILD.gn files
Unreferenced, and not working at all in Crashpad-standalone.

Copied from Chromium at 52a9831d81f2099ef9f50fcdaca5853019262c35 to have
a point where a roll back into Chromium should be a no-op (with Chromium's
build/secondary/third_party/crashpad/... removed).

I'm not sure what we want to do about the various gni references into
Chromium (e.g. //build/config/sanitizers/sanitizers.gni, //testing/test.gni,
etc.) but I guess the sooner they live in Crashpad rather than in Chromium
the sooner we can figure out the sort of knobs and dials we need.

Bug: crashpad:79
Change-Id: Id99c29123bcd4174ee2bcc128c2be87e3c94fa3f
Reviewed-on: https://chromium-review.googlesource.com/777819
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Scott Graham <scottmg@chromium.org>
2017-11-20 18:08:23 +00:00
Mark Mentovai
22e8c33b21 linux: Provide PTRACE_GET_THREAD_AREA for 32-bit x86 with glibc
glibc’s own <sys/ptrace.h> should provide this but doesn’t. See
https://sourceware.org/bugzilla/show_bug.cgi?id=22433.

The copy in compat provided it when targeting x86-64 and using glibc.
util/linux/ptracer.cc uses it when targeting both 32-bit x86 and x86-64,
so the compat definition must be made to apply to 32-bit x86 too.

This also provides a #define using the same name as the constant, which
is what glibc’s <sys/ptrace.h> does for other constants.

Bug: crashpad:30
Change-Id: I5a0734a236d1c25398fb69e66f58dfe118658b68
Reviewed-on: https://chromium-review.googlesource.com/765257
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-11-13 22:36:45 +00:00
Mark Mentovai
c49da9caef win: Expect uneven symbolic link support
As mentioned at
https://chromium-review.googlesource.com/c/chromium/src/+/735820#message-e8b199498d8b850f2612c46648069d819dd47517,
the typical Windows behavior for symbolic links requires administrative
privileges.

Symbolic links are available to non-administrators in Windows 10.0.15063
and later (1703, Creators Update), provided that developer mode has been
enabled and SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE is passed to
CreateSymbolicLink(). See
https://blogs.windows.com/buildingapps/2016/12/02/symlinks-windows-10/.

This adds SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE to uses of
CreateSymbolicLink(), and creates test::CanCreateSymbolicLinks() to
determine whether symbolic link creation is possible. Tests that
exercise symbolic links are adapted to gate all symbolic link operations
on this test.

Test: crashpad_util_test DirectoryReader.*:Filesystem.*
Change-Id: I8250cadd974ffcc7abe32701a0d5bc487061baf0
Bug: crashpad:
Reviewed-on: https://chromium-review.googlesource.com/739472
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-10-26 23:01:14 +00:00
Mark Mentovai
a327c86a52 C++14 is required, don’t pretend to support pre-C++11 or pre-MSVS 2015
Change-Id: Ide835421599480acc63e8e88ce2217433c0d376e
Reviewed-on: https://chromium-review.googlesource.com/719036
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
2017-10-13 15:49:59 +00:00
Mark Mentovai
4c4e67952c win: 10.0.16299.0 SDK compatibility
This corresponds to Windows 10 version 1709 (Fall Creators Update,
“Redstone 3”).

While compiling util/win/nt_internals.cc:

…\crashpad\crashpad\util\win\nt_internals.cc(22): error C2371: 'CLIENT_ID': redefinition; different basic types
c:\program files (x86)\windows kits\10\include\10.0.16299.0\um\winternl.h(83): note: see declaration of 'CLIENT_ID'

The CLIENT_ID structure, which should have been part of the SDK to begin
with, has been added. Provide a compatible definition in <winternl.h>.

Bug: chromium:773476
Change-Id: Iafc77f8cffd06d1194fc909bad587f1ffd1687a2
Reviewed-on: https://chromium-review.googlesource.com/711415
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2017-10-11 22:39:00 +00:00
Mark Mentovai
2633708f84 android: Support mmap() with large file offsets and API < 21
Chrome (and therefore mini_chromium) has always built with
_FILE_OFFSET_BITS=64, which is intended to enable a 64-bit off_t even
for 32-bit programs. However, support was never present in Android with
NDK traditional headers.

The new NDK unified headers do recognize _FILE_OFFSET_BITS=64 and enable
a 64-bit off_t, along with corresponding functions and system call
wrappers. However, no mmap() wrapper supporting a 64-bit off_t for
32-bit programs was available prior to API 21 (Android 5.0 “Lollipop”),
so when targeting older API levels, NDK headers do not proivde an mmap()
declaration. This avoids silently truncating 64-bit off_t values to 32
bits. NDK r15b did make such an mmap() wrapper available
(https://android.googlesource.com/platform/bionic/+/785b249df024), and
it did silently truncate, but this was removed for r15c
(https://android.googlesource.com/platform/bionic/+/00fedf587917).

How should this work if _FILE_OFFSET_BITS is set to 64 and recent
unified headers are in use?

The strategy employed here is to provide an mmap() declaration in
compat, with a 64-bit off_t. That mmap() will call to Bionic’s mmap64()
wrapper if available (it’s available since Android 5.0 “Lollipop”). If
unavailable, it implements the same logic that mmap64() does directly,
which predominantly involves calling the __mmap2() system call. Bionic
has always provided wrappers for __mmap2().

Additional reading:
https://android.googlesource.com/platform/bionic/+/0bfcbaf4d069/docs/32-bit-abi.md#is-32_bit-1
https://github.com/android-ndk/ndk/issues/442

Bug: crashpad:30
Change-Id: I98c10e2eda773cb6f3d9eb8db9b8bfde43c885e7
Reviewed-on: https://chromium-review.googlesource.com/705674
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-10-06 21:07:47 +00:00
Mark Mentovai
10411266ed linux/android: List compat headers in compat.gyp
One more for Windows too: compat/win/sys/time.h.

Bug: crashpad:30
Change-Id: I1f11933a5937a65db10774d0710d44dc85f8586a
Reviewed-on: https://chromium-review.googlesource.com/705278
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-10-06 17:06:54 +00:00
Joshua Peraza
6de7ad8a22 Fix Android x86_64 build when using traditional headers
Bug: crashpad:30
Change-Id: I4b4e478bb3811fd5d9d66d98a4ecc811be3ea129
Reviewed-on: https://chromium-review.googlesource.com/703689
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-10-06 00:05:44 +00:00
Joshua Peraza
edf4dde8ae linux: Add ExceptionSnapshotLinux
Bug: crashpad:30
Change-Id: I450d53a89af2995c0fd13b31821360e781fe015a
Reviewed-on: https://chromium-review.googlesource.com/589747
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-08-02 02:29:51 +00:00
Joshua Peraza
37f20f7b14 Add ThreadSnapshotLinux
Bug: crashpad:30
Change-Id: Iee8eaecadc4b8d61d3975a79fbc7f80dbb39a134
Reviewed-on: https://chromium-review.googlesource.com/580207
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-07-20 19:55:21 +00:00
Joshua Peraza
6b5f139d88 linux: Add ProcessReader
ProcessReader is responsible for collecting information needed to build
a snapshot of the target process, independent of the Snapshot
interface. This CL includes implementation and tests for collecting
thread information, but does not yet collect module information.

Bug: crashpad:30
Change-Id: I911f155c953129a5fa8c031e923c0de2bd740ce0
Reviewed-on: https://chromium-review.googlesource.com/488162
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-07-19 18:16:09 +00:00
Joshua Peraza
5536baff13 linux: Use PTRACE_GET_THREAD_AREA for x86 ThreadInfo.GetThreadArea
Linux supports TLS on x86 by allocating slots in the GDT, accessible
via the system calls get/set_thread_area. This allows segment
registers (%gs on x86) to be used to quickly access the TLS.

Previously, we used PTRACE_GETREGSET with the NT_386_TLS regset. This
"register set" provides access to the subarray of the GDT used for TLS.
However, there are multiple slots provided and we don't know which one
is being used by the threading library for the current thread's TLS.
Previously, we were just using the first one, which worked for x86 on
64-bit kernels, but not 32-bit kernels. On 32-bit kernels, the first
slot ended up pointing to the TLS of the main thread.

The authoritative index of the current thread's TLS in the GDT is
given by bits 3-15 of %gs. However, this index cannot be used with
PTRACE_GETREGSET+NT386_TLS because we don't know the location of the
TLS slots in the GDT. PTRACE_GET_THREAD_AREA, however, accepts an
index from the start of the GDT similarly to get/set_thread_area.

Bug: crashpad:30
Change-Id: Ie6dfbdd088c6816fad409812a1a97037d4b38fd7
Reviewed-on: https://chromium-review.googlesource.com/575318
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-07-19 16:42:19 +00:00
Joshua Peraza
4224be41d7 linux: Add ElfImageReader to read ELF images via ProcessMemory
Bug: crashpad:30
Change-Id: Id2a6a1868103b0f4374816e58aab365a977b010d
Reviewed-on: https://chromium-review.googlesource.com/508836
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2017-07-06 16:51:29 +00:00
Mark Mentovai
c4f6ca3c6a mac: Provide a larger thread state buffer for AVX-512 on 10.13
Crashpad doesn’t use AVX-512, but when receiving replies to exceptions
forwarded to ReportCrash, may see buffers large enough to contain
AVX-512 thread state. This can result in messages like
“UniversalExceptionRaise: (ipc/rcv) msg too large (0x10004004)”.

I386_THREAD_STATE_MAX has increased from 224 to 614 in the 10.13 SDK,
meaning that the maximum supported size for old_state and new_state in
[mach_]exception_raise_state[_identity]() has increased from 896 to
2,456 bytes. This constant defines the size of the buffer that these
MIG-generated routines will work with. By providing this definition in
compat, the buffer size is increased when building with older SDKs.

Note that on the “send” side, the size of the message given to
mach_msg() will be trimmed to include only the valid part of the state
area based on the stateCnt field, so increasing the value to 614 here
won’t result Crashpad sending messages this large. That would be a
potential interoperability concern with older OS versions.

Bug: crashpad:185, crashpad:190
Change-Id: Ia46091ae46fd6227a17f59eb4bc00914be471aa7
Reviewed-on: https://chromium-review.googlesource.com/541515
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-06-20 14:31:38 +00:00
Mark Mentovai
107fb76317 mac: Handle _dyld_get_all_image_infos() not being available on 10.13
_dyld_get_all_image_infos() was only used in test code in Crashpad.

This addresses two related problems.

When running on 10.13 or later, _dyld_get_all_image_infos() is not
available. It appears to still be implemented in dyld, but its symbol is
now private. This was always known to be an “internal” interface. When
it’s not available, fall back to obtaining the address of the process’
dyld_all_image_infos structure by calling task_info(…, TASK_DYLD_INFO,
…). Note that this is the same thing that the code being tested does,
although the tests are not rendered entirely pointless because the code
being tested consumes dyld_all_image_infos through its own
implementation of an out-of-process reader interface, while the
dyld_all_image_infos data obtained by _dyld_get_all_image_infos() is
handled strictly in-process by ordinary memory reads. This is covered by
bug 187.

When building with the 10.13 SDK, no _dyld_get_all_image_infos symbol is
available to link against. In this case, access the symbol strictly at
runtime via dlopen() if it may be available, or when expecting to only
run on 10.13 and later, don’t even bother looking for this symbol. This
is covered by part of bug 188.

Bug: crashpad:185, crashpad:187, crashpad:188
Change-Id: Ib283e070faf5d1ec35deee420213b53ec24fb1d3
Reviewed-on: https://chromium-review.googlesource.com/534633
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-06-14 15:08:05 +00:00
Joshua Peraza
8fb23f2acc linux: Provide ThreadInfo to collect register sets with ptrace
ThreadInfo provides a uniform interface to collect register sets or
the thread-local storage address across bitness for x86 and ARM family
architectures. Additionally, ThreadInfo.h defines context structs which
mirror those provided in sys/user.h. This allows tracing across bitness
as the structs in sys/user.h are only provided for a single target
architecture.

Bug: crashpad:30
Change-Id: I91d0d788927bdac5fb630a6ad3c6ea6d3645ef8a
Reviewed-on: https://chromium-review.googlesource.com/494075
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-06-01 19:25:06 +00:00
Mark Mentovai
f53f2c84cc Fix comments identifying the source of module TimeDateStamp information
Change-Id: I164f0208db103410c3133a67a994a4f603ce1b27
Reviewed-on: https://chromium-review.googlesource.com/494827
Reviewed-by: Scott Graham <scottmg@chromium.org>
2017-05-03 21:13:05 +00:00
Pierre-Antoine Manzagol
7d56fd2386 Rely on winsock2.h for timeval
Bug: crashpad:
Change-Id: Iee8ebfaf7c4a1e8e87fcfcbc6ee8a4529a2f7c52
Reviewed-on: https://chromium-review.googlesource.com/493893
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Pierre-Antoine Manzagol <manzagop@chromium.org>
2017-05-03 17:53:45 +00:00
Mark Mentovai
e142aa87d6 linux: Fix crashpad_util_test ScopedPtraceAttach.* with the Yama LSM
When Yama is enabled and /proc/sys/kernel/yama/ptrace_scope is set to 1
(YAMA_SCOPE_RELATIONAL), for a child to ptrace() its parent, the parent
must first call prctl(PR_SET_PTRACER, child_pid, ...).

Bug: crashpad:30
Test: crashpad_util_test ScopedPtraceAttach.*
Change-Id: Ic85e8551259f17f372b2362887e7701b833b4cb4
Reviewed-on: https://chromium-review.googlesource.com/472006
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-04-07 21:28:59 +00:00
Mark Mentovai
82009cd14d android: Support builds with NDK API versions older than 21 (compat)
The new Linux ProcessInfo implementation uses two macros not readily
available in NDK API versions older than 21 (Android 5.0.0): NT_PRSTATUS
and PR_GETREGSET.

Chrome uses API 21 for 64-bit builds, but uses API 16 for 32-bit builds.

NT_PRSTATUS is normally defined by <elf.h> or by <linux/elf.h>, included
by <elf.h>. Although the definition in <linux/elf.h> is available in
older NDK API versions, this internal header does not mix well with
<elf.h> unless <elf.h> contemplates this combination. As of NDK API 21,
<elf.h> actually delegates most of its work to <linux/elf.h>.

PR_GETREGSET is not available in the NDK at all until API 21. Its
definition is in <linux/ptrace.h>. Most user code should #include
<sys/ptrace.h> instead, which includes <linux/ptrace.h>.

Bug: crashpad:30
Test: crashpad_util_test ProcessInfo.*
Change-Id: I4d07a9964db4665a49bde490e905ae9126880bc5
Reviewed-on: https://chromium-review.googlesource.com/455659
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-03-15 17:48:12 +00:00
Mark Mentovai
f848952e05 Support MINIDUMP_MISC_INFO_5 defined in Windows 10
MINIDUMP_MISC_INFO_5 can carry information about extended XSTATE state
components and the process cookie value.

I made some informed guesses about the precise meanings of some of the
attributes of the XSTATE stuff.

I don’t know what “process cookie” refers to yet. My guess is that it’s
the stack canary value, or something similar. But since this isn’t an
informed guess, I haven’t written it into the documentation.

Crashpad does not yet use either of these features.

BUG=crashpad:58

Change-Id: I614568287a01fec99d6cd60e378a6d6e20b4f48c
Reviewed-on: https://chromium-review.googlesource.com/409630
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2017-03-02 19:27:21 +00:00
Mark Mentovai
1382618fbe Provide backup #defines for things introduced in SDK 10.0.10240.0
This follows discussion on
https://chromium-review.googlesource.com/409098/.

Change-Id: Ic82b64a14bb89cfdf1c88b1482cc2c2c9c0c2589
Reviewed-on: https://chromium-review.googlesource.com/409604
Reviewed-by: Scott Graham <scottmg@chromium.org>
2016-11-10 01:50:17 +00:00
Mark Mentovai
dd4859965f Update compat version of winnt.h to 10.0.14393.0 SDK (Windows 10 1607)
This defines PROCESSOR_ARCHITECTURE_ARM64 and
PROCESSOR_ARCHITECTURE_ARM32_ON_WIN64, usable in
MINIDUMP_SYSTEM_INFO::ProcessorArchitecture.

This also defines four new PF_* flags usable in
CPU_INFORMATION::OtherCpuInfo::ProcessorFeatures.

Definitions are provided in compat/non_win, and #ifdef-guarded
definitions in compat/win for compatibility with Windows SDKs older than
Chrome’s minimum requirement.

PROCESSOR_ARCHITECTURE_ARM64 means the same thing that Breakpad used the
value 0x8003 for. At this point, Crashpad aims to use the
officially-defined constant. In the minidump_extensions.h
MinidumpCPUArchitecture enum, 0x8003 remains present and documented as
deprecated to discourage reuse of that constant for another purpose.

BUG=

Change-Id: Ic4b5fb9de31c5f00f3698f112633ece2a036b889
Reviewed-on: https://chromium-review.googlesource.com/409098
Reviewed-by: Scott Graham <scottmg@chromium.org>
2016-11-09 17:43:27 +00:00
Mark Mentovai
acabe35928 doc: Fix all Doxygen warnings, cleaning up some generated documentation
This makes Doxygen’s output more actionable by setting QUIET = YES to
suppress verbose progress spew, and WARN_IF_UNDOCUMENTED = NO to prevent
warnings for undocumented classes and members from being generated. The
latter is too noisy, producing 721 warnings in the current codebase.

The remaining warnings produced by Doxygen were useful and actionable.
They fell into two categories: abuses of Doxygen’s markup syntax, and
missing (or misspelled) parameter documentation. In a small number of
cases, pass-through parameters had intentionally been left undocumented.
In these cases, they are now given blank \param descriptions. This is
not optimal, but there doesn’t appear to be any other way to tell
Doxygen to allow a single parameter to be undocumented.

Some tricky Doxygen errors were resolved by asking it to not enter
directiores that we do not provide documentation in (such as the
“on-platform” compat directories, compat/mac and compat/win, as well as
compat/non_cxx11_lib) while allowing it to enter the
“off-platform” directories that we do document (compat/non_mac and
compat/non_win).

A Doxygen run (doc/support/generate_doxygen.sh) now produces no output
at all. It would produce warnings if any were triggered.

Not directly related, but still relevant to documentation,
doc/support/generate.sh is updated to remove temporary removals of
now-extinct files and directories. doc/appengine/README is updated so
that a consistent path to “goapp” is used throughout the file.

Change-Id: I300730c04de4d3340551ea3086ca70cc5ff862d1
Reviewed-on: https://chromium-review.googlesource.com/408812
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-11-08 19:24:05 +00:00
Mark Mentovai
952f787f4a doc: Standardize on “macOS” in comments
Use “macOS” as the generic unversioned name of the operating system in
comments. For version-specific references, use Mac OS X through 10.6, OS
X from 10.7 through 10.11, and macOS for 10.12.

Change-Id: I1ebee64fbf79200bc799d4a351725dd73257b54d
Reviewed-on: https://chromium-review.googlesource.com/408269
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-11-08 19:21:44 +00:00
Mark Mentovai
3887d99e48 mac: Handle EXC_RESOURCE RESOURCE_TYPE_IO
RESOURCE_TYPE_IO always appears to be non-fatal based on disassembly of
the function responsible for sending it in xnu 3705.0.0.1.10 (10.12dp1
16A201w).

BUG=crashpad:120,crashpad:124

Change-Id: I9dcc6673f922cbd7af910b76991825a9d9c96fe6
Reviewed-on: https://chromium-review.googlesource.com/355250
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-06-23 15:11:55 +00:00
Mark Mentovai
c281e30f93 mac: Update the dyld_all_image_infos structure for 10.12
BUG=crashpad:120

Change-Id: I7b2df5f2de13517b2586569ce267bcb0ae845101
Reviewed-on: https://chromium-review.googlesource.com/353830
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2016-06-20 16:14:24 +00:00
Taiju Tsuiki
12536e06e5 Replace base/template_util.h stuff with C++11 type_traits
BUG=chromium:554293

Change-Id: I5fe06bcba261dd770f1882519b541f870f4a1e62
Reviewed-on: https://chromium-review.googlesource.com/331150
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-04-01 15:29:16 +00:00
Scott Graham
c307f94f19 Support custom streams in the minidump
BUG=crashpad:95

Change-Id: Iee956906651dfd56e0ae3d2bcec82daabdc97067
Reviewed-on: https://chromium-review.googlesource.com/329733
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-03-02 17:39:34 +00:00
Scott Graham
badfacccee win: Add support for capturing unloaded modules
R=mark@chromium.org
BUG=crashpad:89

Change-Id: Ib6a67147e538811168d68f14a457fdceab30c02e
Reviewed-on: https://chromium-review.googlesource.com/327231
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-02-18 00:55:38 +00:00
Mark Mentovai
6d2d31d2d1 Use base/macros.h instead of base/basictypes.h
This was done in Chromium’s local copy of Crashpad in 562827afb599. This
change is similar to that one, except more care was taken to avoid
including headers from a .cc or _test.cc when already included by the
associated .h. Rather than using <stddef.h> for size_t, Crashpad has
always used <sys/types.h>, so that’s used here as well.

This updates mini_chromium to 8a2363f486e3a0dc562a68884832d06d28d38dcc,
which removes base/basictypes.h.

e128dcf10122 Remove base/move.h; use std::move() instead of Pass()
8a2363f486e3 Move basictypes.h to macros.h

R=avi@chromium.org

Review URL: https://codereview.chromium.org/1566713002 .
2016-01-06 12:22:50 -05:00
Mark Mentovai
583d1dc3ef Provide std::move() in compat instead of using crashpad::move()
This more-natural spelling doesn’t require Crashpad developers to have
to remember anything special when writing code in Crashpad. It’s easier
to grep for and it’s easier to remove the “compat” part when pre-C++11
libraries are no longer relevant.

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1513573005 .
2015-12-09 17:36:32 -05:00
Scott Graham
fabcd79057 Add missing comma in compat.gyp
Causes a warning in the gyp-msvs generator.

R=mark@chromium.org

Review URL: https://codereview.chromium.org/1490073005 .
2015-12-02 15:31:44 -08:00
Mark Mentovai
04d97ca86e win: Add a note about /Z7 obsolescence regarding CodeView debug info
BUG=crashpad:47
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/1414323003 .
2015-11-02 12:20:25 -05:00
Scott Graham
3d598cdbcd Change file op |ssize_t|s to FileOperationResult
R=mark@chromium.org

Review URL: https://codereview.chromium.org/1416493006 .
2015-10-22 16:14:18 -07:00
Scott Graham
3261edd997 Write MINIDUMP_HANDLE_DATA_STREAM to minidump
R=mark@chromium.org
BUG=crashpad:21, crashpad:52

Review URL: https://codereview.chromium.org/1419623003 .
2015-10-21 10:43:42 -07:00
Scott Graham
4600643a78 Some plumbing for the beginning of getting handles into snapshot/minidump
Follows https://codereview.chromium.org/1400413002/.

R=mark@chromium.org
BUG=crashpad:21, crashpad:46, crashpad:52

Review URL: https://codereview.chromium.org/1407643004 .
2015-10-16 15:58:40 -07:00
Scott Graham
019a0cec8b win: Write memory map info as MINIDUMP_MEMORY_INFO[_LIST]
Makes !vprot work in windbg, e.g.

0:000> !vprot 0x970000
BaseAddress:       00970000
AllocationBase:    00970000
AllocationProtect: 00000004  PAGE_READWRITE
RegionSize:        00001000
State:             00001000  MEM_COMMIT
Protect:           00000001  PAGE_NOACCESS
Type:              00020000  MEM_PRIVATE

...

0:000> !vprot 0x97a000
BaseAddress:       0097a000
AllocationBase:    00970000
AllocationProtect: 00000004  PAGE_READWRITE
RegionSize:        00001000
State:             00001000  MEM_COMMIT
Protect:           00000140  PAGE_EXECUTE_READWRITE + PAGE_GUARD
Type:              00020000  MEM_PRIVATE

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

R=mark@chromium.org
BUG=crashpad:20, crashpad:46

Review URL: https://codereview.chromium.org/1379873005 .
2015-10-13 13:15:44 -07:00
Scott Graham
937d3d710c Mostly-boilerplate to add MemoryMapSnapshot
Follows https://codereview.chromium.org/1375313005.

Adds MINIDUMP_MEMORY_INFO for non-win in dbghelp.h.

R=mark@chromium.org
BUG=crashpad:20, crashpad:46

Review URL: https://codereview.chromium.org/1377133006 .
2015-10-13 12:37:44 -07:00
Scott Graham
6082aed2f2 win: Get Crashpad compiling under VS2015
R=mark@chromium.org
BUG=crashpad:1, chromium:440500

Review URL: https://codereview.chromium.org/1357833002 .
2015-09-21 10:51:15 -07:00
Mark Mentovai
9086d25ce8 Don’t trigger EXC_CORPSE_NOTIFY on OS X 10.11
CrashReportExceptionHandler::CatchMachException() must always set a
valid new_state. Failing to do so appears to trigger corpse generation
on OS X 10.11. This is addressed by calling ExcServerCopyState().
Previously, this was not done for exceptions forwarded to the user
ReportCrash, under the apparent mistaken assumption that ReportCrash
would do it. However, ReportCrash is given copies of out-parameters like
new_state to explicitly prevent it from influencing Crashpad’s returned
state.

ExcServerSuccessfulReturnValue() must not return MACH_RCV_PORT_DIED for
an EXC_CRASH handler on OS X 10.11. This appears to trigger corpse
generation. This is addressed by always returning KERN_SUCCESS from
EXC_CRASH handlers on OS X 10.11.

This also adds generic EXC_CORPSE_NOTIFY support throughout Crashpad.
The crashpad_handler does not listen for this exception type, but it is
now possible to work with this exception type using tools like
exception_port_tool and catch_exception_tool.

BUG=crashpad:48
TEST=Crashes handled by crashpad_handler do not result in the generation
     of reports in the root /Library/Logs/DiagnosticReports.

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

Review URL: https://codereview.chromium.org/1305893010 .
2015-09-04 14:29:12 -04:00
Scott Graham
3ef04d14f2 Implement ModuleSnapshotWin::UUID
Reads CodeView PDB GUID from Debug Directory of PE header.

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

Review URL: https://codereview.chromium.org/1311003003 .
2015-09-01 09:32:09 -07:00
Scott Graham
a691448ffb win: Implement exception snapshot
Refactor some of the NT internals helpers and cpu_context to share
between the thread and exception snapshot code.

Add test that runs crashing child and validates the exception in the
snapshot.

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

Review URL: https://codereview.chromium.org/1126413008 .
2015-08-18 12:25:19 -07:00
Mark Mentovai
0366307615 win: Provide strcasecmp() in <strings.h> in compat.
base::strcasecmp() has been deprecated since upstream 8a800901b78a2.

BUG=chromium:472900
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1275633002 .
2015-08-05 16:34:50 -04: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
17b770ece4 win: get tools/crashpad_database_util mostly working
- Add public domain getopt implementation to third_party.
- Add timegm to compat/win.
- Add stub of strptime to compat/win.

Requires https://codereview.chromium.org/1119173003/ and
https://codereview.chromium.org/1117013006/.

Rather than working in wchar_t everywhere on Windows, convert
UTF16 command line arguments in wmain to UTF8, work primarily
in UTF8, and convert back when necessary to UTF16 for base::FilePath.
This avoids the need to genericize over all the standard C string
functions, getopt, etc. while still handling non-ASCII properly.

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

Review URL: https://codereview.chromium.org/1119783005
2015-05-06 10:28:07 -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
e1347a740c Handle EXC_RESOURCE and EXC_GUARD exceptions properly.
These two exception types use all 64 bits of the code[0] field.  The
ExceptionSnapshot was unprepared to stuff this into a 32-bit field.  To
resolve the discrepancy, the more-significant data is taken from the
high 32 bits of code[0]. No information is lost because the full code[0]
is made available as part of the Codes() vector.

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

Review URL: https://codereview.chromium.org/1050313003
2015-04-02 15:49:51 -04:00
Mark Mentovai
98cca0e5fc compat/mac: 10.6 SDK compatibility for pre-Xcode 4.2 10.6 SDK.
Some definitions were added to the 10.6 SDK during its lifetime, and
aren’t present in older versions of the SDK. The AVX definitions are in
this group.

Apparently, not all of Chrome’s builders use the same version of this
SDK. A try bot failure was encountered for
https://codereview.chromium.org/1011503002/ in
http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_compile_dbg_ng/builds/33868/steps/compile%20%28with%20patch%29/logs/stdio.

This provides definitions in compat for when they aren’t available from
the SDK.

TEST=compile
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/1001733003
2015-03-16 13:41:48 -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
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
Scott Graham
bcc580e561 win: Add implementation of system_snapshot for Windows
ProcessReaderWin only a stub for now.

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

Review URL: https://codereview.chromium.org/936333004
2015-03-02 13:06:34 -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
Scott Graham
012ddc9752 win: Add compat header for sys/types.h
To add definition of ssize_t. Uses #include <../include/...> to
emulate #include_next, similar to the mac headers.

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

Review URL: https://codereview.chromium.org/793013002
2014-12-10 11:39:50 -08: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
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
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
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
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
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
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
dfe81014f7 Add compat to Crashpad.
compat includes headers providing definitions normally provided by the
system, in cases where the system SDK does not always provide the
correct or up-to-date definitions, and cases where code on different
platforms needs to access definitions normally only available on one
platform.

To provide definitions on a single platform, where the system SDK may
not provide the definitions correctly, use subdirectories named for the
platform, such as “mac”.

To provide definitions normally available on only one platform to
others, use subdirectories that identify that they are to be used on
platforms other than the one that originated their definitions, such as
“non_win”.

In all cases, headers should be named as they are natively in their
respective SDKs, so that it’s possible to #include them according to
their usual names.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/432843002
2014-07-31 13:45:51 -04:00