1From 5465f3e79f961abcf911586ddd3a41c13e1906cb Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 13 Feb 2019 09:51:14 -0800
4Subject: [PATCH] breakpad: Fix build with musl
5
6  elf_core_dump.h:59:2: error: "Unsupported __WORDSIZE for ElfCoreDump."
7  #error "Unsupported __WORDSIZE for ElfCoreDump."
8   ^
9
10Upstream-Status: Pending
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12
13---
14 .../breakpad/src/client/linux/handler/exception_handler.cc  | 6 +++++-
15 .../breakpad/breakpad/src/common/linux/elf_core_dump.h      | 1 +
16 2 files changed, 6 insertions(+), 1 deletion(-)
17
18diff --git a/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc b/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc
19index 36de9be320..bdd31b5172 100644
20--- a/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc
21+++ b/third_party/breakpad/breakpad/src/client/linux/handler/exception_handler.cc
22@@ -488,8 +488,10 @@ bool ExceptionHandler::SimulateSignalDelivery(int sig) {
23   // ExceptionHandler::HandleSignal().
24   siginfo.si_code = SI_USER;
25   siginfo.si_pid = getpid();
26-  ucontext_t context;
27+  ucontext_t context = {0};
28+#if defined(__GLIBC__)
29   getcontext(&context);
30+#endif
31   return HandleSignal(sig, &siginfo, &context);
32 }
33
34@@ -674,9 +676,11 @@ bool ExceptionHandler::WriteMinidump() {
35   sys_prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
36
37   CrashContext context;
38+#if defined(__GLIBC__)
39   int getcontext_result = getcontext(&context.context);
40   if (getcontext_result)
41     return false;
42+#endif
43
44 #if defined(__i386__)
45   // In CPUFillFromUContext in minidumpwriter.cc the stack pointer is retrieved
46diff --git a/third_party/breakpad/breakpad/src/common/linux/elf_core_dump.h b/third_party/breakpad/breakpad/src/common/linux/elf_core_dump.h
47index 4f27179f47..343e950530 100644
48--- a/third_party/breakpad/breakpad/src/common/linux/elf_core_dump.h
49+++ b/third_party/breakpad/breakpad/src/common/linux/elf_core_dump.h
50@@ -36,6 +36,7 @@
51 #include <limits.h>
52 #include <link.h>
53 #include <stddef.h>
54+#include <sys/reg.h>
55
56 #include "common/memory_range.h"
57
58