49 lines
2.3 KiB
Diff
49 lines
2.3 KiB
Diff
commit 4840cf7299bb312125d41fc84733c15c2370f18e
|
|
Author: DokFaust <rodia@autistici.org>
|
|
Date: Fri Jun 8 19:23:01 2018 +0200
|
|
|
|
Add debug line-level code information to OProfile module
|
|
|
|
diff --git a/lib/ExecutionEngine/OProfileJIT/LLVMBuild.txt b/lib/ExecutionEngine/OProfileJIT/LLVMBuild.txt
|
|
index 7d5550046a5..ea100286318 100644
|
|
--- a/lib/ExecutionEngine/OProfileJIT/LLVMBuild.txt
|
|
+++ b/lib/ExecutionEngine/OProfileJIT/LLVMBuild.txt
|
|
@@ -24 +24 @@ parent = ExecutionEngine
|
|
-required_libraries = Support Object ExecutionEngine
|
|
+required_libraries = DebugInfoDWARF Support Object ExecutionEngine
|
|
diff --git a/lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp b/lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp
|
|
index 3581d645839..045ecb82853 100644
|
|
--- a/lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp
|
|
+++ b/lib/ExecutionEngine/OProfileJIT/OProfileJITEventListener.cpp
|
|
@@ -26,0 +27,2 @@
|
|
+#include "llvm/DebugInfo/DIContext.h"
|
|
+#include "llvm/DebugInfo/DWARF/DWARFContext.h"
|
|
@@ -86,0 +89,2 @@ void OProfileJITEventListener::NotifyObjectEmitted(
|
|
+ std::unique_ptr<DIContext> Context = DWARFContext::create(DebugObj);
|
|
+ std::string SourceFileName;
|
|
@@ -111 +115,23 @@ void OProfileJITEventListener::NotifyObjectEmitted(
|
|
- // 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;
|
|
+ }
|