aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/FaultMapParser.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@sifive.com>2021-01-27 10:21:47 -0800
committerCraig Topper <craig.topper@sifive.com>2021-01-27 10:39:59 -0800
commit0b50fa99452f7f3077e62348b6cf6850a65930af (patch)
tree0888dcdee3534cc0daf3f553644da8fd3151415a /llvm/lib/Object/FaultMapParser.cpp
parent74c87a363fd0e8586e46c04e113c49c6dc2a0bc8 (diff)
downloadllvm-0b50fa99452f7f3077e62348b6cf6850a65930af.zip
llvm-0b50fa99452f7f3077e62348b6cf6850a65930af.tar.gz
llvm-0b50fa99452f7f3077e62348b6cf6850a65930af.tar.bz2
[FaultsMaps][llvm-objdump] Move FaultMapParser to Object/. Remove CodeGen dependency from llvm-objdump
FaultsMapParser lived in CodeGen and was forcing llvm-objdump to link CodeGen and everything CodeGen depends on. This was previously attempted in r240364 to fix a link failure. The CodeGen dependency was independently added to fix the same link failure, and that ended up being kept. Removing the dependency seems like the correct layering for llvm-objdump. Reviewed By: MaskRay, jhenderson Differential Revision: https://reviews.llvm.org/D95414
Diffstat (limited to 'llvm/lib/Object/FaultMapParser.cpp')
-rw-r--r--llvm/lib/Object/FaultMapParser.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/llvm/lib/Object/FaultMapParser.cpp b/llvm/lib/Object/FaultMapParser.cpp
new file mode 100644
index 0000000..9e83bc1
--- /dev/null
+++ b/llvm/lib/Object/FaultMapParser.cpp
@@ -0,0 +1,66 @@
+//===----------------------- FaultMapParser.cpp ---------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Object/FaultMapParser.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/Format.h"
+#include "llvm/Support/raw_ostream.h"
+
+using namespace llvm;
+
+void printFaultType(FaultMapParser::FaultKind FT, raw_ostream &OS) {
+ switch (FT) {
+ default:
+ llvm_unreachable("unhandled fault type!");
+ case FaultMapParser::FaultingLoad:
+ OS << "FaultingLoad";
+ break;
+ case FaultMapParser::FaultingLoadStore:
+ OS << "FaultingLoadStore";
+ break;
+ case FaultMapParser::FaultingStore:
+ OS << "FaultingStore";
+ break;
+ }
+}
+
+raw_ostream &
+llvm::operator<<(raw_ostream &OS,
+ const FaultMapParser::FunctionFaultInfoAccessor &FFI) {
+ OS << "Fault kind: ";
+ printFaultType((FaultMapParser::FaultKind)FFI.getFaultKind(), OS);
+ OS << ", faulting PC offset: " << FFI.getFaultingPCOffset()
+ << ", handling PC offset: " << FFI.getHandlerPCOffset();
+ return OS;
+}
+
+raw_ostream &llvm::operator<<(raw_ostream &OS,
+ const FaultMapParser::FunctionInfoAccessor &FI) {
+ OS << "FunctionAddress: " << format_hex(FI.getFunctionAddr(), 8)
+ << ", NumFaultingPCs: " << FI.getNumFaultingPCs() << "\n";
+ for (unsigned I = 0, E = FI.getNumFaultingPCs(); I != E; ++I)
+ OS << FI.getFunctionFaultInfoAt(I) << "\n";
+ return OS;
+}
+
+raw_ostream &llvm::operator<<(raw_ostream &OS, const FaultMapParser &FMP) {
+ OS << "Version: " << format_hex(FMP.getFaultMapVersion(), 2) << "\n";
+ OS << "NumFunctions: " << FMP.getNumFunctions() << "\n";
+
+ if (FMP.getNumFunctions() == 0)
+ return OS;
+
+ FaultMapParser::FunctionInfoAccessor FI;
+
+ for (unsigned I = 0, E = FMP.getNumFunctions(); I != E; ++I) {
+ FI = (I == 0) ? FMP.getFirstFunctionInfo() : FI.getNextFunctionInfo();
+ OS << FI;
+ }
+
+ return OS;
+}