template <uint16_t Version, class AddrType, class RefAddrType>
void TestAllForms() {
- Triple Triple = getHostTripleForAddrSize(sizeof(AddrType));
+ Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType));
if (!isConfigurationSupported(Triple))
return;
}
template <uint16_t Version, class AddrType> void TestChildren() {
- Triple Triple = getHostTripleForAddrSize(sizeof(AddrType));
+ Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType));
if (!isConfigurationSupported(Triple))
return;
}
template <uint16_t Version, class AddrType> void TestReferences() {
- Triple Triple = getHostTripleForAddrSize(sizeof(AddrType));
+ Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType));
if (!isConfigurationSupported(Triple))
return;
}
template <uint16_t Version, class AddrType> void TestAddresses() {
- Triple Triple = getHostTripleForAddrSize(sizeof(AddrType));
+ Triple Triple = getDefaultTargetTripleForAddrSize(sizeof(AddrType));
if (!isConfigurationSupported(Triple))
return;
}
TEST(DWARFDebugInfo, TestStringOffsets) {
- Triple Triple = getHostTripleForAddrSize(sizeof(void *));
+ Triple Triple = getNormalizedDefaultTargetTriple();
if (!isConfigurationSupported(Triple))
return;
}
TEST(DWARFDebugInfo, TestEmptyStringOffsets) {
- Triple Triple = getHostTripleForAddrSize(sizeof(void *));
+ Triple Triple = getNormalizedDefaultTargetTriple();
if (!isConfigurationSupported(Triple))
return;
}
TEST(DWARFDebugInfo, TestRelations) {
- Triple Triple = getHostTripleForAddrSize(sizeof(void *));
+ Triple Triple = getNormalizedDefaultTargetTriple();
if (!isConfigurationSupported(Triple))
return;
}
TEST(DWARFDebugInfo, TestChildIterators) {
- Triple Triple = getHostTripleForAddrSize(sizeof(void *));
+ Triple Triple = getNormalizedDefaultTargetTriple();
if (!isConfigurationSupported(Triple))
return;
}
TEST(DWARFDebugInfo, TestAttributeIterators) {
- Triple Triple = getHostTripleForAddrSize(sizeof(void *));
+ Triple Triple = getNormalizedDefaultTargetTriple();
if (!isConfigurationSupported(Triple))
return;
}
TEST(DWARFDebugInfo, TestFindRecurse) {
- Triple Triple = getHostTripleForAddrSize(sizeof(void *));
+ Triple Triple = getNormalizedDefaultTargetTriple();
if (!isConfigurationSupported(Triple))
return;
}
TEST(DWARFDebugInfo, TestFindAttrs) {
- Triple Triple = getHostTripleForAddrSize(sizeof(void *));
+ Triple Triple = getNormalizedDefaultTargetTriple();
if (!isConfigurationSupported(Triple))
return;
}
TEST(DWARFDebugInfo, TestImplicitConstAbbrevs) {
- Triple Triple = getHostTripleForAddrSize(sizeof(void *));
+ Triple Triple = getNormalizedDefaultTargetTriple();
if (!isConfigurationSupported(Triple))
return;
}
bool setupGenerator(uint16_t Version = 4) {
- Triple T = getHostTripleForAddrSize(8);
+ Triple T = getDefaultTargetTripleForAddrSize(8);
if (!isConfigurationSupported(T))
return false;
auto ExpectedGenerator = Generator::create(T, Version);
Context = createContext();
assert(Context != nullptr && "test state is not valid");
const DWARFObject &Obj = Context->getDWARFObj();
- LineData = DWARFDataExtractor(Obj, Obj.getLineSection(),
- sys::IsLittleEndianHost, 8);
+ LineData = DWARFDataExtractor(
+ Obj, Obj.getLineSection(),
+ getDefaultTargetTripleForAddrSize(8).isLittleEndian(), 8);
}
std::unique_ptr<DWARFContext> createContext() {
#include "DwarfUtils.h"
#include "llvm/ADT/Triple.h"
#include "llvm/Config/llvm-config.h"
+#include "llvm/Support/Host.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/TargetSelect.h"
}
}
-Triple llvm::dwarf::utils::getHostTripleForAddrSize(uint8_t AddrSize) {
- Triple T(Triple::normalize(LLVM_HOST_TRIPLE));
+Triple llvm::dwarf::utils::getNormalizedDefaultTargetTriple() {
+ 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())
return T.get64BitArchVariant();
if (AddrSize == 4 && T.isArch64Bit())