0002-Replace-remaining-references-to-struct-ucontext-with.patch 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. From 7975a962e1d6dbad5a46792a54e647abd7caf5f1 Mon Sep 17 00:00:00 2001
  2. From: Mark Mentovai <mark@chromium.org>
  3. Date: Tue, 19 Sep 2017 22:48:30 -0400
  4. Subject: [PATCH] Replace remaining references to 'struct ucontext' with
  5. 'ucontext_t'
  6. This relands
  7. https://chromium.googlesource.com/breakpad/breakpad/src/+/e3035bc406cee8a4d765e59ad46eb828705f17f4,
  8. which was accidentally committed to breakpad/breakpad/src, the read-only
  9. mirror of src in breakpad/breakpad. (Well, it should have been
  10. read-only.) See https://crbug.com/766164.
  11. This fixes issues with glibc-2.26.
  12. See https://bugs.gentoo.org/show_bug.cgi?id=628782 ,
  13. https://sourceware.org/git/?p=glibc.git;h=251287734e89a52da3db682a8241eb6bccc050c9 , and
  14. https://sourceware.org/ml/libc-alpha/2017-08/msg00010.html for context.
  15. Change-Id: Id66f474d636dd2afa450bab925c5514a800fdd6f
  16. Reviewed-on: https://chromium-review.googlesource.com/674304
  17. Reviewed-by: Mark Mentovai <mark@chromium.org>
  18. (cherry picked from commit bddcc58860f522a0d4cbaa7e9d04058caee0db9d)
  19. [Romain: backport from upstream]
  20. Signed-off-by: Romain Naour <romain.naour@gmail.com>
  21. ---
  22. .../linux/dump_writer_common/ucontext_reader.cc | 32 +++++++++++-----------
  23. .../linux/dump_writer_common/ucontext_reader.h | 14 +++++-----
  24. src/client/linux/handler/exception_handler.cc | 10 +++----
  25. src/client/linux/handler/exception_handler.h | 6 ++--
  26. .../linux/microdump_writer/microdump_writer.cc | 2 +-
  27. .../linux/minidump_writer/minidump_writer.cc | 2 +-
  28. 6 files changed, 33 insertions(+), 33 deletions(-)
  29. diff --git a/src/client/linux/dump_writer_common/ucontext_reader.cc b/src/client/linux/dump_writer_common/ucontext_reader.cc
  30. index c80724d..052ce37 100644
  31. --- a/src/client/linux/dump_writer_common/ucontext_reader.cc
  32. +++ b/src/client/linux/dump_writer_common/ucontext_reader.cc
  33. @@ -36,19 +36,19 @@ namespace google_breakpad {
  34. // Minidump defines register structures which are different from the raw
  35. // structures which we get from the kernel. These are platform specific
  36. -// functions to juggle the ucontext and user structures into minidump format.
  37. +// functions to juggle the ucontext_t and user structures into minidump format.
  38. #if defined(__i386__)
  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_ESP];
  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_EIP];
  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* fp) {
  50. const greg_t* regs = uc->uc_mcontext.gregs;
  51. @@ -88,15 +88,15 @@ void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
  52. #elif defined(__x86_64)
  53. -uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) {
  54. +uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
  55. return uc->uc_mcontext.gregs[REG_RSP];
  56. }
  57. -uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) {
  58. +uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
  59. return uc->uc_mcontext.gregs[REG_RIP];
  60. }
  61. -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
  62. +void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
  63. const struct _libc_fpstate* fpregs) {
  64. const greg_t* regs = uc->uc_mcontext.gregs;
  65. @@ -145,15 +145,15 @@ void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
  66. #elif defined(__ARM_EABI__)
  67. -uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) {
  68. +uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
  69. return uc->uc_mcontext.arm_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.arm_pc;
  74. }
  75. -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc) {
  76. +void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc) {
  77. out->context_flags = MD_CONTEXT_ARM_FULL;
  78. out->iregs[0] = uc->uc_mcontext.arm_r0;
  79. @@ -184,15 +184,15 @@ void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc) {
  80. #elif defined(__aarch64__)
  81. -uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) {
  82. +uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
  83. return uc->uc_mcontext.sp;
  84. }
  85. -uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) {
  86. +uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
  87. return uc->uc_mcontext.pc;
  88. }
  89. -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
  90. +void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
  91. const struct fpsimd_context* fpregs) {
  92. out->context_flags = MD_CONTEXT_ARM64_FULL;
  93. @@ -210,15 +210,15 @@ void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
  94. #elif defined(__mips__)
  95. -uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) {
  96. +uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
  97. return uc->uc_mcontext.gregs[MD_CONTEXT_MIPS_REG_SP];
  98. }
  99. -uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) {
  100. +uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
  101. return uc->uc_mcontext.pc;
  102. }
  103. -void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc) {
  104. +void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc) {
  105. #if _MIPS_SIM == _ABI64
  106. out->context_flags = MD_CONTEXT_MIPS64_FULL;
  107. #elif _MIPS_SIM == _ABIO32
  108. diff --git a/src/client/linux/dump_writer_common/ucontext_reader.h b/src/client/linux/dump_writer_common/ucontext_reader.h
  109. index b6e77b4..2de80b7 100644
  110. --- a/src/client/linux/dump_writer_common/ucontext_reader.h
  111. +++ b/src/client/linux/dump_writer_common/ucontext_reader.h
  112. @@ -39,23 +39,23 @@
  113. namespace google_breakpad {
  114. -// Wraps platform-dependent implementations of accessors to ucontext structs.
  115. +// Wraps platform-dependent implementations of accessors to ucontext_t structs.
  116. struct UContextReader {
  117. - static uintptr_t GetStackPointer(const struct ucontext* uc);
  118. + static uintptr_t GetStackPointer(const ucontext_t* uc);
  119. - static uintptr_t GetInstructionPointer(const struct ucontext* uc);
  120. + static uintptr_t GetInstructionPointer(const ucontext_t* uc);
  121. - // Juggle a arch-specific ucontext into a minidump format
  122. + // Juggle a arch-specific ucontext_t into a minidump format
  123. // out: the minidump structure
  124. // info: the collection of register structures.
  125. #if defined(__i386__) || defined(__x86_64)
  126. - static void FillCPUContext(RawContextCPU *out, const ucontext *uc,
  127. + static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
  128. const struct _libc_fpstate* fp);
  129. #elif defined(__aarch64__)
  130. - static void FillCPUContext(RawContextCPU *out, const ucontext *uc,
  131. + static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
  132. const struct fpsimd_context* fpregs);
  133. #else
  134. - static void FillCPUContext(RawContextCPU *out, const ucontext *uc);
  135. + static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc);
  136. #endif
  137. };
  138. diff --git a/src/client/linux/handler/exception_handler.cc b/src/client/linux/handler/exception_handler.cc
  139. index b63f973..3d809b8 100644
  140. --- a/src/client/linux/handler/exception_handler.cc
  141. +++ b/src/client/linux/handler/exception_handler.cc
  142. @@ -439,9 +439,9 @@ bool ExceptionHandler::HandleSignal(int sig, siginfo_t* info, void* uc) {
  143. // Fill in all the holes in the struct to make Valgrind happy.
  144. memset(&g_crash_context_, 0, sizeof(g_crash_context_));
  145. memcpy(&g_crash_context_.siginfo, info, sizeof(siginfo_t));
  146. - memcpy(&g_crash_context_.context, uc, sizeof(struct ucontext));
  147. + memcpy(&g_crash_context_.context, uc, sizeof(ucontext_t));
  148. #if defined(__aarch64__)
  149. - struct ucontext* uc_ptr = (struct ucontext*)uc;
  150. + ucontext_t* uc_ptr = (ucontext_t*)uc;
  151. struct fpsimd_context* fp_ptr =
  152. (struct fpsimd_context*)&uc_ptr->uc_mcontext.__reserved;
  153. if (fp_ptr->head.magic == FPSIMD_MAGIC) {
  154. @@ -450,9 +450,9 @@ bool ExceptionHandler::HandleSignal(int sig, siginfo_t* info, void* uc) {
  155. }
  156. #elif !defined(__ARM_EABI__) && !defined(__mips__)
  157. // FP state is not part of user ABI on ARM Linux.
  158. - // In case of MIPS Linux FP state is already part of struct ucontext
  159. + // In case of MIPS Linux FP state is already part of ucontext_t
  160. // and 'float_state' is not a member of CrashContext.
  161. - struct ucontext* uc_ptr = (struct ucontext*)uc;
  162. + ucontext_t* uc_ptr = (ucontext_t*)uc;
  163. if (uc_ptr->uc_mcontext.fpregs) {
  164. memcpy(&g_crash_context_.float_state, uc_ptr->uc_mcontext.fpregs,
  165. sizeof(g_crash_context_.float_state));
  166. @@ -476,7 +476,7 @@ bool ExceptionHandler::SimulateSignalDelivery(int sig) {
  167. // ExceptionHandler::HandleSignal().
  168. siginfo.si_code = SI_USER;
  169. siginfo.si_pid = getpid();
  170. - struct ucontext context;
  171. + ucontext_t context;
  172. getcontext(&context);
  173. return HandleSignal(sig, &siginfo, &context);
  174. }
  175. diff --git a/src/client/linux/handler/exception_handler.h b/src/client/linux/handler/exception_handler.h
  176. index 591c310..42f4055 100644
  177. --- a/src/client/linux/handler/exception_handler.h
  178. +++ b/src/client/linux/handler/exception_handler.h
  179. @@ -191,11 +191,11 @@ class ExceptionHandler {
  180. struct CrashContext {
  181. siginfo_t siginfo;
  182. pid_t tid; // the crashing thread.
  183. - struct ucontext context;
  184. + ucontext_t context;
  185. #if !defined(__ARM_EABI__) && !defined(__mips__)
  186. // #ifdef this out because FP state is not part of user ABI for Linux ARM.
  187. - // In case of MIPS Linux FP state is already part of struct
  188. - // ucontext so 'float_state' is not required.
  189. + // In case of MIPS Linux FP state is already part of ucontext_t so
  190. + // 'float_state' is not required.
  191. fpstate_t float_state;
  192. #endif
  193. };
  194. diff --git a/src/client/linux/microdump_writer/microdump_writer.cc b/src/client/linux/microdump_writer/microdump_writer.cc
  195. index 6f5b435..a508667 100644
  196. --- a/src/client/linux/microdump_writer/microdump_writer.cc
  197. +++ b/src/client/linux/microdump_writer/microdump_writer.cc
  198. @@ -571,7 +571,7 @@ class MicrodumpWriter {
  199. void* Alloc(unsigned bytes) { return dumper_->allocator()->Alloc(bytes); }
  200. - const struct ucontext* const ucontext_;
  201. + const ucontext_t* const ucontext_;
  202. #if !defined(__ARM_EABI__) && !defined(__mips__)
  203. const google_breakpad::fpstate_t* const float_state_;
  204. #endif
  205. diff --git a/src/client/linux/minidump_writer/minidump_writer.cc b/src/client/linux/minidump_writer/minidump_writer.cc
  206. index 86009b9..f2aec73 100644
  207. --- a/src/client/linux/minidump_writer/minidump_writer.cc
  208. +++ b/src/client/linux/minidump_writer/minidump_writer.cc
  209. @@ -1248,7 +1248,7 @@ class MinidumpWriter {
  210. const int fd_; // File descriptor where the minidum should be written.
  211. const char* path_; // Path to the file where the minidum should be written.
  212. - const struct ucontext* const ucontext_; // also from the signal handler
  213. + const ucontext_t* const ucontext_; // also from the signal handler
  214. #if !defined(__ARM_EABI__) && !defined(__mips__)
  215. const google_breakpad::fpstate_t* const float_state_; // ditto
  216. #endif
  217. --
  218. 2.9.5