diff options
author | Jason Molenda <jmolenda@apple.com> | 2013-07-22 22:11:53 +0000 |
---|---|---|
committer | Jason Molenda <jmolenda@apple.com> | 2013-07-22 22:11:53 +0000 |
commit | 01aa53440b04d51c30ce1f96eab2779f88414cad (patch) | |
tree | 6295d5087ce23a2751b2000221cb2329ee394031 /lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp | |
parent | cb132face0605c71dc40cd6632fd449b6785b2ce (diff) | |
download | bcm5719-llvm-01aa53440b04d51c30ce1f96eab2779f88414cad.tar.gz bcm5719-llvm-01aa53440b04d51c30ce1f96eab2779f88414cad.zip |
When a Cortex-M3 target is selected (armv7m), force disassembly to be in
thumb mode.
<rdar://problem/14107444>, <rdar://problem/14107405>
llvm-svn: 186881
Diffstat (limited to 'lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp')
-rw-r--r-- | lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp index 437860101e0..233515a23f2 100644 --- a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp +++ b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp @@ -613,17 +613,9 @@ DisassemblerLLVMC::DisassemblerLLVMC (const ArchSpec &arch, const char *flavor_s } } - m_disasm_ap.reset (new LLVMCDisassembler(triple, flavor, *this)); - if (!m_disasm_ap->IsValid()) - { - // We use m_disasm_ap.get() to tell whether we are valid or not, so if this isn't good for some reason, - // we reset it, and then we won't be valid and FindPlugin will fail and we won't get used. - m_disasm_ap.reset(); - } - + ArchSpec thumb_arch(arch); if (arch.GetTriple().getArch() == llvm::Triple::arm) { - ArchSpec thumb_arch(arch); std::string thumb_arch_name (thumb_arch.GetTriple().getArchName().str()); // Replace "arm" with "thumb" so we get all thumb variants correct if (thumb_arch_name.size() > 3) @@ -636,6 +628,27 @@ DisassemblerLLVMC::DisassemblerLLVMC (const ArchSpec &arch, const char *flavor_s thumb_arch_name = "thumbv7"; } thumb_arch.GetTriple().setArchName(llvm::StringRef(thumb_arch_name.c_str())); + } + + // Cortex-M3 devices (e.g. armv7m) can only execute thumb (T2) instructions, + // so hardcode the primary disassembler to thumb mode. + if (arch.GetTriple().getArch() == llvm::Triple::arm + && (arch.GetCore() == ArchSpec::Core::eCore_arm_armv7m || arch.GetCore() == ArchSpec::Core::eCore_arm_armv7em)) + { + triple = thumb_arch.GetTriple().getTriple().c_str(); + } + + m_disasm_ap.reset (new LLVMCDisassembler(triple, flavor, *this)); + if (!m_disasm_ap->IsValid()) + { + // We use m_disasm_ap.get() to tell whether we are valid or not, so if this isn't good for some reason, + // we reset it, and then we won't be valid and FindPlugin will fail and we won't get used. + m_disasm_ap.reset(); + } + + // For arm CPUs that can execute arm or thumb instructions, also create a thumb instruction disassembler. + if (arch.GetTriple().getArch() == llvm::Triple::arm) + { std::string thumb_triple(thumb_arch.GetTriple().getTriple()); m_alternate_disasm_ap.reset(new LLVMCDisassembler(thumb_triple.c_str(), flavor, *this)); if (!m_alternate_disasm_ap->IsValid()) |