diff options
author | Andrew Kaylor <andrew.kaylor@intel.com> | 2018-06-15 00:07:28 +0000 |
---|---|---|
committer | Andrew Kaylor <andrew.kaylor@intel.com> | 2018-06-15 00:07:28 +0000 |
commit | 36bb0ad07898e40ca2ff26f13f16482940a722b1 (patch) | |
tree | 6d38a09323c77e434adebb01af7fd89dc062bb7e /llvm/lib/ExecutionEngine/OProfileJIT | |
parent | d65dba56a6bea23ca183dab3b95c1d74451bdb12 (diff) | |
download | bcm5719-llvm-36bb0ad07898e40ca2ff26f13f16482940a722b1.tar.gz bcm5719-llvm-36bb0ad07898e40ca2ff26f13f16482940a722b1.zip |
Add debug info for OProfile profiling support
Patch by Gaetano Priori
Differential Revision: https://reviews.llvm.org/D47925
llvm-svn: 334782
Diffstat (limited to 'llvm/lib/ExecutionEngine/OProfileJIT')
-rw-r--r-- | llvm/lib/ExecutionEngine/OProfileJIT/LLVMBuild.txt | 2 | ||||
-rw-r--r-- | llvm/lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp | 26 |
2 files changed, 26 insertions, 2 deletions
diff --git a/llvm/lib/ExecutionEngine/OProfileJIT/LLVMBuild.txt b/llvm/lib/ExecutionEngine/OProfileJIT/LLVMBuild.txt index 7d5550046a5..ea100286318 100644 --- a/llvm/lib/ExecutionEngine/OProfileJIT/LLVMBuild.txt +++ b/llvm/lib/ExecutionEngine/OProfileJIT/LLVMBuild.txt @@ -21,4 +21,4 @@ type = OptionalLibrary name = OProfileJIT parent = ExecutionEngine -required_libraries = Support Object ExecutionEngine +required_libraries = DebugInfoDWARF Support Object ExecutionEngine diff --git a/llvm/lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp b/llvm/lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp index 1cdd1e3d743..6f0825fb38d 100644 --- a/llvm/lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp +++ b/llvm/lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp @@ -15,6 +15,7 @@ #include "llvm-c/ExecutionEngine.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/Config/config.h" +#include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/ExecutionEngine/JITEventListener.h" #include "llvm/ExecutionEngine/OProfileWrapper.h" #include "llvm/ExecutionEngine/RuntimeDyld.h" @@ -86,6 +87,7 @@ void OProfileJITEventListener::NotifyObjectEmitted( OwningBinary<ObjectFile> DebugObjOwner = L.getObjectForDebug(Obj); const ObjectFile &DebugObj = *DebugObjOwner.getBinary(); + std::unique_ptr<DIContext> Context = DWARFContext::create(DebugObj); // Use symbol info to iterate functions in the object. for (const std::pair<SymbolRef, uint64_t> &P : computeSymbolSizes(DebugObj)) { @@ -110,7 +112,29 @@ void OProfileJITEventListener::NotifyObjectEmitted( << ((char *)Addr + Size) << "]\n"); continue; } - // TODO: support line number info (similar to IntelJITEventListener.cpp) + + DILineInfoTable Lines = Context->getLineInfoForAddressRange(Addr, Size); + size_t i = 0; + size_t num_entries = Lines.size(); + struct debug_line_info *debug_line; + debug_line = (struct debug_line_info *)calloc( + num_entries, sizeof(struct debug_line_info)); + + for (auto& It : Lines) { + debug_line[i].vma = (unsigned long)It.first; + debug_line[i].lineno = It.second.Line; + debug_line[i].filename = + const_cast<char *>(Lines.front().second.FileName.c_str()); + ++i; + } + + if (Wrapper->op_write_debug_line_info((void *)Addr, num_entries, + debug_line) == -1) { + LLVM_DEBUG(dbgs() << "Failed to tell OProfiler about debug object at [" + << (void *)Addr << "-" << ((char *)Addr + Size) + << "]\n"); + continue; + } } DebugObjects[Obj.getData().data()] = std::move(DebugObjOwner); |