forked from OSchip/llvm-project
Fix DWARF DebugInfo unit test errors when cross-compiling
Summary: When building with a Default Target set we can experience issues in the DWARF DebugInfo unit tests because: They assume we can generate object files for the host platform. Some tests assume the endianess of the target we are generating DWARF for and the host match. This patch correct these issues by ensuring the tests which generate objects in memory are run with respect to LVM_DEFAULT_TARGET_TRIPLE and it's endianess. We also make sure we don't use the hosts address size for line test and split the triple util function in DwarfUtils into a version that takes an address size and one that doesn't. See also for discussion: http://lists.llvm.org/pipermail/llvm-dev/2019-March/131212.html Patch by: daltenty Differential Revision: https://reviews.llvm.org/D62084 llvm-svn: 362454
This commit is contained in:
parent
099f4a9fa8
commit
552fda839a
|
@ -41,7 +41,7 @@ namespace {
|
||||||
|
|
||||||
template <uint16_t Version, class AddrType, class RefAddrType>
|
template <uint16_t Version, class AddrType, class RefAddrType>
|
||||||
void TestAllForms() {
|
void TestAllForms() {
|
||||||
Triple Triple = getHostTripleForAddrSize(sizeof(AddrType));
|
Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType));
|
||||||
if (!isConfigurationSupported(Triple))
|
if (!isConfigurationSupported(Triple))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -455,7 +455,7 @@ TEST(DWARFDebugInfo, TestDWARF32Version5Addr8AllForms) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <uint16_t Version, class AddrType> void TestChildren() {
|
template <uint16_t Version, class AddrType> void TestChildren() {
|
||||||
Triple Triple = getHostTripleForAddrSize(sizeof(AddrType));
|
Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType));
|
||||||
if (!isConfigurationSupported(Triple))
|
if (!isConfigurationSupported(Triple))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -585,7 +585,7 @@ TEST(DWARFDebugInfo, TestDWARF32Version4Addr8Children) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <uint16_t Version, class AddrType> void TestReferences() {
|
template <uint16_t Version, class AddrType> void TestReferences() {
|
||||||
Triple Triple = getHostTripleForAddrSize(sizeof(AddrType));
|
Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType));
|
||||||
if (!isConfigurationSupported(Triple))
|
if (!isConfigurationSupported(Triple))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -835,7 +835,7 @@ TEST(DWARFDebugInfo, TestDWARF32Version4Addr8References) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <uint16_t Version, class AddrType> void TestAddresses() {
|
template <uint16_t Version, class AddrType> void TestAddresses() {
|
||||||
Triple Triple = getHostTripleForAddrSize(sizeof(AddrType));
|
Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType));
|
||||||
if (!isConfigurationSupported(Triple))
|
if (!isConfigurationSupported(Triple))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1007,7 +1007,7 @@ TEST(DWARFDebugInfo, TestDWARF32Version4Addr8Addresses) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(DWARFDebugInfo, TestStringOffsets) {
|
TEST(DWARFDebugInfo, TestStringOffsets) {
|
||||||
Triple Triple = getHostTripleForAddrSize(sizeof(void *));
|
Triple Triple = getNormalizedDefaultTargetTriple();
|
||||||
if (!isConfigurationSupported(Triple))
|
if (!isConfigurationSupported(Triple))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1071,7 +1071,7 @@ TEST(DWARFDebugInfo, TestStringOffsets) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(DWARFDebugInfo, TestEmptyStringOffsets) {
|
TEST(DWARFDebugInfo, TestEmptyStringOffsets) {
|
||||||
Triple Triple = getHostTripleForAddrSize(sizeof(void *));
|
Triple Triple = getNormalizedDefaultTargetTriple();
|
||||||
if (!isConfigurationSupported(Triple))
|
if (!isConfigurationSupported(Triple))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1100,7 +1100,7 @@ TEST(DWARFDebugInfo, TestEmptyStringOffsets) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(DWARFDebugInfo, TestRelations) {
|
TEST(DWARFDebugInfo, TestRelations) {
|
||||||
Triple Triple = getHostTripleForAddrSize(sizeof(void *));
|
Triple Triple = getNormalizedDefaultTargetTriple();
|
||||||
if (!isConfigurationSupported(Triple))
|
if (!isConfigurationSupported(Triple))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1287,7 +1287,7 @@ TEST(DWARFDebugInfo, TestDWARFDie) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(DWARFDebugInfo, TestChildIterators) {
|
TEST(DWARFDebugInfo, TestChildIterators) {
|
||||||
Triple Triple = getHostTripleForAddrSize(sizeof(void *));
|
Triple Triple = getNormalizedDefaultTargetTriple();
|
||||||
if (!isConfigurationSupported(Triple))
|
if (!isConfigurationSupported(Triple))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1401,7 +1401,7 @@ TEST(DWARFDebugInfo, TestEmptyChildren) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(DWARFDebugInfo, TestAttributeIterators) {
|
TEST(DWARFDebugInfo, TestAttributeIterators) {
|
||||||
Triple Triple = getHostTripleForAddrSize(sizeof(void *));
|
Triple Triple = getNormalizedDefaultTargetTriple();
|
||||||
if (!isConfigurationSupported(Triple))
|
if (!isConfigurationSupported(Triple))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1463,7 +1463,7 @@ TEST(DWARFDebugInfo, TestAttributeIterators) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(DWARFDebugInfo, TestFindRecurse) {
|
TEST(DWARFDebugInfo, TestFindRecurse) {
|
||||||
Triple Triple = getHostTripleForAddrSize(sizeof(void *));
|
Triple Triple = getNormalizedDefaultTargetTriple();
|
||||||
if (!isConfigurationSupported(Triple))
|
if (!isConfigurationSupported(Triple))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1677,7 +1677,7 @@ TEST(DWARFDebugInfo, TestDwarfToFunctions) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(DWARFDebugInfo, TestFindAttrs) {
|
TEST(DWARFDebugInfo, TestFindAttrs) {
|
||||||
Triple Triple = getHostTripleForAddrSize(sizeof(void *));
|
Triple Triple = getNormalizedDefaultTargetTriple();
|
||||||
if (!isConfigurationSupported(Triple))
|
if (!isConfigurationSupported(Triple))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1740,7 +1740,7 @@ TEST(DWARFDebugInfo, TestFindAttrs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(DWARFDebugInfo, TestImplicitConstAbbrevs) {
|
TEST(DWARFDebugInfo, TestImplicitConstAbbrevs) {
|
||||||
Triple Triple = getHostTripleForAddrSize(sizeof(void *));
|
Triple Triple = getNormalizedDefaultTargetTriple();
|
||||||
if (!isConfigurationSupported(Triple))
|
if (!isConfigurationSupported(Triple))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ struct CommonFixture {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool setupGenerator(uint16_t Version = 4) {
|
bool setupGenerator(uint16_t Version = 4) {
|
||||||
Triple T = getHostTripleForAddrSize(8);
|
Triple T = getDefaultTargetTripleForAddrSize(8);
|
||||||
if (!isConfigurationSupported(T))
|
if (!isConfigurationSupported(T))
|
||||||
return false;
|
return false;
|
||||||
auto ExpectedGenerator = Generator::create(T, Version);
|
auto ExpectedGenerator = Generator::create(T, Version);
|
||||||
|
@ -50,8 +50,9 @@ struct CommonFixture {
|
||||||
Context = createContext();
|
Context = createContext();
|
||||||
assert(Context != nullptr && "test state is not valid");
|
assert(Context != nullptr && "test state is not valid");
|
||||||
const DWARFObject &Obj = Context->getDWARFObj();
|
const DWARFObject &Obj = Context->getDWARFObj();
|
||||||
LineData = DWARFDataExtractor(Obj, Obj.getLineSection(),
|
LineData = DWARFDataExtractor(
|
||||||
sys::IsLittleEndianHost, 8);
|
Obj, Obj.getLineSection(),
|
||||||
|
getDefaultTargetTripleForAddrSize(8).isLittleEndian(), 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<DWARFContext> createContext() {
|
std::unique_ptr<DWARFContext> createContext() {
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
#include "DwarfUtils.h"
|
#include "DwarfUtils.h"
|
||||||
#include "llvm/ADT/Triple.h"
|
#include "llvm/ADT/Triple.h"
|
||||||
#include "llvm/Config/llvm-config.h"
|
#include "llvm/Config/llvm-config.h"
|
||||||
|
#include "llvm/Support/Host.h"
|
||||||
#include "llvm/Support/TargetRegistry.h"
|
#include "llvm/Support/TargetRegistry.h"
|
||||||
#include "llvm/Support/TargetSelect.h"
|
#include "llvm/Support/TargetSelect.h"
|
||||||
|
|
||||||
|
@ -25,9 +26,20 @@ static void initLLVMIfNeeded() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Triple llvm::dwarf::utils::getHostTripleForAddrSize(uint8_t AddrSize) {
|
Triple llvm::dwarf::utils::getNormalizedDefaultTargetTriple() {
|
||||||
Triple T(Triple::normalize(LLVM_HOST_TRIPLE));
|
Triple T(Triple::normalize(sys::getDefaultTargetTriple()));
|
||||||
|
|
||||||
|
return T;
|
||||||
|
}
|
||||||
|
|
||||||
|
Triple llvm::dwarf::utils::getDefaultTargetTripleForAddrSize(uint8_t AddrSize) {
|
||||||
|
Triple T = getNormalizedDefaultTargetTriple();
|
||||||
|
|
||||||
|
assert((AddrSize == 4 || AddrSize == 8) &&
|
||||||
|
"Only 32-bit/64-bit address size variants are supported");
|
||||||
|
|
||||||
|
// If a 32-bit/64-bit address size was specified, try to convert the triple
|
||||||
|
// if it is for the wrong variant.
|
||||||
if (AddrSize == 8 && T.isArch32Bit())
|
if (AddrSize == 8 && T.isArch32Bit())
|
||||||
return T.get64BitArchVariant();
|
return T.get64BitArchVariant();
|
||||||
if (AddrSize == 4 && T.isArch64Bit())
|
if (AddrSize == 4 && T.isArch64Bit())
|
||||||
|
|
|
@ -18,7 +18,8 @@ class Triple;
|
||||||
namespace dwarf {
|
namespace dwarf {
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
Triple getHostTripleForAddrSize(uint8_t AddrSize);
|
Triple getDefaultTargetTripleForAddrSize(uint8_t AddrSize);
|
||||||
|
Triple getNormalizedDefaultTargetTriple();
|
||||||
bool isConfigurationSupported(Triple &T);
|
bool isConfigurationSupported(Triple &T);
|
||||||
|
|
||||||
} // end namespace utils
|
} // end namespace utils
|
||||||
|
|
Loading…
Reference in New Issue