glibc-2.26-fix.diff 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. From 6a0b7c8ecf0734ba1bcdccf8e0ee97e721fd5420 Mon Sep 17 00:00:00 2001
  2. Message-Id: <6a0b7c8ecf0734ba1bcdccf8e0ee97e721fd5420.1505113337.git.jan.steffens@gmail.com>
  3. From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= <emilio@crisal.io>
  4. Date: Sat, 19 Aug 2017 20:14:25 +0200
  5. Subject: [PATCH] Fix use of struct ucontext (squash 2 commits)
  6. Needed for building with glibc 2.26.
  7. Bug 1385667: Use ucontext_t consistently in breakpad-client. r=ted
  8. MozReview-Commit-ID: AJhzJdNXP0f
  9. Bug 1394149: Fix remaining uses of ucontext in breakpad-client. r=ted
  10. MozReview-Commit-ID: 5tP7fXsI7dQ
  11. ---
  12. .../linux/dump_writer_common/ucontext_reader.cc | 30 +++++++++++-----------
  13. .../linux/dump_writer_common/ucontext_reader.h | 10 ++++----
  14. .../linux/handler/exception_handler.cc | 10 ++++----
  15. .../linux/handler/exception_handler.h | 2 +-
  16. .../linux/microdump_writer/microdump_writer.cc | 2 +-
  17. .../linux/minidump_writer/minidump_writer.cc | 2 +-
  18. 6 files changed, 28 insertions(+), 28 deletions(-)
  19. diff --git a/toolkit/crashreporter/breakpad-client/linux/dump_writer_common/ucontext_reader.cc b/toolkit/crashreporter/breakpad-client/linux/dump_writer_common/ucontext_reader.cc
  20. index 999960912e459e1b..303c0ebd32b663c4 100644
  21. --- a/toolkit/crashreporter/breakpad-client/linux/dump_writer_common/ucontext_reader.cc
  22. +++ b/toolkit/crashreporter/breakpad-client/linux/dump_writer_common/ucontext_reader.cc
  23. @@ -40,15 +40,15 @@ namespace google_breakpad {
  24. #if defined(__i386__)
  25. -uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) {
  26. +uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
  27. return uc->uc_mcontext.gregs[REG_ESP];
  28. }
  29. -uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) {
  30. +uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
  31. return uc->uc_mcontext.gregs[REG_EIP];
  32. }
  33. -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
  34. +void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
  35. const struct _libc_fpstate* fp) {
  36. const greg_t* regs = uc->uc_mcontext.gregs;
  37. @@ -88,15 +88,15 @@ void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
  38. #elif defined(__x86_64)
  39. -uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) {
  40. +uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
  41. return uc->uc_mcontext.gregs[REG_RSP];
  42. }
  43. -uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) {
  44. +uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
  45. return uc->uc_mcontext.gregs[REG_RIP];
  46. }
  47. -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
  48. +void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
  49. const struct _libc_fpstate* fpregs) {
  50. const greg_t* regs = uc->uc_mcontext.gregs;
  51. @@ -145,15 +145,15 @@ void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
  52. #elif defined(__ARM_EABI__)
  53. -uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) {
  54. +uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
  55. return uc->uc_mcontext.arm_sp;
  56. }
  57. -uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) {
  58. +uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
  59. return uc->uc_mcontext.arm_pc;
  60. }
  61. -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc) {
  62. +void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc) {
  63. out->context_flags = MD_CONTEXT_ARM_FULL;
  64. out->iregs[0] = uc->uc_mcontext.arm_r0;
  65. @@ -184,41 +184,41 @@ void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc) {
  66. #elif defined(__aarch64__)
  67. -uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) {
  68. +uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
  69. return uc->uc_mcontext.sp;
  70. }
  71. -uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) {
  72. +uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
  73. return uc->uc_mcontext.pc;
  74. }
  75. -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
  76. +void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
  77. const struct fpsimd_context* fpregs) {
  78. out->context_flags = MD_CONTEXT_ARM64_FULL;
  79. out->cpsr = static_cast<uint32_t>(uc->uc_mcontext.pstate);
  80. for (int i = 0; i < MD_CONTEXT_ARM64_REG_SP; ++i)
  81. out->iregs[i] = uc->uc_mcontext.regs[i];
  82. out->iregs[MD_CONTEXT_ARM64_REG_SP] = uc->uc_mcontext.sp;
  83. out->iregs[MD_CONTEXT_ARM64_REG_PC] = uc->uc_mcontext.pc;
  84. out->float_save.fpsr = fpregs->fpsr;
  85. out->float_save.fpcr = fpregs->fpcr;
  86. my_memcpy(&out->float_save.regs, &fpregs->vregs,
  87. MD_FLOATINGSAVEAREA_ARM64_FPR_COUNT * 16);
  88. }
  89. #elif defined(__mips__)
  90. -uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) {
  91. +uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
  92. return uc->uc_mcontext.gregs[MD_CONTEXT_MIPS_REG_SP];
  93. }
  94. -uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) {
  95. +uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
  96. return uc->uc_mcontext.pc;
  97. }
  98. -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc) {
  99. +void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc) {
  100. #if _MIPS_SIM == _ABI64
  101. out->context_flags = MD_CONTEXT_MIPS64_FULL;
  102. #elif _MIPS_SIM == _ABIO32
  103. diff --git a/toolkit/crashreporter/breakpad-client/linux/dump_writer_common/ucontext_reader.h b/toolkit/crashreporter/breakpad-client/linux/dump_writer_common/ucontext_reader.h
  104. index c533e28ba7441e83..039752a2dfb6e589 100644
  105. --- a/toolkit/crashreporter/breakpad-client/linux/dump_writer_common/ucontext_reader.h
  106. +++ b/toolkit/crashreporter/breakpad-client/linux/dump_writer_common/ucontext_reader.h
  107. @@ -41,21 +41,21 @@ namespace google_breakpad {
  108. // Wraps platform-dependent implementations of accessors to ucontext structs.
  109. struct UContextReader {
  110. - static uintptr_t GetStackPointer(const struct ucontext* uc);
  111. + static uintptr_t GetStackPointer(const ucontext_t* uc);
  112. - static uintptr_t GetInstructionPointer(const struct ucontext* uc);
  113. + static uintptr_t GetInstructionPointer(const ucontext_t* uc);
  114. // Juggle a arch-specific ucontext into a minidump format
  115. // out: the minidump structure
  116. // info: the collection of register structures.
  117. #if defined(__i386__) || defined(__x86_64)
  118. - static void FillCPUContext(RawContextCPU *out, const ucontext *uc,
  119. + static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
  120. const struct _libc_fpstate* fp);
  121. #elif defined(__aarch64__)
  122. - static void FillCPUContext(RawContextCPU *out, const ucontext *uc,
  123. + static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
  124. const struct fpsimd_context* fpregs);
  125. #else
  126. - static void FillCPUContext(RawContextCPU *out, const ucontext *uc);
  127. + static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc);
  128. #endif
  129. };
  130. diff --git a/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.cc b/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.cc
  131. index 71a51a763938e39d..12df9bc96ec45fea 100644
  132. --- a/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.cc
  133. +++ b/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.cc
  134. @@ -439,44 +439,44 @@ bool ExceptionHandler::HandleSignal(int sig, siginfo_t* info, void* uc) {
  135. // Fill in all the holes in the struct to make Valgrind happy.
  136. memset(&g_crash_context_, 0, sizeof(g_crash_context_));
  137. memcpy(&g_crash_context_.siginfo, info, sizeof(siginfo_t));
  138. - memcpy(&g_crash_context_.context, uc, sizeof(struct ucontext));
  139. + memcpy(&g_crash_context_.context, uc, sizeof(ucontext_t));
  140. #if defined(__aarch64__)
  141. - struct ucontext* uc_ptr = (struct ucontext*)uc;
  142. + ucontext_t* uc_ptr = (ucontext_t*)uc;
  143. struct fpsimd_context* fp_ptr =
  144. (struct fpsimd_context*)&uc_ptr->uc_mcontext.__reserved;
  145. if (fp_ptr->head.magic == FPSIMD_MAGIC) {
  146. memcpy(&g_crash_context_.float_state, fp_ptr,
  147. sizeof(g_crash_context_.float_state));
  148. }
  149. #elif !defined(__ARM_EABI__) && !defined(__mips__)
  150. // FP state is not part of user ABI on ARM Linux.
  151. - // In case of MIPS Linux FP state is already part of struct ucontext
  152. + // In case of MIPS Linux FP state is already part of ucontext_t
  153. // and 'float_state' is not a member of CrashContext.
  154. - struct ucontext* uc_ptr = (struct ucontext*)uc;
  155. + ucontext_t* uc_ptr = (ucontext_t*)uc;
  156. if (uc_ptr->uc_mcontext.fpregs) {
  157. memcpy(&g_crash_context_.float_state, uc_ptr->uc_mcontext.fpregs,
  158. sizeof(g_crash_context_.float_state));
  159. }
  160. #endif
  161. g_crash_context_.tid = syscall(__NR_gettid);
  162. if (crash_handler_ != NULL) {
  163. if (crash_handler_(&g_crash_context_, sizeof(g_crash_context_),
  164. callback_context_)) {
  165. return true;
  166. }
  167. }
  168. return GenerateDump(&g_crash_context_);
  169. }
  170. // This is a public interface to HandleSignal that allows the client to
  171. // generate a crash dump. This function may run in a compromised context.
  172. bool ExceptionHandler::SimulateSignalDelivery(int sig) {
  173. siginfo_t siginfo = {};
  174. // Mimic a trusted signal to allow tracing the process (see
  175. // ExceptionHandler::HandleSignal().
  176. siginfo.si_code = SI_USER;
  177. siginfo.si_pid = getpid();
  178. - struct ucontext context;
  179. + ucontext_t context;
  180. getcontext(&context);
  181. return HandleSignal(sig, &siginfo, &context);
  182. }
  183. diff --git a/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.h b/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.h
  184. index 711586fec7ddae59..be1880170e2826b0 100644
  185. --- a/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.h
  186. +++ b/toolkit/crashreporter/breakpad-client/linux/handler/exception_handler.h
  187. @@ -191,7 +191,7 @@ class ExceptionHandler {
  188. struct CrashContext {
  189. siginfo_t siginfo;
  190. pid_t tid; // the crashing thread.
  191. - struct ucontext context;
  192. + ucontext_t context;
  193. #if !defined(__ARM_EABI__) && !defined(__mips__)
  194. // #ifdef this out because FP state is not part of user ABI for Linux ARM.
  195. // In case of MIPS Linux FP state is already part of struct
  196. diff --git a/toolkit/crashreporter/breakpad-client/linux/microdump_writer/microdump_writer.cc b/toolkit/crashreporter/breakpad-client/linux/microdump_writer/microdump_writer.cc
  197. index ff20bf36584c876b..a0b90e08fc5f0cff 100644
  198. --- a/toolkit/crashreporter/breakpad-client/linux/microdump_writer/microdump_writer.cc
  199. +++ b/toolkit/crashreporter/breakpad-client/linux/microdump_writer/microdump_writer.cc
  200. @@ -571,7 +571,7 @@ class MicrodumpWriter {
  201. void* Alloc(unsigned bytes) { return dumper_->allocator()->Alloc(bytes); }
  202. - const struct ucontext* const ucontext_;
  203. + const ucontext_t* const ucontext_;
  204. #if !defined(__ARM_EABI__) && !defined(__mips__)
  205. const google_breakpad::fpstate_t* const float_state_;
  206. #endif
  207. diff --git a/toolkit/crashreporter/breakpad-client/linux/minidump_writer/minidump_writer.cc b/toolkit/crashreporter/breakpad-client/linux/minidump_writer/minidump_writer.cc
  208. index 0650bb95c179464a..6b5304bcd605ca3a 100644
  209. --- a/toolkit/crashreporter/breakpad-client/linux/minidump_writer/minidump_writer.cc
  210. +++ b/toolkit/crashreporter/breakpad-client/linux/minidump_writer/minidump_writer.cc
  211. @@ -1247,7 +1247,7 @@ class MinidumpWriter {
  212. const int fd_; // File descriptor where the minidum should be written.
  213. const char* path_; // Path to the file where the minidum should be written.
  214. - const struct ucontext* const ucontext_; // also from the signal handler
  215. + const ucontext_t* const ucontext_; // also from the signal handler
  216. #if !defined(__ARM_EABI__) && !defined(__mips__)
  217. const google_breakpad::fpstate_t* const float_state_; // ditto
  218. #endif
  219. --
  220. 2.14.1