[Lldb-commits] [lldb] r245645 - The llvm Triple for an armv6m now comes back as llvm::Triple::thumb.

Tamas Berghammer via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 2 06:35:47 PDT 2015


Hi Jason,

This commit caused a regression in disassembling thumb code when the
architecture is specified explicitly for the disassemble  because we try to
create an alternative thumb disassembler even when the primary disassembler
is already thumb.

I committed in a fix as
http://llvm.org/viewvc/llvm-project?rev=246649&view=rev but please check
that it don't break the original functionality you tried to implement.

Thanks,
Tamas

On Fri, Aug 21, 2015 at 1:14 AM Jason Molenda via lldb-commits <
lldb-commits at lists.llvm.org> wrote:

> Author: jmolenda
> Date: Thu Aug 20 19:13:37 2015
> New Revision: 245645
>
> URL: http://llvm.org/viewvc/llvm-project?rev=245645&view=rev
> Log:
> The llvm Triple for an armv6m now comes back as llvm::Triple::thumb.
> This was breaking disassembly for arm machines that we force to be
> thumb mode all the time because we were only checking for
> llvm::Triple::arm.
> i.e.
>
> armv6m (ARM Cortex-M0)
> armv7m (ARM Cortex-M3)
> armv7em (ARM Cortex-M4)
>
> <rdar://problem/22334522>
>
>
> Modified:
>     lldb/trunk/source/Core/Disassembler.cpp
>     lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
>     lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
>     lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp
>
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
>     lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
>
> Modified: lldb/trunk/source/Core/Disassembler.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=245645&r1=245644&r2=245645&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Core/Disassembler.cpp (original)
> +++ lldb/trunk/source/Core/Disassembler.cpp Thu Aug 20 19:13:37 2015
> @@ -1264,7 +1264,7 @@ Disassembler::Disassembler(const ArchSpe
>      // If this is an arm variant that can only include thumb (T16, T32)
>      // instructions, force the arch triple to be "thumbv.." instead of
>      // "armv..."
> -    if (arch.GetTriple().getArch() == llvm::Triple::arm
> +    if ((arch.GetTriple().getArch() == llvm::Triple::arm ||
> arch.GetTriple().getArch() == llvm::Triple::thumb)
>          && (arch.GetCore() == ArchSpec::Core::eCore_arm_armv7m
>              || arch.GetCore() == ArchSpec::Core::eCore_arm_armv7em
>              || arch.GetCore() == ArchSpec::Core::eCore_arm_armv6m))
>
> Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp?rev=245645&r1=245644&r2=245645&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
> (original)
> +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp Thu
> Aug 20 19:13:37 2015
> @@ -604,7 +604,7 @@ DisassemblerLLVMC::DisassemblerLLVMC (co
>      }
>
>      ArchSpec thumb_arch(arch);
> -    if (arch.GetTriple().getArch() == llvm::Triple::arm)
> +    if (arch.GetTriple().getArch() == llvm::Triple::arm ||
> arch.GetTriple().getArch() == llvm::Triple::thumb)
>      {
>          std::string thumb_arch_name
> (thumb_arch.GetTriple().getArchName().str());
>          // Replace "arm" with "thumb" so we get all thumb variants correct
> @@ -626,7 +626,7 @@ DisassemblerLLVMC::DisassemblerLLVMC (co
>      // Handle the Cortex-M0 (armv6m) the same; the ISA is a subset of the
> T and T32
>      // instructions defined in ARMv7-A.
>
> -    if (arch.GetTriple().getArch() == llvm::Triple::arm
> +    if ((arch.GetTriple().getArch() == llvm::Triple::arm ||
> arch.GetTriple().getArch() == llvm::Triple::thumb)
>          && (arch.GetCore() == ArchSpec::Core::eCore_arm_armv7m
>              || arch.GetCore() == ArchSpec::Core::eCore_arm_armv7em
>              || arch.GetCore() == ArchSpec::Core::eCore_arm_armv6m))
> @@ -698,7 +698,7 @@ DisassemblerLLVMC::DisassemblerLLVMC (co
>      }
>
>      // For arm CPUs that can execute arm or thumb instructions, also
> create a thumb instruction disassembler.
> -    if (arch.GetTriple().getArch() == llvm::Triple::arm)
> +    if (arch.GetTriple().getArch() == llvm::Triple::arm ||
> arch.GetTriple().getArch() == llvm::Triple::thumb)
>      {
>          std::string thumb_triple(thumb_arch.GetTriple().getTriple());
>          m_alternate_disasm_ap.reset(new
> LLVMCDisassembler(thumb_triple.c_str(), "", "", flavor, *this));
>
> Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=245645&r1=245644&r2=245645&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
> (original)
> +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Thu
> Aug 20 19:13:37 2015
> @@ -5721,6 +5721,7 @@ ObjectFileMachO::SaveCore (const lldb::P
>              {
>                  case llvm::Triple::aarch64:
>                  case llvm::Triple::arm:
> +                case llvm::Triple::thumb:
>                  case llvm::Triple::x86:
>                  case llvm::Triple::x86_64:
>                      make_core = true;
>
> Modified:
> lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp?rev=245645&r1=245644&r2=245645&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp
> (original)
> +++ lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp
> Thu Aug 20 19:13:37 2015
> @@ -58,6 +58,7 @@ StopInfoMachException::GetDescription ()
>                  }
>                  break;
>              case llvm::Triple::arm:
> +            case llvm::Triple::thumb:
>                  switch (m_exc_code)
>                  {
>                  case 0x101: code_desc = "EXC_ARM_DA_ALIGN"; break;
> @@ -104,6 +105,7 @@ StopInfoMachException::GetDescription ()
>                  break;
>
>              case llvm::Triple::arm:
> +            case llvm::Triple::thumb:
>                  if (m_exc_code == 1)
>                      code_desc = "EXC_ARM_UNDEFINED";
>                  break;
> @@ -188,6 +190,7 @@ StopInfoMachException::GetDescription ()
>                      break;
>
>                  case llvm::Triple::arm:
> +                case llvm::Triple::thumb:
>                      switch (m_exc_code)
>                      {
>                      case 0x101: code_desc = "EXC_ARM_DA_ALIGN"; break;
> @@ -408,6 +411,7 @@ StopInfoMachException::CreateStopReasonW
>                      break;
>
>                  case llvm::Triple::arm:
> +                case llvm::Triple::thumb:
>                      if (exc_code == 0x102) // EXC_ARM_DA_DEBUG
>                      {
>                          // It's a watchpoint, then, if the exc_sub_code
> indicates a known/enabled
>
> Modified:
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp?rev=245645&r1=245644&r2=245645&view=diff
>
> ==============================================================================
> ---
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
> (original)
> +++
> lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
> Thu Aug 20 19:13:37 2015
> @@ -1209,6 +1209,7 @@ GDBRemoteCommunicationServerCommon::Crea
>              switch (proc_triple.getArch ())
>              {
>                  case llvm::Triple::arm:
> +                case llvm::Triple::thumb:
>                  case llvm::Triple::aarch64:
>                      ostype = "ios";
>                      break;
>
> Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=245645&r1=245644&r2=245645&view=diff
>
> ==============================================================================
> --- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
> (original)
> +++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Thu
> Aug 20 19:13:37 2015
> @@ -735,11 +735,12 @@ ProcessGDBRemote::BuildDynamicRegisterIn
>      if (!target_arch.IsValid())
>      {
>          if (remote_arch.IsValid()
> -              && remote_arch.GetMachine() == llvm::Triple::arm
> +              && (remote_arch.GetMachine() == llvm::Triple::arm ||
> remote_arch.GetMachine() == llvm::Triple::thumb)
>                && remote_arch.GetTriple().getVendor() ==
> llvm::Triple::Apple)
>              m_register_info.HardcodeARMRegisters(from_scratch);
>      }
> -    else if (target_arch.GetMachine() == llvm::Triple::arm)
> +    else if (target_arch.GetMachine() == llvm::Triple::arm
> +            || target_arch.GetMachine() == llvm::Triple::thumb)
>      {
>          m_register_info.HardcodeARMRegisters(from_scratch);
>      }
> @@ -1250,8 +1251,8 @@ ProcessGDBRemote::DidLaunchOrAttach (Arc
>                  // it has, so we really need to take the remote host
> architecture as our
>                  // defacto architecture in this case.
>
> -                if (process_arch.GetMachine() == llvm::Triple::arm &&
> -                    process_arch.GetTriple().getVendor() ==
> llvm::Triple::Apple)
> +                if ((process_arch.GetMachine() == llvm::Triple::arm ||
> process_arch.GetMachine() == llvm::Triple::thumb)
> +                    && process_arch.GetTriple().getVendor() ==
> llvm::Triple::Apple)
>                  {
>                      GetTarget().SetArchitecture (process_arch);
>                      if (log)
>
>
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20150902/459fafdc/attachment-0001.html>


More information about the lldb-commits mailing list