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