about summary refs log tree commit diff homepage
path: root/lib/Core
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2014-09-14 15:07:29 -0700
committerDaniel Dunbar <daniel@zuster.org>2014-09-14 15:07:29 -0700
commit0aa44d4f61032836744d7a20f219af4463e99a23 (patch)
treed0ea1277443fec619fee688796a1a4fe38cddac3 /lib/Core
parent8ecd31572aae60ed50f487bccaad6abb7b346528 (diff)
downloadklee-0aa44d4f61032836744d7a20f219af4463e99a23.tar.gz
[Core] Fix a bug in how source file names were written in .istats files.
 - KCachegrind appears to expect the first function name to be preceeded by the
   name of the file it appears in. Otherwise, it will end up creating two
   different records for the function, one of which has no file name and won't
   have any statistics.
Diffstat (limited to 'lib/Core')
-rw-r--r--lib/Core/StatsTracker.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp
index e664d1ae..54dd0df8 100644
--- a/lib/Core/StatsTracker.cpp
+++ b/lib/Core/StatsTracker.cpp
@@ -501,6 +501,15 @@ void StatsTracker::writeIStats() {
   for (Module::iterator fnIt = m->begin(), fn_ie = m->end(); 
        fnIt != fn_ie; ++fnIt) {
     if (!fnIt->isDeclaration()) {
+      // Always try to write the filename before the function name, as otherwise
+      // KCachegrind can create two entries for the function, one with an
+      // unnamed file and one without.
+      const InstructionInfo &ii = executor.kmodule->infos->getFunctionInfo(fnIt);
+      if (ii.file != sourceFile) {
+        of << "fl=" << ii.file << "\n";
+        sourceFile = ii.file;
+      }
+      
       of << "fn=" << fnIt->getName().str() << "\n";
       for (Function::iterator bbIt = fnIt->begin(), bb_ie = fnIt->end(); 
            bbIt != bb_ie; ++bbIt) {