1 //===----------------------- FaultMapParser.cpp ---------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Object/FaultMapParser.h"
10 #include "llvm/Support/ErrorHandling.h"
11 #include "llvm/Support/Format.h"
12 #include "llvm/Support/raw_ostream.h"
16 void printFaultType(FaultMapParser::FaultKind FT
, raw_ostream
&OS
) {
19 llvm_unreachable("unhandled fault type!");
20 case FaultMapParser::FaultingLoad
:
23 case FaultMapParser::FaultingLoadStore
:
24 OS
<< "FaultingLoadStore";
26 case FaultMapParser::FaultingStore
:
27 OS
<< "FaultingStore";
33 llvm::operator<<(raw_ostream
&OS
,
34 const FaultMapParser::FunctionFaultInfoAccessor
&FFI
) {
36 printFaultType((FaultMapParser::FaultKind
)FFI
.getFaultKind(), OS
);
37 OS
<< ", faulting PC offset: " << FFI
.getFaultingPCOffset()
38 << ", handling PC offset: " << FFI
.getHandlerPCOffset();
42 raw_ostream
&llvm::operator<<(raw_ostream
&OS
,
43 const FaultMapParser::FunctionInfoAccessor
&FI
) {
44 OS
<< "FunctionAddress: " << format_hex(FI
.getFunctionAddr(), 8)
45 << ", NumFaultingPCs: " << FI
.getNumFaultingPCs() << "\n";
46 for (unsigned I
= 0, E
= FI
.getNumFaultingPCs(); I
!= E
; ++I
)
47 OS
<< FI
.getFunctionFaultInfoAt(I
) << "\n";
51 raw_ostream
&llvm::operator<<(raw_ostream
&OS
, const FaultMapParser
&FMP
) {
52 OS
<< "Version: " << format_hex(FMP
.getFaultMapVersion(), 2) << "\n";
53 OS
<< "NumFunctions: " << FMP
.getNumFunctions() << "\n";
55 if (FMP
.getNumFunctions() == 0)
58 FaultMapParser::FunctionInfoAccessor FI
;
60 for (unsigned I
= 0, E
= FMP
.getNumFunctions(); I
!= E
; ++I
) {
61 FI
= (I
== 0) ? FMP
.getFirstFunctionInfo() : FI
.getNextFunctionInfo();