Skip to content

Commit 38e5f71

Browse files
committed
[lldb] Add target triple on D TypeSystem
1 parent 806fe93 commit 38e5f71

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

lldb/source/Plugins/TypeSystem/D/TypeSystemD.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace lldb_private {
1515
// LLVM RTTI support
1616
char TypeSystemD::ID;
1717

18-
TypeSystemD::TypeSystemD() = default;
18+
TypeSystemD::TypeSystemD(llvm::Triple target_triple) : m_target_triple(target_triple) {}
1919

2020
TypeSystemD::~TypeSystemD() { Finalize(); }
2121
void TypeSystemD::Finalize() {}
@@ -59,8 +59,23 @@ lldb::TypeSystemSP TypeSystemD::CreateInstance(lldb::LanguageType language,
5959
if (!arch.IsValid())
6060
return lldb::TypeSystemSP();
6161

62+
llvm::Triple triple = arch.GetTriple();
63+
// LLVM wants this to be set to iOS or MacOSX; if we're working on
64+
// a bare-boards type image, change the triple for llvm's benefit.
65+
if (triple.getVendor() == llvm::Triple::Apple &&
66+
triple.getOS() == llvm::Triple::UnknownOS) {
67+
if (triple.getArch() == llvm::Triple::arm ||
68+
triple.getArch() == llvm::Triple::aarch64 ||
69+
triple.getArch() == llvm::Triple::aarch64_32 ||
70+
triple.getArch() == llvm::Triple::thumb) {
71+
triple.setOS(llvm::Triple::IOS);
72+
} else {
73+
triple.setOS(llvm::Triple::MacOSX);
74+
}
75+
}
76+
6277
if (module)
63-
return std::shared_ptr<TypeSystemD>(new TypeSystemD);
78+
return std::shared_ptr<TypeSystemD>(new TypeSystemD(triple));
6479

6580
return lldb::TypeSystemSP();
6681
}

lldb/source/Plugins/TypeSystem/D/TypeSystemD.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class TypeSystemD : public TypeSystem {
3131
bool isA(const void *ClassID) const override { return ClassID == &ID; }
3232
static bool classof(const TypeSystem *ts) { return ts->isA(&ID); }
3333

34-
explicit TypeSystemD();
34+
explicit TypeSystemD(llvm::Triple);
3535
~TypeSystemD() override;
3636

3737
void Finalize() override;
@@ -346,6 +346,7 @@ class TypeSystemD : public TypeSystem {
346346
CompilerType GetBuiltinTypeForDWARFEncodingAndBitSize(uint32_t dw_ate, uint32_t bit_size);
347347

348348
std::unique_ptr<DWARFASTParserD> m_dwarf_ast_parser_up;
349+
llvm::Triple m_target_triple;
349350
};
350351

351352
} // namespace lldb_private

0 commit comments

Comments
 (0)