about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorMartin Nowack <m.nowack@imperial.ac.uk>2020-01-16 18:37:28 +0000
committerCristian Cadar <c.cadar@imperial.ac.uk>2020-01-18 16:34:03 +0000
commit4300ed7cd1ec48292a1983bb80161099f15b2023 (patch)
tree5f95eb4109c216fab9ff91595d8b656e85bea499
parentc7cdc0f15f0f08fb4a808096e741263ff4fb26e3 (diff)
downloadklee-4300ed7cd1ec48292a1983bb80161099f15b2023.tar.gz
Fix handling of debug information for functions
Tracking function locations separately correctly without prefixing
it with a directory.
-rw-r--r--lib/Module/InstructionInfoTable.cpp10
-rw-r--r--test/Feature/SourceMapping.c4
2 files changed, 4 insertions, 10 deletions
diff --git a/lib/Module/InstructionInfoTable.cpp b/lib/Module/InstructionInfoTable.cpp
index 48575c82..90b0e022 100644
--- a/lib/Module/InstructionInfoTable.cpp
+++ b/lib/Module/InstructionInfoTable.cpp
@@ -81,14 +81,6 @@ buildInstructionToLineMap(const llvm::Module &m) {
   return mapping;
 }
 
-static std::string getFullPath(llvm::StringRef Directory,
-                               llvm::StringRef FileName) {
-  llvm::SmallString<128> file_pathname(Directory);
-  llvm::sys::path::append(file_pathname, FileName);
-
-  return file_pathname.str();
-}
-
 class DebugInfoExtractor {
   std::vector<std::unique_ptr<std::string>> &internedStrings;
   std::map<uintptr_t, uint64_t> lineTable;
@@ -126,7 +118,7 @@ public:
     auto dsub = llvm::getDISubprogram(&Func);
 #endif
     if (dsub != nullptr) {
-      auto path = getFullPath(dsub->getDirectory(), dsub->getFilename());
+      auto path = dsub->getFilename();
       return std::unique_ptr<FunctionInfo>(new FunctionInfo(
           0, getInternedString(path), dsub->getLine(), asmLine));
     }
diff --git a/test/Feature/SourceMapping.c b/test/Feature/SourceMapping.c
index 6a071933..de0c0605 100644
--- a/test/Feature/SourceMapping.c
+++ b/test/Feature/SourceMapping.c
@@ -11,7 +11,7 @@
 
 // Assuming the compiler doesn't reorder things, f0 should be first, and it
 // should immediately follow the first file name marker.
-// CHECK: fl={{.*}}/SourceMapping.c
+// CHECK: fl={{.*}}test/Feature/SourceMapping.c
 // CHECK-NEXT: fn=f0
 
 // Ensure we have a known position for the first instruction (instr and line
@@ -35,6 +35,8 @@ int f1(int a, int b) {
 // This check just brackets the checks above, to make sure they fall in the
 // appropriate region of the run.istats file.
 //
+// Explicitly check that there is no duplication of the path
+// CHECK-NOT: fl={{.*}}/test/Feature/{{.*}}/test/Feature/SourceMapping.c
 // CHECK: fn=main
 int main() {
   int x = f1(1, 2);