about summary refs log tree commit diff
path: root/patches/dafl-extract-file-name.patch
blob: db6fdd6720394c8a1aaa0356fd9154e745afbd11 (plain) (blame)
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
commit 50d68fc44948ab3b25a7af2f5fc9918110b1939a
Author: goodtaeeun <goodtaeeun@kaist.ac.kr>
Date:   2024-02-13 15:24:01 +0900

    [DAFL] extract file name from function

diff --git a/llvm_mode/afl-llvm-pass.so.cc b/llvm_mode/afl-llvm-pass.so.cc
index af989c2037b2..ecc017e9f3e0 100644
--- a/llvm_mode/afl-llvm-pass.so.cc
+++ b/llvm_mode/afl-llvm-pass.so.cc
@@ -162,12 +162,21 @@ bool AFLCoverage::runOnModule(Module &M) {
   std::string file_name = M.getSourceFileName();
   std::set<std::string> covered_targets;
 
-  std::size_t tokloc = file_name.find_last_of('/');
-  if (tokloc != std::string::npos) {
-    file_name = file_name.substr(tokloc + 1, std::string::npos);
-  }
+  
 
   for (auto &F : M) {
+
+    // Get file name from function in case the module is a combined bc file.
+    if (auto *SP = F.getSubprogram()) {
+        file_name = SP->getFilename().str();
+    }
+
+    // Keep only the file name.
+    std::size_t tokloc = file_name.find_last_of('/');
+    if (tokloc != std::string::npos) {
+      file_name = file_name.substr(tokloc + 1, std::string::npos);
+    }
+
     bool is_inst_targ = false;
     const std::string func_name = F.getName().str();
     std::set<std::string>::iterator it;