forked from ~ljy/RK356X_SDK_RELEASE

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