[PATCH] D47925: Add debug info for OProfile porifling support
Gaetano Priori via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 8 12:15:08 PDT 2018
gipri updated this revision to Diff 150552.
gipri edited the summary of this revision.
gipri added a comment.
Clang-format
https://reviews.llvm.org/D47925
Files:
lib/ExecutionEngine/OProfileJIT/LLVMBuild.txt
lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp
Index: lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp
===================================================================
--- lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp
+++ lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp
@@ -14,6 +14,8 @@
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/Config/config.h"
+#include "llvm/DebugInfo/DIContext.h"
+#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/ExecutionEngine/JITEventListener.h"
#include "llvm/ExecutionEngine/OProfileWrapper.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h"
@@ -84,10 +86,12 @@
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)) {
SymbolRef Sym = P.first;
+ std::string SourceFileName;
if (!Sym.getType() || *Sym.getType() != SymbolRef::ST_Function)
continue;
@@ -108,7 +112,29 @@
<< "]\n");
continue;
}
- // TODO: support line number info (similar to IntelJITEventListener.cpp)
+ DILineInfoTable Lines = Context->getLineInfoForAddressRange(Addr, Size);
+ DILineInfoTable::iterator Begin = Lines.begin();
+ DILineInfoTable::iterator End = Lines.end();
+ size_t i = 0;
+
+ size_t num_entries = std::distance(Begin, End);
+ static struct debug_line_info* debug_line;
+ debug_line = (struct debug_line_info * )calloc(num_entries, sizeof(struct debug_line_info));
+
+ for(DILineInfoTable::iterator It=Begin; It != End; ++It){
+ i = std::distance(Begin,It);
+ debug_line[i].vma = (unsigned long) It->first;
+ debug_line[i].lineno = It->second.Line;
+ SourceFileName = Lines.front().second.FileName;
+ debug_line[i].filename = const_cast<char *>(SourceFileName.c_str());
+ }
+
+ if(Wrapper->op_write_debug_line_info((void*) Addr, num_entries, debug_line) == -1) {
+ DEBUG(dbgs() << "Failed to tell OProfiler about debug object at ["
+ << (void*) Addr << "-" << ((char *) Addr + Size)
+ << "]\n");
+ continue;
+ }
}
DebugObjects[Obj.getData().data()] = std::move(DebugObjOwner);
Index: lib/ExecutionEngine/OProfileJIT/LLVMBuild.txt
===================================================================
--- lib/ExecutionEngine/OProfileJIT/LLVMBuild.txt
+++ 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47925.150552.patch
Type: text/x-patch
Size: 2824 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180608/ceb6ce29/attachment.bin>
More information about the llvm-commits
mailing list