File: llvm-OProfile-line-num.patch

package info (click to toggle)
julia 1.0.3%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 49,452 kB
  • sloc: lisp: 236,453; ansic: 55,579; cpp: 25,603; makefile: 1,685; pascal: 1,130; sh: 956; asm: 86; xml: 76
file content (48 lines) | stat: -rw-r--r-- 2,384 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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;
+    }