@@ -185,48 +185,77 @@ std::string LinuxSignals::GetSignalDescriptionFromSiginfo(
185
185
if (code == 0 )
186
186
return GetSignalDescription (signo, code);
187
187
188
- lldb::ValueObjectSP sifields =
189
- siginfo_sp->GetChildMemberWithName (" _sifields" );
188
+ auto sifields = siginfo_sp->GetChildMemberWithName (" _sifields" );
189
+ if (!sifields)
190
+ return GetSignalDescription (signo, code);
191
+
192
+ // declare everything that we can populate later.
193
+ std::optional<lldb::addr_t > addr;
194
+ std::optional<lldb::addr_t > upper;
195
+ std::optional<lldb::addr_t > lower;
196
+ std::optional<uint32_t > pid;
197
+ std::optional<uint32_t > uid;
198
+
190
199
// The negative si_codes are special and mean this signal was sent from user
191
200
// space not the kernel. These take precedence because they break some of the
192
201
// invariants around kernel sent signals. Such as SIGSEGV won't have an
193
202
// address.
194
203
if (code < 0 ) {
195
- lldb::ValueObjectSP sikill = sifields->GetChildMemberWithName (" _kill" );
196
- uint32_t pid =
197
- sikill->GetChildMemberWithName (" si_pid" )->GetValueAsUnsigned (-1 );
198
- uint32_t uid =
199
- sikill->GetChildMemberWithName (" si_uid" )->GetValueAsUnsigned (-1 );
200
- return GetSignalDescription (signo, code, std::nullopt, std::nullopt,
201
- std::nullopt, pid, uid);
202
- }
204
+ auto sikill = sifields->GetChildMemberWithName (" _kill" );
205
+ if (sikill) {
206
+ auto pid_sp = sikill->GetChildMemberWithName (" si_pid" );
207
+ if (pid_sp)
208
+ pid = pid_sp->GetValueAsUnsigned (-1 );
209
+ auto uid_sp = sikill->GetChildMemberWithName (" si_uid" );
210
+ if (uid_sp)
211
+ uid = uid_sp->GetValueAsUnsigned (-1 );
212
+ }
213
+ } else {
203
214
204
- switch (signo) {
205
- case SIGILL:
206
- case SIGFPE:
207
- case SIGBUS: {
208
- lldb::ValueObjectSP sigfault =
209
- sifields->GetChildMemberWithName (" _sigfault" );
210
- lldb::addr_t addr =
211
- sigfault->GetChildMemberWithName (" si_addr" )->GetValueAsUnsigned (-1 );
212
- return GetSignalDescription (signo, code, addr);
213
- }
214
- case SIGSEGV: {
215
- lldb::ValueObjectSP sigfault =
216
- sifields->GetChildMemberWithName (" _sigfault" );
217
- lldb::addr_t addr =
218
- sigfault->GetChildMemberWithName (" si_addr" )->GetValueAsUnsigned (-1 );
219
-
220
- lldb::ValueObjectSP bounds =
221
- sigfault->GetChildMemberWithName (" _bounds" )->GetChildMemberWithName (
222
- " _addr_bnd" );
223
- lldb::addr_t lower =
224
- bounds->GetChildMemberWithName (" _lower" )->GetValueAsUnsigned (-1 );
225
- lldb::addr_t upper =
226
- bounds->GetChildMemberWithName (" _upper" )->GetValueAsUnsigned (-1 );
227
- return GetSignalDescription (signo, code, addr, lower, upper);
228
- }
229
- default :
230
- return GetSignalDescription (signo, code);
215
+ switch (signo) {
216
+ case SIGILL:
217
+ case SIGFPE:
218
+ case SIGBUS: {
219
+ auto sigfault = sifields->GetChildMemberWithName (" _sigfault" );
220
+ if (!sigfault)
221
+ break ;
222
+
223
+ auto addr_sp = sigfault->GetChildMemberWithName (" si_addr" );
224
+ if (addr_sp)
225
+ addr = addr_sp->GetValueAsUnsigned (-1 );
226
+ break ;
227
+ }
228
+ case SIGSEGV: {
229
+ auto sigfault = sifields->GetChildMemberWithName (" _sigfault" );
230
+ if (!sigfault)
231
+ break ;
232
+
233
+ auto addr_sp = sigfault->GetChildMemberWithName (" si_addr" );
234
+ if (addr_sp)
235
+ addr = addr_sp->GetValueAsUnsigned (-1 );
236
+
237
+ auto bounds_sp = sigfault->GetChildMemberWithName (" _bounds" );
238
+ if (!bounds_sp)
239
+ break ;
240
+
241
+ auto addr_bnds_sp = bounds_sp->GetChildMemberWithName (" _addr_bnd" );
242
+ if (!addr_bnds_sp)
243
+ break ;
244
+
245
+ auto lower_sp = addr_bnds_sp->GetChildMemberWithName (" _lower" );
246
+ if (lower_sp)
247
+ lower = lower_sp->GetValueAsUnsigned (-1 );
248
+
249
+ auto upper_sp = addr_bnds_sp->GetChildMemberWithName (" _upper" );
250
+ if (upper_sp)
251
+ upper = upper_sp->GetValueAsUnsigned (-1 );
252
+
253
+ break ;
254
+ }
255
+ default :
256
+ break ;
257
+ }
231
258
}
259
+
260
+ return GetSignalDescription (signo, code, addr, lower, upper, uid, pid);
232
261
}
0 commit comments