diff --git a/llvm/test/tools/llvm-exegesis/X86/latency/subprocess-segfault.s b/llvm/test/tools/llvm-exegesis/X86/latency/subprocess-segfault.s index 92b08e1c18c62..db04f8522e4e0 100644 --- a/llvm/test/tools/llvm-exegesis/X86/latency/subprocess-segfault.s +++ b/llvm/test/tools/llvm-exegesis/X86/latency/subprocess-segfault.s @@ -2,7 +2,7 @@ # RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mode=latency -snippets-file=%s -execution-mode=subprocess | FileCheck %s -# CHECK: error: 'The benchmarking subprocess sent unexpected signal: Segmentation fault' +# CHECK: error: The snippet crashed with signal Segmentation fault at address 10000 -# LLVM-EXEGESIS-DEFREG RBX 0 +# LLVM-EXEGESIS-DEFREG RBX 10000 movq (%rbx), %rax diff --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp index 85375dec2a44c..f5d73a8bd6a31 100644 --- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp +++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp @@ -374,8 +374,8 @@ class SubProcessFunctionExecutorImpl } return make_error( - "The benchmarking subprocess sent unexpected signal: " + - Twine(strsignal(ChildSignalInfo.si_signo))); + ChildSignalInfo.si_signo, + reinterpret_cast(ChildSignalInfo.si_addr)); } [[noreturn]] void prepareAndRunBenchmark(int Pipe, diff --git a/llvm/tools/llvm-exegesis/lib/Error.cpp b/llvm/tools/llvm-exegesis/lib/Error.cpp index 51ce41bf00bf5..213e54e3bcf53 100644 --- a/llvm/tools/llvm-exegesis/lib/Error.cpp +++ b/llvm/tools/llvm-exegesis/lib/Error.cpp @@ -8,6 +8,10 @@ #include "Error.h" +#ifdef LLVM_ON_UNIX +#include +#endif // LLVM_ON_UNIX + namespace llvm { namespace exegesis { @@ -21,7 +25,18 @@ std::error_code ClusteringError::convertToErrorCode() const { char SnippetCrash::ID; -void SnippetCrash::log(raw_ostream &OS) const { OS << Msg; } +void SnippetCrash::log(raw_ostream &OS) const { + if (SISignalNumber == -1) { + OS << Msg; + return; + } +#ifdef LLVM_ON_UNIX + OS << "The snippet crashed with signal " << strsignal(SISignalNumber) + << " at address " << Twine::utohexstr(SIAddress); +#else + OS << "The snippet crashed with a signal"; +#endif // LLVM_ON_UNIX +} std::error_code SnippetCrash::convertToErrorCode() const { return inconvertibleErrorCode(); diff --git a/llvm/tools/llvm-exegesis/lib/Error.h b/llvm/tools/llvm-exegesis/lib/Error.h index e5fa093e6e125..8d3f394ed8d6e 100644 --- a/llvm/tools/llvm-exegesis/lib/Error.h +++ b/llvm/tools/llvm-exegesis/lib/Error.h @@ -12,6 +12,8 @@ #include "llvm/ADT/Twine.h" #include "llvm/Support/Error.h" +#include + namespace llvm { namespace exegesis { @@ -41,7 +43,10 @@ class ClusteringError : public ErrorInfo { class SnippetCrash : public ErrorInfo { public: static char ID; - SnippetCrash(const Twine &S) : Msg(S.str()) {} + SnippetCrash(const Twine &S) + : Msg(S.str()), SIAddress(-1), SISignalNumber(-1) {} + SnippetCrash(int SISignalNumber_, intptr_t SIAddress_) + : Msg(""), SIAddress(SIAddress_), SISignalNumber(SISignalNumber_) {} void log(raw_ostream &OS) const override; @@ -49,6 +54,8 @@ class SnippetCrash : public ErrorInfo { private: std::string Msg; + intptr_t SIAddress; + int SISignalNumber; }; } // namespace exegesis