diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:41:05 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:41:05 +0000 |
| commit | 01095a5d43bbfde13731688ddcf6048ebb8b7721 (patch) | |
| tree | 4def12e759965de927d963ac65840d663ef9d1ea /tools/llvm-cov/TestingSupport.cpp | |
| parent | f0f4822ed4b66e3579e92a89f368f8fb860e218e (diff) | |
Diffstat (limited to 'tools/llvm-cov/TestingSupport.cpp')
| -rw-r--r-- | tools/llvm-cov/TestingSupport.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/tools/llvm-cov/TestingSupport.cpp b/tools/llvm-cov/TestingSupport.cpp index 6959897482ca2..72768f4fd583f 100644 --- a/tools/llvm-cov/TestingSupport.cpp +++ b/tools/llvm-cov/TestingSupport.cpp @@ -8,11 +8,9 @@ //===----------------------------------------------------------------------===// #include "llvm/Object/ObjectFile.h" +#include "llvm/ProfileData/InstrProf.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/LEB128.h" -#include "llvm/Support/ManagedStatic.h" -#include "llvm/Support/PrettyStackTrace.h" -#include "llvm/Support/Signals.h" #include "llvm/Support/raw_ostream.h" #include <functional> #include <system_error> @@ -21,10 +19,6 @@ using namespace llvm; using namespace object; int convertForTestingMain(int argc, const char *argv[]) { - sys::PrintStackTraceOnErrorSignal(); - PrettyStackTraceProgram X(argc, argv); - llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. - cl::opt<std::string> InputSourceFile(cl::Positional, cl::Required, cl::desc("<Source file>")); @@ -36,8 +30,12 @@ int convertForTestingMain(int argc, const char *argv[]) { cl::ParseCommandLineOptions(argc, argv, "LLVM code coverage tool\n"); auto ObjErr = llvm::object::ObjectFile::createObjectFile(InputSourceFile); - if (auto Err = ObjErr.getError()) { - errs() << "error: " << Err.message() << "\n"; + if (!ObjErr) { + std::string Buf; + raw_string_ostream OS(Buf); + logAllUnhandledErrors(ObjErr.takeError(), OS, ""); + OS.flush(); + errs() << "error: " << Buf; return 1; } ObjectFile *OF = ObjErr.get().getBinary(); @@ -54,9 +52,9 @@ int convertForTestingMain(int argc, const char *argv[]) { StringRef Name; if (Section.getName(Name)) return 1; - if (Name == "__llvm_prf_names") { + if (Name == llvm::getInstrProfNameSectionName(false)) { ProfileNames = Section; - } else if (Name == "__llvm_covmap") { + } else if (Name == llvm::getInstrProfCoverageSectionName(false)) { CoverageMapping = Section; } else continue; @@ -84,7 +82,11 @@ int convertForTestingMain(int argc, const char *argv[]) { OS << "llvmcovmtestdata"; encodeULEB128(ProfileNamesData.size(), OS); encodeULEB128(ProfileNamesAddress, OS); - OS << ProfileNamesData << CoverageMappingData; + OS << ProfileNamesData; + // Coverage mapping data is expected to have an alignment of 8. + for (unsigned Pad = OffsetToAlignment(OS.tell(), 8); Pad; --Pad) + OS.write(uint8_t(0)); + OS << CoverageMappingData; return 0; } |
