[llvm] r249785 - Address review comments, remove error case and return 0 instead as required by tests
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 8 17:15:08 PDT 2015
Author: rnk
Date: Thu Oct 8 19:15:08 2015
New Revision: 249785
URL: http://llvm.org/viewvc/llvm-project?rev=249785&view=rev
Log:
Address review comments, remove error case and return 0 instead as required by tests
Removed:
llvm/trunk/test/tools/llvm-symbolizer/Inputs/coff-dwarf.input
llvm/trunk/test/tools/llvm-symbolizer/pdb/Inputs/test.exe.input
Modified:
llvm/trunk/include/llvm/Object/COFF.h
llvm/trunk/lib/Object/COFFObjectFile.cpp
llvm/trunk/test/tools/llvm-symbolizer/coff-dwarf.test
llvm/trunk/test/tools/llvm-symbolizer/pdb/pdb.test
llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp
Modified: llvm/trunk/include/llvm/Object/COFF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=249785&r1=249784&r2=249785&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/COFF.h (original)
+++ llvm/trunk/include/llvm/Object/COFF.h Thu Oct 8 19:15:08 2015
@@ -773,7 +773,7 @@ public:
std::error_code getSectionContents(const coff_section *Sec,
ArrayRef<uint8_t> &Res) const;
- ErrorOr<uint64_t> getImageBase() const;
+ uint64_t getImageBase() const;
std::error_code getVaPtr(uint64_t VA, uintptr_t &Res) const;
std::error_code getRvaPtr(uint32_t Rva, uintptr_t &Res) const;
std::error_code getHintName(uint32_t Rva, uint16_t &Hint,
Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=249785&r1=249784&r2=249785&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFObjectFile.cpp Thu Oct 8 19:15:08 2015
@@ -174,7 +174,7 @@ ErrorOr<uint64_t> COFFObjectFile::getSym
// The section VirtualAddress does not include ImageBase, and we want to
// return virtual addresses.
- Result += getImageBase().get();
+ Result += getImageBase();
return Result;
}
@@ -271,7 +271,7 @@ uint64_t COFFObjectFile::getSectionAddre
// The section VirtualAddress does not include ImageBase, and we want to
// return virtual addresses.
- Result += getImageBase().get();
+ Result += getImageBase();
return Result;
}
@@ -418,17 +418,18 @@ std::error_code COFFObjectFile::initSymb
return std::error_code();
}
-ErrorOr<uint64_t> COFFObjectFile::getImageBase() const {
+uint64_t COFFObjectFile::getImageBase() const {
if (PE32Header)
- return uint64_t(PE32Header->ImageBase);
+ return PE32Header->ImageBase;
else if (PE32PlusHeader)
- return uint64_t(PE32PlusHeader->ImageBase);
- return object_error::parse_failed;
+ return PE32PlusHeader->ImageBase;
+ // This actually comes up in practice.
+ return 0;
}
// Returns the file offset for the given VA.
std::error_code COFFObjectFile::getVaPtr(uint64_t Addr, uintptr_t &Res) const {
- uint64_t ImageBase = getImageBase().get();
+ uint64_t ImageBase = getImageBase();
uint64_t Rva = Addr - ImageBase;
assert(Rva <= UINT32_MAX);
return getRvaPtr((uint32_t)Rva, Res);
Removed: llvm/trunk/test/tools/llvm-symbolizer/Inputs/coff-dwarf.input
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/Inputs/coff-dwarf.input?rev=249784&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-symbolizer/Inputs/coff-dwarf.input (original)
+++ llvm/trunk/test/tools/llvm-symbolizer/Inputs/coff-dwarf.input (removed)
@@ -1,2 +0,0 @@
-0x5009
-0x5038
Modified: llvm/trunk/test/tools/llvm-symbolizer/coff-dwarf.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/coff-dwarf.test?rev=249785&r1=249784&r2=249785&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-symbolizer/coff-dwarf.test (original)
+++ llvm/trunk/test/tools/llvm-symbolizer/coff-dwarf.test Thu Oct 8 19:15:08 2015
@@ -1,5 +1,9 @@
-RUN: llvm-symbolizer --inlining --relative-address -obj="%p/Inputs/coff-dwarf.exe" \
-RUN: < %p/Inputs/coff-dwarf.input | FileCheck %s
+RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \
+RUN: | llvm-symbolizer --inlining --relative-address -obj="%p/Inputs/coff-dwarf.exe" \
+RUN: | FileCheck %s
+
+ADDR: 0x5009
+ADDR: 0x5038
CHECK: foo(void)
CHECK: coff-dwarf.cpp:7
Removed: llvm/trunk/test/tools/llvm-symbolizer/pdb/Inputs/test.exe.input
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/pdb/Inputs/test.exe.input?rev=249784&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-symbolizer/pdb/Inputs/test.exe.input (original)
+++ llvm/trunk/test/tools/llvm-symbolizer/pdb/Inputs/test.exe.input (removed)
@@ -1,8 +0,0 @@
-0x401000
-0x401010
-0x401070
-0x401030
-0x401040
-0x401050
-0x401060
-0x500000
Modified: llvm/trunk/test/tools/llvm-symbolizer/pdb/pdb.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-symbolizer/pdb/pdb.test?rev=249785&r1=249784&r2=249785&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-symbolizer/pdb/pdb.test (original)
+++ llvm/trunk/test/tools/llvm-symbolizer/pdb/pdb.test Thu Oct 8 19:15:08 2015
@@ -1,18 +1,27 @@
-RUN: llvm-symbolizer -obj="%p/Inputs/test.exe" < "%p/Inputs/test.exe.input" | \
-RUN: FileCheck %s --check-prefix=CHECK
-RUN: llvm-symbolizer -obj="%p/Inputs/test.exe" < "%p/Inputs/test.exe.input" | \
-RUN: FileCheck %s --check-prefix=CHECK
-RUN: llvm-symbolizer -obj="%p/Inputs/test.exe" -demangle=false < \
-RUN: "%p/Inputs/test.exe.input" | FileCheck %s --check-prefix=CHECK-NO-DEMANGLE
+RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \
+RUN: | llvm-symbolizer -obj="%p/Inputs/test.exe" \
+RUN: | FileCheck %s --check-prefix=CHECK
+RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \
+RUN: | llvm-symbolizer -obj="%p/Inputs/test.exe" -demangle=false \
+RUN: | FileCheck %s --check-prefix=CHECK-NO-DEMANGLE
Subtract ImageBase from all the offsets and run the test again with
--relative-address.
-RUN: python -c 'import sys;print "\n".join([hex(int(x, 16) - 0x400000) for x in sys.stdin])' \
-RUN: < %p/Inputs/test.exe.input \
+RUN: grep '^ADDR:' %s | sed -s 's/ADDR: //' \
+RUN: | python -c 'import sys;print "\n".join([hex(int(x, 16) - 0x400000) for x in sys.stdin])' \
RUN: | llvm-symbolizer -obj="%p/Inputs/test.exe" -demangle=false --relative-address \
RUN: | FileCheck %s --check-prefix=CHECK-NO-DEMANGLE
+ADDR: 0x401000
+ADDR: 0x401010
+ADDR: 0x401070
+ADDR: 0x401030
+ADDR: 0x401040
+ADDR: 0x401050
+ADDR: 0x401060
+ADDR: 0x500000
+
CHECK: foo(void)
CHECK-NEXT: test.cpp:10
CHECK: main
Modified: llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp?rev=249785&r1=249784&r2=249785&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp (original)
+++ llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp Thu Oct 8 19:15:08 2015
@@ -128,8 +128,7 @@ bool ModuleInfo::isWin32Module() const {
uint64_t ModuleInfo::getModulePreferredBase() const {
if (auto *CoffObject = dyn_cast<COFFObjectFile>(Module))
- if (auto Base = CoffObject->getImageBase())
- return Base.get();
+ return CoffObject->getImageBase();
return 0;
}
More information about the llvm-commits
mailing list