From: Jeremy Kerr Date: Fri, 17 Apr 2009 05:40:57 +0000 (+1000) Subject: Add --opreport and --opannotate options X-Git-Url: https://git.ozlabs.org/?p=hiprofile;a=commitdiff_plain;h=45d77ca5ecee3a58aa0d889ad1d3b72368966e7f Add --opreport and --opannotate options To allow specific oprofile binaries to be used Signed-off-by: Jeremy Kerr --- diff --git a/hiprofile.py b/hiprofile.py index f6456a4..212fbf1 100644 --- a/hiprofile.py +++ b/hiprofile.py @@ -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 ]) - 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)' ] @@ -182,7 +182,7 @@ class Binary(object): 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 ])] @@ -252,9 +252,9 @@ class Report(object): for binary in self.binaries: binary.threshold(thresholds) - def annotate(self, conn): + def annotate(self, conn, options): for binary in self.binaries: - binary.annotate(self, conn) + binary.annotate(self, conn, options) @staticmethod def parse(doc, hostname): @@ -288,8 +288,8 @@ class Report(object): 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: diff --git a/scripts/hiprofile b/scripts/hiprofile index 2ec3cb9..aa1e361 100755 --- a/scripts/hiprofile +++ b/scripts/hiprofile @@ -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('--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() @@ -33,11 +38,11 @@ def main(args): conn = Connection(options.host) - report = Report.extract(conn) + report = Report.extract(conn, options) report.threshold(default_thresholds) - report.annotate(conn) + report.annotate(conn, options) write_report(report, resourcedir, options.outdir)