15 Commits

Author SHA1 Message Date
Joshua Peraza
06a688ddc1 linux: setup a signal stack
Bug: crashpad:340
Change-Id: I035d988bc8e76dbf80c07f0c92b07dbefeba8bd1
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2209768
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-07-15 19:00:09 +00:00
Mark Mentovai
b9c828ea83 android: Fix “gn analyze”
On Android, the compat library built compat/android/sys/mman.cc, which
provides a fallback for mmap, and compat/linux/sys/mman.cc, which
provides a fallback for memfd_create. This can result in two object
files colliding in the library, which is flagged as a “gn analyze”
error:

> ERROR at //crashpad/compat/BUILD.gn:62:5: Duplicate object file
>     static_library(target_name) {
>     ^----------------------------
> The target //crashpad/compat:compat
> generates two object files with the same name:
>   obj/crashpad/compat/compat/mman.o
>
> It could be you accidentally have a file listed twice in the
> sources. Or, depending on how your toolchain maps sources to
> object files, two source files with the same name in different
> directories could map to the same object file.
>
> In the latter case, either rename one of the files or move one of
> the sources to a separate source_set to avoid them both being in
> the same target.

The files are renamed to avoid this collision. The associated headers
cannot be renamed because they need to shadow the SDK’s copies. There is
no “gn analyze” conflict reported for headers with the same name.

Change-Id: Ia49ef5ff8375673395597e96555f72f7c69e3564
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2285965
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2020-07-08 13:53:20 +00:00
Joshua Peraza
80473094a4 linux, compat: add a memfd_create wrapper
Change-Id: Iecbf85d0e963779b4c16083b481f4ab50f509115
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1774899
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-08-30 19:33:36 +00:00
Adam Kallai
7198015c73 Fix the Chromium build on ChromeOS for aarch64
PTRACE_GET_THREAD_AREA is only removed from the newer version of glibc (>=2.28)
for aarch64. Since ChromeOS uses 2.23 version of glibc currently,
so it should be handled in crashpad to avoid the redefinition.

BUG=chromium:873168

Change-Id: I8da6bc0595b814b0490b38da6f4a68e6803bb5b9
Reviewed-on: https://chromium-review.googlesource.com/1188309
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Commit-Queue: Mark Mentovai <mark@chromium.org>
2018-08-24 16:52:31 +00:00
Joshua Peraza
063ff78a25 Use __aarch64__ instead of __arm64__
__aarch64__ should always be defined for 64-bit ARM, while __arm64__
only sometimes is.

Change-Id: I46a6469d8f5e74ad79b6ded51a809fbf88e5170a
Reviewed-on: https://chromium-review.googlesource.com/1151541
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-07-26 16:37:25 +00:00
Joshua Peraza
0c8f035a50 linux, non-glibc: fix build after eb7d8a4c
The pre-processor attempts to parse an entire expression before
evaluating sub-expressions, so undefined macros result in a syntax
error.

Change-Id: Ie950867897a1befd221bdbe4719f2365f5cc75ee
Reviewed-on: https://chromium-review.googlesource.com/1132328
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-07-10 21:27:15 +00:00
Djordje Golubovic
cb41ba7471 Added MIPS support to crashpad.
Modified gyp/gn files to support MIPS targets.

Implemented thread_info, cpu_context, signal context classes for MIPS target.

Addressed MIPS specific signal ordering.

Added "MIPS Technologies, Inc." to AUTHORS file.

Bug: crashpad:232
Change-Id: Ibfc221ba54088e95f984b9dc6be5fd52f86abcc2
Reviewed-on: https://chromium-review.googlesource.com/1064594
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-07-10 15:29:34 +00:00
Joshua Peraza
eb7d8a4cde Alias user regs structs for glibc ARM64 pre 2.20
Change-Id: Ie8e4ce8df34c4d14e874884db50d748d03af9592
Reviewed-on: https://chromium-review.googlesource.com/1117644
Reviewed-by: Scott Graham <scottmg@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-06-27 22:23:42 +00:00
Tom Anderson
75b672be06 Fix arm build with glibc 2.27
This is a followup to [1] which fixed the x86 build for glibc 2.27.  But there
was a similar block of code that was only present on arm, which was causing the
arm build to fail.  This CL makes the equivalent change to [1].

[1] 3a20d34ac3

BUG=chromium:843240
R=mark@chromium.org

Change-Id: I4b2786ddcdd0d9920aca25b3ad00c5ba716ca30a
Reviewed-on: https://chromium-review.googlesource.com/1060155
Commit-Queue: Scott Graham <scottmg@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
2018-05-15 18:48:24 +00:00
Tom Anderson
3a20d34ac3 Fix build with glibc 2.27
Glibc now defines PTRACE_GET_THREAD_AREA as an enum value.  Trying to define our
own will result in an error:

../../third_party/crashpad/crashpad/compat/linux/sys/ptrace.h:25:35: error: redefinition of 'PTRACE_GET_THREAD_AREA' as different kind of symbol
static constexpr __ptrace_request PTRACE_GET_THREAD_AREA =
                                  ^
../../build/linux/debian_sid_amd64-sysroot/usr/include/x86_64-linux-gnu/sys/ptrace.h:110:3: note: previous definition is here
  PTRACE_GET_THREAD_AREA = 25,

However, glibc also defines a new macro for the corresponding value, so it's
possible to detect this case:

----- ptrace.h -----
  /* Get a TLS entry in the GDT.  */
  PTRACE_GET_THREAD_AREA = 25,
#define PT_GET_THREAD_AREA PTRACE_GET_THREAD_AREA
----- ptrace.h -----

This CL prevents defining our own PTRACE_GET_THREAD_AREA when PT_GET_THREAD_AREA
is defined.

Bug: None
Change-Id: Idf931e54dadd57788f04da47f12f0f0588a255cc
Reviewed-on: https://chromium-review.googlesource.com/999161
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-04-06 01:34:50 +00:00
Jose Dapena Paz
08ce02c352 Fix crashpad build on non Android ARMEL with a recent GLIBC.
user_vfp is not declared anymore in sys/user.h, but in specific
internal kernel asm user.h in GLIBC. So building crashpad on ARMEL
with such a GLIBC will fail to build.

Also, sys/ptrace.h will not include the declarations for
PTRACE_GET_THREAD_AREA and PTRACE_GETVFPREG in arm (they are in
asm/ptrace.h and not included from sys/ptrace.h). So provide
compatibility declarations accordingly for arm architecture.

Change-Id: I58ab5274a66d84c0cbc9e9e9b23e0abc37bf67e5
Reviewed-on: https://chromium-review.googlesource.com/996073
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-04-04 20:35:04 +00:00
Joshua Peraza
24f07f7c43 linux: Enable ARM family exception and thread snapshots
ARM references:
http://elixir.free-electrons.com/linux/latest/source/arch/arm/include/asm/ucontext.h
http://elixir.free-electrons.com/linux/latest/source/arch/arm/kernel/signal.c#L185

ARM64 references:
http://elixir.free-electrons.com/linux/latest/source/arch/arm64/include/uapi/asm/sigcontext.h
http://elixir.free-electrons.com/linux/latest/source/arch/arm64/kernel/signal.c#L371

Bug: crashpad:30
Change-Id: I53f235b5826607db260bd1e43a819a93284843f5
Reviewed-on: https://chromium-review.googlesource.com/865435
Reviewed-by: Mark Mentovai <mark@chromium.org>
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
2018-01-24 17:09:24 +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
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
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