diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2012-12-31 15:45:31 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2012-12-31 15:45:31 +0000 |
commit | ad784790ad28023ef5041beac6c23a8250778f3f (patch) | |
tree | dcf0d8236fdc704eb35a812ad6a27016e0bd4be5 | |
parent | 1318e14f3e9d786ea108d99ecaee7b5baa9b8fd0 (diff) |
Check for errors. Extracted from a patch by Sami Liedes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171301 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | tools/llvm-readobj/llvm-readobj.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/llvm-readobj/llvm-readobj.cpp b/tools/llvm-readobj/llvm-readobj.cpp index 252a37798c..8f8804a7c4 100644 --- a/tools/llvm-readobj/llvm-readobj.cpp +++ b/tools/llvm-readobj/llvm-readobj.cpp @@ -69,6 +69,11 @@ static std::string getSymbolFlagStr(uint32_t Flags) { return result; } +static void checkError(error_code ec, const char *msg) { + if (ec) + report_fatal_error(std::string(msg) + ": " + ec.message()); +} + static void dumpSymbol(const SymbolRef &Sym, const ObjectFile *obj, bool IsDynamic) { StringRef Name; @@ -77,12 +82,13 @@ dumpSymbol(const SymbolRef &Sym, const ObjectFile *obj, bool IsDynamic) { uint64_t Address; uint64_t Size; uint64_t FileOffset; - Sym.getName(Name); - Sym.getAddress(Address); - Sym.getSize(Size); - Sym.getFileOffset(FileOffset); - Sym.getType(Type); - Sym.getFlags(Flags); + checkError(Sym.getName(Name), "SymbolRef.getName() failed"); + checkError(Sym.getAddress(Address), "SymbolRef.getAddress() failed"); + checkError(Sym.getSize(Size), "SymbolRef.getSize() failed"); + checkError(Sym.getFileOffset(FileOffset), + "SymbolRef.getFileOffset() failed"); + checkError(Sym.getType(Type), "SymbolRef.getType() failed"); + checkError(Sym.getFlags(Flags), "SymbolRef.getFlags() failed"); std::string FullName = Name; // If this is a dynamic symbol from an ELF object, append |