breakpad-use-ucontext_t.patch 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. From b6a312ed8e144a37da840ae50dbd39df5ffb7e9f Mon Sep 17 00:00:00 2001
  2. From: Khem Raj <raj.khem@gmail.com>
  3. Date: Sun, 2 Jul 2017 16:34:54 -0700
  4. Subject: [PATCH 2/2] replace struct ucontext with ucontext_t
  5. glibc 2.26 does not expose struct ucontext any longer
  6. Upstream-Status: Pending
  7. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  8. ---
  9. .../linux/dump_writer_common/ucontext_reader.cc | 30 +++++++++++-----------
  10. .../linux/dump_writer_common/ucontext_reader.h | 10 ++++----
  11. .../src/client/linux/handler/exception_handler.cc | 8 +++---
  12. .../src/client/linux/handler/exception_handler.h | 2 +-
  13. .../linux/microdump_writer/microdump_writer.cc | 2 +-
  14. .../linux/minidump_writer/minidump_writer.cc | 2 +-
  15. 6 files changed, 27 insertions(+), 27 deletions(-)
  16. diff --git a/breakpad/src/client/linux/dump_writer_common/ucontext_reader.cc b/breakpad/src/client/linux/dump_writer_common/ucontext_reader.cc
  17. index c80724dd8..93b4d9f85 100644
  18. --- a/breakpad/src/client/linux/dump_writer_common/ucontext_reader.cc
  19. +++ b/breakpad/src/client/linux/dump_writer_common/ucontext_reader.cc
  20. @@ -40,15 +40,15 @@ namespace google_breakpad {
  21. #if defined(__i386__)
  22. -uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) {
  23. +uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
  24. return uc->uc_mcontext.gregs[REG_ESP];
  25. }
  26. -uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) {
  27. +uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
  28. return uc->uc_mcontext.gregs[REG_EIP];
  29. }
  30. -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
  31. +void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
  32. const struct _libc_fpstate* fp) {
  33. const greg_t* regs = uc->uc_mcontext.gregs;
  34. @@ -88,15 +88,15 @@ void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
  35. #elif defined(__x86_64)
  36. -uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) {
  37. +uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
  38. return uc->uc_mcontext.gregs[REG_RSP];
  39. }
  40. -uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) {
  41. +uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
  42. return uc->uc_mcontext.gregs[REG_RIP];
  43. }
  44. -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
  45. +void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
  46. const struct _libc_fpstate* fpregs) {
  47. const greg_t* regs = uc->uc_mcontext.gregs;
  48. @@ -145,15 +145,15 @@ void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
  49. #elif defined(__ARM_EABI__)
  50. -uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) {
  51. +uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
  52. return uc->uc_mcontext.arm_sp;
  53. }
  54. -uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) {
  55. +uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
  56. return uc->uc_mcontext.arm_pc;
  57. }
  58. -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc) {
  59. +void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc) {
  60. out->context_flags = MD_CONTEXT_ARM_FULL;
  61. out->iregs[0] = uc->uc_mcontext.arm_r0;
  62. @@ -184,15 +184,15 @@ void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc) {
  63. #elif defined(__aarch64__)
  64. -uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) {
  65. +uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
  66. return uc->uc_mcontext.sp;
  67. }
  68. -uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) {
  69. +uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
  70. return uc->uc_mcontext.pc;
  71. }
  72. -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
  73. +void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
  74. const struct fpsimd_context* fpregs) {
  75. out->context_flags = MD_CONTEXT_ARM64_FULL;
  76. @@ -210,15 +210,15 @@ void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
  77. #elif defined(__mips__)
  78. -uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) {
  79. +uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
  80. return uc->uc_mcontext.gregs[MD_CONTEXT_MIPS_REG_SP];
  81. }
  82. -uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) {
  83. +uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
  84. return uc->uc_mcontext.pc;
  85. }
  86. -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc) {
  87. +void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc) {
  88. #if _MIPS_SIM == _ABI64
  89. out->context_flags = MD_CONTEXT_MIPS64_FULL;
  90. #elif _MIPS_SIM == _ABIO32
  91. diff --git a/breakpad/src/client/linux/dump_writer_common/ucontext_reader.h b/breakpad/src/client/linux/dump_writer_common/ucontext_reader.h
  92. index b6e77b4b5..2369a9ad3 100644
  93. --- a/breakpad/src/client/linux/dump_writer_common/ucontext_reader.h
  94. +++ b/breakpad/src/client/linux/dump_writer_common/ucontext_reader.h
  95. @@ -41,21 +41,21 @@ namespace google_breakpad {
  96. // Wraps platform-dependent implementations of accessors to ucontext structs.
  97. struct UContextReader {
  98. - static uintptr_t GetStackPointer(const struct ucontext* uc);
  99. + static uintptr_t GetStackPointer(const ucontext_t* uc);
  100. - static uintptr_t GetInstructionPointer(const struct ucontext* uc);
  101. + static uintptr_t GetInstructionPointer(const ucontext_t* uc);
  102. // Juggle a arch-specific ucontext into a minidump format
  103. // out: the minidump structure
  104. // info: the collection of register structures.
  105. #if defined(__i386__) || defined(__x86_64)
  106. - static void FillCPUContext(RawContextCPU *out, const ucontext *uc,
  107. + static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
  108. const struct _libc_fpstate* fp);
  109. #elif defined(__aarch64__)
  110. - static void FillCPUContext(RawContextCPU *out, const ucontext *uc,
  111. + static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
  112. const struct fpsimd_context* fpregs);
  113. #else
  114. - static void FillCPUContext(RawContextCPU *out, const ucontext *uc);
  115. + static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc);
  116. #endif
  117. };
  118. diff --git a/breakpad/src/client/linux/handler/exception_handler.cc b/breakpad/src/client/linux/handler/exception_handler.cc
  119. index b63f973b8..f2688acaf 100644
  120. --- a/breakpad/src/client/linux/handler/exception_handler.cc
  121. +++ b/breakpad/src/client/linux/handler/exception_handler.cc
  122. @@ -439,9 +439,9 @@ bool ExceptionHandler::HandleSignal(int sig, siginfo_t* info, void* uc) {
  123. // Fill in all the holes in the struct to make Valgrind happy.
  124. memset(&g_crash_context_, 0, sizeof(g_crash_context_));
  125. memcpy(&g_crash_context_.siginfo, info, sizeof(siginfo_t));
  126. - memcpy(&g_crash_context_.context, uc, sizeof(struct ucontext));
  127. + memcpy(&g_crash_context_.context, uc, sizeof(ucontext_t));
  128. #if defined(__aarch64__)
  129. - struct ucontext* uc_ptr = (struct ucontext*)uc;
  130. + ucontext_t* uc_ptr = (ucontext_t*)uc;
  131. struct fpsimd_context* fp_ptr =
  132. (struct fpsimd_context*)&uc_ptr->uc_mcontext.__reserved;
  133. if (fp_ptr->head.magic == FPSIMD_MAGIC) {
  134. @@ -452,7 +452,7 @@ bool ExceptionHandler::HandleSignal(int sig, siginfo_t* info, void* uc) {
  135. // FP state is not part of user ABI on ARM Linux.
  136. // In case of MIPS Linux FP state is already part of struct ucontext
  137. // and 'float_state' is not a member of CrashContext.
  138. - struct ucontext* uc_ptr = (struct ucontext*)uc;
  139. + ucontext_t* uc_ptr = (ucontext_t*)uc;
  140. if (uc_ptr->uc_mcontext.fpregs) {
  141. memcpy(&g_crash_context_.float_state, uc_ptr->uc_mcontext.fpregs,
  142. sizeof(g_crash_context_.float_state));
  143. @@ -476,7 +476,7 @@ bool ExceptionHandler::SimulateSignalDelivery(int sig) {
  144. // ExceptionHandler::HandleSignal().
  145. siginfo.si_code = SI_USER;
  146. siginfo.si_pid = getpid();
  147. - struct ucontext context;
  148. + ucontext_t context;
  149. getcontext(&context);
  150. return HandleSignal(sig, &siginfo, &context);
  151. }
  152. diff --git a/breakpad/src/client/linux/handler/exception_handler.h b/breakpad/src/client/linux/handler/exception_handler.h
  153. index 591c31085..846df772f 100644
  154. --- a/breakpad/src/client/linux/handler/exception_handler.h
  155. +++ b/breakpad/src/client/linux/handler/exception_handler.h
  156. @@ -191,7 +191,7 @@ class ExceptionHandler {
  157. struct CrashContext {
  158. siginfo_t siginfo;
  159. pid_t tid; // the crashing thread.
  160. - struct ucontext context;
  161. + ucontext_t context;
  162. #if !defined(__ARM_EABI__) && !defined(__mips__)
  163. // #ifdef this out because FP state is not part of user ABI for Linux ARM.
  164. // In case of MIPS Linux FP state is already part of struct
  165. diff --git a/breakpad/src/client/linux/microdump_writer/microdump_writer.cc b/breakpad/src/client/linux/microdump_writer/microdump_writer.cc
  166. index 6f5b43559..a508667a0 100644
  167. --- a/breakpad/src/client/linux/microdump_writer/microdump_writer.cc
  168. +++ b/breakpad/src/client/linux/microdump_writer/microdump_writer.cc
  169. @@ -571,7 +571,7 @@ class MicrodumpWriter {
  170. void* Alloc(unsigned bytes) { return dumper_->allocator()->Alloc(bytes); }
  171. - const struct ucontext* const ucontext_;
  172. + const ucontext_t* const ucontext_;
  173. #if !defined(__ARM_EABI__) && !defined(__mips__)
  174. const google_breakpad::fpstate_t* const float_state_;
  175. #endif
  176. diff --git a/breakpad/src/client/linux/minidump_writer/minidump_writer.cc b/breakpad/src/client/linux/minidump_writer/minidump_writer.cc
  177. index 86009b9f6..f2aec73d7 100644
  178. --- a/breakpad/src/client/linux/minidump_writer/minidump_writer.cc
  179. +++ b/breakpad/src/client/linux/minidump_writer/minidump_writer.cc
  180. @@ -1248,7 +1248,7 @@ class MinidumpWriter {
  181. const int fd_; // File descriptor where the minidum should be written.
  182. const char* path_; // Path to the file where the minidum should be written.
  183. - const struct ucontext* const ucontext_; // also from the signal handler
  184. + const ucontext_t* const ucontext_; // also from the signal handler
  185. #if !defined(__ARM_EABI__) && !defined(__mips__)
  186. const google_breakpad::fpstate_t* const float_state_; // ditto
  187. #endif
  188. --
  189. 2.13.2