xref: /llvm-project/llvm/tools/llvm-exegesis/lib/Error.cpp (revision 89e6a288674c9fae33aeb5448c7b1fe782b2bf53)
1 //===-- Error.cpp -----------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "Error.h"
10 #include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
11 
12 #ifdef LLVM_ON_UNIX
13 #include "llvm/Support/SystemZ/zOSSupport.h"
14 #include <string.h>
15 #endif // LLVM_ON_UNIX
16 
17 namespace llvm {
18 namespace exegesis {
19 
20 char ClusteringError::ID;
21 
22 void ClusteringError::log(raw_ostream &OS) const { OS << Msg; }
23 
24 std::error_code ClusteringError::convertToErrorCode() const {
25   return inconvertibleErrorCode();
26 }
27 
28 char SnippetExecutionFailure::ID;
29 
30 std::error_code SnippetExecutionFailure::convertToErrorCode() const {
31   return inconvertibleErrorCode();
32 }
33 
34 char SnippetSegmentationFault::ID;
35 
36 void SnippetSegmentationFault::log(raw_ostream &OS) const {
37   OS << "The snippet encountered a segmentation fault at address "
38      << Twine::utohexstr(Address);
39 }
40 
41 char SnippetSignal::ID;
42 
43 void SnippetSignal::log(raw_ostream &OS) const {
44   OS << "snippet crashed while running";
45 #ifdef LLVM_ON_UNIX
46   OS << ": " << strsignal(SignalNumber);
47 #else
48   (void)SignalNumber;
49 #endif // LLVM_ON_UNIX
50 }
51 
52 } // namespace exegesis
53 } // namespace llvm
54