[llvm-dev] Implementation of DWARF expression parser

Gwynne Raskind via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 11 16:57:42 PDT 2016


> On Jul 11, 2016, at 16:21, Frédéric Riss <friss at apple.com> wrote:
> 
> Hi,
> 
> 
> 
>> On Jul 10, 2016, at 12:15 AM, Gwynne Raskind <gwynne at darkrainfall.org> wrote:
>> 
>> Hi Frédéric and LLVM,
>> 
>> I managed to finally come back to this after quite a while. Frédéric, thank you very much for the pointer to your work; it’s saving me a lot of time!
>> 
>> Unfortunately, I am running into one issue that my knowledge isn’t complete enough to solve on my own yet. The description of D6771 reads, "It requires a few preliminary patches like landing D6243 and adding a MCRegisterInfo in the DWARFContext". The latter, adding an MCRegisterInfo, seems to be a bit beyond me.
>> 
>> Specifically, while I can get a target architecture from a given ObjectFile using getArch(), I’m not sure how to turn this into an MCRegisterInfo (or really anything, such as Target, that could lead to one). My most recent attempt, using TargetRegistry::lookupTarget() to get a Target and then use createMCRegInfo(), fails with a complaint that no targets are registered,
> 
> This is the real issue. The targets need to be registered, and for now llvm-dwarfdump didn’t require any target-specific code, so it didn’t do this.
> 
> I think you need something like this:
> 
> #include "llvm/Support/TargetSelect.h"
> 
>  llvm::InitializeAllTargetInfos();
>  llvm::InitializeAllTargetMCs();
>  llvm::InitializeAllTargets();
> 
> Before doing lookupTarget. For this to work, you will also need to add MC and ${LLVM_TARGETS_TO_BUILD} to the LLVM_LINK_COMPONENTS variable in the CMakeList.txt
> 
> (Note one bad side effect of this is that llvm-dwarfdump will become a much bigger executable, but I don’t see any way around this currently)
> 
> Fred

I actually tried that, but got tripped up by a laundry list of linker errors I’m still sorting through (pretty sure my config is just messed up in general, I’m about to basically start more or less fresh); I was hoping there was some better way than figuring out how to convert an architecture "unsigned" value to a triple string :/ (My first attempt cheated by using the knowledge that my ObjectFile was actually a MachOObjectFile to call the getArch() form that returns a Triple directly). At least I was on the right track. Thanks again!

-- Gwynne Raskind



More information about the llvm-dev mailing list