]> git.ozlabs.org Git - hiprofile/commitdiff
Add --opreport and --opannotate options
authorJeremy Kerr <jk@ozlabs.org>
Fri, 17 Apr 2009 05:40:57 +0000 (15:40 +1000)
committerJeremy Kerr <jk@ozlabs.org>
Fri, 17 Apr 2009 05:40:57 +0000 (15:40 +1000)
To allow specific oprofile binaries to be used

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
hiprofile.py
scripts/hiprofile

index f6456a4423297eada40b27a5431019dba6d11618..212fbf13e76a32e8dd26fdbb650fd387df5edb12 100644 (file)
@@ -174,7 +174,7 @@ class Binary(object):
                 lambda r: r.count, thresholds['symbol'])
         self.reference_dict = dict([ (r.name, r) for r in self.references ])
 
                 lambda r: r.count, thresholds['symbol'])
         self.reference_dict = dict([ (r.name, r) for r in self.references ])
 
-    def annotate(self, report, conn):
+    def annotate(self, report, conn, options):
         fn_re = re.compile('^[0-9a-f]+\s+<[^>]+>: /\* (\S+) total:')
 
         symbols = [ s for s in self.references if s.name != '(no symbols)' ]
         fn_re = re.compile('^[0-9a-f]+\s+<[^>]+>: /\* (\S+) total:')
 
         symbols = [ s for s in self.references if s.name != '(no symbols)' ]
@@ -182,7 +182,7 @@ class Binary(object):
         if not symbols:
             return
 
         if not symbols:
             return
 
-        command = ['opannotate', '--source', '--assembly',
+        command = [options.opannotate, '--source', '--assembly',
             '--include-file=' + self.name,
             '-i', ','.join([ s.name for s in symbols ])]
 
             '--include-file=' + self.name,
             '-i', ','.join([ s.name for s in symbols ])]
 
@@ -252,9 +252,9 @@ class Report(object):
         for binary in self.binaries:
             binary.threshold(thresholds)
 
         for binary in self.binaries:
             binary.threshold(thresholds)
 
-    def annotate(self, conn):
+    def annotate(self, conn, options):
         for binary in self.binaries:
         for binary in self.binaries:
-            binary.annotate(self, conn)
+            binary.annotate(self, conn, options)
 
     @staticmethod
     def parse(doc, hostname):
 
     @staticmethod
     def parse(doc, hostname):
@@ -288,8 +288,8 @@ class Report(object):
         return report
 
     @staticmethod
         return report
 
     @staticmethod
-    def extract(connection):
-        fd = connection.execute(['opreport', '--xml'])
+    def extract(connection, options):
+        fd = connection.execute([options.opreport, '--xml'])
         doc = parseXML(fd)
 
         if connection.host:
         doc = parseXML(fd)
 
         if connection.host:
index 2ec3cb9b53b494118ab7d0f72044b41b24672ab2..aa1e361bb48f521e994657e5a100480c35e20464 100755 (executable)
@@ -23,6 +23,11 @@ def main(args):
     parser.add_option('-o', '--output-dir', dest = 'outdir',
             help = 'create output in directory DIR', metavar = 'DIR',
             default = default_outdir)
     parser.add_option('-o', '--output-dir', dest = 'outdir',
             help = 'create output in directory DIR', metavar = 'DIR',
             default = default_outdir)
+    parser.add_option('--opreport', dest = 'opreport', default = 'opreport',
+            help = 'use opreport binary at PATH', metavar = 'PATH')
+    parser.add_option('--opannotate', dest = 'opannotate',
+            default = 'opannotate',
+            help = 'use opannotate binary at PATH', metavar = 'PATH')
 
     (options, args) = parser.parse_args()
 
 
     (options, args) = parser.parse_args()
 
@@ -33,11 +38,11 @@ def main(args):
 
     conn = Connection(options.host)
 
 
     conn = Connection(options.host)
 
-    report = Report.extract(conn)
+    report = Report.extract(conn, options)
 
     report.threshold(default_thresholds)
 
 
     report.threshold(default_thresholds)
 
-    report.annotate(conn)
+    report.annotate(conn, options)
 
     write_report(report, resourcedir, options.outdir)
 
 
     write_report(report, resourcedir, options.outdir)