@@ -542,6 +542,14 @@ size_t ELFLinuxSigInfo::GetSize(const lldb_private::ArchSpec &arch) {
542
542
}
543
543
}
544
544
545
+ static bool IsSignalWithAddrValue (int signo) {
546
+ // SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP
547
+ // We can't use the enum here because it may not be available on windows or
548
+ // other platforms. We should make an LLDB platform agnostic enum for this
549
+ // in the future.
550
+ return signo == 8 || signo == 4 || signo == 11 || signo == 7 || signo == 5 ;
551
+ }
552
+
545
553
Status ELFLinuxSigInfo::Parse (const DataExtractor &data, const ArchSpec &arch) {
546
554
Status error;
547
555
uint64_t size = GetSize (arch);
@@ -561,31 +569,20 @@ Status ELFLinuxSigInfo::Parse(const DataExtractor &data, const ArchSpec &arch) {
561
569
// 64b ELF have a 4 byte pad.
562
570
if (data.GetAddressByteSize () == 8 )
563
571
offset += 4 ;
564
- switch (si_signo) {
565
- case SIGFPE:
566
- case SIGILL:
567
- case SIGSEGV:
568
- case SIGBUS:
569
- case SIGTRAP:
570
- addr = (void *)data.GetAddress (&offset);
572
+ if (IsSignalWithAddrValue (si_signo)) {
573
+ addr = data.GetAddress (&offset);
571
574
addr_lsb = data.GetU16 (&offset);
572
- return error;
573
- default :
574
- return error;
575
575
}
576
+
577
+ return error;
576
578
}
577
579
578
580
std::string ELFLinuxSigInfo::GetDescription () {
579
- switch (si_signo) {
580
- case SIGFPE:
581
- case SIGILL:
582
- case SIGSEGV:
583
- case SIGBUS:
584
- case SIGTRAP:
581
+ if (IsSignalWithAddrValue (si_signo))
585
582
return lldb_private::UnixSignals::CreateForHost ()->GetSignalDescription (
586
583
si_signo, si_code, reinterpret_cast <uintptr_t >(addr));
587
- default :
588
- return lldb_private::UnixSignals::CreateForHost ()->GetSignalDescription (
584
+
585
+
586
+ return lldb_private::UnixSignals::CreateForHost ()->GetSignalDescription (
589
587
si_signo, si_code);
590
- }
591
588
}
0 commit comments