blob: 07cb8a366ea2f75eb1857ac5298e8e0c5b0e4406 [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001From b90c8f3b60bfe5dbed2823620242e9d30b9eb28f Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Wed, 28 Jun 2017 19:01:18 -0700
4Subject: [PATCH] Replace use of struct ucontext with ucontext_t
5
6glibc 2.26 would not expose struct ucontext anymore
7
8Signed-off-by: Khem Raj <raj.khem@gmail.com>
9---
10Upstream-Status: Pending
11
12 .../linux/dump_writer_common/ucontext_reader.cc | 32 +++++++++++-----------
13 .../linux/dump_writer_common/ucontext_reader.h | 14 +++++-----
14 src/client/linux/handler/exception_handler.cc | 10 +++----
15 src/client/linux/handler/exception_handler.h | 4 +--
16 .../linux/microdump_writer/microdump_writer.cc | 2 +-
17 .../linux/minidump_writer/minidump_writer.cc | 2 +-
18 6 files changed, 32 insertions(+), 32 deletions(-)
19
20diff --git a/src/client/linux/dump_writer_common/ucontext_reader.cc b/src/client/linux/dump_writer_common/ucontext_reader.cc
21index c80724dd..052ce37c 100644
22--- a/src/client/linux/dump_writer_common/ucontext_reader.cc
23+++ b/src/client/linux/dump_writer_common/ucontext_reader.cc
24@@ -36,19 +36,19 @@ namespace google_breakpad {
25
26 // Minidump defines register structures which are different from the raw
27 // structures which we get from the kernel. These are platform specific
28-// functions to juggle the ucontext and user structures into minidump format.
29+// functions to juggle the ucontext_t and user structures into minidump format.
30
31 #if defined(__i386__)
32
33-uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) {
34+uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
35 return uc->uc_mcontext.gregs[REG_ESP];
36 }
37
38-uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) {
39+uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
40 return uc->uc_mcontext.gregs[REG_EIP];
41 }
42
43-void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
44+void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
45 const struct _libc_fpstate* fp) {
46 const greg_t* regs = uc->uc_mcontext.gregs;
47
48@@ -88,15 +88,15 @@ void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
49
50 #elif defined(__x86_64)
51
52-uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) {
53+uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
54 return uc->uc_mcontext.gregs[REG_RSP];
55 }
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
62-void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
63+void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
64 const struct _libc_fpstate* fpregs) {
65 const greg_t* regs = uc->uc_mcontext.gregs;
66
67@@ -145,15 +145,15 @@ void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
68
69 #elif defined(__ARM_EABI__)
70
71-uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) {
72+uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
73 return uc->uc_mcontext.arm_sp;
74 }
75
76-uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) {
77+uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
78 return uc->uc_mcontext.arm_pc;
79 }
80
81-void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc) {
82+void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc) {
83 out->context_flags = MD_CONTEXT_ARM_FULL;
84
85 out->iregs[0] = uc->uc_mcontext.arm_r0;
86@@ -184,15 +184,15 @@ void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc) {
87
88 #elif defined(__aarch64__)
89
90-uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) {
91+uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
92 return uc->uc_mcontext.sp;
93 }
94
95-uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) {
96+uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
97 return uc->uc_mcontext.pc;
98 }
99
100-void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
101+void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
102 const struct fpsimd_context* fpregs) {
103 out->context_flags = MD_CONTEXT_ARM64_FULL;
104
105@@ -210,15 +210,15 @@ void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc,
106
107 #elif defined(__mips__)
108
109-uintptr_t UContextReader::GetStackPointer(const struct ucontext* uc) {
110+uintptr_t UContextReader::GetStackPointer(const ucontext_t* uc) {
111 return uc->uc_mcontext.gregs[MD_CONTEXT_MIPS_REG_SP];
112 }
113
114-uintptr_t UContextReader::GetInstructionPointer(const struct ucontext* uc) {
115+uintptr_t UContextReader::GetInstructionPointer(const ucontext_t* uc) {
116 return uc->uc_mcontext.pc;
117 }
118
119-void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext *uc) {
120+void UContextReader::FillCPUContext(RawContextCPU *out, const ucontext_t *uc) {
121 #if _MIPS_SIM == _ABI64
122 out->context_flags = MD_CONTEXT_MIPS64_FULL;
123 #elif _MIPS_SIM == _ABIO32
124diff --git a/src/client/linux/dump_writer_common/ucontext_reader.h b/src/client/linux/dump_writer_common/ucontext_reader.h
125index b6e77b4b..2de80b70 100644
126--- a/src/client/linux/dump_writer_common/ucontext_reader.h
127+++ b/src/client/linux/dump_writer_common/ucontext_reader.h
128@@ -39,23 +39,23 @@
129
130 namespace google_breakpad {
131
132-// Wraps platform-dependent implementations of accessors to ucontext structs.
133+// Wraps platform-dependent implementations of accessors to ucontext_t structs.
134 struct UContextReader {
135- static uintptr_t GetStackPointer(const struct ucontext* uc);
136+ static uintptr_t GetStackPointer(const ucontext_t* uc);
137
138- static uintptr_t GetInstructionPointer(const struct ucontext* uc);
139+ static uintptr_t GetInstructionPointer(const ucontext_t* uc);
140
141- // Juggle a arch-specific ucontext into a minidump format
142+ // Juggle a arch-specific ucontext_t into a minidump format
143 // out: the minidump structure
144 // info: the collection of register structures.
145 #if defined(__i386__) || defined(__x86_64)
146- static void FillCPUContext(RawContextCPU *out, const ucontext *uc,
147+ static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
148 const struct _libc_fpstate* fp);
149 #elif defined(__aarch64__)
150- static void FillCPUContext(RawContextCPU *out, const ucontext *uc,
151+ static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc,
152 const struct fpsimd_context* fpregs);
153 #else
154- static void FillCPUContext(RawContextCPU *out, const ucontext *uc);
155+ static void FillCPUContext(RawContextCPU *out, const ucontext_t *uc);
156 #endif
157 };
158
159diff --git a/src/client/linux/handler/exception_handler.cc b/src/client/linux/handler/exception_handler.cc
160index 586d84e9..05936d28 100644
161--- a/src/client/linux/handler/exception_handler.cc
162+++ b/src/client/linux/handler/exception_handler.cc
163@@ -457,9 +457,9 @@ bool ExceptionHandler::HandleSignal(int /*sig*/, siginfo_t* info, void* uc) {
164 // Fill in all the holes in the struct to make Valgrind happy.
165 memset(&g_crash_context_, 0, sizeof(g_crash_context_));
166 memcpy(&g_crash_context_.siginfo, info, sizeof(siginfo_t));
167- memcpy(&g_crash_context_.context, uc, sizeof(struct ucontext));
168+ memcpy(&g_crash_context_.context, uc, sizeof(ucontext_t));
169 #if defined(__aarch64__)
170- struct ucontext* uc_ptr = (struct ucontext*)uc;
171+ ucontext_t* uc_ptr = (ucontext_t*)uc;
172 struct fpsimd_context* fp_ptr =
173 (struct fpsimd_context*)&uc_ptr->uc_mcontext.__reserved;
174 if (fp_ptr->head.magic == FPSIMD_MAGIC) {
175@@ -468,9 +468,9 @@ bool ExceptionHandler::HandleSignal(int /*sig*/, siginfo_t* info, void* uc) {
176 }
177 #elif !defined(__ARM_EABI__) && !defined(__mips__)
178 // FP state is not part of user ABI on ARM Linux.
179- // In case of MIPS Linux FP state is already part of struct ucontext
180+ // In case of MIPS Linux FP state is already part of ucontext_t
181 // and 'float_state' is not a member of CrashContext.
182- struct ucontext* uc_ptr = (struct ucontext*)uc;
183+ ucontext_t* uc_ptr = (ucontext_t*)uc;
184 if (uc_ptr->uc_mcontext.fpregs) {
185 memcpy(&g_crash_context_.float_state, uc_ptr->uc_mcontext.fpregs,
186 sizeof(g_crash_context_.float_state));
187@@ -494,7 +494,7 @@ bool ExceptionHandler::SimulateSignalDelivery(int sig) {
188 // ExceptionHandler::HandleSignal().
189 siginfo.si_code = SI_USER;
190 siginfo.si_pid = getpid();
191- struct ucontext context;
192+ ucontext_t context;
193 getcontext(&context);
194 return HandleSignal(sig, &siginfo, &context);
195 }
196diff --git a/src/client/linux/handler/exception_handler.h b/src/client/linux/handler/exception_handler.h
197index daba57e0..25598a29 100644
198--- a/src/client/linux/handler/exception_handler.h
199+++ b/src/client/linux/handler/exception_handler.h
200@@ -191,11 +191,11 @@ class ExceptionHandler {
201 struct CrashContext {
202 siginfo_t siginfo;
203 pid_t tid; // the crashing thread.
204- struct ucontext context;
205+ ucontext_t context;
206 #if !defined(__ARM_EABI__) && !defined(__mips__)
207 // #ifdef this out because FP state is not part of user ABI for Linux ARM.
208 // In case of MIPS Linux FP state is already part of struct
209- // ucontext so 'float_state' is not required.
210+ // ucontext_t so 'float_state' is not required.
211 fpstate_t float_state;
212 #endif
213 };
214diff --git a/src/client/linux/microdump_writer/microdump_writer.cc b/src/client/linux/microdump_writer/microdump_writer.cc
215index 3764eec2..80ad5c46 100644
216--- a/src/client/linux/microdump_writer/microdump_writer.cc
217+++ b/src/client/linux/microdump_writer/microdump_writer.cc
218@@ -593,7 +593,7 @@ class MicrodumpWriter {
219
220 void* Alloc(unsigned bytes) { return dumper_->allocator()->Alloc(bytes); }
221
222- const struct ucontext* const ucontext_;
223+ const ucontext_t* const ucontext_;
224 #if !defined(__ARM_EABI__) && !defined(__mips__)
225 const google_breakpad::fpstate_t* const float_state_;
226 #endif
227diff --git a/src/client/linux/minidump_writer/minidump_writer.cc b/src/client/linux/minidump_writer/minidump_writer.cc
228index d11ba6e5..c7161434 100644
229--- a/src/client/linux/minidump_writer/minidump_writer.cc
230+++ b/src/client/linux/minidump_writer/minidump_writer.cc
231@@ -1323,7 +1323,7 @@ class MinidumpWriter {
232 const int fd_; // File descriptor where the minidum should be written.
233 const char* path_; // Path to the file where the minidum should be written.
234
235- const struct ucontext* const ucontext_; // also from the signal handler
236+ const ucontext_t* const ucontext_; // also from the signal handler
237 #if !defined(__ARM_EABI__) && !defined(__mips__)
238 const google_breakpad::fpstate_t* const float_state_; // ditto
239 #endif
240--
2412.13.2
242