[LNT] r264040 - [profile] cPerf: fetch both static and dynamic symbols
James Molloy via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 22 04:45:38 PDT 2016
Author: jamesm
Date: Tue Mar 22 06:45:37 2016
New Revision: 264040
URL: http://llvm.org/viewvc/llvm-project?rev=264040&view=rev
Log:
[profile] cPerf: fetch both static and dynamic symbols
Libraries often don't have dynamic symbols, but do have static ones. Make
sure we fetch both.
Modified:
lnt/trunk/lnt/testing/profile/cPerf.cpp
lnt/trunk/tests/testing/Inputs/fake-nm.py
lnt/trunk/tests/testing/cPerf.py
Modified: lnt/trunk/lnt/testing/profile/cPerf.cpp
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/testing/profile/cPerf.cpp?rev=264040&r1=264039&r2=264040&view=diff
==============================================================================
--- lnt/trunk/lnt/testing/profile/cPerf.cpp (original)
+++ lnt/trunk/lnt/testing/profile/cPerf.cpp Tue Mar 22 06:45:37 2016
@@ -223,6 +223,9 @@ struct Symbol {
std::string Name;
bool operator<(const Symbol &Other) const { return Start < Other.Start; }
+ bool operator==(const Symbol &Other) const {
+ return Start == Other.Start && End == Other.End && Name == Other.Name;
+ }
};
class NmOutput : public std::vector<Symbol> {
@@ -231,10 +234,12 @@ public:
NmOutput(std::string Nm) : Nm(Nm) {}
- void reset(Map *M) {
- clear();
-
- std::string Cmd = Nm + " -D -S --defined-only " + std::string(M->Filename) +
+ void fetchSymbols(Map *M, bool Dynamic) {
+ std::string D = "-D";
+ if (!Dynamic)
+ // Don't fetch the dynamic symbols - instead fetch static ones.
+ D = "";
+ std::string Cmd = Nm + " " + D + " -S --defined-only " + std::string(M->Filename) +
" 2>/dev/null";
auto Stream = ForkAndExec(Cmd);
@@ -279,7 +284,17 @@ public:
fclose(Stream);
wait(NULL);
+ }
+
+ void reset(Map *M) {
+ clear();
+ // Fetch both dynamic and static symbols, sort and unique them.
+ fetchSymbols(M, true);
+ fetchSymbols(M, false);
+
std::sort(begin(), end());
+ auto NewEnd = std::unique(begin(), end());
+ erase(NewEnd, end());
}
};
Modified: lnt/trunk/tests/testing/Inputs/fake-nm.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/testing/Inputs/fake-nm.py?rev=264040&r1=264039&r2=264040&view=diff
==============================================================================
--- lnt/trunk/tests/testing/Inputs/fake-nm.py (original)
+++ lnt/trunk/tests/testing/Inputs/fake-nm.py Tue Mar 22 06:45:37 2016
@@ -1,3 +1,7 @@
import os, sys
+if '--fake-nm-be-non-dynamic' in sys.argv:
+ if '-D' in sys.argv:
+ sys.exit(0)
+
sys.stdout.write(open(sys.argv[1]).read())
Modified: lnt/trunk/tests/testing/cPerf.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/tests/testing/cPerf.py?rev=264040&r1=264039&r2=264040&view=diff
==============================================================================
--- lnt/trunk/tests/testing/cPerf.py (original)
+++ lnt/trunk/tests/testing/cPerf.py Tue Mar 22 06:45:37 2016
@@ -22,9 +22,12 @@ class CPerfTest(unittest.TestCase):
- def _getNm(self, perf_data_fname):
+ def _getNm(self, perf_data_fname, non_dynamic=False):
stub = perf_data_fname.rsplit('.perf_data', 1)[0]
- return 'python %s/fake-nm.py %s.nm.out' % (self.inputs, stub)
+ s = 'python %s/fake-nm.py %s.nm.out' % (self.inputs, stub)
+ if non_dynamic:
+ s += ' --fake-nm-be-non-dynamic'
+ return s
def _getObjdump(self, perf_data_fname):
stub = perf_data_fname.rsplit('.perf_data', 1)[0]
@@ -53,7 +56,16 @@ class CPerfTest(unittest.TestCase):
propagateExceptions=True)
self.assertEqual(p.data, self.expected_data['fib2-aarch64'])
-
+
+ def test_aarch64_fib2_nondynamic(self):
+ perf_data = self._getInput('fib2-aarch64.perf_data')
+ p = LinuxPerfProfile.deserialize(open(perf_data),
+ nm=self._getNm(perf_data, True),
+ objdump=self._getObjdump(perf_data),
+ propagateExceptions=True)
+
+ self.assertEqual(p.data, self.expected_data['fib2-aarch64'])
+
def test_random_guff(self):
# Create complete rubbish and throw it at cPerf, expecting an
# AssertionError.
More information about the llvm-commits
mailing list