diff options
author | Andrew Kaylor <andrew.kaylor@intel.com> | 2013-01-28 19:52:37 +0000 |
---|---|---|
committer | Andrew Kaylor <andrew.kaylor@intel.com> | 2013-01-28 19:52:37 +0000 |
commit | 710cb0c7826c61b432e19d5899a2f26f76d7aa81 (patch) | |
tree | ed8f79a169a0ab4360e5680008b8748b0a78ed70 /lib/ExecutionEngine | |
parent | 3c1c042a64e0d0d01c0e2817aa1f0f5c9c726a80 (diff) | |
download | external_llvm-710cb0c7826c61b432e19d5899a2f26f76d7aa81.zip external_llvm-710cb0c7826c61b432e19d5899a2f26f76d7aa81.tar.gz external_llvm-710cb0c7826c61b432e19d5899a2f26f76d7aa81.tar.bz2 |
Add support for source and line information to IntelJITEventListener for object emitted by MCJIT.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173712 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine')
-rw-r--r-- | lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp | 53 |
1 files changed, 45 insertions, 8 deletions
diff --git a/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp b/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp index 0f99596..3645a4d 100644 --- a/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp +++ b/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp @@ -22,7 +22,9 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/CodeGen/MachineFunction.h" +#include "llvm/DebugInfo/DIContext.h" #include "llvm/ExecutionEngine/ObjectImage.h" +#include "llvm/Object/ObjectFile.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/Errno.h" @@ -78,6 +80,18 @@ static LineNumberInfo LineStartToIntelJITFormat( return Result; } +static LineNumberInfo DILineInfoToIntelJITFormat(uintptr_t StartAddress, + uintptr_t Address, + DILineInfo Line) +{ + LineNumberInfo Result; + + Result.Offset = Address - StartAddress; + Result.LineNumber = Line.getLine(); + + return Result; +} + static iJIT_Method_Load FunctionDescToIntelJITFormat( IntelJITEventsWrapper& Wrapper, const char* FnName, @@ -177,6 +191,7 @@ void IntelJITEventListener::NotifyFreeingMachineCode(void *FnStart) { void IntelJITEventListener::NotifyObjectEmitted(const ObjectImage &Obj) { // Get the address of the object image for use as a unique identifier const void* ObjData = Obj.getData().data(); + DIContext* Context = DIContext::getDWARFContext(Obj.getObjectFile()); MethodAddressVector Functions; // Use symbol info to iterate functions in the object. @@ -185,12 +200,15 @@ void IntelJITEventListener::NotifyObjectEmitted(const ObjectImage &Obj) { E = Obj.end_symbols(); I != E && !ec; I.increment(ec)) { + std::vector<LineNumberInfo> LineInfo; + std::string SourceFileName; + object::SymbolRef::Type SymType; if (I->getType(SymType)) continue; if (SymType == object::SymbolRef::ST_Function) { - StringRef Name; - uint64_t Addr; - uint64_t Size; + StringRef Name; + uint64_t Addr; + uint64_t Size; if (I->getName(Name)) continue; if (I->getAddress(Addr)) continue; if (I->getSize(Size)) continue; @@ -203,11 +221,30 @@ void IntelJITEventListener::NotifyObjectEmitted(const ObjectImage &Obj) { Name.data(), Addr, Size); - - // FIXME: Try to find line info for this function in the DWARF sections. - FunctionMessage.source_file_name = 0; - FunctionMessage.line_number_size = 0; - FunctionMessage.line_number_table = 0; + if (Context) { + DILineInfoTable Lines = Context->getLineInfoForAddressRange(Addr, Size); + DILineInfoTable::iterator Begin = Lines.begin(); + DILineInfoTable::iterator End = Lines.end(); + for (DILineInfoTable::iterator It = Begin; It != End; ++It) { + LineInfo.push_back(DILineInfoToIntelJITFormat((uintptr_t)Addr, + It->first, + It->second)); + } + if (LineInfo.size() == 0) { + FunctionMessage.source_file_name = 0; + FunctionMessage.line_number_size = 0; + FunctionMessage.line_number_table = 0; + } else { + SourceFileName = Lines.front().second.getFileName(); + FunctionMessage.source_file_name = (char *)SourceFileName.c_str(); + FunctionMessage.line_number_size = LineInfo.size(); + FunctionMessage.line_number_table = &*LineInfo.begin(); + } + } else { + FunctionMessage.source_file_name = 0; + FunctionMessage.line_number_size = 0; + FunctionMessage.line_number_table = 0; + } Wrapper->iJIT_NotifyEvent(iJVM_EVENT_TYPE_METHOD_LOAD_FINISHED, &FunctionMessage); |