[Lldb-commits] [PATCH] D13578: Allow generic arm ArchSpec to merge with specific arm ArchSpec; allow Cortex M0-7's to always force thumb mode

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Thu Oct 8 19:46:31 PDT 2015


jasonmolenda created this revision.
jasonmolenda added a reviewer: tberghammer.
jasonmolenda added subscribers: lldb-commits, clayborg.
jasonmolenda set the repository for this revision to rL LLVM.
Herald added subscribers: rengolin, aemerson.

This patch is to address a few issues I came up with when working on an armcc-generated ELF binary being run on a Cortex-M4 core with lldb.  The first problem is that the elf binary comes in as a generic "arm" triple ("arm--") and the second is that we don't see to get any arm/thumb hints about the functions in this binary.

This is a Cortex-M4 ("armv7em") so the instructions are always thumb.  

When lldb calls the instruction unwinder (FuncUnwinders::GetUnwindAssemblyProfiler) it gets the object file's arch and merges in the Target's arch via ArchSpec::MergeFrom.  The object file has "arm--", the target has "armv7em-unknown-unknown".  The changes to MergeFrom allow us to replace the "arm" cpu part of the triple with the Target's "armv7em".

I wanted to centralize the "Cortex M0-M7 are always thumb" special knowledge a little better - we already had two examples where we were checking against specific core types (armv6m, armv7m, armv7em) in the disassembler.  So I added a method to ArchSpec to check that.  It's a very arm specific method name, but it seems a bit of an arm specific problem that we're trying to identify here.

Down in the instruction emulation I use the ArchSpec method to make sure we don't try to emulate anything as arm because we're missing the arm/thumb hints from the ObjectFile.

I imagine at some point I'll want to do something in SysV-Arm ABI plugin for the DefaultUnwindPlan to say that if this core is always running thumb instructions, the frame pointer is r7 for instance.  That default UnwindPlan which uses the arm r11 as a frame pointer is a problem for the unwinder's behavior in a real mixed arm/thumb environment - we sidestep it inside Apple be using r7 as the frame pointer for both types of code.

Tamas, I put you as the reviewer because this is closest to what you work on regularly.  Please let me know what you think when you have a chance.

Repository:
  rL LLVM

http://reviews.llvm.org/D13578

Files:
  include/lldb/Core/ArchSpec.h
  source/Core/ArchSpec.cpp
  source/Core/Disassembler.cpp
  source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
  source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13578.36921.patch
Type: text/x-patch
Size: 6914 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20151009/4c67a761/attachment-0001.bin>


More information about the lldb-commits mailing list