summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/test/tools/dsymutil/arch-option.test2
-rw-r--r--llvm/test/tools/dsymutil/debug-map-parsing.test8
-rw-r--r--llvm/tools/dsymutil/DebugMap.cpp3
-rw-r--r--llvm/tools/dsymutil/DwarfLinker.cpp22
-rw-r--r--llvm/tools/dsymutil/ErrorReporting.h33
-rw-r--r--llvm/tools/dsymutil/MachODebugMapParser.cpp14
-rw-r--r--llvm/tools/dsymutil/MachOUtils.cpp9
-rw-r--r--llvm/tools/dsymutil/dsymutil.cpp40
8 files changed, 79 insertions, 52 deletions
diff --git a/llvm/test/tools/dsymutil/arch-option.test b/llvm/test/tools/dsymutil/arch-option.test
index a028bd7e060..02a151cc553 100644
--- a/llvm/test/tools/dsymutil/arch-option.test
+++ b/llvm/test/tools/dsymutil/arch-option.test
@@ -35,5 +35,5 @@ ARM64-NOT: ---
CHECK: ...
-BADARCH: error: Unsupported cpu architecture: 'arm42'
+BADARCH: error: unsupported cpu architecture: 'arm42'
EMPTY: error: no architecture to link
diff --git a/llvm/test/tools/dsymutil/debug-map-parsing.test b/llvm/test/tools/dsymutil/debug-map-parsing.test
index 05beb8e9bcc..0aa95c3f988 100644
--- a/llvm/test/tools/dsymutil/debug-map-parsing.test
+++ b/llvm/test/tools/dsymutil/debug-map-parsing.test
@@ -71,9 +71,9 @@ CHECK-ARCHIVE: ...
Check that we warn about missing object files (this presumes that the files aren't
present in the machine's /Inputs/ folder, which should be a pretty safe bet).
-NOT-FOUND: cannot open{{.*}}"/Inputs/basic1.macho.x86_64.o": {{[Nn]o}} such file
-NOT-FOUND: cannot open{{.*}}"/Inputs/basic2.macho.x86_64.o": {{[Nn]o}} such file
-NOT-FOUND: cannot open{{.*}}"/Inputs/basic3.macho.x86_64.o": {{[Nn]o}} such file
+NOT-FOUND: cannot open{{.*}}'/Inputs/basic1.macho.x86_64.o': {{[Nn]o}} such file
+NOT-FOUND: cannot open{{.*}}'/Inputs/basic2.macho.x86_64.o': {{[Nn]o}} such file
+NOT-FOUND: cannot open{{.*}}'/Inputs/basic3.macho.x86_64.o': {{[Nn]o}} such file
NOT-FOUND: ---
NOT-FOUND-NEXT: triple: 'x86_64-apple-darwin'
NOT-FOUND-NEXT: binary-path:{{.*}}/Inputs/basic.macho.x86_64
@@ -81,5 +81,5 @@ NOT-FOUND-NEXT: ...
Check that we correctly error out on invalid executatble.
-NO-EXECUTABLE: cannot parse{{.*}}/inexistant": {{[Nn]o}} such file
+NO-EXECUTABLE: cannot parse{{.*}}/inexistant': {{[Nn]o}} such file
NO-EXECUTABLE-NOT: ---
diff --git a/llvm/tools/dsymutil/DebugMap.cpp b/llvm/tools/dsymutil/DebugMap.cpp
index 24bc973b465..fc5e879f4f7 100644
--- a/llvm/tools/dsymutil/DebugMap.cpp
+++ b/llvm/tools/dsymutil/DebugMap.cpp
@@ -9,6 +9,7 @@
#include "DebugMap.h"
#include "BinaryHolder.h"
+#include "ErrorReporting.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringMap.h"
@@ -241,7 +242,7 @@ MappingTraits<dsymutil::DebugMapObject>::YamlDMO::denormalize(IO &IO) {
sys::path::append(Path, Filename);
auto ErrOrObjectFiles = BinHolder.GetObjectFiles(Path);
if (auto EC = ErrOrObjectFiles.getError()) {
- errs() << "warning: Unable to open " << Path << " " << EC.message() << '\n';
+ warn_ostream() << "Unable to open " << Path << " " << EC.message() << '\n';
} else if (auto ErrOrObjectFile = BinHolder.Get(Ctxt.BinaryTriple)) {
// Rewrite the object file symbol addresses in the debug map. The
// YAML input is mainly used to test llvm-dsymutil without
diff --git a/llvm/tools/dsymutil/DwarfLinker.cpp b/llvm/tools/dsymutil/DwarfLinker.cpp
index 6f76d746c0c..3024967db62 100644
--- a/llvm/tools/dsymutil/DwarfLinker.cpp
+++ b/llvm/tools/dsymutil/DwarfLinker.cpp
@@ -9,6 +9,7 @@
#include "BinaryHolder.h"
#include "DebugMap.h"
+#include "ErrorReporting.h"
#include "MachOUtils.h"
#include "NonRelocatableStringpool.h"
#include "dsymutil.h"
@@ -78,7 +79,6 @@
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/ThreadPool.h"
#include "llvm/Support/ToolOutputFile.h"
-#include "llvm/Support/WithColor.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
@@ -580,19 +580,7 @@ static bool inFunctionScope(CompileUnit &U, unsigned Idx) {
}
return false;
}
-
-static raw_ostream &error_ostream() {
- return WithColor(errs(), HighlightColor::Error).get() << "error: ";
-}
-
-static raw_ostream &warn_ostream() {
- return WithColor(errs(), HighlightColor::Warning).get() << "warning: ";
-}
-
-static raw_ostream &note_ostream() {
- return WithColor(errs(), HighlightColor::Note).get() << "note: ";
-}
-} // end anonymous namespace
+} // namespace
void warn(Twine Warning, Twine Context) {
warn_ostream() << Warning + "\n";
@@ -4171,7 +4159,7 @@ bool DwarfLinker::link(const DebugMap &Map) {
StringRef File = LinkContext.DMO.getObjectFilename();
auto ErrorOrMem = MemoryBuffer::getFile(File);
if (!ErrorOrMem) {
- errs() << "Warning: Could not open " << File << "\n";
+ warn("Could not open '" + File + "'\n");
continue;
}
sys::fs::file_status Stat;
@@ -4353,5 +4341,5 @@ bool linkDwarf(raw_fd_ostream &OutFile, const DebugMap &DM,
return Linker.link(DM);
}
-} // end namespace dsymutil
-} // end namespace llvm
+} // namespace dsymutil
+} // namespace llvm
diff --git a/llvm/tools/dsymutil/ErrorReporting.h b/llvm/tools/dsymutil/ErrorReporting.h
new file mode 100644
index 00000000000..a22adc8ab44
--- /dev/null
+++ b/llvm/tools/dsymutil/ErrorReporting.h
@@ -0,0 +1,33 @@
+//===- ErrorReporting.h - dsymutil error reporting -------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TOOLS_DSYMUTIL_ERRORREPORTING_H
+#define LLVM_TOOLS_DSYMUTIL_ERRORREPORTING_H
+#include "llvm/Support/WithColor.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace llvm {
+namespace dsymutil {
+
+inline raw_ostream &error_ostream() {
+ return WithColor(errs(), HighlightColor::Error).get() << "error: ";
+}
+
+inline raw_ostream &warn_ostream() {
+ return WithColor(errs(), HighlightColor::Warning).get() << "warning: ";
+}
+
+inline raw_ostream &note_ostream() {
+ return WithColor(errs(), HighlightColor::Note).get() << "note: ";
+}
+
+} // namespace dsymutil
+} // end namespace llvm
+
+#endif // LLVM_TOOLS_DSYMUTIL_ERRORREPORTING_H
diff --git a/llvm/tools/dsymutil/MachODebugMapParser.cpp b/llvm/tools/dsymutil/MachODebugMapParser.cpp
index 2b16b0c7457..be0671f7c5d 100644
--- a/llvm/tools/dsymutil/MachODebugMapParser.cpp
+++ b/llvm/tools/dsymutil/MachODebugMapParser.cpp
@@ -9,6 +9,7 @@
#include "BinaryHolder.h"
#include "DebugMap.h"
+#include "ErrorReporting.h"
#include "llvm/ADT/Optional.h"
#include "llvm/Object/MachO.h"
#include "llvm/Support/Path.h"
@@ -97,7 +98,7 @@ private:
StringRef BinaryPath);
};
-static void Warning(const Twine &Msg) { errs() << "warning: " + Msg + "\n"; }
+static void Warning(const Twine &Msg) { warn_ostream() << Msg << '\n'; }
} // anonymous namespace
/// Reset the parser state corresponding to the current object
@@ -121,16 +122,17 @@ void MachODebugMapParser::switchToNewDebugMapObject(
auto MachOOrError =
CurrentObjectHolder.GetFilesAs<MachOObjectFile>(Path, Timestamp);
if (auto Error = MachOOrError.getError()) {
- Warning(Twine("cannot open debug object \"") + Path.str() +
- "\": " + Error.message() + "\n");
+ Warning(Twine("cannot open debug object '") + Path.str() +
+ "': " + Error.message());
return;
}
auto ErrOrAchObj =
CurrentObjectHolder.GetAs<MachOObjectFile>(Result->getTriple());
- if (auto Err = ErrOrAchObj.getError()) {
- return Warning(Twine("cannot open debug object \"") + Path.str() +
- "\": " + Err.message() + "\n");
+ if (auto Error = ErrOrAchObj.getError()) {
+ Warning(Twine("cannot open debug object '") + Path.str() +
+ "': " + Error.message());
+ return;
}
CurrentDebugMapObject =
diff --git a/llvm/tools/dsymutil/MachOUtils.cpp b/llvm/tools/dsymutil/MachOUtils.cpp
index 562dd5d7998..fd963138087 100644
--- a/llvm/tools/dsymutil/MachOUtils.cpp
+++ b/llvm/tools/dsymutil/MachOUtils.cpp
@@ -10,6 +10,7 @@
#include "MachOUtils.h"
#include "BinaryHolder.h"
#include "DebugMap.h"
+#include "ErrorReporting.h"
#include "NonRelocatableStringpool.h"
#include "dsymutil.h"
#include "llvm/MC/MCAsmLayout.h"
@@ -38,7 +39,7 @@ static bool runLipo(StringRef SDKPath, SmallVectorImpl<const char *> &Args) {
Path = sys::findProgramByName("lipo");
if (!Path) {
- errs() << "error: lipo: " << Path.getError().message() << "\n";
+ error_ostream() << "lipo: " << Path.getError().message() << "\n";
return false;
}
@@ -46,7 +47,7 @@ static bool runLipo(StringRef SDKPath, SmallVectorImpl<const char *> &Args) {
int result =
sys::ExecuteAndWait(*Path, Args.data(), nullptr, {}, 0, 0, &ErrMsg);
if (result) {
- errs() << "error: lipo: " << ErrMsg << "\n";
+ error_ostream() << "lipo: " << ErrMsg << "\n";
return false;
}
@@ -63,8 +64,8 @@ bool generateUniversalBinary(SmallVectorImpl<ArchAndFilename> &ArchFiles,
StringRef From(ArchFiles.front().Path);
if (sys::fs::rename(From, OutputFileName)) {
if (std::error_code EC = sys::fs::copy_file(From, OutputFileName)) {
- errs() << "error: while copying " << From << " to " << OutputFileName
- << ": " << EC.message() << "\n";
+ error_ostream() << "while copying " << From << " to " << OutputFileName
+ << ": " << EC.message() << "\n";
return false;
}
sys::fs::remove(From);
diff --git a/llvm/tools/dsymutil/dsymutil.cpp b/llvm/tools/dsymutil/dsymutil.cpp
index bbde2094f02..533ff896713 100644
--- a/llvm/tools/dsymutil/dsymutil.cpp
+++ b/llvm/tools/dsymutil/dsymutil.cpp
@@ -15,6 +15,7 @@
#include "dsymutil.h"
#include "CFBundle.h"
#include "DebugMap.h"
+#include "ErrorReporting.h"
#include "MachOUtils.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
@@ -156,8 +157,8 @@ static bool createPlistFile(llvm::StringRef Bin, llvm::StringRef BundleRoot) {
std::error_code EC;
llvm::raw_fd_ostream PL(InfoPlist, EC, llvm::sys::fs::F_Text);
if (EC) {
- llvm::errs() << "error: cannot create plist file " << InfoPlist << ": "
- << EC.message() << '\n';
+ error_ostream() << "cannot create plist file " << InfoPlist << ": "
+ << EC.message() << '\n';
return false;
}
@@ -214,8 +215,8 @@ static bool createBundleDir(llvm::StringRef BundleBase) {
llvm::sys::path::append(Bundle, "Contents", "Resources", "DWARF");
if (std::error_code EC = create_directories(Bundle.str(), true,
llvm::sys::fs::perms::all_all)) {
- llvm::errs() << "error: cannot create directory " << Bundle << ": "
- << EC.message() << "\n";
+ error_ostream() << "cannot create directory " << Bundle << ": "
+ << EC.message() << "\n";
return false;
}
return true;
@@ -223,8 +224,8 @@ static bool createBundleDir(llvm::StringRef BundleBase) {
static bool verify(llvm::StringRef OutputFile, llvm::StringRef Arch) {
if (OutputFile == "-") {
- llvm::errs() << "warning: verification skipped for " << Arch
- << "because writing to stdout.\n";
+ warn_ostream() << "verification skipped for " << Arch
+ << "because writing to stdout.\n";
return true;
}
@@ -242,7 +243,7 @@ static bool verify(llvm::StringRef OutputFile, llvm::StringRef Arch) {
DIDumpOptions DumpOpts;
bool success = DICtx->verify(os, DumpOpts.noImplicitRecursion());
if (!success)
- errs() << "error: verification failed for " << Arch << '\n';
+ error_ostream() << "verification failed for " << Arch << '\n';
return success;
}
@@ -314,7 +315,7 @@ static Expected<LinkOptions> getOptions() {
// used a unique BinaryHolder object that could cache multiple
// binaries this restriction would go away.
return make_error<StringError>(
- "error: standard input cannot be used as input for a dSYM update.",
+ "standard input cannot be used as input for a dSYM update.",
inconvertibleErrorCode());
}
@@ -404,7 +405,7 @@ int main(int argc, char **argv) {
auto OptionsOrErr = getOptions();
if (!OptionsOrErr) {
- errs() << "error: " << toString(OptionsOrErr.takeError());
+ error_ostream() << toString(OptionsOrErr.takeError());
return 1;
}
@@ -415,24 +416,24 @@ int main(int argc, char **argv) {
auto InputsOrErr = getInputs(OptionsOrErr->Update);
if (!InputsOrErr) {
- errs() << "error: " << toString(InputsOrErr.takeError()) << '\n';
+ error_ostream() << toString(InputsOrErr.takeError()) << '\n';
return 1;
}
if (!FlatOut && OutputFileOpt == "-") {
- llvm::errs() << "error: cannot emit to standard output without --flat\n";
+ error_ostream() << "cannot emit to standard output without --flat\n";
return 1;
}
if (InputsOrErr->size() > 1 && FlatOut && !OutputFileOpt.empty()) {
- llvm::errs() << "error: cannot use -o with multiple inputs in flat mode\n";
+ error_ostream() << "cannot use -o with multiple inputs in flat mode\n";
return 1;
}
for (const auto &Arch : ArchFlags)
if (Arch != "*" && Arch != "all" &&
!llvm::object::MachOObjectFile::isValidArch(Arch)) {
- llvm::errs() << "error: Unsupported cpu architecture: '" << Arch << "'\n";
+ error_ostream() << "unsupported cpu architecture: '" << Arch << "'\n";
return 1;
}
@@ -448,8 +449,8 @@ int main(int argc, char **argv) {
Verbose, InputIsYAMLDebugMap);
if (auto EC = DebugMapPtrsOrErr.getError()) {
- llvm::errs() << "error: cannot parse the debug map for \"" << InputFile
- << "\": " << EC.message() << '\n';
+ error_ostream() << "cannot parse the debug map for '" << InputFile
+ << "': " << EC.message() << '\n';
return 1;
}
@@ -463,7 +464,7 @@ int main(int argc, char **argv) {
// Ensure that the debug map is not empty (anymore).
if (DebugMapPtrsOrErr->empty()) {
- llvm::errs() << "error: no architecture to link\n";
+ error_ostream() << "no architecture to link\n";
return 1;
}
@@ -492,9 +493,10 @@ int main(int argc, char **argv) {
continue;
if (Map->begin() == Map->end())
- llvm::errs() << "warning: no debug symbols in executable (-arch "
- << MachOUtils::getArchName(Map->getTriple().getArchName())
- << ")\n";
+ warn_ostream() << "no debug symbols in executable (-arch "
+ << MachOUtils::getArchName(
+ Map->getTriple().getArchName())
+ << ")\n";
// Using a std::shared_ptr rather than std::unique_ptr because move-only
// types don't work with std::bind in the ThreadPool implementation.
OpenPOWER on IntegriCloud